mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.1-A to HEAD
7698: Added transform method to content web service git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8662 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,4 +23,9 @@ public interface ContentServiceSoapPort extends java.rmi.Remote {
|
|||||||
* Clears content from the repository.
|
* Clears content from the repository.
|
||||||
*/
|
*/
|
||||||
public org.alfresco.repo.webservice.content.Content[] clear(org.alfresco.repo.webservice.types.Predicate items, java.lang.String property) throws java.rmi.RemoteException, org.alfresco.repo.webservice.content.ContentFault;
|
public org.alfresco.repo.webservice.content.Content[] clear(org.alfresco.repo.webservice.types.Predicate items, java.lang.String property) throws java.rmi.RemoteException, org.alfresco.repo.webservice.content.ContentFault;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms content from one mimetype to another.
|
||||||
|
*/
|
||||||
|
public org.alfresco.repo.webservice.content.Content transform(org.alfresco.repo.webservice.types.Reference source, java.lang.String property, org.alfresco.repo.webservice.types.Reference destinationReference, java.lang.String destinationProperty, org.alfresco.repo.webservice.types.ContentFormat destinationFormat) throws java.rmi.RemoteException, org.alfresco.repo.webservice.content.ContentFault;
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,15 @@
|
|||||||
<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:property" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
|
||||||
<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"/>
|
<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>
|
||||||
<parameter name="allowedMethods" value="write clear read"/>
|
<operation name="transform" qname="operNS:transform" 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/transform" >
|
||||||
|
<parameter qname="pns:source" 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:destinationReference" 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:destinationProperty" 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: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"/>
|
||||||
|
|
||||||
<typeMapping
|
<typeMapping
|
||||||
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
|
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
|
||||||
|
@@ -35,6 +35,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.repo.webservice.AbstractWebService;
|
import org.alfresco.repo.webservice.AbstractWebService;
|
||||||
@@ -271,4 +272,61 @@ public class ContentWebService extends AbstractWebService implements
|
|||||||
throw new ContentFault(0, e.getMessage());
|
throw new ContentFault(0, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms content from one node and mimetype to another node and mimetype
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.webservice.content.ContentServiceSoapPort#transform(org.alfresco.repo.webservice.types.Reference, java.lang.String, org.alfresco.repo.webservice.types.Reference, java.lang.String, org.alfresco.repo.webservice.types.ContentFormat)
|
||||||
|
*/
|
||||||
|
public Content transform(
|
||||||
|
final Reference source,
|
||||||
|
final String property,
|
||||||
|
final Reference destinationReference,
|
||||||
|
final String destinationProperty,
|
||||||
|
final ContentFormat destinationFormat)
|
||||||
|
throws RemoteException, ContentFault
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RetryingTransactionCallback<Content> callback = new RetryingTransactionCallback<Content>()
|
||||||
|
{
|
||||||
|
public Content execute() throws Throwable
|
||||||
|
{
|
||||||
|
// Get the nodes and property qname's
|
||||||
|
NodeRef sourceNodeRef = Utils.convertToNodeRef(source, ContentWebService.this.nodeService, ContentWebService.this.searchService, ContentWebService.this.namespaceService);
|
||||||
|
NodeRef destinationNodeRef = Utils.convertToNodeRef(destinationReference, ContentWebService.this.nodeService, ContentWebService.this.searchService, ContentWebService.this.namespaceService);
|
||||||
|
QName sourceQName = QName.createQName(property);
|
||||||
|
QName destinationQName = QName.createQName(destinationProperty);
|
||||||
|
|
||||||
|
// Get the content reader
|
||||||
|
ContentReader contentReader = ContentWebService.this.contentService.getReader(sourceNodeRef, sourceQName);
|
||||||
|
if (contentReader == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Source content does not exist. Transform could not take place.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the content writer
|
||||||
|
ContentWriter contentWriter = ContentWebService.this.contentService.getWriter(destinationNodeRef, destinationQName, true);
|
||||||
|
contentWriter.setEncoding(destinationFormat.getEncoding());
|
||||||
|
contentWriter.setMimetype(destinationFormat.getMimetype());
|
||||||
|
|
||||||
|
// Transform the content
|
||||||
|
ContentWebService.this.contentService.transform(contentReader, contentWriter);
|
||||||
|
|
||||||
|
// Return the content object to the user
|
||||||
|
return createContent(destinationNodeRef, destinationProperty);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -903,7 +903,15 @@
|
|||||||
<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:property" xmlns:pns="http://www.alfresco.org/ws/service/content/1.0" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
|
||||||
<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"/>
|
<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>
|
||||||
<parameter name="allowedMethods" value="write clear read"/>
|
<operation name="transform" qname="operNS:transform" 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/transform" >
|
||||||
|
<parameter qname="pns:source" 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:destinationReference" 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:destinationProperty" 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: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"/>
|
||||||
|
|
||||||
<typeMapping
|
<typeMapping
|
||||||
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
|
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
|
||||||
@@ -1113,14 +1121,6 @@
|
|||||||
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
|
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
|
||||||
encodingStyle=""
|
encodingStyle=""
|
||||||
/>
|
/>
|
||||||
<typeMapping
|
|
||||||
xmlns:ns="http://www.alfresco.org/ws/model/content/1.0"
|
|
||||||
qname="ns:>Store>address"
|
|
||||||
type="java:java.lang.String"
|
|
||||||
serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"
|
|
||||||
deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"
|
|
||||||
encodingStyle=""
|
|
||||||
/>
|
|
||||||
<typeMapping
|
<typeMapping
|
||||||
xmlns:ns="http://www.alfresco.org/ws/service/content/1.0"
|
xmlns:ns="http://www.alfresco.org/ws/service/content/1.0"
|
||||||
qname="ns:ContentFault"
|
qname="ns:ContentFault"
|
||||||
|
@@ -67,6 +67,26 @@
|
|||||||
<element name="content" type="content:Content" maxOccurs="unbounded" minOccurs="0"/>
|
<element name="content" type="content:Content" maxOccurs="unbounded" minOccurs="0"/>
|
||||||
</sequence>
|
</sequence>
|
||||||
</complexType>
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="transform">
|
||||||
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<element name="source" type="cms:Reference" />
|
||||||
|
<element name="property" type="xsd:string" />
|
||||||
|
<element name="destinationReference" type="cms:Reference"/>
|
||||||
|
<element name="destinationProperty" type="xsd:string"/>
|
||||||
|
<element name="destinationFormat" type="cms:ContentFormat"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="transformResponse">
|
||||||
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<element name="content" type="content:Content"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<complexType name="ContentSegment">
|
<complexType name="ContentSegment">
|
||||||
@@ -122,6 +142,14 @@
|
|||||||
<wsdl:part element="content:clearResponse" name="parameters"/>
|
<wsdl:part element="content:clearResponse" name="parameters"/>
|
||||||
</wsdl:message>
|
</wsdl:message>
|
||||||
|
|
||||||
|
<wsdl:message name="transformRequest">
|
||||||
|
<wsdl:part element="content:transform" name="parameters"/>
|
||||||
|
</wsdl:message>
|
||||||
|
|
||||||
|
<wsdl:message name="transformResponse">
|
||||||
|
<wsdl:part element="content:transformResponse" name="parameters"/>
|
||||||
|
</wsdl:message>
|
||||||
|
|
||||||
<wsdl:message name="ContentFault">
|
<wsdl:message name="ContentFault">
|
||||||
<wsdl:part element="content:ContentFault" name="fault"/>
|
<wsdl:part element="content:ContentFault" name="fault"/>
|
||||||
</wsdl:message>
|
</wsdl:message>
|
||||||
@@ -144,6 +172,12 @@
|
|||||||
<wsdl:input message="content:clearRequest"/>
|
<wsdl:input message="content:clearRequest"/>
|
||||||
<wsdl:output message="content:clearResponse"/>
|
<wsdl:output message="content:clearResponse"/>
|
||||||
<wsdl:fault message="content:ContentFault" name="ContentFault"/>
|
<wsdl:fault message="content:ContentFault" name="ContentFault"/>
|
||||||
|
</wsdl:operation>
|
||||||
|
<wsdl:operation name="transform">
|
||||||
|
<wsdl:documentation>Transforms content from one mimetype to another.</wsdl:documentation>
|
||||||
|
<wsdl:input message="content:transformRequest"/>
|
||||||
|
<wsdl:output message="content:transformResponse"/>
|
||||||
|
<wsdl:fault message="content:ContentFault" name="ContentFault"/>
|
||||||
</wsdl:operation>
|
</wsdl:operation>
|
||||||
</wsdl:portType>
|
</wsdl:portType>
|
||||||
|
|
||||||
@@ -186,7 +220,20 @@
|
|||||||
</wsdl:output>
|
</wsdl:output>
|
||||||
<wsdl:fault name="ContentFault">
|
<wsdl:fault name="ContentFault">
|
||||||
<wsdlsoap:fault namespace="http://www.alfresco.org/ws/service/content/1.0" use="literal" name="ContentFault"/>
|
<wsdlsoap:fault namespace="http://www.alfresco.org/ws/service/content/1.0" use="literal" name="ContentFault"/>
|
||||||
</wsdl:fault>
|
</wsdl:fault>
|
||||||
|
</wsdl:operation>
|
||||||
|
<wsdl:operation name="transform">
|
||||||
|
<wsdl:documentation>Transforms content from one mimetype to another.</wsdl:documentation>
|
||||||
|
<wsdlsoap:operation soapAction="http://www.alfresco.org/ws/service/content/1.0/transform"/>
|
||||||
|
<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>
|
||||||
</wsdl:binding>
|
</wsdl:binding>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user