1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_forms.hxx" 30 31 #include <memory> 32 33 #include "submission_post.hxx" 34 #include "serialization_app_xml.hxx" 35 #include "serialization_urlencoded.hxx" 36 37 #include <osl/file.hxx> 38 #include <unotools/processfactory.hxx> 39 #include <ucbhelper/content.hxx> 40 #include <ucbhelper/activedatasink.hxx> 41 #include <com/sun/star/ucb/PostCommandArgument2.hpp> 42 43 using namespace CSS::uno; 44 using namespace CSS::ucb; 45 using namespace CSS::task; 46 using namespace CSS::io; 47 using namespace rtl; 48 using namespace osl; 49 using namespace ucbhelper; 50 using namespace std; 51 52 53 CSubmissionPost::CSubmissionPost(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment) 54 : CSubmission(aURL, aFragment) 55 { 56 } 57 58 CSubmission::SubmissionResult CSubmissionPost::submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& aInteractionHandler) 59 { 60 // PUT always uses application/xml 61 CSS::uno::Reference< XCommandEnvironment > aEnvironment; 62 auto_ptr< CSerialization > apSerialization(createSerialization(aInteractionHandler,aEnvironment)); 63 64 try { 65 ucbhelper::Content aContent(m_aURLObj.GetMainURL(INetURLObject::NO_DECODE), aEnvironment); 66 67 // use post command 68 69 OUString aCommandName = OUString::createFromAscii("post"); 70 PostCommandArgument2 aPostArgument; 71 aPostArgument.Source = apSerialization->getInputStream(); 72 //CSS::uno::Reference< XInterface > aSink( m_aFactory->createInstance( 73 // OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY_THROW); 74 CSS::uno::Reference< XActiveDataSink > aSink(new ucbhelper::ActiveDataSink); 75 // OUString::createFromAscii("com.sun.star.io.Pipe")), UNO_QUERY_THROW); 76 aPostArgument.Sink = aSink; 77 aPostArgument.MediaType = OUString::createFromAscii("application/xml"); 78 aPostArgument.Referer = OUString(); 79 Any aCommandArgument; 80 aCommandArgument <<= aPostArgument; 81 aContent.executeCommand( aCommandName, aCommandArgument); 82 83 // wait for command to finish 84 // pProgressHelper->m_cFinished.wait(); 85 86 // CSS::uno::Reference< XOutputStream > xOut(aSink, UNO_QUERY_THROW); 87 // xOut->closeOutput(); 88 89 try { 90 // m_aResultStream = CSS::uno::Reference< XInputStream >(aSink, UNO_QUERY_THROW); 91 m_aResultStream = aSink->getInputStream(); 92 } catch (Exception&) { 93 OSL_ENSURE(sal_False, "Cannot open reply stream from content"); 94 } 95 } catch (Exception&) 96 { 97 // XXX 98 OSL_ENSURE(sal_False, "Exception during UCB operatration."); 99 return UNKNOWN_ERROR; 100 } 101 102 103 return SUCCESS; 104 } 105 106