Merged V2.1-A to HEAD

7970: Added 'writeWithAttachment' method to the contentweb service API.
   7972: Added unit test to check CML creation of files and folders with spaces in the names


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8663 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-04-02 16:56:09 +00:00
parent 9fb99816e4
commit 8d0db44bc6
5 changed files with 172 additions and 19 deletions

View File

@@ -19,6 +19,11 @@ public interface ContentServiceSoapPort extends java.rmi.Remote {
*/
public org.alfresco.repo.webservice.content.Content write(org.alfresco.repo.webservice.types.Reference node, java.lang.String property, byte[] content, org.alfresco.repo.webservice.types.ContentFormat format) throws java.rmi.RemoteException, org.alfresco.repo.webservice.content.ContentFault;
/**
* Writes the attached content into the repository.
*/
public org.alfresco.repo.webservice.content.Content writeWithAttachment(org.alfresco.repo.webservice.types.Reference node, java.lang.String property, org.alfresco.repo.webservice.types.ContentFormat format) throws java.rmi.RemoteException, org.alfresco.repo.webservice.content.ContentFault;
/**
* Clears content from the repository.
*/

View File

@@ -32,6 +32,12 @@
<parameter qname="pns:format" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:ContentFormat" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<fault name="ContentFault" qname="fns:ContentFault" xmlns:fns="http://www.alfresco.org/ws/service/content/1.0" class="org.alfresco.repo.webservice.content.ContentFault" type="tns:ContentFault" xmlns:tns="http://www.alfresco.org/ws/service/content/1.0"/>
</operation>
<operation name="writeWithAttachment" qname="operNS:writeWithAttachment" xmlns:operNS="http://www.alfresco.org/ws/service/content/1.0" returnQName="retNS:content" xmlns:retNS="http://www.alfresco.org/ws/service/content/1.0" returnType="rtns:Content" xmlns:rtns="http://www.alfresco.org/ws/service/content/1.0" soapAction="http://www.alfresco.org/ws/service/content/1.0/writeWithAttachment" >
<parameter qname="pns:node" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:Reference" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<parameter qname="pns:property" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
<parameter qname="pns:format" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:ContentFormat" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<fault name="ContentFault" qname="fns:ContentFault" xmlns:fns="http://www.alfresco.org/ws/service/content/1.0" class="org.alfresco.repo.webservice.content.ContentFault" type="tns:ContentFault" xmlns:tns="http://www.alfresco.org/ws/service/content/1.0"/>
</operation>
<operation name="clear" qname="operNS:clear" xmlns:operNS="http://www.alfresco.org/ws/service/content/1.0" returnQName="retNS:content" xmlns:retNS="http://www.alfresco.org/ws/service/content/1.0" returnType="rtns:Content" xmlns:rtns="http://www.alfresco.org/ws/service/content/1.0" soapAction="http://www.alfresco.org/ws/service/content/1.0/clear" >
<parameter qname="pns:items" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:Predicate" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<parameter qname="pns:property" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
@@ -45,7 +51,7 @@
<parameter qname="pns:destinationFormat" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:ContentFormat" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<fault name="ContentFault" qname="fns:ContentFault" xmlns:fns="http://www.alfresco.org/ws/service/content/1.0" class="org.alfresco.repo.webservice.content.ContentFault" type="tns:ContentFault" xmlns:tns="http://www.alfresco.org/ws/service/content/1.0"/>
</operation>
<parameter name="allowedMethods" value="write transform clear read"/>
<parameter name="allowedMethods" value="write transform clear writeWithAttachment read"/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
@@ -103,14 +109,6 @@
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
qname="ns:Path"
type="java:java.lang.String"
serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"
deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
qname="ns:ResultSetRow"
@@ -119,6 +117,14 @@
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
qname="ns:Path"
type="java:java.lang.String"
serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"
deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
qname="ns:ResultSet"

View File

@@ -31,8 +31,10 @@ import java.net.URLEncoder;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.activation.DataHandler;
import javax.servlet.http.HttpServletRequest;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -47,7 +49,11 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.attachments.AttachmentPart;
import org.apache.axis.attachments.Attachments;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -227,6 +233,90 @@ public class ContentWebService extends AbstractWebService implements
throw new ContentFault(0, e.getMessage());
}
}
/**
* @see org.alfresco.repo.webservice.content.ContentServiceSoapPort#writeWithAttachments(org.alfresco.repo.webservice.types.Reference[], java.lang.String[], org.alfresco.repo.webservice.types.ContentFormat[])
*/
public Content writeWithAttachment(final Reference node, final String property, final ContentFormat format)
throws RemoteException, ContentFault
{
try
{
RetryingTransactionCallback<Content> callback = new RetryingTransactionCallback<Content>()
{
public Content execute() throws Throwable
{
AttachmentPart[] attachments = getMessageAttachments();
if (attachments.length != 1)
{
throw new AlfrescoRuntimeException("Expecting only one attachment");
}
// create a NodeRef from the parent reference
NodeRef nodeRef = Utils.convertToNodeRef(node, nodeService, searchService, namespaceService);
// Get the content writer
ContentWriter writer = contentService.getWriter(nodeRef, QName.createQName(property), true);
// Set the content format details (if they have been specified)
if (format != null)
{
writer.setEncoding(format.getEncoding());
writer.setMimetype(format.getMimetype());
}
// Write the content (just need to get the first in the array since we are only expecting one attachment)
DataHandler dh = attachments[0].getDataHandler();
InputStream is = dh.getInputStream();
writer.putContent(is);
// Debug
if (logger.isDebugEnabled())
{
logger.debug("Updated content for node with id: " + nodeRef.getId());
}
// Return the content object
return createContent(nodeRef, property);
}
};
return Utils.getRetryingTransactionHelper(MessageContext.getCurrentContext()).doInTransaction(callback);
}
catch (Throwable e)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", e);
}
throw new ContentFault(0, e.getMessage());
}
}
@SuppressWarnings("unchecked")
private AttachmentPart[] getMessageAttachments()
throws AxisFault
{
MessageContext msgContext = MessageContext.getCurrentContext();
Message reqMsg = msgContext.getRequestMessage();
Attachments messageAttachments = reqMsg.getAttachmentsImpl();
if (null == messageAttachments)
{
return new AttachmentPart[0];
}
int attachmentCount = messageAttachments.getAttachmentCount();
AttachmentPart attachments[] = new AttachmentPart[attachmentCount];
Iterator it = messageAttachments.getAttachments().iterator();
int count = 0;
while (it.hasNext())
{
AttachmentPart part = (AttachmentPart)it.next();
attachments[count++] = part;
}
return attachments;
}
/**
* @see org.alfresco.repo.webservice.content.ContentServiceSoapPort#clear(org.alfresco.repo.webservice.types.Predicate,

View File

@@ -898,6 +898,12 @@
<parameter qname="pns:format" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:ContentFormat" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<fault name="ContentFault" qname="fns:ContentFault" xmlns:fns="http://www.alfresco.org/ws/service/content/1.0" class="org.alfresco.repo.webservice.content.ContentFault" type="tns:ContentFault" xmlns:tns="http://www.alfresco.org/ws/service/content/1.0"/>
</operation>
<operation name="writeWithAttachment" qname="operNS:writeWithAttachment" xmlns:operNS="http://www.alfresco.org/ws/service/content/1.0" returnQName="retNS:content" xmlns:retNS="http://www.alfresco.org/ws/service/content/1.0" returnType="rtns:Content" xmlns:rtns="http://www.alfresco.org/ws/service/content/1.0" soapAction="http://www.alfresco.org/ws/service/content/1.0/writeWithAttachment" >
<parameter qname="pns:node" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:Reference" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<parameter qname="pns:property" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
<parameter qname="pns:format" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:ContentFormat" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<fault name="ContentFault" qname="fns:ContentFault" xmlns:fns="http://www.alfresco.org/ws/service/content/1.0" class="org.alfresco.repo.webservice.content.ContentFault" type="tns:ContentFault" xmlns:tns="http://www.alfresco.org/ws/service/content/1.0"/>
</operation>
<operation name="clear" qname="operNS:clear" xmlns:operNS="http://www.alfresco.org/ws/service/content/1.0" returnQName="retNS:content" xmlns:retNS="http://www.alfresco.org/ws/service/content/1.0" returnType="rtns:Content" xmlns:rtns="http://www.alfresco.org/ws/service/content/1.0" soapAction="http://www.alfresco.org/ws/service/content/1.0/clear" >
<parameter qname="pns:items" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:Predicate" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<parameter qname="pns:property" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
@@ -911,7 +917,7 @@
<parameter qname="pns:destinationFormat" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:ContentFormat" xmlns:tns="http://www.alfresco.org/ws/model/content/1.0"/>
<fault name="ContentFault" qname="fns:ContentFault" xmlns:fns="http://www.alfresco.org/ws/service/content/1.0" class="org.alfresco.repo.webservice.content.ContentFault" type="tns:ContentFault" xmlns:tns="http://www.alfresco.org/ws/service/content/1.0"/>
</operation>
<parameter name="allowedMethods" value="write transform clear read"/>
<parameter name="allowedMethods" value="write transform clear writeWithAttachment read"/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
@@ -969,14 +975,6 @@
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
qname="ns:Path"
type="java:java.lang.String"
serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"
deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
qname="ns:ResultSetRow"
@@ -985,6 +983,14 @@
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
qname="ns:Path"
type="java:java.lang.String"
serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"
deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
qname="ns:ResultSet"
@@ -1161,7 +1167,7 @@
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
</service>
</service>
<service name="AuthoringService" provider="java:SpringRPC" style="wrapped" use="literal">
<documentation>Provides support for collaborative editing of content.</documentation>

View File

@@ -52,6 +52,25 @@
</complexType>
</element>
<element name="writeWithAttachment">
<complexType>
<sequence>
<element name="node" type="cms:Reference"/>
<element name="property" type="xsd:string"/>
<element name="format" type="cms:ContentFormat"/>
</sequence>
</complexType>
</element>
<element name="writeWithAttachmentResponse">
<complexType>
<sequence>
<element name="content" type="content:Content"/>
</sequence>
</complexType>
</element>
<element name="clear">
<complexType>
<sequence>
@@ -134,6 +153,14 @@
<wsdl:part element="content:writeResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="writeWithAttachmentRequest">
<wsdl:part element="content:writeWithAttachment" name="parameters"/>
</wsdl:message>
<wsdl:message name="writeWithAttachmentResponse">
<wsdl:part element="content:writeWithAttachmentResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="clearRequest">
<wsdl:part element="content:clear" name="parameters"/>
</wsdl:message>
@@ -167,6 +194,12 @@
<wsdl:output message="content:writeResponse"/>
<wsdl:fault message="content:ContentFault" name="ContentFault"/>
</wsdl:operation>
<wsdl:operation name="writeWithAttachment">
<wsdl:documentation>Writes the attached content into the repository.</wsdl:documentation>
<wsdl:input message="content:writeWithAttachmentRequest"/>
<wsdl:output message="content:writeWithAttachmentResponse"/>
<wsdl:fault message="content:ContentFault" name="ContentFault"/>
</wsdl:operation>
<wsdl:operation name="clear">
<wsdl:documentation>Clears content from the repository.</wsdl:documentation>
<wsdl:input message="content:clearRequest"/>
@@ -207,6 +240,19 @@
</wsdl:output>
<wsdl:fault name="ContentFault">
<wsdlsoap:fault namespace="http://www.alfresco.org/ws/service/content/1.0" use="literal" name="ContentFault"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="writeWithAttachment">
<wsdl:documentation>Writes attached content to the repository.</wsdl:documentation>
<wsdlsoap:operation soapAction="http://www.alfresco.org/ws/service/content/1.0/writeWithAttachment"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ContentFault">
<wsdlsoap:fault namespace="http://www.alfresco.org/ws/service/content/1.0" use="literal" name="ContentFault"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="clear">