2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-11-16 10:00:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 08:08:03 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-11-16 10:00:56 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-11-16 10:00:56 +00:00
|
|
|
*
|
2008-04-11 08:08:03 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-11-16 10:00:56 +00:00
|
|
|
*
|
2008-04-11 08:08:03 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-11-16 10:00:56 +00:00
|
|
|
*
|
2008-04-11 08:08:03 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-11-16 10:00:56 +00:00
|
|
|
*
|
2008-04-11 08:08:03 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-11-16 10:00:56 +00:00
|
|
|
*
|
2008-04-11 08:08:03 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-11-16 10:00:56 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 23:07:43 +00:00
|
|
|
|
2004-11-16 10:00:56 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "submission_post.hxx"
|
|
|
|
#include "serialization_app_xml.hxx"
|
|
|
|
#include "serialization_urlencoded.hxx"
|
|
|
|
|
|
|
|
#include <osl/file.hxx>
|
|
|
|
#include <ucbhelper/content.hxx>
|
2005-10-24 06:38:49 +00:00
|
|
|
#include <ucbhelper/activedatasink.hxx>
|
2004-11-16 10:00:56 +00:00
|
|
|
#include <com/sun/star/ucb/PostCommandArgument2.hpp>
|
|
|
|
|
|
|
|
using namespace CSS::uno;
|
|
|
|
using namespace CSS::ucb;
|
|
|
|
using namespace CSS::task;
|
|
|
|
using namespace CSS::io;
|
|
|
|
using namespace osl;
|
2007-06-05 16:45:38 +00:00
|
|
|
using namespace ucbhelper;
|
2004-11-16 10:00:56 +00:00
|
|
|
using namespace std;
|
|
|
|
|
2011-02-26 01:19:34 +01:00
|
|
|
using ::rtl::OUString;
|
|
|
|
|
2004-11-16 10:00:56 +00:00
|
|
|
|
|
|
|
CSubmissionPost::CSubmissionPost(const rtl::OUString& aURL, const CSS::uno::Reference< CSS::xml::dom::XDocumentFragment >& aFragment)
|
|
|
|
: CSubmission(aURL, aFragment)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-03-23 10:41:04 +00:00
|
|
|
CSubmission::SubmissionResult CSubmissionPost::submit(const CSS::uno::Reference< CSS::task::XInteractionHandler >& aInteractionHandler)
|
2004-11-16 10:00:56 +00:00
|
|
|
{
|
|
|
|
// PUT always uses application/xml
|
2009-04-23 10:42:05 +00:00
|
|
|
CSS::uno::Reference< XCommandEnvironment > aEnvironment;
|
|
|
|
auto_ptr< CSerialization > apSerialization(createSerialization(aInteractionHandler,aEnvironment));
|
2004-11-16 10:00:56 +00:00
|
|
|
|
|
|
|
try {
|
2007-06-05 16:45:38 +00:00
|
|
|
ucbhelper::Content aContent(m_aURLObj.GetMainURL(INetURLObject::NO_DECODE), aEnvironment);
|
2004-11-16 10:00:56 +00:00
|
|
|
|
|
|
|
// use post command
|
2010-11-23 22:41:07 +01:00
|
|
|
OUString aCommandName(RTL_CONSTASCII_USTRINGPARAM("post"));
|
2004-11-16 10:00:56 +00:00
|
|
|
PostCommandArgument2 aPostArgument;
|
|
|
|
aPostArgument.Source = apSerialization->getInputStream();
|
2007-06-05 16:45:38 +00:00
|
|
|
CSS::uno::Reference< XActiveDataSink > aSink(new ucbhelper::ActiveDataSink);
|
2004-11-16 10:00:56 +00:00
|
|
|
aPostArgument.Sink = aSink;
|
2010-11-23 22:41:07 +01:00
|
|
|
aPostArgument.MediaType = OUString(RTL_CONSTASCII_USTRINGPARAM("application/xml"));
|
2004-11-16 10:00:56 +00:00
|
|
|
aPostArgument.Referer = OUString();
|
|
|
|
Any aCommandArgument;
|
|
|
|
aCommandArgument <<= aPostArgument;
|
|
|
|
aContent.executeCommand( aCommandName, aCommandArgument);
|
|
|
|
|
2005-03-23 10:41:04 +00:00
|
|
|
try {
|
2005-10-24 06:38:49 +00:00
|
|
|
m_aResultStream = aSink->getInputStream();
|
2011-12-11 18:51:50 +09:00
|
|
|
} catch (const Exception&) {
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL("Cannot open reply stream from content");
|
2005-03-23 10:41:04 +00:00
|
|
|
}
|
2011-12-11 18:51:50 +09:00
|
|
|
} catch (const Exception&)
|
2004-11-16 10:00:56 +00:00
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL("Exception during UCB operatration.");
|
2004-11-16 10:00:56 +00:00
|
|
|
return UNKNOWN_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|