mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- Added writeContent statement to CML
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3615 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -225,6 +225,14 @@
|
||||
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
|
||||
encodingStyle=""
|
||||
/>
|
||||
<typeMapping
|
||||
xmlns:ns="http://www.alfresco.org/ws/cml/1.0"
|
||||
qname="ns:>CML>writeContent"
|
||||
type="java:org.alfresco.repo.webservice.types.CMLWriteContent"
|
||||
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
|
||||
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
|
||||
encodingStyle=""
|
||||
/>
|
||||
<typeMapping
|
||||
xmlns:ns="http://www.alfresco.org/ws/cml/1.0"
|
||||
qname="ns:>CML>removeAspect"
|
||||
|
@@ -16,6 +16,8 @@ public class CML implements java.io.Serializable {
|
||||
|
||||
private org.alfresco.repo.webservice.types.CMLUpdate[] update;
|
||||
|
||||
private org.alfresco.repo.webservice.types.CMLWriteContent[] writeContent;
|
||||
|
||||
private org.alfresco.repo.webservice.types.CMLDelete[] delete;
|
||||
|
||||
private org.alfresco.repo.webservice.types.CMLMove[] move;
|
||||
@@ -38,6 +40,7 @@ public class CML implements java.io.Serializable {
|
||||
org.alfresco.repo.webservice.types.CMLAddAspect[] addAspect,
|
||||
org.alfresco.repo.webservice.types.CMLRemoveAspect[] removeAspect,
|
||||
org.alfresco.repo.webservice.types.CMLUpdate[] update,
|
||||
org.alfresco.repo.webservice.types.CMLWriteContent[] writeContent,
|
||||
org.alfresco.repo.webservice.types.CMLDelete[] delete,
|
||||
org.alfresco.repo.webservice.types.CMLMove[] move,
|
||||
org.alfresco.repo.webservice.types.CMLCopy[] copy,
|
||||
@@ -49,6 +52,7 @@ public class CML implements java.io.Serializable {
|
||||
this.addAspect = addAspect;
|
||||
this.removeAspect = removeAspect;
|
||||
this.update = update;
|
||||
this.writeContent = writeContent;
|
||||
this.delete = delete;
|
||||
this.move = move;
|
||||
this.copy = copy;
|
||||
@@ -171,6 +175,34 @@ public class CML implements java.io.Serializable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the writeContent value for this CML.
|
||||
*
|
||||
* @return writeContent
|
||||
*/
|
||||
public org.alfresco.repo.webservice.types.CMLWriteContent[] getWriteContent() {
|
||||
return writeContent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the writeContent value for this CML.
|
||||
*
|
||||
* @param writeContent
|
||||
*/
|
||||
public void setWriteContent(org.alfresco.repo.webservice.types.CMLWriteContent[] writeContent) {
|
||||
this.writeContent = writeContent;
|
||||
}
|
||||
|
||||
public org.alfresco.repo.webservice.types.CMLWriteContent getWriteContent(int i) {
|
||||
return this.writeContent[i];
|
||||
}
|
||||
|
||||
public void setWriteContent(int i, org.alfresco.repo.webservice.types.CMLWriteContent _value) {
|
||||
this.writeContent[i] = _value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the delete value for this CML.
|
||||
*
|
||||
@@ -390,6 +422,9 @@ public class CML implements java.io.Serializable {
|
||||
((this.update==null && other.getUpdate()==null) ||
|
||||
(this.update!=null &&
|
||||
java.util.Arrays.equals(this.update, other.getUpdate()))) &&
|
||||
((this.writeContent==null && other.getWriteContent()==null) ||
|
||||
(this.writeContent!=null &&
|
||||
java.util.Arrays.equals(this.writeContent, other.getWriteContent()))) &&
|
||||
((this.delete==null && other.getDelete()==null) ||
|
||||
(this.delete!=null &&
|
||||
java.util.Arrays.equals(this.delete, other.getDelete()))) &&
|
||||
@@ -466,6 +501,17 @@ public class CML implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getWriteContent() != null) {
|
||||
for (int i=0;
|
||||
i<java.lang.reflect.Array.getLength(getWriteContent());
|
||||
i++) {
|
||||
java.lang.Object obj = java.lang.reflect.Array.get(getWriteContent(), i);
|
||||
if (obj != null &&
|
||||
!obj.getClass().isArray()) {
|
||||
_hashCode += obj.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getDelete() != null) {
|
||||
for (int i=0;
|
||||
i<java.lang.reflect.Array.getLength(getDelete());
|
||||
@@ -586,6 +632,14 @@ public class CML implements java.io.Serializable {
|
||||
elemField.setMaxOccursUnbounded(true);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("writeContent");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", "writeContent"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", ">CML>writeContent"));
|
||||
elemField.setMinOccurs(0);
|
||||
elemField.setNillable(false);
|
||||
elemField.setMaxOccursUnbounded(true);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("delete");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", "delete"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", ">CML>delete"));
|
||||
|
@@ -0,0 +1,273 @@
|
||||
/**
|
||||
* CMLWriteContent.java
|
||||
*
|
||||
* This file was auto-generated from WSDL
|
||||
* by the Apache Axis 1.3 Oct 05, 2005 (05:23:37 EDT) WSDL2Java emitter.
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.webservice.types;
|
||||
|
||||
public class CMLWriteContent implements java.io.Serializable {
|
||||
private java.lang.String property;
|
||||
|
||||
private byte[] content;
|
||||
|
||||
private org.alfresco.repo.webservice.types.ContentFormat format;
|
||||
|
||||
private org.alfresco.repo.webservice.types.Predicate where;
|
||||
|
||||
private java.lang.String where_id;
|
||||
|
||||
public CMLWriteContent() {
|
||||
}
|
||||
|
||||
public CMLWriteContent(
|
||||
java.lang.String property,
|
||||
byte[] content,
|
||||
org.alfresco.repo.webservice.types.ContentFormat format,
|
||||
org.alfresco.repo.webservice.types.Predicate where,
|
||||
java.lang.String where_id) {
|
||||
this.property = property;
|
||||
this.content = content;
|
||||
this.format = format;
|
||||
this.where = where;
|
||||
this.where_id = where_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the property value for this CMLWriteContent.
|
||||
*
|
||||
* @return property
|
||||
*/
|
||||
public java.lang.String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the property value for this CMLWriteContent.
|
||||
*
|
||||
* @param property
|
||||
*/
|
||||
public void setProperty(java.lang.String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the content value for this CMLWriteContent.
|
||||
*
|
||||
* @return content
|
||||
*/
|
||||
public byte[] getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the content value for this CMLWriteContent.
|
||||
*
|
||||
* @param content
|
||||
*/
|
||||
public void setContent(byte[] content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the format value for this CMLWriteContent.
|
||||
*
|
||||
* @return format
|
||||
*/
|
||||
public org.alfresco.repo.webservice.types.ContentFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the format value for this CMLWriteContent.
|
||||
*
|
||||
* @param format
|
||||
*/
|
||||
public void setFormat(org.alfresco.repo.webservice.types.ContentFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the where value for this CMLWriteContent.
|
||||
*
|
||||
* @return where
|
||||
*/
|
||||
public org.alfresco.repo.webservice.types.Predicate getWhere() {
|
||||
return where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the where value for this CMLWriteContent.
|
||||
*
|
||||
* @param where
|
||||
*/
|
||||
public void setWhere(org.alfresco.repo.webservice.types.Predicate where) {
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the where_id value for this CMLWriteContent.
|
||||
*
|
||||
* @return where_id
|
||||
*/
|
||||
public java.lang.String getWhere_id() {
|
||||
return where_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the where_id value for this CMLWriteContent.
|
||||
*
|
||||
* @param where_id
|
||||
*/
|
||||
public void setWhere_id(java.lang.String where_id) {
|
||||
this.where_id = where_id;
|
||||
}
|
||||
|
||||
private java.lang.Object __equalsCalc = null;
|
||||
public synchronized boolean equals(java.lang.Object obj) {
|
||||
if (!(obj instanceof CMLWriteContent)) return false;
|
||||
CMLWriteContent other = (CMLWriteContent) obj;
|
||||
if (obj == null) return false;
|
||||
if (this == obj) return true;
|
||||
if (__equalsCalc != null) {
|
||||
return (__equalsCalc == obj);
|
||||
}
|
||||
__equalsCalc = obj;
|
||||
boolean _equals;
|
||||
_equals = true &&
|
||||
((this.property==null && other.getProperty()==null) ||
|
||||
(this.property!=null &&
|
||||
this.property.equals(other.getProperty()))) &&
|
||||
((this.content==null && other.getContent()==null) ||
|
||||
(this.content!=null &&
|
||||
java.util.Arrays.equals(this.content, other.getContent()))) &&
|
||||
((this.format==null && other.getFormat()==null) ||
|
||||
(this.format!=null &&
|
||||
this.format.equals(other.getFormat()))) &&
|
||||
((this.where==null && other.getWhere()==null) ||
|
||||
(this.where!=null &&
|
||||
this.where.equals(other.getWhere()))) &&
|
||||
((this.where_id==null && other.getWhere_id()==null) ||
|
||||
(this.where_id!=null &&
|
||||
this.where_id.equals(other.getWhere_id())));
|
||||
__equalsCalc = null;
|
||||
return _equals;
|
||||
}
|
||||
|
||||
private boolean __hashCodeCalc = false;
|
||||
public synchronized int hashCode() {
|
||||
if (__hashCodeCalc) {
|
||||
return 0;
|
||||
}
|
||||
__hashCodeCalc = true;
|
||||
int _hashCode = 1;
|
||||
if (getProperty() != null) {
|
||||
_hashCode += getProperty().hashCode();
|
||||
}
|
||||
if (getContent() != null) {
|
||||
for (int i=0;
|
||||
i<java.lang.reflect.Array.getLength(getContent());
|
||||
i++) {
|
||||
java.lang.Object obj = java.lang.reflect.Array.get(getContent(), i);
|
||||
if (obj != null &&
|
||||
!obj.getClass().isArray()) {
|
||||
_hashCode += obj.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getFormat() != null) {
|
||||
_hashCode += getFormat().hashCode();
|
||||
}
|
||||
if (getWhere() != null) {
|
||||
_hashCode += getWhere().hashCode();
|
||||
}
|
||||
if (getWhere_id() != null) {
|
||||
_hashCode += getWhere_id().hashCode();
|
||||
}
|
||||
__hashCodeCalc = false;
|
||||
return _hashCode;
|
||||
}
|
||||
|
||||
// Type metadata
|
||||
private static org.apache.axis.description.TypeDesc typeDesc =
|
||||
new org.apache.axis.description.TypeDesc(CMLWriteContent.class, true);
|
||||
|
||||
static {
|
||||
typeDesc.setXmlType(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", ">CML>writeContent"));
|
||||
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("property");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", "property"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("content");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", "content"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "base64Binary"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("format");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", "format"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.alfresco.org/ws/model/content/1.0", "ContentFormat"));
|
||||
elemField.setNillable(false);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("where");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", "where"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.alfresco.org/ws/model/content/1.0", "Predicate"));
|
||||
elemField.setMinOccurs(0);
|
||||
elemField.setNillable(true);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
elemField = new org.apache.axis.description.ElementDesc();
|
||||
elemField.setFieldName("where_id");
|
||||
elemField.setXmlName(new javax.xml.namespace.QName("http://www.alfresco.org/ws/cml/1.0", "where_id"));
|
||||
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||
elemField.setMinOccurs(0);
|
||||
elemField.setNillable(true);
|
||||
typeDesc.addFieldDesc(elemField);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type metadata object
|
||||
*/
|
||||
public static org.apache.axis.description.TypeDesc getTypeDesc() {
|
||||
return typeDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Serializer
|
||||
*/
|
||||
public static org.apache.axis.encoding.Serializer getSerializer(
|
||||
java.lang.String mechType,
|
||||
java.lang.Class _javaType,
|
||||
javax.xml.namespace.QName _xmlType) {
|
||||
return
|
||||
new org.apache.axis.encoding.ser.BeanSerializer(
|
||||
_javaType, _xmlType, typeDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Deserializer
|
||||
*/
|
||||
public static org.apache.axis.encoding.Deserializer getDeserializer(
|
||||
java.lang.String mechType,
|
||||
java.lang.Class _javaType,
|
||||
javax.xml.namespace.QName _xmlType) {
|
||||
return
|
||||
new org.apache.axis.encoding.ser.BeanDeserializer(
|
||||
_javaType, _xmlType, typeDesc);
|
||||
}
|
||||
|
||||
}
|
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.webservice;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -35,11 +37,15 @@ import org.alfresco.repo.webservice.types.CMLRemoveAspect;
|
||||
import org.alfresco.repo.webservice.types.CMLRemoveAssociation;
|
||||
import org.alfresco.repo.webservice.types.CMLRemoveChild;
|
||||
import org.alfresco.repo.webservice.types.CMLUpdate;
|
||||
import org.alfresco.repo.webservice.types.CMLWriteContent;
|
||||
import org.alfresco.repo.webservice.types.ContentFormat;
|
||||
import org.alfresco.repo.webservice.types.NamedValue;
|
||||
import org.alfresco.repo.webservice.types.ParentReference;
|
||||
import org.alfresco.repo.webservice.types.Predicate;
|
||||
import org.alfresco.repo.webservice.types.Reference;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.CopyService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -64,12 +70,14 @@ public class CMLUtil
|
||||
private static final String REMOVE_CHILD = "removeChild";
|
||||
private static final String CREATE_ASSOCIATION = "createAssociation";
|
||||
private static final String REMOVE_ASSOCIATION = "removeAssociation";
|
||||
private static final String WRITE_CONTENT = "writeContent";
|
||||
|
||||
private NodeService nodeService;
|
||||
private SearchService searchService;
|
||||
private NamespaceService namespaceService;
|
||||
private CopyService copyService;
|
||||
private DictionaryService dictionaryService;
|
||||
private ContentService contentService;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
@@ -96,6 +104,11 @@ public class CMLUtil
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a cml update query.
|
||||
*
|
||||
@@ -147,6 +160,15 @@ public class CMLUtil
|
||||
}
|
||||
}
|
||||
|
||||
CMLWriteContent[] writes = cml.getWriteContent();
|
||||
if (writes != null)
|
||||
{
|
||||
for (CMLWriteContent write : writes)
|
||||
{
|
||||
executeCMLWriteContent(write, context, results);
|
||||
}
|
||||
}
|
||||
|
||||
// Execute delete
|
||||
CMLDelete[] deletes = cml.getDelete();
|
||||
if (deletes != null)
|
||||
@@ -375,6 +397,34 @@ public class CMLUtil
|
||||
}
|
||||
}
|
||||
|
||||
private void executeCMLWriteContent(CMLWriteContent write, ExecutionContext context, List<UpdateResult> results)
|
||||
{
|
||||
// Get the nodes and content property
|
||||
List<NodeRef> nodeRefs = getNodeRefList(write.getWhere_id(), write.getWhere(), context);
|
||||
QName property = QName.createQName(write.getProperty());
|
||||
ContentFormat format = write.getFormat();
|
||||
byte[] content = write.getContent();
|
||||
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
//Get the content writer
|
||||
ContentWriter writer = this.contentService.getWriter(nodeRef, 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
|
||||
InputStream is = new ByteArrayInputStream(content);
|
||||
writer.putContent(is);
|
||||
|
||||
results.add(createResult(WRITE_CONTENT, null, nodeRef, nodeRef));
|
||||
}
|
||||
}
|
||||
|
||||
private void executeCMLDelete(CMLDelete delete, ExecutionContext context, List<UpdateResult> results)
|
||||
{
|
||||
List<NodeRef> nodeRefs = Utils.resolvePredicate(delete.getWhere(), this.nodeService, this.searchService, this.namespaceService);
|
||||
|
@@ -34,6 +34,8 @@ import org.alfresco.repo.webservice.types.CMLRemoveAspect;
|
||||
import org.alfresco.repo.webservice.types.CMLRemoveAssociation;
|
||||
import org.alfresco.repo.webservice.types.CMLRemoveChild;
|
||||
import org.alfresco.repo.webservice.types.CMLUpdate;
|
||||
import org.alfresco.repo.webservice.types.CMLWriteContent;
|
||||
import org.alfresco.repo.webservice.types.ContentFormat;
|
||||
import org.alfresco.repo.webservice.types.NamedValue;
|
||||
import org.alfresco.repo.webservice.types.ParentReference;
|
||||
import org.alfresco.repo.webservice.types.Predicate;
|
||||
@@ -41,6 +43,8 @@ import org.alfresco.repo.webservice.types.Reference;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@@ -57,6 +61,7 @@ public class CMLUtilTest extends BaseSpringTest
|
||||
{
|
||||
private static final ContentData CONTENT_DATA_TEXT_UTF8 = new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8");
|
||||
private static final ContentData CONTENT_DATA_HTML_UTF16 = new ContentData(null, MimetypeMap.MIMETYPE_HTML, 0L, "UTF-16");
|
||||
private static final String TEST_CONTENT = "This is some test content";
|
||||
|
||||
private CMLUtil cmlUtil;
|
||||
private NodeService nodeService;
|
||||
@@ -67,6 +72,7 @@ public class CMLUtilTest extends BaseSpringTest
|
||||
private SearchService searchService;
|
||||
private NodeRef folderNodeRef;
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private ContentService contentService;
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations()
|
||||
@@ -82,6 +88,7 @@ public class CMLUtilTest extends BaseSpringTest
|
||||
this.searchService = (SearchService)this.applicationContext.getBean("searchService");
|
||||
this.namespaceService = (NamespaceService)this.applicationContext.getBean("namespaceService");
|
||||
this.authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent");
|
||||
this.contentService = (ContentService)this.applicationContext.getBean("contentService");
|
||||
|
||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||
|
||||
@@ -212,6 +219,32 @@ public class CMLUtilTest extends BaseSpringTest
|
||||
assertEquals(CONTENT_DATA_HTML_UTF16, this.nodeService.getProperty(this.nodeRef, ContentModel.PROP_CONTENT));
|
||||
}
|
||||
|
||||
public void testWriteContent()
|
||||
{
|
||||
CMLWriteContent write = new CMLWriteContent();
|
||||
write.setWhere(createPredicate(this.nodeRef));
|
||||
write.setProperty(ContentModel.PROP_CONTENT.toString());
|
||||
ContentFormat format = new ContentFormat(MimetypeMap.MIMETYPE_TEXT_PLAIN, "UTF-8");
|
||||
write.setFormat(format);
|
||||
write.setContent(TEST_CONTENT.getBytes());
|
||||
|
||||
CML cml = new CML();
|
||||
cml.setWriteContent(new CMLWriteContent[]{write});
|
||||
|
||||
UpdateResult[] result = this.cmlUtil.executeCML(cml);
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.length);
|
||||
|
||||
UpdateResult updateResult = result[0];
|
||||
assertEquals("writeContent", updateResult.getStatement());
|
||||
assertNotNull(updateResult.getSource());
|
||||
assertNotNull(updateResult.getDestination());
|
||||
|
||||
ContentReader reader = this.contentService.getReader(this.nodeRef, ContentModel.PROP_CONTENT);
|
||||
assertNotNull(reader);
|
||||
assertEquals(reader.getContentString(), TEST_CONTENT);
|
||||
}
|
||||
|
||||
public void testDelete()
|
||||
{
|
||||
CMLDelete delete = new CMLDelete();
|
||||
|
@@ -49,6 +49,9 @@
|
||||
<property name="dictionaryService">
|
||||
<ref bean="DictionaryService"/>
|
||||
</property>
|
||||
<property name="contentService">
|
||||
<ref bean="ContentService"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Implementations of each exposed web service -->
|
||||
|
@@ -52,7 +52,18 @@
|
||||
<xsd:group ref="cml:Where"></xsd:group>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="writeContent" maxOccurs="unbounded" minOccurs="0">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="property" type="xsd:string"/>
|
||||
<xsd:element name="content" type="xsd:base64Binary"/>
|
||||
<xsd:element name="format" type="cms:ContentFormat"/>
|
||||
<xsd:group ref="cml:Where"></xsd:group>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="delete" maxOccurs="unbounded" minOccurs="0">
|
||||
<xsd:complexType>
|
||||
|
Reference in New Issue
Block a user