mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged DEV/CMIS0_61 to HEAD (part 4)
14095 CMIS 0.61 Web Services Including Tests & JavaClient 14123 Several Minor Fixes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14177 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,7 +28,9 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.repo.cmis.ws.FilterNotValidException;
|
||||
import org.alfresco.repo.cmis.ws.CmisException;
|
||||
import org.alfresco.repo.cmis.ws.EnumServiceException;
|
||||
import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils;
|
||||
|
||||
/**
|
||||
* Property filter supporting CMIS filter expression
|
||||
@@ -52,11 +54,11 @@ public class PropertyFilter
|
||||
* @param filter filter value (case insensitive)
|
||||
* @throws FilterNotValidException if filter string isn't valid
|
||||
*/
|
||||
public PropertyFilter(String filter) throws FilterNotValidException
|
||||
public PropertyFilter(String filter, CmisObjectsUtils cmisObjectsUtils) throws CmisException
|
||||
{
|
||||
if (filter == null || filter.length() < MINIMAL_ALLOWED_STRUCTURE_SIZE ? false : !PROPERTY_FILTER_REGEX.matcher(filter).matches())
|
||||
{
|
||||
throw new FilterNotValidException("\"" + filter + "\" filter value is invalid");
|
||||
throw cmisObjectsUtils.createCmisException(("\"" + filter + "\" filter value is invalid"), EnumServiceException.FILTER_NOT_VALID);
|
||||
}
|
||||
|
||||
if (!filter.equals(MATCH_ALL_FILTER) && filter.length() >= MINIMAL_ALLOWED_STRUCTURE_SIZE)
|
||||
|
@@ -24,15 +24,15 @@
|
||||
*/
|
||||
package org.alfresco.repo.cmis;
|
||||
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.FilterNotValidException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.alfresco.repo.cmis.ws.CmisException;
|
||||
import org.alfresco.repo.cmis.ws.EnumServiceException;
|
||||
import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class PropertyFilterTest extends TestCase
|
||||
public class PropertyFilterTest extends AbstractDependencyInjectionSpringContextTests
|
||||
{
|
||||
private static final String NAME_TOKEN = "name";
|
||||
|
||||
@@ -58,22 +58,28 @@ public class PropertyFilterTest extends TestCase
|
||||
private static final String INVALID_FILTER_WITH_DENIED_SYMBOL = "ObjectId; name";
|
||||
private static final String INVALID_FILTER_WITH_LAST_INVALID_SYMBOL = "ObjectId, name*";
|
||||
|
||||
|
||||
private CmisObjectsUtils cmisObjectsUtils;
|
||||
|
||||
public void setCmisObjectsUtils(CmisObjectsUtils cmisObjectsUtils)
|
||||
{
|
||||
this.cmisObjectsUtils = cmisObjectsUtils;
|
||||
}
|
||||
|
||||
public void testValidFilters() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
allTokensValidAssertion(new PropertyFilter());
|
||||
allTokensValidAssertion(new PropertyFilter(VALID_MATCHE_ALL_EMPTY_FILTER));
|
||||
allTokensValidAssertion(new PropertyFilter(VALID_MATCHE_ALL_FILTER));
|
||||
allTokensValidAssertion(new PropertyFilter(VALID_MATCHE_ALL_EMPTY_FILTER, cmisObjectsUtils));
|
||||
allTokensValidAssertion(new PropertyFilter(VALID_MATCHE_ALL_FILTER, cmisObjectsUtils));
|
||||
|
||||
onlyNameTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_NAME));
|
||||
onlyNameTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_NAME, cmisObjectsUtils));
|
||||
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(LONG_VALID_FILTER_WITH_SEVERAL_TOKENS));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_WITHOUT_BREAKS));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_BREAKS_IN_SOME_PLACES));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_SEVERAL_BREAKS_IN_SOME_PLACES));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS, cmisObjectsUtils));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(LONG_VALID_FILTER_WITH_SEVERAL_TOKENS, cmisObjectsUtils));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_WITHOUT_BREAKS, cmisObjectsUtils));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_BREAKS_IN_SOME_PLACES, cmisObjectsUtils));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_SEVERAL_BREAKS_IN_SOME_PLACES, cmisObjectsUtils));
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
@@ -142,14 +148,22 @@ public class PropertyFilterTest extends TestCase
|
||||
{
|
||||
try
|
||||
{
|
||||
new PropertyFilter(filterValue);
|
||||
new PropertyFilter(filterValue, cmisObjectsUtils);
|
||||
|
||||
fail("Invalid filter \"" + filterValue + "\" was interpreted as valid");
|
||||
}
|
||||
catch (Throwable e)
|
||||
catch (CmisException e)
|
||||
{
|
||||
assertTrue(("Unexpected exception type was thrown: " + e.getClass().getName()), e instanceof FilterNotValidException);
|
||||
assertEquals(("Unexpected exception type was thrown: " + e.getClass().getName()), EnumServiceException.FILTER_NOT_VALID, e.getFaultInfo().getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations()
|
||||
{
|
||||
setAutowireMode(AUTOWIRE_BY_NAME);
|
||||
setDependencyCheck(false);
|
||||
|
||||
return new String[] { "classpath:alfresco/cmis-ws-context.xml" };
|
||||
}
|
||||
}
|
||||
|
@@ -39,6 +39,7 @@ import org.apache.ws.security.handler.WSHandlerConstants;
|
||||
import org.apache.ws.security.handler.WSHandlerResult;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class AuthenticationInterceptor extends AbstractSoapInterceptor
|
||||
|
@@ -48,7 +48,9 @@ public class ContentReaderDataSource implements DataSource
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.activation.DataSource#getContentType()
|
||||
*/
|
||||
public String getContentType()
|
||||
@@ -56,7 +58,9 @@ public class ContentReaderDataSource implements DataSource
|
||||
return contentReader.getMimetype();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.activation.DataSource#getInputStream()
|
||||
*/
|
||||
public InputStream getInputStream() throws IOException
|
||||
@@ -64,7 +68,9 @@ public class ContentReaderDataSource implements DataSource
|
||||
return contentReader.getContentInputStream();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.activation.DataSource#getName()
|
||||
*/
|
||||
public String getName()
|
||||
@@ -72,7 +78,9 @@ public class ContentReaderDataSource implements DataSource
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.activation.DataSource#getOutputStream()
|
||||
*/
|
||||
public OutputStream getOutputStream() throws IOException
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -67,7 +67,7 @@ import org.alfresco.service.descriptor.DescriptorService;
|
||||
|
||||
/**
|
||||
* Base class for all CMIS web services
|
||||
*
|
||||
*
|
||||
* @author Michael Shavnev
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
@@ -77,6 +77,9 @@ public class DMAbstractServicePort
|
||||
private static final String BASE_TYPE_PROPERTY_NAME = "BaseType";
|
||||
protected static final String INITIAL_VERSION_DESCRIPTION = "Initial version";
|
||||
|
||||
private static final String INVALID_REPOSITORY_ID_MESSAGE = "Invalid repository id";
|
||||
private static final String INVALID_FOLDER_OBJECT_ID_MESSAGE = "OID for non-existent object or not folder object";
|
||||
|
||||
private DatatypeFactory _datatypeFactory;
|
||||
private Paging paging = new Paging();
|
||||
|
||||
@@ -92,7 +95,6 @@ public class DMAbstractServicePort
|
||||
protected SearchService searchService;
|
||||
protected CmisObjectsUtils cmisObjectsUtils;
|
||||
|
||||
|
||||
public void setCmisService(CMISServices cmisService)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
@@ -143,13 +145,13 @@ public class DMAbstractServicePort
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
protected static PropertyFilter createPropertyFilter(String filter) throws FilterNotValidException
|
||||
|
||||
protected PropertyFilter createPropertyFilter(String filter) throws CmisException
|
||||
{
|
||||
return (filter == null) ? (new PropertyFilter()) : (new PropertyFilter(filter));
|
||||
return (filter == null) ? (new PropertyFilter()) : (new PropertyFilter(filter, cmisObjectsUtils));
|
||||
}
|
||||
|
||||
protected static PropertyFilter createPropertyFilter(JAXBElement<String> element) throws FilterNotValidException
|
||||
protected PropertyFilter createPropertyFilter(JAXBElement<String> element) throws CmisException
|
||||
{
|
||||
String filter = null;
|
||||
if (element != null)
|
||||
@@ -167,7 +169,7 @@ public class DMAbstractServicePort
|
||||
|
||||
/**
|
||||
* Converts Date object to XMLGregorianCalendar object
|
||||
*
|
||||
*
|
||||
* @param date Date object
|
||||
* @return XMLGregorianCalendar object
|
||||
*/
|
||||
@@ -200,10 +202,9 @@ public class DMAbstractServicePort
|
||||
* @param filter properties filter value for filtering objects returning properties
|
||||
* @param sourceList the list that contains all returning Node References
|
||||
* @param resultList the list of <b>CmisObjectType</b> values for end response result collecting
|
||||
* @throws InvalidArgumentException
|
||||
* @throws FilterNotValidException
|
||||
* @throws CmisException
|
||||
*/
|
||||
protected void createCmisObjectList(PropertyFilter filter, List<NodeRef> sourceList, List<CmisObjectType> resultList) throws InvalidArgumentException, FilterNotValidException
|
||||
protected void createCmisObjectList(PropertyFilter filter, List<NodeRef> sourceList, List<CmisObjectType> resultList) throws CmisException
|
||||
{
|
||||
for (NodeRef objectNodeRef : sourceList)
|
||||
{
|
||||
@@ -227,15 +228,15 @@ public class DMAbstractServicePort
|
||||
|
||||
/**
|
||||
* Asserts "Folder with folderNodeRef exists"
|
||||
*
|
||||
*
|
||||
* @param folderNodeRef node reference
|
||||
* @throws FolderNotValidException folderNodeRef doesn't exist or folderNodeRef isn't for folder object
|
||||
*/
|
||||
protected void assertExistFolder(NodeRef folderNodeRef) throws FolderNotValidException
|
||||
protected void assertExistFolder(NodeRef folderNodeRef) throws CmisException
|
||||
{
|
||||
if (!this.cmisObjectsUtils.isFolder(folderNodeRef))
|
||||
{
|
||||
throw new FolderNotValidException("OID for non-existent object or not folder object");
|
||||
throw new CmisException(INVALID_FOLDER_OBJECT_ID_MESSAGE, cmisObjectsUtils.createCmisException(INVALID_FOLDER_OBJECT_ID_MESSAGE, EnumServiceException.INVALID_ARGUMENT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,19 +244,19 @@ public class DMAbstractServicePort
|
||||
* Checks specified in CMIS request parameters repository Id.
|
||||
*
|
||||
* @param repositoryId repository id
|
||||
* @throws InvalidArgumentException repository diesn't exist
|
||||
* @throws CmisException repository diesn't exist
|
||||
*/
|
||||
protected void checkRepositoryId(String repositoryId) throws InvalidArgumentException
|
||||
protected void checkRepositoryId(String repositoryId) throws CmisException
|
||||
{
|
||||
if (!this.descriptorService.getCurrentRepositoryDescriptor().getId().equals(repositoryId))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid repository id");
|
||||
throw cmisObjectsUtils.createCmisException(INVALID_REPOSITORY_ID_MESSAGE, EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CMIS properties for object
|
||||
*
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param filter property filter
|
||||
* @return properties
|
||||
@@ -352,7 +353,8 @@ public class DMAbstractServicePort
|
||||
result.put(VersionModel.PROP_VERSION_TYPE, versionType);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addBooleanProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties)
|
||||
{
|
||||
Serializable value = alfrescoProperties.get(name);
|
||||
@@ -360,26 +362,25 @@ public class DMAbstractServicePort
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
long index = 0;
|
||||
for (Object multiValue : (Collection)value)
|
||||
for (Object multiValue : (Collection) value)
|
||||
{
|
||||
CmisPropertyBoolean propBoolean = new CmisPropertyBoolean ();
|
||||
propBoolean.setIndex(BigInteger.valueOf(index++));
|
||||
CmisPropertyBoolean propBoolean = new CmisPropertyBoolean();
|
||||
propBoolean.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propBoolean.setValue((Boolean) multiValue);
|
||||
propBoolean.getValue().add((Boolean) multiValue);
|
||||
properties.getProperty().add(propBoolean);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CmisPropertyBoolean propBoolean = new CmisPropertyBoolean ();
|
||||
CmisPropertyBoolean propBoolean = new CmisPropertyBoolean();
|
||||
propBoolean.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propBoolean.setValue((Boolean) value);
|
||||
propBoolean.getValue().add((Boolean) value);
|
||||
properties.getProperty().add(propBoolean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addDateTimeProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties)
|
||||
{
|
||||
Serializable value = alfrescoProperties.get(name);
|
||||
@@ -387,13 +388,11 @@ public class DMAbstractServicePort
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
long index = 0;
|
||||
for (Object multiValue : (Collection)value)
|
||||
for (Object multiValue : (Collection) value)
|
||||
{
|
||||
CmisPropertyDateTime propDateTime = new CmisPropertyDateTime();
|
||||
propDateTime.setIndex(BigInteger.valueOf(index++));
|
||||
propDateTime.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propDateTime.setValue(convert((Date) multiValue));
|
||||
propDateTime.getValue().add(convert((Date) multiValue));
|
||||
properties.getProperty().add(propDateTime);
|
||||
}
|
||||
}
|
||||
@@ -401,12 +400,13 @@ public class DMAbstractServicePort
|
||||
{
|
||||
CmisPropertyDateTime propDateTime = new CmisPropertyDateTime();
|
||||
propDateTime.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propDateTime.setValue(convert((Date) value));
|
||||
propDateTime.getValue().add(convert((Date) value));
|
||||
properties.getProperty().add(propDateTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addIDProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties)
|
||||
{
|
||||
Serializable value = alfrescoProperties.get(name);
|
||||
@@ -414,13 +414,11 @@ public class DMAbstractServicePort
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
long index = 0;
|
||||
for (Object multiValue : (Collection)value)
|
||||
for (Object multiValue : (Collection) value)
|
||||
{
|
||||
CmisPropertyId propID = new CmisPropertyId();
|
||||
propID.setIndex(BigInteger.valueOf(index++));
|
||||
propID.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propID.setValue(multiValue.toString());
|
||||
propID.getValue().add(multiValue.toString());
|
||||
properties.getProperty().add(propID);
|
||||
}
|
||||
}
|
||||
@@ -428,12 +426,13 @@ public class DMAbstractServicePort
|
||||
{
|
||||
CmisPropertyId propID = new CmisPropertyId();
|
||||
propID.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propID.setValue(value.toString());
|
||||
propID.getValue().add(value.toString());
|
||||
properties.getProperty().add(propID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addIntegerProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties)
|
||||
{
|
||||
Serializable value = alfrescoProperties.get(name);
|
||||
@@ -441,13 +440,11 @@ public class DMAbstractServicePort
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
long index = 0;
|
||||
for (Object multiValue : (Collection)value)
|
||||
for (Object multiValue : (Collection) value)
|
||||
{
|
||||
CmisPropertyInteger propInteger = new CmisPropertyInteger();
|
||||
propInteger.setIndex(BigInteger.valueOf(index++));
|
||||
propInteger.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propInteger.setValue(BigInteger.valueOf((Long) multiValue));
|
||||
propInteger.getValue().add(BigInteger.valueOf((Long) multiValue));
|
||||
properties.getProperty().add(propInteger);
|
||||
}
|
||||
}
|
||||
@@ -455,12 +452,13 @@ public class DMAbstractServicePort
|
||||
{
|
||||
CmisPropertyInteger propInteger = new CmisPropertyInteger();
|
||||
propInteger.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propInteger.setValue(BigInteger.valueOf((Long) value));
|
||||
propInteger.getValue().add(BigInteger.valueOf((Long) value));
|
||||
properties.getProperty().add(propInteger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addDecimalProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties)
|
||||
{
|
||||
Serializable value = alfrescoProperties.get(name);
|
||||
@@ -468,13 +466,11 @@ public class DMAbstractServicePort
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
long index = 0;
|
||||
for (Object multiValue : (Collection)value)
|
||||
for (Object multiValue : (Collection) value)
|
||||
{
|
||||
CmisPropertyDecimal propDecimal = new CmisPropertyDecimal();
|
||||
propDecimal.setIndex(BigInteger.valueOf(index++));
|
||||
propDecimal.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propDecimal.setValue(BigDecimal.valueOf((Long) multiValue));
|
||||
propDecimal.getValue().add(BigDecimal.valueOf((Long) multiValue));
|
||||
properties.getProperty().add(propDecimal);
|
||||
}
|
||||
}
|
||||
@@ -482,12 +478,13 @@ public class DMAbstractServicePort
|
||||
{
|
||||
CmisPropertyDecimal propDecimal = new CmisPropertyDecimal();
|
||||
propDecimal.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propDecimal.setValue(BigDecimal.valueOf((Long) value));
|
||||
propDecimal.getValue().add(BigDecimal.valueOf((Long) value));
|
||||
properties.getProperty().add(propDecimal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addStringProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties)
|
||||
{
|
||||
Serializable value = alfrescoProperties.get(name);
|
||||
@@ -495,13 +492,11 @@ public class DMAbstractServicePort
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
long index = 0;
|
||||
for (Object multiValue : (Collection)value)
|
||||
for (Object multiValue : (Collection) value)
|
||||
{
|
||||
CmisPropertyString propString = new CmisPropertyString();
|
||||
propString.setIndex(BigInteger.valueOf(index++));
|
||||
propString.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propString.setValue(multiValue.toString());
|
||||
propString.getValue().add(multiValue.toString());
|
||||
properties.getProperty().add(propString);
|
||||
}
|
||||
}
|
||||
@@ -509,7 +504,7 @@ public class DMAbstractServicePort
|
||||
{
|
||||
CmisPropertyString propString = new CmisPropertyString();
|
||||
propString.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propString.setValue(value.toString());
|
||||
propString.getValue().add(value.toString());
|
||||
properties.getProperty().add(propString);
|
||||
}
|
||||
}
|
||||
@@ -521,11 +516,12 @@ public class DMAbstractServicePort
|
||||
{
|
||||
CmisPropertyString propString = new CmisPropertyString();
|
||||
propString.setName(name);
|
||||
propString.setValue(value);
|
||||
propString.getValue().add(value);
|
||||
properties.getProperty().add(propString);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addURIProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties)
|
||||
{
|
||||
Serializable value = alfrescoProperties.get(name);
|
||||
@@ -533,13 +529,11 @@ public class DMAbstractServicePort
|
||||
{
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
long index = 0;
|
||||
for (Object multiValue : (Collection)value)
|
||||
for (Object multiValue : (Collection) value)
|
||||
{
|
||||
CmisPropertyUri propString = new CmisPropertyUri();
|
||||
propString.setIndex(BigInteger.valueOf(index++));
|
||||
propString.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propString.setValue(multiValue.toString());
|
||||
propString.getValue().add(multiValue.toString());
|
||||
properties.getProperty().add(propString);
|
||||
}
|
||||
}
|
||||
@@ -547,12 +541,12 @@ public class DMAbstractServicePort
|
||||
{
|
||||
CmisPropertyUri propString = new CmisPropertyUri();
|
||||
propString.setName(PropertyUtil.getCMISPropertyName(name));
|
||||
propString.setValue(value.toString());
|
||||
propString.getValue().add(value.toString());
|
||||
properties.getProperty().add(propString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets all <i>properties</i>' fields for specified node
|
||||
*
|
||||
@@ -572,7 +566,7 @@ public class DMAbstractServicePort
|
||||
|
||||
/**
|
||||
* Returns latest minor or major version of document
|
||||
*
|
||||
*
|
||||
* @param documentNodeRef document node reference
|
||||
* @param major need latest major version
|
||||
* @return latest version node reference
|
||||
@@ -590,23 +584,29 @@ public class DMAbstractServicePort
|
||||
{
|
||||
Version latestVersion = versionService.getCurrentVersion(latestVersionNodeRef);
|
||||
|
||||
if (latestVersion.getVersionType().equals(VersionType.MAJOR) == false)
|
||||
if ((latestVersion != null) && (VersionType.MAJOR != latestVersion.getVersionType()))
|
||||
{
|
||||
VersionHistory versionHistory = versionService.getVersionHistory(currentVersion.getVersionedNodeRef());
|
||||
|
||||
do
|
||||
if (versionHistory != null)
|
||||
{
|
||||
latestVersion = versionHistory.getPredecessor(latestVersion);
|
||||
} while (latestVersion.getVersionType().equals(VersionType.MAJOR) == false);
|
||||
do
|
||||
{
|
||||
latestVersion = versionHistory.getPredecessor(latestVersion);
|
||||
} while (latestVersion != null && (VersionType.MAJOR != latestVersion.getVersionType()));
|
||||
}
|
||||
|
||||
latestVersionNodeRef = latestVersion.getFrozenStateNodeRef();
|
||||
if (latestVersion != null)
|
||||
{
|
||||
latestVersionNodeRef = latestVersion.getFrozenStateNodeRef();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return latestVersionNodeRef;
|
||||
}
|
||||
|
||||
|
||||
protected NodeRef checkoutNode(NodeRef documentNodeReference)
|
||||
{
|
||||
if (!this.nodeService.hasAspect(documentNodeReference, ContentModel.ASPECT_VERSIONABLE))
|
||||
@@ -616,7 +616,7 @@ public class DMAbstractServicePort
|
||||
return checkOutCheckInService.checkout(documentNodeReference);
|
||||
}
|
||||
|
||||
protected CMISTypeDefinition getCmisTypeDefinition(String typeId) throws InvalidArgumentException
|
||||
protected CMISTypeDefinition getCmisTypeDefinition(String typeId) throws CmisException
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -624,7 +624,7 @@ public class DMAbstractServicePort
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid typeId " + typeId);
|
||||
throw new CmisException(("Invalid typeId " + typeId), cmisObjectsUtils.createCmisException(("Invalid typeId " + typeId), EnumServiceException.INVALID_ARGUMENT));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,12 @@
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.cmis.CMISQueryOptions;
|
||||
import org.alfresco.cmis.CMISResultSet;
|
||||
@@ -40,7 +44,7 @@ import org.alfresco.repo.cmis.PropertyFilter;
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
*/
|
||||
@javax.jws.WebService(name = "DiscoveryServicePort", serviceName = "DiscoveryService", portName = "DiscoveryServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.DiscoveryServicePort")
|
||||
@javax.jws.WebService(name = "DiscoveryServicePort", serviceName = "DiscoveryService", portName = "DiscoveryServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200901", endpointInterface = "org.alfresco.repo.cmis.ws.DiscoveryServicePort")
|
||||
public class DMDiscoveryServicePort extends DMAbstractServicePort implements DiscoveryServicePort
|
||||
{
|
||||
|
||||
@@ -49,18 +53,13 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
|
||||
* part of query
|
||||
*
|
||||
* @param parameters query parameters
|
||||
* @return collection of CmisObjectType and boolean hasMoreItems
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public QueryResponse query(CmisQueryType parameters) throws PermissionDeniedException, UpdateConflictException, OperationNotSupportedException, InvalidArgumentException,
|
||||
RuntimeException, ConstraintViolationException
|
||||
public QueryResponse query(CmisQueryType parameters) throws CmisException
|
||||
{
|
||||
// TODO: searchAllVersions, returnAllowableActions, includeRelationships
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
// TODO: searchAllVersions, returnAllowableActions
|
||||
CMISQueryOptions options = new CMISQueryOptions(parameters.getStatement(), cmisService.getDefaultRootStoreRef());
|
||||
|
||||
if (parameters.getSkipCount() != null)
|
||||
@@ -78,7 +77,7 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
|
||||
CMISResultSetMetaData metaData = resultSet.getMetaData();
|
||||
CMISResultSetColumn[] columns = metaData.getColumns();
|
||||
PropertyFilter filter = new PropertyFilter();
|
||||
|
||||
|
||||
// build query response
|
||||
QueryResponse response = new QueryResponse();
|
||||
|
||||
@@ -87,7 +86,7 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
|
||||
{
|
||||
CmisPropertiesType properties = new CmisPropertiesType();
|
||||
Map<String, Serializable> values = row.getValues();
|
||||
|
||||
|
||||
// for each column...
|
||||
for (CMISResultSetColumn column : columns)
|
||||
{
|
||||
@@ -123,22 +122,27 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
|
||||
else if (type == CMISDataTypeEnum.XML)
|
||||
{
|
||||
// TODO:
|
||||
throw new UnsupportedOperationException();
|
||||
throw cmisObjectsUtils.createCmisException("", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
else if (type == CMISDataTypeEnum.HTML)
|
||||
{
|
||||
// TODO:
|
||||
throw new UnsupportedOperationException();
|
||||
throw cmisObjectsUtils.createCmisException("", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CmisObjectType object = new CmisObjectType();
|
||||
object.setProperties(properties);
|
||||
response.getObject().add(object);
|
||||
}
|
||||
|
||||
|
||||
response.setHasMoreItems(resultSet.hasMore());
|
||||
return response;
|
||||
}
|
||||
|
||||
public void getContentChanges(String repositoryId, Holder<String> changeToken, BigInteger maxItems, Boolean includeACL, Boolean includeProperties, String filter,
|
||||
Holder<List<CmisObjectType>> changedObject) throws CmisException
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
@@ -33,7 +35,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "MultiFilingServicePort", serviceName = "MultiFilingService", portName = "MultiFilingServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.MultiFilingServicePort")
|
||||
@javax.jws.WebService(name = "MultiFilingServicePort", serviceName = "MultiFilingService", portName = "MultiFilingServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200901", endpointInterface = "org.alfresco.repo.cmis.ws.MultiFilingServicePort")
|
||||
public class DMMultiFilingServicePort extends DMAbstractServicePort implements MultiFilingServicePort
|
||||
{
|
||||
/**
|
||||
@@ -42,24 +44,22 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
|
||||
* @param repositoryId Repository Id
|
||||
* @param objectId object Id to be added to a folder
|
||||
* @param folderId folder Id to which the object is added
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws FolderNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT)
|
||||
*/
|
||||
public void addObjectToFolder(String repositoryId, String objectId, String folderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void addObjectToFolder(String repositoryId, String objectId, String folderId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef parentFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
// TODO: check for allowed child object types
|
||||
CMISTypeDefinition objectType = cmisDictionaryService.findType((String) cmisService.getProperty(objectNodeRef, CMISDictionaryModel.PROP_OBJECT_TYPE_ID));
|
||||
CMISTypeDefinition folderType = cmisDictionaryService.findType((String) cmisService.getProperty(parentFolderNodeRef, CMISDictionaryModel.PROP_OBJECT_TYPE_ID));
|
||||
|
||||
if (!folderType.getAllowedTargetTypes().contains(objectType))
|
||||
{
|
||||
cmisObjectsUtils.createCmisException("The typeID of Object is not in the list of AllowedChildObjectTypeIds of the parent-folder specified by folderId",
|
||||
EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
cmisObjectsUtils.addObjectToFolder(objectNodeRef, parentFolderNodeRef);
|
||||
}
|
||||
|
||||
@@ -69,18 +69,9 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId The object to be removed from a folder
|
||||
* @param folderId The folder to be removed from.
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws FolderNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws NotInFolderException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
@@ -92,11 +83,11 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
|
||||
|
||||
if (!cmisObjectsUtils.removeObject(objectNodeReference, folderNodeReference))
|
||||
{
|
||||
throw new NotInFolderException("The specified Object is not child of the specified Folder Object");
|
||||
throw cmisObjectsUtils.createCmisException("The specified Object is not child of the specified Folder Object", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
private NodeRef checkAndReceiveFolderIdentifier(String folderIdentifier) throws OperationNotSupportedException
|
||||
private NodeRef checkAndReceiveFolderIdentifier(String folderIdentifier) throws CmisException
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -104,15 +95,15 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new OperationNotSupportedException("Unfiling is not supported. An Object can't be deleted from all Folders");
|
||||
throw cmisObjectsUtils.createCmisException("Unfiling is not supported. An Object can't be deleted from all Folders", EnumServiceException.NOT_SUPPORTED, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkObjectChildParentRelationships(NodeRef objectNodeReference, NodeRef folderNodeReference) throws OperationNotSupportedException
|
||||
private void checkObjectChildParentRelationships(NodeRef objectNodeReference, NodeRef folderNodeReference) throws CmisException
|
||||
{
|
||||
if (cmisObjectsUtils.isPrimaryObjectParent(folderNodeReference, objectNodeReference))
|
||||
{
|
||||
throw new OperationNotSupportedException("Unfiling is not supported. Use deleteObjectService instead");
|
||||
throw cmisObjectsUtils.createCmisException("Unfiling is not supported. Use deleteObjectService instead", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -28,15 +28,19 @@ import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISTypesFilterEnum;
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
import com.sun.star.auth.InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Port for navigation service
|
||||
@@ -44,42 +48,45 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "NavigationServicePort", serviceName = "NavigationService", portName = "NavigationServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.NavigationServicePort")
|
||||
@javax.jws.WebService(name = "NavigationServicePort", serviceName = "NavigationService", portName = "NavigationServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200901", endpointInterface = "org.alfresco.repo.cmis.ws.NavigationServicePort")
|
||||
public class DMNavigationServicePort extends DMAbstractServicePort implements NavigationServicePort
|
||||
{
|
||||
private static final String POLICIES_LISTING_UNSUPPORTED_EXCEPTION_MESSAGE = "Policies listing isn't supported";
|
||||
private static final int EQUALS_CONDITION_VALUE = 0;
|
||||
private static final BigInteger FULL_DESCENDANTS_HIERARCHY_CONDITION = BigInteger.valueOf(-1l);
|
||||
|
||||
private static final String FILTER_TOKENS_DELIMETER = ", ";
|
||||
private static final String POLICIES_LISTING_UNSUPPORTED_EXCEPTION_MESSAGE = "Policies listing isn't supported";
|
||||
|
||||
private static final Pattern ORDER_BY_CLAUSE_MASK = Pattern.compile("^( )*([\\p{Alnum}_]+(( )+((ASC)|(DESC)))?){1}((,){1}( )*[\\p{Alnum}_]+(( )+((ASC)|(DESC)))?)*( )*$",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/**
|
||||
* Gets the private working copies of checked-out objects that the user is allowed to update.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; folderID: folder Id; filter: property filter; includeAllowableActions; includeRelationships; maxItems: 0 = Unlimited;
|
||||
* skipCount: 0 = start at beginning
|
||||
* @return collection of CmisObjectType and boolean hasMoreItems
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws FilterNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FolderNotValidException
|
||||
* @throws PermissionDeniedException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetCheckedoutDocsResponse getCheckedoutDocs(GetCheckedoutDocs parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException,
|
||||
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
public GetCheckedoutDocsResponse getCheckedoutDocs(GetCheckedoutDocs parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
|
||||
NodeRef folderId = null;
|
||||
String folderIdParam = parameters.getFolderID() == null ? null : parameters.getFolderID().getValue();
|
||||
if (folderIdParam != null)
|
||||
String folderIdParam = parameters.getFolderId() == null ? null : parameters.getFolderId().getValue();
|
||||
if ((folderIdParam != null) && !folderIdParam.equals(""))
|
||||
{
|
||||
folderId = cmisObjectsUtils.getIdentifierInstance(folderIdParam, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
List<Pair<String, Boolean>> orderingFields = null;
|
||||
if ((parameters.getOrderBy() != null) && (parameters.getOrderBy().getValue() != null) && !parameters.getOrderBy().getValue().equals(""))
|
||||
{
|
||||
orderingFields = checkAndParseOrderByClause(parameters.getOrderBy().getValue());
|
||||
}
|
||||
|
||||
// TODO: Ordering functionality SHOULD be moved to getChildren service method
|
||||
NodeRef[] nodeRefs = cmisService.getCheckedOut(AuthenticationUtil.getFullyAuthenticatedUser(), folderId, (folderId == null));
|
||||
Cursor cursor = createCursor(nodeRefs.length, parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null,
|
||||
parameters.getMaxItems() != null ? parameters.getMaxItems().getValue() : null);
|
||||
@@ -106,29 +113,29 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
* @param parameters repositoryId: repository Id; folderId: folder Id; type: DOCUMENTS, FOLDERS, POLICIES, ANY; filter: property filter; includeAllowableActions;
|
||||
* includeRelationships; maxItems: 0 = Unlimited; skipCount: 0 = start at beginning
|
||||
* @return collection of CmisObjectType and boolean hasMoreItems
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws FilterNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FolderNotValidException
|
||||
* @throws PermissionDeniedException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetChildrenResponse getChildren(GetChildren parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException,
|
||||
FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
public GetChildrenResponse getChildren(GetChildren parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
|
||||
NodeRef folderNodeRef = cmisObjectsUtils.getIdentifierInstance(parameters.getFolderId(), AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
EnumTypesOfFileableObjects types = EnumTypesOfFileableObjects.ANY;
|
||||
if (parameters.getType() != null)
|
||||
if ((parameters.getType() != null) && ((parameters.getType().getValue() != null)))
|
||||
{
|
||||
types = parameters.getType().getValue();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
List<Pair<String, Boolean>> orderingFields = null;
|
||||
if ((parameters.getOrderBy() != null) && !parameters.getOrderBy().equals(""))
|
||||
{
|
||||
orderingFields = checkAndParseOrderByClause(parameters.getOrderBy());
|
||||
}
|
||||
|
||||
// TODO: Ordering functionality SHOULD be moved to getChildren service method
|
||||
NodeRef[] listing = null;
|
||||
switch (types)
|
||||
{
|
||||
@@ -139,7 +146,8 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
listing = cmisService.getChildren(folderNodeRef, CMISTypesFilterEnum.FOLDERS);
|
||||
break;
|
||||
case POLICIES:
|
||||
throw new OperationNotSupportedException(POLICIES_LISTING_UNSUPPORTED_EXCEPTION_MESSAGE);
|
||||
throw new CmisException(POLICIES_LISTING_UNSUPPORTED_EXCEPTION_MESSAGE, cmisObjectsUtils.createCmisException(POLICIES_LISTING_UNSUPPORTED_EXCEPTION_MESSAGE,
|
||||
EnumServiceException.NOT_SUPPORTED));
|
||||
case ANY:
|
||||
listing = cmisService.getChildren(folderNodeRef, CMISTypesFilterEnum.ANY);
|
||||
break;
|
||||
@@ -156,11 +164,36 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
resultListing.add(createCmisObject(listing[index].toString(), propertyFilter));
|
||||
}
|
||||
|
||||
// TODO: includeAllowableActions, includeRelationships
|
||||
|
||||
response.setHasMoreItems(cursor.getEndRow() < (listing.length - 1));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
// TODO: This method will create appropriate Ordering fields
|
||||
private List<Pair<String, Boolean>> checkAndParseOrderByClause(String orderByClause) throws CmisException
|
||||
{
|
||||
List<Pair<String, Boolean>> result = new LinkedList<Pair<String, Boolean>>();
|
||||
|
||||
if (!ORDER_BY_CLAUSE_MASK.matcher(orderByClause).matches())
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException(("\"" + orderByClause + "\" Order By Clause is invalid!"), EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
for (String token : orderByClause.split(","))
|
||||
{
|
||||
token = token.trim();
|
||||
|
||||
String[] direction = token.split(" ");
|
||||
String fieldName = direction[0];
|
||||
|
||||
result.add(new Pair<String, Boolean>(fieldName, ((direction.length == 1) ? (true) : (direction[direction.length - 1].toLowerCase().equals("asc")))));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of descendant objects contained at one or more levels in the tree rooted at the specified folder. Only the filter-selected properties associated with each
|
||||
* object are returned. The content-stream is not returned. For paging through the children (depth of 1) only use {@link #getChildren(GetChildren parameters)}.
|
||||
@@ -168,18 +201,9 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
* @param parameters repositoryId: repository Id; folderId: folder Id; depth: 1 this folder only (Default), N folders deep, -1 for all levels; filter: property filter;
|
||||
* includeAllowableActions; includeRelationships;
|
||||
* @return collection of CmisObjectType
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws FilterNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FolderNotValidException
|
||||
* @throws PermissionDeniedException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetDescendantsResponse getDescendants(GetDescendants parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException,
|
||||
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
public GetDescendantsResponse getDescendants(GetDescendants parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
@@ -188,18 +212,27 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
|
||||
GetDescendantsResponse response = new GetDescendantsResponse();
|
||||
HierarchyReceiverStrategy receiver = createHierarchyReceiver(parameters.getType() != null ? parameters.getType() : EnumTypesOfFileableObjects.ANY, depth);
|
||||
createCmisObjectList(propertyFilter, receiver.receiveHierarchy(parameters.getFolderId()), response.getObject());
|
||||
|
||||
List<Pair<String, Boolean>> orderingFields = null;
|
||||
if ((parameters.getOrderBy() != null) && !parameters.getOrderBy().equals(""))
|
||||
{
|
||||
orderingFields = checkAndParseOrderByClause(parameters.getOrderBy());
|
||||
}
|
||||
|
||||
// TODO: Ordering functionality SHOULD be moved to getChildren service method
|
||||
createCmisObjectList(propertyFilter, receiver.receiveHierarchy(parameters.getFolderId(), orderingFields), response.getObject());
|
||||
|
||||
// TODO: includeAllowableActions, includeRelationships
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private void checkDepthParameter(BigInteger depth) throws InvalidArgumentException
|
||||
private void checkDepthParameter(BigInteger depth) throws CmisException
|
||||
{
|
||||
if (depth.equals(BigInteger.ZERO) || (depth.compareTo(FULL_DESCENDANTS_HIERARCHY_CONDITION) < EQUALS_CONDITION_VALUE))
|
||||
{
|
||||
throw new InvalidArgumentException("The specified descendants depth is not valid. Valid depth values are: -1 (full hierarchy), N > 0");
|
||||
throw cmisObjectsUtils.createCmisException("The specified descendants depth is not valid. Valid depth values are: -1 (full hierarchy), N > 0",
|
||||
EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,20 +242,26 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
* @param parameters repositoryId: repository Id; folderId: folder Id; filter: property filter; includeAllowableActions; includeRelationships; returnToRoot: If false, return
|
||||
* only the immediate parent of the folder. If true, return an ordered list of all ancestor folders from the specified folder to the root folder
|
||||
* @return collection of CmisObjectType
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws FilterNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FolderNotValidException
|
||||
* @throws PermissionDeniedException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetFolderParentResponse getFolderParent(GetFolderParent parameters)
|
||||
throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
public GetFolderParentResponse getFolderParent(GetFolderParent parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
String filter = parameters.getFilter();
|
||||
if (filter != null)
|
||||
{
|
||||
if (!filter.contains(CMISDictionaryModel.PROP_PARENT_ID))
|
||||
{
|
||||
filter = CMISDictionaryModel.PROP_PARENT_ID + FILTER_TOKENS_DELIMETER + filter;
|
||||
}
|
||||
|
||||
if (!filter.contains(CMISDictionaryModel.PROP_OBJECT_ID))
|
||||
{
|
||||
filter = CMISDictionaryModel.PROP_OBJECT_ID + FILTER_TOKENS_DELIMETER + filter;
|
||||
}
|
||||
}
|
||||
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
GetFolderParentResponse response = new GetFolderParentResponse();
|
||||
|
||||
@@ -240,18 +279,10 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; objectId: object Id; filter: property filter; includeAllowableActions; includeRelationships;
|
||||
* @return collection of CmisObjectType
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws FilterNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FolderNotValidException
|
||||
* @throws PermissionDeniedException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetObjectParentsResponse getObjectParents(GetObjectParents parameters)
|
||||
throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
public GetObjectParentsResponse getObjectParents(GetObjectParents parameters) throws CmisException
|
||||
{
|
||||
// TODO: Policy
|
||||
|
||||
@@ -259,7 +290,8 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
GetObjectParentsResponse response = new GetObjectParentsResponse();
|
||||
|
||||
List<NodeRef> parents = receiveObjectParents((NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier());
|
||||
List<NodeRef> parents = receiveObjectParents((NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OBJECT)
|
||||
.getConvertedIdentifier());
|
||||
createCmisObjectList(propertyFilter, parents, response.getObject());
|
||||
|
||||
// TODO: includeAllowableActions, includeRelationships
|
||||
@@ -267,19 +299,19 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
return response;
|
||||
}
|
||||
|
||||
private List<NodeRef> receiveParentList(String targetChildIdentifier, boolean fullParentsHierarchy)
|
||||
throws InvalidNodeRefException, InvalidArgumentException, ObjectNotFoundException
|
||||
private List<NodeRef> receiveParentList(String targetChildIdentifier, boolean fullParentsHierarchy) throws CmisException
|
||||
{
|
||||
List<NodeRef> result = new LinkedList<NodeRef>();
|
||||
if (targetChildIdentifier.equals(cmisService.getDefaultRootNodeRef().toString()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
NodeRef currentParent = receiveNextParentNodeReference((NodeRef) cmisObjectsUtils.getIdentifierInstance(targetChildIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(), result);
|
||||
|
||||
NodeRef currentParent = receiveNextParentNodeReference((NodeRef) cmisObjectsUtils.getIdentifierInstance(targetChildIdentifier, AlfrescoObjectType.FOLDER_OBJECT)
|
||||
.getConvertedIdentifier(), result);
|
||||
return (fullParentsHierarchy) ? (receiveFullAncestorsHierachy(currentParent, result)) : (result);
|
||||
}
|
||||
|
||||
|
||||
private List<NodeRef> receiveFullAncestorsHierachy(NodeRef currentParent, List<NodeRef> parents)
|
||||
{
|
||||
String lastAncestorIdentifier = cmisService.getDefaultRootNodeRef().toString();
|
||||
@@ -289,18 +321,18 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
}
|
||||
return parents;
|
||||
}
|
||||
|
||||
|
||||
private NodeRef receiveNextParentNodeReference(NodeRef currentParent, List<NodeRef> parents)
|
||||
{
|
||||
currentParent = nodeService.getPrimaryParent(currentParent).getParentRef();
|
||||
currentParent = nodeService.getPrimaryParent(currentParent).getParentRef();
|
||||
if (currentParent != null)
|
||||
{
|
||||
parents.add(currentParent);
|
||||
}
|
||||
return currentParent;
|
||||
}
|
||||
|
||||
private List<NodeRef> receiveObjectParents(NodeRef objectId) throws InvalidArgumentException
|
||||
|
||||
private List<NodeRef> receiveObjectParents(NodeRef objectId) throws CmisException
|
||||
{
|
||||
List<NodeRef> parents = new LinkedList<NodeRef>();
|
||||
for (ChildAssociationRef childParentAssociation : nodeService.getParentAssocs(objectId))
|
||||
@@ -310,7 +342,6 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
return parents;
|
||||
}
|
||||
|
||||
|
||||
private HierarchyReceiverStrategy createHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType, BigInteger finalDepth)
|
||||
{
|
||||
if (finalDepth.equals(FULL_DESCENDANTS_HIERARCHY_CONDITION))
|
||||
@@ -323,14 +354,15 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
}
|
||||
}
|
||||
|
||||
private void separateDescendantsObjects(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> descendantsFolders, List<NodeRef> currentLayerFolders, List<NodeRef> currentLayerDocuments)
|
||||
private void separateDescendantsObjects(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> descendantsFolders, List<NodeRef> currentLayerFolders,
|
||||
List<NodeRef> currentLayerDocuments, List<Pair<String, Boolean>> orderingFields)
|
||||
{
|
||||
for (NodeRef element : descendantsFolders)
|
||||
{
|
||||
// TODO: OrderBy functionality processing. Instead Arrays.asList() it is necessary to add ordering processing method to store each new element where it should go
|
||||
// TODO: Ordering functionality SHOULD be moved to getChildren service method
|
||||
currentLayerFolders.addAll(Arrays.asList(cmisService.getChildren(element, CMISTypesFilterEnum.FOLDERS)));
|
||||
|
||||
// TODO: OrderBy functionality processing. Instead Arrays.asList() it is necessary to add ordering processing method to store each new element where it should go
|
||||
// TODO: Ordering functionality SHOULD be moved to getChildren service method
|
||||
if ((returnObjectsType == EnumTypesOfFileableObjects.ANY) || (returnObjectsType == EnumTypesOfFileableObjects.DOCUMENTS))
|
||||
{
|
||||
currentLayerDocuments.addAll(Arrays.asList(cmisService.getChildren(element, CMISTypesFilterEnum.DOCUMENTS)));
|
||||
@@ -339,9 +371,9 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
}
|
||||
|
||||
private List<NodeRef> performDescendantsResultObjectsStoring(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> resultList, List<NodeRef> descendantsFolders,
|
||||
List<NodeRef> currentLayerFolders, List<NodeRef> currentLayerDocuments)
|
||||
List<NodeRef> currentLayerFolders, List<NodeRef> currentLayerDocuments, List<Pair<String, Boolean>> orderingFields)
|
||||
{
|
||||
separateDescendantsObjects(returnObjectsType, descendantsFolders, currentLayerFolders, currentLayerDocuments);
|
||||
separateDescendantsObjects(returnObjectsType, descendantsFolders, currentLayerFolders, currentLayerDocuments, orderingFields);
|
||||
|
||||
if ((returnObjectsType == EnumTypesOfFileableObjects.ANY) || (returnObjectsType == EnumTypesOfFileableObjects.FOLDERS))
|
||||
{
|
||||
@@ -363,7 +395,7 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
* @return <b>List</b> that contains all appropriates layers of Alfresco objects
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException;
|
||||
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier, List<Pair<String, Boolean>> orderFields) throws CmisException;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,12 +418,13 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
/**
|
||||
* Traverse Alfresco objects hierarchy until there is some Folder-objects can be found
|
||||
*/
|
||||
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException
|
||||
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier, List<Pair<String, Boolean>> orderingFields) throws CmisException
|
||||
{
|
||||
descendantsFolders.add((NodeRef) cmisObjectsUtils.getIdentifierInstance(rootFolderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier());
|
||||
while (!descendantsFolders.isEmpty())
|
||||
{
|
||||
descendantsFolders = performDescendantsResultObjectsStoring(returnObjectsType, resultList, descendantsFolders, new LinkedList<NodeRef>(), new LinkedList<NodeRef>());
|
||||
descendantsFolders = performDescendantsResultObjectsStoring(returnObjectsType, resultList, descendantsFolders, new LinkedList<NodeRef>(),
|
||||
new LinkedList<NodeRef>(), orderingFields);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
@@ -422,13 +455,14 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
/**
|
||||
* This method of this class receives Alfresco objects hierarchy until specified layer number
|
||||
*/
|
||||
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException
|
||||
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier, List<Pair<String, Boolean>> orderingFields) throws CmisException
|
||||
{
|
||||
descendantsFolders.add((NodeRef) cmisObjectsUtils.getIdentifierInstance(rootFolderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier());
|
||||
|
||||
do
|
||||
{
|
||||
descendantsFolders = performDescendantsResultObjectsStoring(this.returnObjectsType, this.resultList, this.descendantsFolders, new LinkedList<NodeRef>(), new LinkedList<NodeRef>());
|
||||
descendantsFolders = performDescendantsResultObjectsStoring(this.returnObjectsType, this.resultList, this.descendantsFolders, new LinkedList<NodeRef>(),
|
||||
new LinkedList<NodeRef>(), orderingFields);
|
||||
currentDepth = currentDepth.add(BigInteger.ONE);
|
||||
} while (!descendantsFolders.isEmpty() && (currentDepth.compareTo(this.finalDepth) < EQUALS_CONDITION_VALUE));
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -29,12 +29,15 @@ import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -49,11 +52,13 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.NodeLockedException;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
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.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionType;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
@@ -63,7 +68,7 @@ import org.alfresco.service.namespace.QName;
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "ObjectServicePort", serviceName = "ObjectService", portName = "ObjectServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.ObjectServicePort")
|
||||
@javax.jws.WebService(name = "ObjectServicePort", serviceName = "ObjectService", portName = "ObjectServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200901", endpointInterface = "org.alfresco.repo.cmis.ws.ObjectServicePort")
|
||||
public class DMObjectServicePort extends DMAbstractServicePort implements ObjectServicePort
|
||||
{
|
||||
private static final int SINGLE_PARENT_CONDITION = 1;
|
||||
@@ -76,13 +81,12 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a document object of the specified type, and optionally adds the document to a folder
|
||||
*
|
||||
@@ -93,37 +97,18 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param contentStream content stream
|
||||
* @param versioningState versioning state (checkedout, minor, major)
|
||||
* @return Id of the created document object
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws StorageException
|
||||
* @throws StreamNotSupportedException
|
||||
* @throws FolderNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws TypeNotFoundException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* STREAM_NOT_SUPPORTED)
|
||||
*/
|
||||
public String createDocument(String repositoryId, String typeId, CmisPropertiesType properties, String folderId, CmisContentStreamType contentStream, EnumVersioningState versioningState)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, FolderNotValidException,
|
||||
OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public String createDocument(String repositoryId, String typeId, CmisPropertiesType properties, String folderId, CmisContentStreamType contentStream,
|
||||
EnumVersioningState versioningState) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
NodeRef parentNodeRef = safeGetFolderNodeRef(folderId);
|
||||
Map<String, Serializable> propertiesMap = getPropertiesMap(properties);
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType(typeId);
|
||||
if (typeDef.getTypeId().getScope() != CMISScope.DOCUMENT)
|
||||
{
|
||||
throw new ConstraintViolationException("Invalid document type " + typeId);
|
||||
}
|
||||
|
||||
NodeRef parentNodeRef = safeGetFolderNodeRef(folderId);
|
||||
|
||||
String documentName = (String) propertiesMap.get(CMISDictionaryModel.PROP_NAME);
|
||||
if (documentName == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Name property not found");
|
||||
}
|
||||
String documentName = checkConstraintsAndGetName(typeId, typeDef, parentNodeRef, contentStream, propertiesMap, versioningState);
|
||||
|
||||
NodeRef newDocumentNodeRef = fileFolderService.create(parentNodeRef, documentName, typeDef.getTypeId().getQName()).getNodeRef();
|
||||
ContentWriter writer = fileFolderService.getWriter(newDocumentNodeRef);
|
||||
@@ -132,6 +117,10 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
{
|
||||
writer.setMimetype(mimeType);
|
||||
}
|
||||
else if (contentStream.getMimeType() != null)
|
||||
{
|
||||
writer.setMimetype(contentStream.getMimeType());
|
||||
}
|
||||
InputStream inputstream = null;
|
||||
try
|
||||
{
|
||||
@@ -139,7 +128,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new ConstraintViolationException("", e.getCause());
|
||||
throw cmisObjectsUtils.createCmisException(e.toString(), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
writer.putContent(inputstream);
|
||||
|
||||
@@ -153,21 +142,70 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
|
||||
switch (versioningState)
|
||||
{
|
||||
case CHECKEDOUT:
|
||||
newDocumentNodeRef = checkoutNode(newDocumentNodeRef);
|
||||
break;
|
||||
case MAJOR:
|
||||
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR));
|
||||
break;
|
||||
case MINOR:
|
||||
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MINOR));
|
||||
break;
|
||||
case CHECKEDOUT:
|
||||
newDocumentNodeRef = checkoutNode(newDocumentNodeRef);
|
||||
break;
|
||||
case MAJOR:
|
||||
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR));
|
||||
break;
|
||||
case MINOR:
|
||||
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MINOR));
|
||||
break;
|
||||
}
|
||||
|
||||
String versionLabel = (String) cmisService.getProperty(newDocumentNodeRef, CMISDictionaryModel.PROP_VERSION_LABEL);
|
||||
return versionLabel != null && versionLabel.contains(VERSION_DELIMETER) ?
|
||||
newDocumentNodeRef.toString() + CmisObjectsUtils.NODE_REFERENCE_ID_DELIMETER + versionLabel :
|
||||
newDocumentNodeRef.toString();
|
||||
return versionLabel != null && versionLabel.contains(VERSION_DELIMETER) ? newDocumentNodeRef.toString() + CmisObjectsUtils.NODE_REFERENCE_ID_DELIMETER + versionLabel
|
||||
: newDocumentNodeRef.toString();
|
||||
}
|
||||
|
||||
private String checkConstraintsAndGetName(String documentTypeId, CMISTypeDefinition typeDef, NodeRef parentNodeRef, CmisContentStreamType contentStream,
|
||||
Map<String, Serializable> propertiesMap, EnumVersioningState versioningState) throws CmisException
|
||||
{
|
||||
if ((typeDef.getTypeId().getScope() != CMISScope.DOCUMENT) || !typeDef.isCreatable())
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException(("Invalid document type \"" + documentTypeId + "\". Specified type is not Document type or type is not Creatable"),
|
||||
EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
if (CMISContentStreamAllowedEnum.NOT_ALLOWED == typeDef.getContentStreamAllowed())
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException(("Content stream not allowed for \"" + documentTypeId + "\" document object type"),
|
||||
EnumServiceException.STREAM_NOT_SUPPORTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((CMISContentStreamAllowedEnum.REQUIRED == typeDef.getContentStreamAllowed()) && (contentStream == null))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("Content stream for document object of " + documentTypeId + " type is required", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeDef.isVersionable() && (versioningState != null))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException(("Verioning for \"" + documentTypeId + "\" document type is not allowed"), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
String folderTypeId = (String) cmisService.getProperty(parentNodeRef, CMISDictionaryModel.PROP_OBJECT_TYPE_ID);
|
||||
CMISTypeDefinition folderTypeDefinition = cmisDictionaryService.findType(folderTypeId);
|
||||
if ((folderTypeDefinition.getAllowedTargetTypes() != null) && !folderTypeDefinition.getAllowedTargetTypes().isEmpty()
|
||||
&& !folderTypeDefinition.getAllowedTargetTypes().contains(typeDef))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException(("Children of \"" + documentTypeId + "\" type are not allowed for specified folder"), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
String result = (String) propertiesMap.get(CMISDictionaryModel.PROP_NAME);
|
||||
if (result == null)
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("Name property not found", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
CMISPropertyDefinition nameProperty = cmisDictionaryService.findProperty(CMISDictionaryModel.PROP_NAME, null);
|
||||
if ((nameProperty.getMaximumLength() > 0) && (result.length() > nameProperty.getMaximumLength()))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("Name property length too big", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,34 +216,31 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param properties CMIS properties
|
||||
* @param folderId parent folder for this new folder
|
||||
* @return Id of the created folder object
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FolderNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws TypeNotFoundException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE)
|
||||
*/
|
||||
public String createFolder(String repositoryId, String typeId, CmisPropertiesType properties, String folderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public String createFolder(String repositoryId, String typeId, CmisPropertiesType properties, String folderId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef folderNodeRef = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef folderNodeRef = null;
|
||||
try
|
||||
{
|
||||
folderNodeRef = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
}
|
||||
catch (CmisException e)
|
||||
{
|
||||
e.getFaultInfo().setType(EnumServiceException.CONSTRAINT);
|
||||
throw e;
|
||||
}
|
||||
|
||||
CMISTypeDefinition type = getCmisTypeDefinition(typeId);
|
||||
if (type == null || type.getTypeId().getScope() != CMISScope.FOLDER)
|
||||
{
|
||||
throw new TypeNotFoundException(typeId);
|
||||
throw cmisObjectsUtils.createCmisException("The typeID is not an Object-Type whose baseType is 'Folder': " + typeId, EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
Map<String, Serializable> propertiesMap = getPropertiesMap(properties);
|
||||
String name = (String) propertiesMap.get(CMISDictionaryModel.PROP_NAME);
|
||||
if (name == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Name property not found");
|
||||
}
|
||||
|
||||
checkPropertyName(type, name);
|
||||
assertExistFolder(folderNodeRef);
|
||||
|
||||
try
|
||||
@@ -217,7 +252,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
}
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
throw new UpdateConflictException("Folder already exists");
|
||||
throw cmisObjectsUtils.createCmisException("Folder already exists", EnumServiceException.CONTENT_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,20 +264,11 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param properties CMIS properties
|
||||
* @param folderId parent folder for this new policy
|
||||
* @return Id of the created policy object
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FolderNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws TypeNotFoundException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE)
|
||||
*/
|
||||
public String createPolicy(String repositoryId, String typeId, CmisPropertiesType properties, String folderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public String createPolicy(String repositoryId, String typeId, CmisPropertiesType properties, String folderId) throws CmisException
|
||||
{
|
||||
// TODO:
|
||||
return null;
|
||||
throw cmisObjectsUtils.createCmisException("Policy objects not supported", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,41 +280,34 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param sourceObjectId source object Id
|
||||
* @param targetObjectId target object Id
|
||||
* @return Id of the created relationship object
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws TypeNotFoundException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE)
|
||||
*/
|
||||
public String createRelationship(String repositoryId, String typeId, CmisPropertiesType properties, String sourceObjectId, String targetObjectId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public String createRelationship(String repositoryId, String typeId, CmisPropertiesType properties, String sourceObjectId, String targetObjectId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
NodeRef sourceNodeRef;
|
||||
NodeRef targetNodeRef;
|
||||
|
||||
try
|
||||
{
|
||||
sourceNodeRef = cmisObjectsUtils.getIdentifierInstance(sourceObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
|
||||
targetNodeRef = cmisObjectsUtils.getIdentifierInstance(targetObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
|
||||
}
|
||||
catch (InvalidArgumentException e)
|
||||
{
|
||||
if (e.getCause() instanceof ObjectNotFoundException)
|
||||
{
|
||||
throw new ObjectNotFoundException(e.getMessage());
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
sourceNodeRef = cmisObjectsUtils.getIdentifierInstance(sourceObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
|
||||
targetNodeRef = cmisObjectsUtils.getIdentifierInstance(targetObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
|
||||
|
||||
CMISTypeDefinition relationshipType = cmisDictionaryService.findType(typeId);
|
||||
if (relationshipType == null || relationshipType.getTypeId().getScope() != CMISScope.RELATIONSHIP)
|
||||
{
|
||||
throw new TypeNotFoundException(typeId);
|
||||
throw cmisObjectsUtils.createCmisException(typeId, EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
CMISTypeDefinition sourceType = cmisDictionaryService.findType((String) cmisService.getProperty(sourceNodeRef, CMISDictionaryModel.PROP_OBJECT_TYPE_ID));
|
||||
CMISTypeDefinition targetType = cmisDictionaryService.findType((String) cmisService.getProperty(targetNodeRef, CMISDictionaryModel.PROP_OBJECT_TYPE_ID));
|
||||
|
||||
if (!relationshipType.getAllowedSourceTypes().contains(sourceType))
|
||||
{
|
||||
cmisObjectsUtils.createCmisException(("Source object type is not allowed for \"" + typeId + "\" Relationship type"), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
if (!relationshipType.getAllowedTargetTypes().contains(targetType))
|
||||
{
|
||||
cmisObjectsUtils.createCmisException(("Target object type is not allowed for \"" + typeId + "\" Relationship type"), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
QName relationshipTypeQName = relationshipType.getTypeId().getQName();
|
||||
@@ -297,19 +316,19 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
{
|
||||
if (!dictionaryService.isSubClass(nodeService.getType(sourceNodeRef), associationDef.getSourceClass().getName()))
|
||||
{
|
||||
throw new ConstraintViolationException("Source object type isn't allowed as source type");
|
||||
throw cmisObjectsUtils.createCmisException("Source object type isn't allowed as source type", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
if (!dictionaryService.isSubClass(nodeService.getType(targetNodeRef), associationDef.getTargetClass().getName()))
|
||||
{
|
||||
throw new ConstraintViolationException("Target object type isn't allowed as target type");
|
||||
throw cmisObjectsUtils.createCmisException("Target object type isn't allowed as target type", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
return nodeService.createAssociation(sourceNodeRef, targetNodeRef, relationshipTypeQName).toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TypeNotFoundException(relationshipType.getTypeId().getQName() + " Relationship type not found");
|
||||
throw cmisObjectsUtils.createCmisException((relationshipType.getTypeId().getQName() + " Relationship type not found"), EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,22 +338,25 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param documentId document Id
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws StorageException
|
||||
* @throws StreamNotSupportedException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws VersioningException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void deleteContentStream(String repositoryId, String documentId)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, VersioningException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void deleteContentStream(String repositoryId, String documentId) throws CmisException
|
||||
{
|
||||
// TODO: Where is changeToken?
|
||||
checkRepositoryId(repositoryId);
|
||||
safeDeleteContentStream((NodeRef) cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier());
|
||||
NodeRef currentNode = (NodeRef) cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType((String) cmisService.getProperty(currentNode, CMISDictionaryModel.PROP_OBJECT_TYPE_ID));
|
||||
if (CMISContentStreamAllowedEnum.REQUIRED.equals(typeDef.getContentStreamAllowed()))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("The Object<63>s Object-Type definition 'contentStreamAllowed' attribute is set to 'required'.",
|
||||
EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
checkVersion(currentNode);
|
||||
|
||||
safeDeleteContentStream(currentNode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,16 +364,10 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId object Id
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* UPDATE_CONFLICT)
|
||||
*/
|
||||
public void deleteObject(String repositoryId, String objectId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void deleteObject(String repositoryId, String objectId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
@@ -360,7 +376,8 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
checkObjectTypeAndAppropriateStates(objectNodeReference, nodeService.getType(objectNodeReference));
|
||||
if (!cmisObjectsUtils.deleteObject(objectNodeReference))
|
||||
{
|
||||
throw new PermissionDeniedException("Currently authenticated User has no appropriate Permissions to delete specified Object");
|
||||
throw cmisObjectsUtils.createCmisException("Currently authenticated User has no appropriate Permissions to delete specified Object",
|
||||
EnumServiceException.PERMISSION_DENIED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,16 +391,9 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* objects in this tree (Default)
|
||||
* @param continueOnFailure flag
|
||||
* @return collection of object IDs that failed to delete (if continueOnFailure is FALSE, then single object ID)
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FolderNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, UPDATE_CONFLICT)
|
||||
*/
|
||||
public FailedToDelete deleteTree(String repositoryId, String folderId, EnumUnfileNonfolderObjects unfileNonfolderObjects, Boolean continueOnFailure)
|
||||
throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public FailedToDelete deleteTree(String repositoryId, String folderId, EnumUnfileNonfolderObjects unfileNonfolderObjects, Boolean continueOnFailure) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
checkUnfilingIsNotRequested(unfileNonfolderObjects);
|
||||
@@ -403,15 +413,9 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId object Id
|
||||
* @return list of allowable actions
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public CmisAllowableActionsType getAllowableActions(String repositoryId, String objectId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
public CmisAllowableActionsType getAllowableActions(String repositoryId, String objectId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
return determineObjectAllowableActions(cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.ANY_OBJECT));
|
||||
@@ -423,21 +427,27 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param repositoryId repository Id
|
||||
* @param documentId document to return the content-stream
|
||||
* @return content stream
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws StorageException
|
||||
* @throws StreamNotSupportedException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws OffsetException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, STREAM_NOT_SUPPORTED)
|
||||
*/
|
||||
public CmisContentStreamType getContentStream(String repositoryId, String documentId)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, OffsetException
|
||||
public CmisContentStreamType getContentStream(String repositoryId, String documentId) throws CmisException
|
||||
{
|
||||
// TODO:
|
||||
// Specification says:
|
||||
// Each CMIS protocol binding SHALL provide a way for fetching a sub-range within
|
||||
// a content stream, in a manner appropriate to that protocol.
|
||||
//
|
||||
// Implementation of sub-range fetching is suspended.
|
||||
// See http://tools.oasis-open.org/issues/browse/CMIS-134
|
||||
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef nodeRef = cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
|
||||
CMISTypeDefinition typeDefinition = cmisDictionaryService.findType((String) cmisService.getProperty(nodeRef, CMISDictionaryModel.PROP_OBJECT_TYPE_ID));
|
||||
if (CMISContentStreamAllowedEnum.NOT_ALLOWED == typeDefinition.getContentStreamAllowed())
|
||||
{
|
||||
cmisObjectsUtils.createCmisException("Content stream not allowed", EnumServiceException.STREAM_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
CmisContentStreamType response = new CmisContentStreamType();
|
||||
ContentReader reader = safeGetContentReader(nodeRef);
|
||||
|
||||
@@ -457,31 +467,53 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param objectId object Id
|
||||
* @param targetFolderId the target folder to be moved into
|
||||
* @param sourceFolderId the source folder to be moved out of
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws FolderNotValidException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws NotInFolderException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void moveObject(String repositoryId, String objectId, String targetFolderId, String sourceFolderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void moveObject(String repositoryId, String objectId, String targetFolderId, String sourceFolderId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
NodeRef objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef targetFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(targetFolderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef sourceFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(sourceFolderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
// TODO: Allowed_Child_Object_Types
|
||||
NodeRef objectNodeRef = null;
|
||||
|
||||
if (nodeService.getParentAssocs(objectNodeRef).size() == SINGLE_PARENT_CONDITION || !changeObjectParentAssociation(objectNodeRef, targetFolderNodeRef, sourceFolderNodeRef))
|
||||
try
|
||||
{
|
||||
safeMove(objectNodeRef, targetFolderNodeRef);
|
||||
objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
}
|
||||
catch (CmisException e)
|
||||
{
|
||||
e.getFaultInfo().setType(EnumServiceException.CONSTRAINT);
|
||||
throw e;
|
||||
}
|
||||
|
||||
checkVersion(objectNodeRef);
|
||||
|
||||
NodeRef targetFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(targetFolderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
List<ChildAssociationRef> parentsAssociations = nodeService.getParentAssocs(objectNodeRef);
|
||||
NodeRef sourceFolderNodeRef = null;
|
||||
if ((parentsAssociations != null) && (SINGLE_PARENT_CONDITION != nodeService.getParentAssocs(objectNodeRef).size()))
|
||||
{
|
||||
try
|
||||
{
|
||||
sourceFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(sourceFolderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
if (!cmisObjectsUtils.isPrimaryObjectParent(sourceFolderNodeRef, objectNodeRef))
|
||||
{
|
||||
changeObjectParentAssociation(objectNodeRef, targetFolderNodeRef, sourceFolderNodeRef);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (CmisException e)
|
||||
{
|
||||
e.getFaultInfo().setMessage(
|
||||
"Invalid source forlder for multifiled document was specified. Multifiled document must be moved from concrete folder. Exception message: "
|
||||
+ e.getFaultInfo().getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
safeMove(objectNodeRef, targetFolderNodeRef);
|
||||
// TODO: Allowed_Child_Object_Types
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,32 +523,30 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param documentId document Id
|
||||
* @param overwriteFlag flag
|
||||
* @param contentStream content stream
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws StorageException
|
||||
* @throws StreamNotSupportedException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws ContentAlreadyExistsException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* CONTENT_ALREADY_EXISTS, STORAGE, STREAM_NOT_SUPPORTED, UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void setContentStream(String repositoryId, Holder<String> documentId, Boolean overwriteFlag, CmisContentStreamType contentStream)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, ContentAlreadyExistsException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void setContentStream(String repositoryId, Holder<String> documentId, Boolean overwriteFlag, CmisContentStreamType contentStream) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
NodeRef nodeRef = cmisObjectsUtils.getIdentifierInstance(documentId.value, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType((String) cmisService.getProperty(nodeRef, CMISDictionaryModel.PROP_OBJECT_TYPE_ID));
|
||||
if (CMISContentStreamAllowedEnum.NOT_ALLOWED.equals(typeDef.getContentStreamAllowed()))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("The Object<63>s Object-Type definition 'contentStreamAllowed' attribute is set to 'notAllowed'.",
|
||||
EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
if (contentStream.getStream() == null)
|
||||
{
|
||||
throw new InvalidArgumentException("New Content Stream was not provided");
|
||||
throw cmisObjectsUtils.createCmisException("New Content Stream was not provided", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
if ((nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT) != null) && !overwriteFlag)
|
||||
{
|
||||
throw new ContentAlreadyExistsException();
|
||||
throw cmisObjectsUtils.createCmisException("Content already exists", EnumServiceException.CONTENT_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
ContentWriter writer = fileFolderService.getWriter(nodeRef);
|
||||
@@ -527,7 +557,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new ConstraintViolationException("", e.getCause());
|
||||
throw cmisObjectsUtils.createCmisException(e.getMessage(), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
writer.setMimetype(contentStream.getMimeType());
|
||||
@@ -541,20 +571,17 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @param objectId object Id
|
||||
* @param changeToken change token
|
||||
* @param properties list of properties to update
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void updateProperties(String repositoryId, Holder<String> objectId, String changeToken, CmisPropertiesType properties)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void updateProperties(String repositoryId, Holder<String> objectId, String changeToken, CmisPropertiesType properties) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
checkForReadOnlyProperties(properties);
|
||||
|
||||
NodeRef objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId.value, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
String name = (String) PropertyUtil.getProperty(properties, CMISDictionaryModel.PROP_NAME);
|
||||
checkPropertyName(objectNodeRef, name);
|
||||
setProperties(objectNodeRef, properties);
|
||||
|
||||
// TODO: change token
|
||||
@@ -568,27 +595,21 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
*
|
||||
* @param parameters
|
||||
* @return collection collection of CmisObjectType
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FilterNotValidException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FOLDER_NOT_VALID)
|
||||
*/
|
||||
public GetPropertiesResponse getProperties(GetProperties parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
public GetPropertiesResponse getProperties(GetProperties parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
|
||||
String identifier = ((NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier()).toString();
|
||||
EnumReturnVersion returnVersion = (parameters.getReturnVersion() != null && parameters.getReturnVersion().getValue() != null) ? parameters.getReturnVersion().getValue() : null;
|
||||
|
||||
if ((cmisObjectsUtils.determineObjectType(identifier) == EnumObjectType.DOCUMENT) && returnVersion != null)
|
||||
EnumReturnVersion returnVersion = (parameters.getReturnVersion() != null && parameters.getReturnVersion().getValue() != null) ? parameters.getReturnVersion().getValue()
|
||||
: null;
|
||||
|
||||
if ((returnVersion != null) && (cmisObjectsUtils.determineObjectType(identifier) == EnumObjectType.DOCUMENT))
|
||||
{
|
||||
identifier = getLatestNode(new NodeRef(identifier), returnVersion != EnumReturnVersion.LATEST).toString();
|
||||
identifier = getLatestNode(new NodeRef(identifier), (EnumReturnVersion.LATEST != returnVersion)).toString();
|
||||
}
|
||||
|
||||
GetPropertiesResponse response = new GetPropertiesResponse();
|
||||
@@ -609,8 +630,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Serializable> getPropertiesMap(CmisPropertiesType cmisProperties) throws InvalidArgumentException
|
||||
private Map<String, Serializable> getPropertiesMap(CmisPropertiesType cmisProperties) throws CmisException
|
||||
{
|
||||
Map<String, Serializable> properties = new HashMap<String, Serializable>();
|
||||
|
||||
@@ -619,7 +639,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
String name = PropertyUtil.getRepositoryPropertyName(cmisProperty.getName());
|
||||
if (name == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Unknown property with name " + name);
|
||||
throw cmisObjectsUtils.createCmisException(("Unknown property with name " + name), EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
properties.put(name, PropertyUtil.getValue(cmisProperty));
|
||||
@@ -628,24 +648,15 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
return properties;
|
||||
}
|
||||
|
||||
private boolean changeObjectParentAssociation(NodeRef objectNodeRef, NodeRef targetFolderNodeRef, NodeRef sourceFolderNodeReference)
|
||||
throws UpdateConflictException, PermissionDeniedException
|
||||
private void changeObjectParentAssociation(NodeRef objectNodeRef, NodeRef targetFolderNodeRef, NodeRef sourceFolderNodeReference) throws CmisException
|
||||
{
|
||||
if (cmisObjectsUtils.isPrimaryObjectParent(sourceFolderNodeReference, objectNodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!cmisObjectsUtils.removeObject(objectNodeRef, sourceFolderNodeReference) && cmisObjectsUtils.addObjectToFolder(objectNodeRef, targetFolderNodeRef))
|
||||
if (!cmisObjectsUtils.removeObject(objectNodeRef, sourceFolderNodeReference) || !cmisObjectsUtils.addObjectToFolder(objectNodeRef, targetFolderNodeRef))
|
||||
{
|
||||
determineException(cmisObjectsUtils.getLastOperationException());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void safeMove(NodeRef objectNodeRef, NodeRef targetFolderNodeRef)
|
||||
throws PermissionDeniedException, UpdateConflictException
|
||||
private void safeMove(NodeRef objectNodeRef, NodeRef targetFolderNodeRef) throws CmisException
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -657,7 +668,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
}
|
||||
}
|
||||
|
||||
private void safeDeleteContentStream(NodeRef documentNodeReference) throws ConstraintViolationException
|
||||
private void safeDeleteContentStream(NodeRef documentNodeReference) throws CmisException
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -665,73 +676,109 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
}
|
||||
catch (NodeLockedException e)
|
||||
{
|
||||
throw new ConstraintViolationException("Content Stream Deletion is not allowed for specified Document", e);
|
||||
throw cmisObjectsUtils.createCmisException("Content Stream Deletion is not allowed for specified Document", EnumServiceException.UPDATE_CONFLICT);
|
||||
}
|
||||
}
|
||||
|
||||
private ContentReader safeGetContentReader(NodeRef objectNodeReference) throws StorageException
|
||||
private ContentReader safeGetContentReader(NodeRef objectNodeReference) throws CmisException
|
||||
{
|
||||
ContentReader reader = fileFolderService.getReader(objectNodeReference);
|
||||
if (reader == null)
|
||||
{
|
||||
throw new StorageException("The specified Document has no Content Stream");
|
||||
throw cmisObjectsUtils.createCmisException("The specified Document has no Content Stream", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
return reader;
|
||||
}
|
||||
|
||||
private NodeRef safeGetFolderNodeRef(String folderId) throws FolderNotValidException
|
||||
private NodeRef safeGetFolderNodeRef(String folderId) throws CmisException
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
}
|
||||
catch (InvalidArgumentException e)
|
||||
catch (CmisException e)
|
||||
{
|
||||
throw new FolderNotValidException("Unfiling is not suppoerted. Each Document must have existent parent Folder");
|
||||
throw cmisObjectsUtils.createCmisException("Unfiling is not suppoerted. Each Document must have existent parent Folder", EnumServiceException.OBJECT_NOT_FOUND, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkObjectTypeAndAppropriateStates(NodeRef objectNodeReference, QName objectType) throws InvalidArgumentException, ConstraintViolationException
|
||||
|
||||
private void checkObjectTypeAndAppropriateStates(NodeRef objectNodeReference, QName objectType) throws CmisException
|
||||
{
|
||||
if (objectType == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Specified Object has invalid Object Type");
|
||||
throw cmisObjectsUtils.createCmisException("Specified Object has invalid Object Type", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
if (objectType.equals(ContentModel.TYPE_FOLDER) && (nodeService.getChildAssocs(objectNodeReference).size() > 0))
|
||||
{
|
||||
throw new ConstraintViolationException("Could not delete folder with at least one Child");
|
||||
throw cmisObjectsUtils.createCmisException("Could not delete folder with at least one Child", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUnfilingIsNotRequested(EnumUnfileNonfolderObjects unfileNonfolderObjects) throws OperationNotSupportedException
|
||||
private void checkUnfilingIsNotRequested(EnumUnfileNonfolderObjects unfileNonfolderObjects) throws CmisException
|
||||
{
|
||||
if (unfileNonfolderObjects == EnumUnfileNonfolderObjects.UNFILE)
|
||||
{
|
||||
throw new OperationNotSupportedException("Unfiling is not supported");
|
||||
throw cmisObjectsUtils.createCmisException("Unfiling is not supported", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForRootObject(String repositoryId, String objectId) throws OperationNotSupportedException
|
||||
private void checkForRootObject(String repositoryId, String objectId) throws CmisException
|
||||
{
|
||||
if (this.cmisService.getDefaultRootNodeRef().toString().equals(objectId) || repositoryId.equals(objectId))
|
||||
{
|
||||
throw new OperationNotSupportedException("Could not delete Repository object or Root Folder object - operation is not allowed or not supported");
|
||||
throw cmisObjectsUtils.createCmisException("Could not delete Repository object or Root Folder object - operation is not allowed or not supported",
|
||||
EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForReadOnlyProperties(CmisPropertiesType properties) throws ConstraintViolationException
|
||||
private void checkForReadOnlyProperties(CmisPropertiesType properties) throws CmisException
|
||||
{
|
||||
for (CmisProperty property : properties.getProperty())
|
||||
{
|
||||
if (PropertyUtil.isReadOnlyRepositoryProperty(property.getName()))
|
||||
{
|
||||
throw new ConstraintViolationException("The property " + property.getName() + " is Read Only and couldn't be updated");
|
||||
throw cmisObjectsUtils.createCmisException(("The property " + property.getName() + " is Read Only and couldn't be updated"), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CmisAllowableActionsType determineObjectAllowableActions(IdentifierConversionResults objectIdentifierContainer) throws OperationNotSupportedException
|
||||
private void checkVersion(NodeRef currentNode) throws CmisException
|
||||
{
|
||||
if (!cmisObjectsUtils.isFolder(currentNode))
|
||||
{
|
||||
NodeRef latestNode = getLatestNode(currentNode, true);
|
||||
Version currentVersion = versionService.getCurrentVersion(currentNode);
|
||||
Version latestVersion = versionService.getCurrentVersion(latestNode);
|
||||
if ((currentVersion != null && latestVersion != null) && (!currentVersion.getVersionLabel().equals(latestVersion.getVersionLabel())))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("Document is a non-current Document Version", EnumServiceException.VERSIONING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPropertyName(CMISTypeDefinition type, String name) throws CmisException
|
||||
{
|
||||
CMISPropertyDefinition propertyDefinition = cmisDictionaryService.findProperty(CMISDictionaryModel.PROP_NAME, type);
|
||||
|
||||
if (propertyDefinition.isRequired() && (name == null || name.length() < 1))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("Name property required", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
if (name != null && (propertyDefinition.getMaximumLength() > 0) && (name.length() > propertyDefinition.getMaximumLength()))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("Name is too long", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPropertyName(NodeRef node, String name) throws CmisException
|
||||
{
|
||||
CMISTypeDefinition type = cmisDictionaryService.findType((String) cmisService.getProperty(node, CMISDictionaryModel.PROP_OBJECT_TYPE_ID));
|
||||
checkPropertyName(type, name);
|
||||
}
|
||||
|
||||
private CmisAllowableActionsType determineObjectAllowableActions(IdentifierConversionResults objectIdentifierContainer) throws CmisException
|
||||
{
|
||||
Object objectNodeReference = objectIdentifierContainer.getConvertedIdentifier();
|
||||
|
||||
@@ -742,18 +789,18 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
|
||||
switch (cmisObjectsUtils.determineObjectType(objectNodeReference.toString()))
|
||||
{
|
||||
case DOCUMENT:
|
||||
{
|
||||
return determineDocumentAllowableActions((NodeRef) objectNodeReference);
|
||||
}
|
||||
case FOLDER:
|
||||
{
|
||||
return determineFolderAllowableActions((NodeRef) objectNodeReference);
|
||||
}
|
||||
case DOCUMENT:
|
||||
{
|
||||
return determineDocumentAllowableActions((NodeRef) objectNodeReference);
|
||||
}
|
||||
case FOLDER:
|
||||
{
|
||||
return determineFolderAllowableActions((NodeRef) objectNodeReference);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: determinePolicyAllowableActions() when Policy functionality is ready
|
||||
throw new OperationNotSupportedException("It is impossible to get Allowable actions for the specified Object");
|
||||
throw cmisObjectsUtils.createCmisException("It is impossible to get Allowable actions for the specified Object", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
private CmisAllowableActionsType determineBaseAllowableActions(NodeRef objectNodeReference)
|
||||
@@ -816,14 +863,14 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
return result;
|
||||
}
|
||||
|
||||
private void determineException(Throwable lastException) throws PermissionDeniedException, UpdateConflictException
|
||||
private void determineException(Throwable lastException) throws CmisException
|
||||
{
|
||||
if (lastException instanceof AccessDeniedException)
|
||||
{
|
||||
throw new PermissionDeniedException(lastException.getMessage());
|
||||
throw cmisObjectsUtils.createCmisException(lastException.toString(), EnumServiceException.PERMISSION_DENIED);
|
||||
}
|
||||
|
||||
throw new UpdateConflictException("Couldn't to relocate multi-filed Object");
|
||||
throw cmisObjectsUtils.createCmisException("Couldn't to relocate multi-filed Object", EnumServiceException.UPDATE_CONFLICT);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -24,9 +24,11 @@
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
@javax.jws.WebService(name = "PolicyServicePort", serviceName = "PolicyServicePort", portName = "PolicyServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.PolicyServicePort")
|
||||
|
||||
@javax.jws.WebService(name = "PolicyServicePort", serviceName = "PolicyServicePort", portName = "PolicyServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200901", endpointInterface = "org.alfresco.repo.cmis.ws.PolicyServicePort")
|
||||
public class DMPolicyServicePort extends DMAbstractServicePort implements PolicyServicePort
|
||||
{
|
||||
private static final String POLICY_NOT_SUPPORTED_MESSAGE = "PolicyService not supported";
|
||||
|
||||
/**
|
||||
* Applies a policy object to a target object.
|
||||
@@ -34,38 +36,22 @@ public class DMPolicyServicePort extends DMAbstractServicePort implements Policy
|
||||
* @param repositoryId repository Id
|
||||
* @param policyId policy Id
|
||||
* @param objectId target object Id
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT)
|
||||
*/
|
||||
public void applyPolicy(String repositoryId, String policyId, String objectId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void applyPolicy(String repositoryId, String policyId, String objectId) throws CmisException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
throw cmisObjectsUtils.createCmisException(POLICY_NOT_SUPPORTED_MESSAGE, EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of policy objects currently applied to a target object.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; objectId: target object Id; filter: filter specifying which properties to return
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FilterNotValidException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetAppliedPoliciesResponse getAppliedPolicies(GetAppliedPolicies parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException,
|
||||
ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public GetAppliedPoliciesResponse getAppliedPolicies(GetAppliedPolicies parameters) throws CmisException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
throw cmisObjectsUtils.createCmisException(POLICY_NOT_SUPPORTED_MESSAGE, EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,18 +60,10 @@ public class DMPolicyServicePort extends DMAbstractServicePort implements Policy
|
||||
* @param repositoryId repository Id
|
||||
* @param policyId policy Id
|
||||
* @param objectId target object Id.
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT)
|
||||
*/
|
||||
public void removePolicy(String repositoryId, String policyId, String objectId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void removePolicy(String repositoryId, String policyId, String objectId) throws CmisException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
throw cmisObjectsUtils.createCmisException(POLICY_NOT_SUPPORTED_MESSAGE, EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
@@ -45,7 +44,7 @@ import org.alfresco.service.namespace.QNamePattern;
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "RelationshipServicePort", serviceName = "RelationshipService", portName = "RelationshipServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.RelationshipServicePort")
|
||||
@javax.jws.WebService(name = "RelationshipServicePort", serviceName = "RelationshipService", portName = "RelationshipServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200901", endpointInterface = "org.alfresco.repo.cmis.ws.RelationshipServicePort")
|
||||
public class DMRelationshipServicePort extends DMAbstractServicePort implements RelationshipServicePort
|
||||
{
|
||||
private DictionaryService dictionaryService;
|
||||
@@ -55,7 +54,6 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a list of relationships associated with the object, optionally of a specified relationship type, and optionally in a specified direction.
|
||||
*
|
||||
@@ -63,34 +61,39 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
|
||||
* Relationship Type; includeSubRelationshipTypes: false (Default); filter: property filter; includeAllowableActions: false (default); maxItems: 0 = Unlimited;
|
||||
* skipCount: 0 = start at beginning
|
||||
* @return collection of CmisObjectType and boolean hasMoreItems
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FilterNotValidException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws TypeNotFoundException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetRelationshipsResponse getRelationships(GetRelationships parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException,
|
||||
ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public GetRelationshipsResponse getRelationships(GetRelationships parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
EnumRelationshipDirection direction = ((parameters.getDirection() != null) && (parameters.getDirection().getValue() != null)) ? parameters.getDirection().getValue() : EnumRelationshipDirection.SOURCE;
|
||||
Boolean includingSubtypes = ((parameters.getIncludeSubRelationshipTypes() != null) && (parameters.getIncludeSubRelationshipTypes().getValue() != null)) ? parameters.getIncludeSubRelationshipTypes().getValue() : false;
|
||||
EnumRelationshipDirection direction = ((parameters.getDirection() != null) && (parameters.getDirection().getValue() != null)) ? parameters.getDirection().getValue()
|
||||
: EnumRelationshipDirection.SOURCE;
|
||||
Boolean includingSubtypes = ((parameters.getIncludeSubRelationshipTypes() != null) && (parameters.getIncludeSubRelationshipTypes().getValue() != null)) ? parameters
|
||||
.getIncludeSubRelationshipTypes().getValue() : false;
|
||||
String typeId = ((parameters.getTypeId() != null) && (parameters.getTypeId().getValue() != null)) ? parameters.getTypeId().getValue() : null;
|
||||
BigInteger skipCount = ((parameters.getSkipCount() != null) && (parameters.getSkipCount().getValue() != null)) ? parameters.getSkipCount().getValue() : BigInteger.ZERO;
|
||||
BigInteger maxItems = ((parameters.getMaxItems() != null) && (parameters.getMaxItems().getValue() != null)) ? parameters.getMaxItems().getValue() : BigInteger.ZERO;
|
||||
|
||||
CMISTypeDefinition cmisTypeDef = cmisDictionaryService.findType(typeId);
|
||||
QName associationType = cmisTypeDef.getTypeId().getQName();
|
||||
QName associationType = null;
|
||||
if ((parameters.getTypeId() != null) && (parameters.getTypeId().getValue() != null) && !parameters.getTypeId().getValue().equals(""))
|
||||
{
|
||||
CMISTypeDefinition cmisTypeDef = cmisDictionaryService.findType(typeId);
|
||||
associationType = cmisTypeDef.getTypeId().getQName();
|
||||
}
|
||||
|
||||
// TODO: process 'includeAllowableActions' param, see DMObjectServicePort->determineObjectAllowableActions
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
NodeRef objectNodeRef = (NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
List<AssociationRef> assocs = receiveAssociations(objectNodeRef, associationType, direction, includingSubtypes);
|
||||
|
||||
List<AssociationRef> assocs = null;
|
||||
try
|
||||
{
|
||||
assocs = receiveAssociations(objectNodeRef, associationType, direction, includingSubtypes);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("Can't receive associations", e);
|
||||
}
|
||||
return formatResponse(propertyFilter, assocs.toArray(), new GetRelationshipsResponse(), skipCount, maxItems);
|
||||
}
|
||||
|
||||
@@ -99,21 +102,20 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
|
||||
List<AssociationRef> result = new LinkedList<AssociationRef>();
|
||||
QNamePattern matcher = new RelationshipTypeFilter(relationshipType, includeSubtypes);
|
||||
|
||||
if ((direction == EnumRelationshipDirection.BOTH) || (direction == EnumRelationshipDirection.TARGET))
|
||||
if ((direction == EnumRelationshipDirection.EITHER) || (direction == EnumRelationshipDirection.TARGET))
|
||||
{
|
||||
result.addAll(nodeService.getSourceAssocs(objectNodeReference, matcher));
|
||||
}
|
||||
|
||||
if ((direction == EnumRelationshipDirection.BOTH) || (direction == EnumRelationshipDirection.SOURCE))
|
||||
if ((direction == EnumRelationshipDirection.EITHER) || (direction == EnumRelationshipDirection.SOURCE))
|
||||
{
|
||||
result.addAll(nodeService.getTargetAssocs(objectNodeReference, matcher));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private GetRelationshipsResponse formatResponse(PropertyFilter filter, Object[] sourceArray, GetRelationshipsResponse result, BigInteger skipCount, BigInteger maxItems)
|
||||
throws InvalidArgumentException, FilterNotValidException
|
||||
{
|
||||
Cursor cursor = createCursor(sourceArray.length, skipCount, maxItems);
|
||||
for (int i = cursor.getStartRow(); i < cursor.getEndRow(); i++)
|
||||
@@ -123,7 +125,6 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private class RelationshipTypeFilter implements QNamePattern
|
||||
{
|
||||
private boolean includeSubtypes;
|
||||
@@ -152,4 +153,5 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -31,10 +31,12 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISCardinalityEnum;
|
||||
import org.alfresco.cmis.CMISChoice;
|
||||
@@ -43,6 +45,7 @@ import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISJoinEnum;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISQueryEnum;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISUpdatabilityEnum;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
@@ -50,34 +53,38 @@ import org.alfresco.service.descriptor.Descriptor;
|
||||
|
||||
/**
|
||||
* Port for repository service.
|
||||
*
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
*/
|
||||
@javax.jws.WebService(name = "RepositoryServicePort", serviceName = "RepositoryService", portName = "RepositoryServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.RepositoryServicePort")
|
||||
@javax.jws.WebService(name = "RepositoryServicePort", serviceName = "RepositoryService", portName = "RepositoryServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200901", endpointInterface = "org.alfresco.repo.cmis.ws.RepositoryServicePort")
|
||||
public class DMRepositoryServicePort extends DMAbstractServicePort implements RepositoryServicePort
|
||||
{
|
||||
private static Map<CMISJoinEnum, EnumCapabilityJoin> joinEnumMapping;
|
||||
private static Map<CMISContentStreamAllowedEnum, EnumContentStreamAllowed> contentStreamAllowedEnumMapping;
|
||||
private static Map<CMISUpdatabilityEnum, EnumUpdateability> updatabilityEnumMapping;
|
||||
private static Map<CMISUpdatabilityEnum, EnumUpdatability> updatabilityEnumMapping;
|
||||
private static Map<CMISCardinalityEnum, EnumCardinality> cardinalityEnumMapping;
|
||||
private static Map<CMISDataTypeEnum, EnumPropertyType> propertyTypeEnumMapping;
|
||||
private static HashMap<CMISQueryEnum, EnumCapabilityQuery> queryTypeEnumMapping;
|
||||
|
||||
// TODO: Hardcoded! should be reteived using standart mechanism
|
||||
private String repositoryUri = " http://localhost:8080/alfresco/cmis";
|
||||
|
||||
static
|
||||
{
|
||||
joinEnumMapping = new HashMap<CMISJoinEnum, EnumCapabilityJoin>();
|
||||
joinEnumMapping.put(CMISJoinEnum.INNER_AND_OUTER_JOIN_SUPPORT, EnumCapabilityJoin.INNERANDOUTER);
|
||||
joinEnumMapping.put(CMISJoinEnum.INNER_JOIN_SUPPORT, EnumCapabilityJoin.INNERONLY);
|
||||
joinEnumMapping.put(CMISJoinEnum.NO_JOIN_SUPPORT, EnumCapabilityJoin.NOJOIN);
|
||||
joinEnumMapping.put(CMISJoinEnum.NO_JOIN_SUPPORT, EnumCapabilityJoin.NONE);
|
||||
|
||||
contentStreamAllowedEnumMapping = new HashMap<CMISContentStreamAllowedEnum, EnumContentStreamAllowed>();
|
||||
contentStreamAllowedEnumMapping.put(CMISContentStreamAllowedEnum.ALLOWED, EnumContentStreamAllowed.ALLOWED);
|
||||
contentStreamAllowedEnumMapping.put(CMISContentStreamAllowedEnum.NOT_ALLOWED, EnumContentStreamAllowed.NOTALLOWED);
|
||||
contentStreamAllowedEnumMapping.put(CMISContentStreamAllowedEnum.REQUIRED, EnumContentStreamAllowed.REQUIRED);
|
||||
|
||||
updatabilityEnumMapping = new HashMap<CMISUpdatabilityEnum, EnumUpdateability>();
|
||||
updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_AND_WRITE, EnumUpdateability.READWRITE);
|
||||
updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_AND_WRITE_WHEN_CHECKED_OUT, EnumUpdateability.WHENCHECKEDOUT);
|
||||
updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_ONLY, EnumUpdateability.READONLY);
|
||||
updatabilityEnumMapping = new HashMap<CMISUpdatabilityEnum, EnumUpdatability>();
|
||||
updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_AND_WRITE, EnumUpdatability.READWRITE);
|
||||
updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_AND_WRITE_WHEN_CHECKED_OUT, EnumUpdatability.WHENCHECKEDOUT);
|
||||
updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_ONLY, EnumUpdatability.READONLY);
|
||||
|
||||
cardinalityEnumMapping = new HashMap<CMISCardinalityEnum, EnumCardinality>();
|
||||
cardinalityEnumMapping.put(CMISCardinalityEnum.MULTI_VALUED, EnumCardinality.MULTI);
|
||||
@@ -93,25 +100,29 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
propertyTypeEnumMapping.put(CMISDataTypeEnum.STRING, EnumPropertyType.STRING);
|
||||
propertyTypeEnumMapping.put(CMISDataTypeEnum.URI, EnumPropertyType.URI);
|
||||
propertyTypeEnumMapping.put(CMISDataTypeEnum.XML, EnumPropertyType.XML);
|
||||
|
||||
queryTypeEnumMapping = new HashMap<CMISQueryEnum, EnumCapabilityQuery>();
|
||||
queryTypeEnumMapping.put(CMISQueryEnum.BOTH_COMBINED, EnumCapabilityQuery.BOTHCOMBINED);
|
||||
queryTypeEnumMapping.put(CMISQueryEnum.BOTH_SEPERATE, EnumCapabilityQuery.BOTHSEPARATE);
|
||||
queryTypeEnumMapping.put(CMISQueryEnum.FULLTEXT_ONLY, EnumCapabilityQuery.FULLTEXTONLY);
|
||||
queryTypeEnumMapping.put(CMISQueryEnum.METADATA_ONLY, EnumCapabilityQuery.METADATAONLY);
|
||||
queryTypeEnumMapping.put(CMISQueryEnum.NONE, EnumCapabilityQuery.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of available repositories for this CMIS service endpoint.
|
||||
*
|
||||
* @return collection of CmisRepositoryEntryType (repositoryId - repository Id, repositoryName: repository name, repositoryURI: Repository URI)
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws PermissionDeniedException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public List<CmisRepositoryEntryType> getRepositories()
|
||||
throws RuntimeException, InvalidArgumentException, OperationNotSupportedException, UpdateConflictException, PermissionDeniedException
|
||||
public List<CmisRepositoryEntryType> getRepositories() throws CmisException
|
||||
{
|
||||
CmisRepositoryEntryType repositoryEntryType = new CmisRepositoryEntryType();
|
||||
Descriptor serverDescriptor = descriptorService.getCurrentRepositoryDescriptor();
|
||||
repositoryEntryType.setRepositoryID(serverDescriptor.getId());
|
||||
repositoryEntryType.setRepositoryId(serverDescriptor.getId());
|
||||
repositoryEntryType.setRepositoryName(serverDescriptor.getName());
|
||||
// TODO: Hardcoded! repositoryUri should be reteived using standart mechanism
|
||||
repositoryEntryType.setRepositoryURI(repositoryUri);
|
||||
return Collections.singletonList(repositoryEntryType);
|
||||
}
|
||||
|
||||
@@ -120,18 +131,11 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
*
|
||||
* @param parameters repositoryId: repository Id
|
||||
* @return CMIS repository Info
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public CmisRepositoryInfoType getRepositoryInfo(GetRepositoryInfo parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public CmisRepositoryInfoType getRepositoryInfo(String repositoryId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
Descriptor serverDescriptor = descriptorService.getCurrentRepositoryDescriptor();
|
||||
CmisRepositoryInfoType repositoryInfoType = new CmisRepositoryInfoType();
|
||||
@@ -139,27 +143,27 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
repositoryInfoType.setRepositoryName(serverDescriptor.getName());
|
||||
repositoryInfoType.setRepositoryRelationship("self");
|
||||
repositoryInfoType.setRepositoryDescription("");
|
||||
repositoryInfoType.setRootFolderId((String) cmisService.getProperty(cmisService.getDefaultRootNodeRef(), CMISDictionaryModel.PROP_OBJECT_ID));
|
||||
repositoryInfoType.setVendorName("Alfresco");
|
||||
repositoryInfoType.setProductName("Alfresco Repository (" + serverDescriptor.getEdition() + ")");
|
||||
repositoryInfoType.setProductVersion(serverDescriptor.getVersion());
|
||||
|
||||
repositoryInfoType.setRootFolderId((String) cmisService.getProperty(cmisService.getDefaultRootNodeRef(), CMISDictionaryModel.PROP_OBJECT_ID));
|
||||
CmisRepositoryCapabilitiesType capabilities = new CmisRepositoryCapabilitiesType();
|
||||
capabilities.setCapabilityMultifiling(true);
|
||||
capabilities.setCapabilityUnfiling(false);
|
||||
capabilities.setCapabilityVersionSpecificFiling(false);
|
||||
capabilities.setCapabilityPWCUpdateable(true);
|
||||
capabilities.setCapabilityPWCSearchable(cmisQueryService.getPwcSearchable());
|
||||
capabilities.setCapabilityAllVersionsSearchable(cmisQueryService.getAllVersionsSearchable());
|
||||
capabilities.setCapabilityQuery(queryTypeEnumMapping.get(cmisQueryService.getQuerySupport()));
|
||||
capabilities.setCapabilityJoin(joinEnumMapping.get(cmisQueryService.getJoinSupport()));
|
||||
repositoryInfoType.setCapabilities(capabilities);
|
||||
|
||||
repositoryInfoType.setCmisVersionsSupported(cmisService.getCMISVersion());
|
||||
repositoryInfoType.setCmisVersionSupported(cmisService.getCMISVersion());
|
||||
return repositoryInfoType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create web service choice object from repository choice object
|
||||
*
|
||||
*
|
||||
* @param choice repository choice
|
||||
* @param propertyType type of property
|
||||
* @return web service choice
|
||||
@@ -170,54 +174,48 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
|
||||
switch (propertyType)
|
||||
{
|
||||
case BOOLEAN:
|
||||
CmisChoiceBooleanType choiceBooleanType = new CmisChoiceBooleanType();
|
||||
choiceBooleanType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceBooleanType.setKey(choice.getName());
|
||||
choiceBooleanType.setValue((Boolean) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceBoolean(choiceBooleanType);
|
||||
break;
|
||||
case DATETIME:
|
||||
CmisChoiceDateTimeType choiceDateTimeType = new CmisChoiceDateTimeType();
|
||||
choiceDateTimeType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceDateTimeType.setKey(choice.getName());
|
||||
choiceDateTimeType.setValue(convert((Date) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceDateTime(choiceDateTimeType);
|
||||
break;
|
||||
case DECIMAL:
|
||||
CmisChoiceDecimalType choiceDecimalType = new CmisChoiceDecimalType();
|
||||
choiceDecimalType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceDecimalType.setKey(choice.getName());
|
||||
choiceDecimalType.setValue(BigDecimal.valueOf((Double) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceDecimal(choiceDecimalType);
|
||||
break;
|
||||
case HTML:
|
||||
break;
|
||||
case ID:
|
||||
CmisChoiceIdType choiceIdType = new CmisChoiceIdType();
|
||||
choiceIdType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceIdType.setKey(choice.getName());
|
||||
choiceIdType.setValue((String) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceId(choiceIdType);
|
||||
break;
|
||||
case INTEGER:
|
||||
CmisChoiceIntegerType choiceIntegerType = new CmisChoiceIntegerType();
|
||||
choiceIntegerType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceIntegerType.setKey(choice.getName());
|
||||
choiceIntegerType.setValue(BigInteger.valueOf((Integer) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceInteger(choiceIntegerType);
|
||||
break;
|
||||
case STRING:
|
||||
CmisChoiceStringType choiceStringType = new CmisChoiceStringType();
|
||||
choiceStringType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceStringType.setKey(choice.getName());
|
||||
choiceStringType.setValue((String) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceString(choiceStringType);
|
||||
break;
|
||||
case URI:
|
||||
break;
|
||||
case XML:
|
||||
break;
|
||||
case BOOLEAN:
|
||||
CmisChoiceBooleanType choiceBooleanType = new CmisChoiceBooleanType();
|
||||
choiceBooleanType.setKey(choice.getName());
|
||||
choiceBooleanType.getValue().add(Boolean.parseBoolean(choice.getValue().toString()));
|
||||
result = cmisObjectFactory.createChoiceBoolean(choiceBooleanType);
|
||||
break;
|
||||
case DATETIME:
|
||||
CmisChoiceDateTimeType choiceDateTimeType = new CmisChoiceDateTimeType();
|
||||
choiceDateTimeType.setKey(choice.getName());
|
||||
choiceDateTimeType.getValue().add(convert((Date) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceDateTime(choiceDateTimeType);
|
||||
break;
|
||||
case DECIMAL:
|
||||
CmisChoiceDecimalType choiceDecimalType = new CmisChoiceDecimalType();
|
||||
choiceDecimalType.setKey(choice.getName());
|
||||
choiceDecimalType.getValue().add(BigDecimal.valueOf(Double.parseDouble(choice.getValue().toString())));
|
||||
result = cmisObjectFactory.createChoiceDecimal(choiceDecimalType);
|
||||
break;
|
||||
case HTML:
|
||||
break;
|
||||
case ID:
|
||||
CmisChoiceIdType choiceIdType = new CmisChoiceIdType();
|
||||
choiceIdType.setKey(choice.getName());
|
||||
choiceIdType.getValue().add(choice.getValue().toString());
|
||||
result = cmisObjectFactory.createChoiceId(choiceIdType);
|
||||
break;
|
||||
case INTEGER:
|
||||
CmisChoiceIntegerType choiceIntegerType = new CmisChoiceIntegerType();
|
||||
choiceIntegerType.setKey(choice.getName());
|
||||
choiceIntegerType.getValue().add(BigInteger.valueOf(Integer.parseInt(choice.getValue().toString())));
|
||||
result = cmisObjectFactory.createChoiceInteger(choiceIntegerType);
|
||||
break;
|
||||
case STRING:
|
||||
CmisChoiceStringType choiceStringType = new CmisChoiceStringType();
|
||||
choiceStringType.setKey(choice.getName());
|
||||
choiceStringType.getValue().add(choice.getValue().toString());
|
||||
result = cmisObjectFactory.createChoiceString(choiceStringType);
|
||||
break;
|
||||
case URI:
|
||||
break;
|
||||
case XML:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -225,7 +223,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
|
||||
/**
|
||||
* Add choices childrens to list of JAXBElements
|
||||
*
|
||||
*
|
||||
* @param propertyType type of property
|
||||
* @param choices repository choice object
|
||||
* @param cmisChoices web service choice object
|
||||
@@ -246,11 +244,12 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
|
||||
/**
|
||||
* Add root choices to list of choices
|
||||
*
|
||||
*
|
||||
* @param propertyType type of property
|
||||
* @param choices repository choice object
|
||||
* @param cmisChoices web service choice object
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void addChoices(CMISDataTypeEnum propertyType, Collection<CMISChoice> choices, List<CmisChoiceType> cmisChoices)
|
||||
{
|
||||
for (CMISChoice choice : choices)
|
||||
@@ -267,20 +266,21 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
|
||||
/**
|
||||
* Add property definitions to list of definitions
|
||||
*
|
||||
*
|
||||
* @param propertyDefinition repository property definition
|
||||
* @param wsPropertyDefs web service property definition
|
||||
*/
|
||||
private void addPropertyDefs(CMISTypeDefinition typeDefinition, CMISPropertyDefinition propertyDefinition, List<CmisPropertyDefinitionType> wsPropertyDefs)
|
||||
throws CmisException
|
||||
{
|
||||
CmisPropertyDefinitionType wsPropertyDef = new CmisPropertyDefinitionType();
|
||||
CmisPropertyDefinitionType wsPropertyDef = createPropertyDefinitionType(propertyDefinition.getDataType());
|
||||
wsPropertyDef.setName(propertyDefinition.getPropertyId().getName());
|
||||
wsPropertyDef.setId(propertyDefinition.getPropertyId().getId());
|
||||
wsPropertyDef.setDisplayName(propertyDefinition.getDisplayName());
|
||||
wsPropertyDef.setDescription(propertyDefinition.getDescription());
|
||||
wsPropertyDef.setPropertyType(propertyTypeEnumMapping.get(propertyDefinition.getDataType()));
|
||||
wsPropertyDef.setCardinality(cardinalityEnumMapping.get(propertyDefinition.getCardinality()));
|
||||
wsPropertyDef.setUpdateability(updatabilityEnumMapping.get(propertyDefinition.getUpdatability()));
|
||||
wsPropertyDef.setUpdatability(updatabilityEnumMapping.get(propertyDefinition.getUpdatability()));
|
||||
wsPropertyDef.setInherited(!typeDefinition.getOwnedPropertyDefinitions().containsKey(propertyDefinition.getPropertyId()));
|
||||
wsPropertyDef.setRequired(propertyDefinition.isRequired());
|
||||
wsPropertyDef.setQueryable(propertyDefinition.isQueryable());
|
||||
@@ -291,19 +291,67 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
wsPropertyDefs.add(wsPropertyDef);
|
||||
}
|
||||
|
||||
private CmisPropertyDefinitionType createPropertyDefinitionType(CMISDataTypeEnum type) throws CmisException
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BOOLEAN:
|
||||
{
|
||||
return new CmisPropertyBooleanDefinitionType();
|
||||
}
|
||||
case DATETIME:
|
||||
{
|
||||
return new CmisPropertyDateTimeDefinitionType();
|
||||
}
|
||||
case DECIMAL:
|
||||
{
|
||||
return new CmisPropertyDecimalDefinitionType();
|
||||
}
|
||||
case HTML:
|
||||
{
|
||||
return new CmisPropertyHtmlDefinitionType();
|
||||
}
|
||||
case ID:
|
||||
{
|
||||
return new CmisPropertyIdDefinitionType();
|
||||
}
|
||||
case INTEGER:
|
||||
{
|
||||
return new CmisPropertyIntegerDefinitionType();
|
||||
}
|
||||
case STRING:
|
||||
{
|
||||
return new CmisPropertyStringDefinitionType();
|
||||
}
|
||||
case URI:
|
||||
{
|
||||
return new CmisPropertyUriDefinitionType();
|
||||
}
|
||||
case XML:
|
||||
{
|
||||
return new CmisPropertyXmlDefinitionType();
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException(type.getLabel(), EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties for web service type definition
|
||||
*
|
||||
*
|
||||
* @param cmisTypeDefinition web service type definition
|
||||
* @param typeDefinition repository type definition
|
||||
* @param includeProperties true if need property definitions for type definition
|
||||
*/
|
||||
private void setCmisTypeDefinitionProperties(CmisTypeDefinitionType cmisTypeDefinition, CMISTypeDefinition typeDefinition, boolean includeProperties)
|
||||
@SuppressWarnings("unused")
|
||||
private void setCmisTypeDefinitionProperties(CmisTypeDefinitionType cmisTypeDefinition, CMISTypeDefinition typeDefinition, boolean includeProperties) throws CmisException
|
||||
{
|
||||
cmisTypeDefinition.setTypeId(typeDefinition.getTypeId().getId());
|
||||
cmisTypeDefinition.setQueryName(typeDefinition.getQueryName());
|
||||
cmisTypeDefinition.setDisplayName(typeDefinition.getDisplayName());
|
||||
cmisTypeDefinition.setBaseType(EnumObjectType.fromValue(typeDefinition.getBaseType().getTypeId().getId()));
|
||||
cmisTypeDefinition.setBaseType(EnumBaseObjectType.fromValue(typeDefinition.getBaseType().getTypeId().getId()));
|
||||
cmisTypeDefinition.setParentId(typeDefinition.getParentType().getTypeId().getId());
|
||||
cmisTypeDefinition.setBaseTypeQueryName(typeDefinition.getBaseType().getQueryName());
|
||||
cmisTypeDefinition.setDescription(typeDefinition.getDescription());
|
||||
@@ -325,13 +373,13 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
|
||||
/**
|
||||
* Create web service type definition for typeId
|
||||
*
|
||||
*
|
||||
* @param typeId type id
|
||||
* @param includeProperties true if need property definitions for type definition
|
||||
* @return web service type definition
|
||||
* @throws ObjectNotFoundException if type id not found
|
||||
* @throws CmisException if type id not found
|
||||
*/
|
||||
private JAXBElement<? extends CmisTypeDefinitionType> getCmisTypeDefinition(CMISTypeDefinition typeDef, boolean includeProperties) throws ObjectNotFoundException
|
||||
private CmisTypeDefinitionType getCmisTypeDefinition(CMISTypeDefinition typeDef, boolean includeProperties) throws CmisException
|
||||
{
|
||||
if (typeDef.getParentType() == null)
|
||||
{
|
||||
@@ -340,40 +388,40 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
|
||||
if (typeDef == null)
|
||||
{
|
||||
throw new ObjectNotFoundException("Type not found");
|
||||
throw cmisObjectsUtils.createCmisException("Type not found", EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
JAXBElement<? extends CmisTypeDefinitionType> result = null;
|
||||
|
||||
switch (typeDef.getTypeId().getScope())
|
||||
{
|
||||
case DOCUMENT:
|
||||
CmisTypeDocumentDefinitionType documentDefinitionType = new CmisTypeDocumentDefinitionType();
|
||||
setCmisTypeDefinitionProperties(documentDefinitionType, typeDef, includeProperties);
|
||||
documentDefinitionType.setVersionable(typeDef.isVersionable());
|
||||
documentDefinitionType.setContentStreamAllowed(contentStreamAllowedEnumMapping.get(typeDef.getContentStreamAllowed()));
|
||||
result = cmisObjectFactory.createDocumentType(documentDefinitionType);
|
||||
break;
|
||||
case FOLDER:
|
||||
CmisTypeFolderDefinitionType folderDefinitionType = new CmisTypeFolderDefinitionType();
|
||||
setCmisTypeDefinitionProperties(folderDefinitionType, typeDef, includeProperties);
|
||||
result = cmisObjectFactory.createFolderType(folderDefinitionType);
|
||||
break;
|
||||
case POLICY:
|
||||
CmisTypePolicyDefinitionType policyDefinitionType = new CmisTypePolicyDefinitionType();
|
||||
setCmisTypeDefinitionProperties(policyDefinitionType, typeDef, includeProperties);
|
||||
result = cmisObjectFactory.createPolicyType(policyDefinitionType);
|
||||
break;
|
||||
case RELATIONSHIP:
|
||||
CmisTypeRelationshipDefinitionType relationshipDefinitionType = new CmisTypeRelationshipDefinitionType();
|
||||
setCmisTypeDefinitionProperties(relationshipDefinitionType, typeDef, includeProperties);
|
||||
result = cmisObjectFactory.createRelationshipType(relationshipDefinitionType);
|
||||
break;
|
||||
case UNKNOWN:
|
||||
throw new ObjectNotFoundException("Unknown CMIS Type");
|
||||
case DOCUMENT:
|
||||
CmisTypeDocumentDefinitionType documentDefinitionType = new CmisTypeDocumentDefinitionType();
|
||||
setCmisTypeDefinitionProperties(documentDefinitionType, typeDef, includeProperties);
|
||||
documentDefinitionType.setVersionable(typeDef.isVersionable());
|
||||
documentDefinitionType.setContentStreamAllowed(contentStreamAllowedEnumMapping.get(typeDef.getContentStreamAllowed()));
|
||||
result = cmisObjectFactory.createDocumentType(documentDefinitionType);
|
||||
break;
|
||||
case FOLDER:
|
||||
CmisTypeFolderDefinitionType folderDefinitionType = new CmisTypeFolderDefinitionType();
|
||||
setCmisTypeDefinitionProperties(folderDefinitionType, typeDef, includeProperties);
|
||||
result = cmisObjectFactory.createFolderType(folderDefinitionType);
|
||||
break;
|
||||
case POLICY:
|
||||
CmisTypePolicyDefinitionType policyDefinitionType = new CmisTypePolicyDefinitionType();
|
||||
setCmisTypeDefinitionProperties(policyDefinitionType, typeDef, includeProperties);
|
||||
result = cmisObjectFactory.createPolicyType(policyDefinitionType);
|
||||
break;
|
||||
case RELATIONSHIP:
|
||||
CmisTypeRelationshipDefinitionType relationshipDefinitionType = new CmisTypeRelationshipDefinitionType();
|
||||
setCmisTypeDefinitionProperties(relationshipDefinitionType, typeDef, includeProperties);
|
||||
result = cmisObjectFactory.createRelationshipType(relationshipDefinitionType);
|
||||
break;
|
||||
case UNKNOWN:
|
||||
throw new CmisException("Unknown CMIS Type");
|
||||
}
|
||||
|
||||
return result;
|
||||
return result.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,58 +429,50 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; typeId: type Id; returnPropertyDefinitions: false (default); maxItems: 0 = Repository-default number of items(Default);
|
||||
* skipCount: 0 = start;
|
||||
* @return collection of CmisTypeDefinitionType and boolean hasMoreItems
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws PermissionDeniedException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public GetTypesResponse getTypes(GetTypes parameters)
|
||||
throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, OperationNotSupportedException, UpdateConflictException, PermissionDeniedException
|
||||
public void getTypes(String repositoryId, String typeId, Boolean returnPropertyDefinitions, BigInteger maxItems, BigInteger skipCount,
|
||||
Holder<List<CmisTypeDefinitionType>> type, Holder<Boolean> hasMoreItems) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
Collection<CMISTypeDefinition> typeDefs;
|
||||
if (parameters.getTypeId() == null)
|
||||
if ((typeId == null) || typeId.equals(""))
|
||||
{
|
||||
typeDefs = cmisDictionaryService.getAllTypes();
|
||||
}
|
||||
else
|
||||
{
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType(parameters.getTypeId().getValue());
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType(typeId);
|
||||
typeDefs = typeDef.getSubTypes(true);
|
||||
}
|
||||
|
||||
GetTypesResponse response = new GetTypesResponse();
|
||||
if (parameters.getMaxItems() != null)
|
||||
if (maxItems != null)
|
||||
{
|
||||
response.setHasMoreItems(parameters.getMaxItems().getValue().intValue() < typeDefs.size());
|
||||
hasMoreItems.value = new Boolean((skipCount.intValue() + maxItems.intValue()) < typeDefs.size());
|
||||
}
|
||||
|
||||
// skip
|
||||
Cursor cursor = createCursor(typeDefs.size(), parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null, parameters.getMaxItems() != null ? parameters.getMaxItems().getValue() : null);
|
||||
Cursor cursor = createCursor(typeDefs.size(), skipCount, maxItems);
|
||||
Iterator<CMISTypeDefinition> iterTypeDefs = typeDefs.iterator();
|
||||
for (int i = 0; i < cursor.getStartRow(); i++)
|
||||
{
|
||||
iterTypeDefs.next();
|
||||
}
|
||||
|
||||
boolean returnPropertyDefinitions = parameters.getReturnPropertyDefinitions() == null ? false : parameters.getReturnPropertyDefinitions().getValue();
|
||||
boolean returnPropertyDefinitionsVal = returnPropertyDefinitions == null ? false : returnPropertyDefinitions.booleanValue();
|
||||
|
||||
List<JAXBElement<? extends CmisTypeDefinitionType>> types = response.getType();
|
||||
type.value = new LinkedList<CmisTypeDefinitionType>();
|
||||
for (int i = cursor.getStartRow(); i <= cursor.getEndRow(); i++)
|
||||
{
|
||||
JAXBElement<? extends CmisTypeDefinitionType> element = getCmisTypeDefinition(iterTypeDefs.next(), returnPropertyDefinitions);
|
||||
CmisTypeDefinitionType element = getCmisTypeDefinition(iterTypeDefs.next(), returnPropertyDefinitionsVal);
|
||||
if (element != null)
|
||||
{
|
||||
types.add(element);
|
||||
type.value.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
hasMoreItems.value = ((skipCount == null) || (maxItems == null)) ? (false) : ((cursor.getEndRow() < typeDefs.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,24 +480,13 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; typeId: type Id;
|
||||
* @return CMIS type definition
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws TypeNotFoundException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public GetTypeDefinitionResponse getTypeDefinition(GetTypeDefinition parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public CmisTypeDefinitionType getTypeDefinition(String repositoryId, String typeId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
GetTypeDefinitionResponse response = new GetTypeDefinitionResponse();
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType(parameters.getTypeId());
|
||||
response.setType(getCmisTypeDefinition(typeDef, true));
|
||||
return response;
|
||||
checkRepositoryId(repositoryId);
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findType(typeId);
|
||||
return getCmisTypeDefinition(typeDef, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -37,27 +38,49 @@ import org.springframework.aop.ThrowsAdvice;
|
||||
*/
|
||||
public class DMServicePortThrowsAdvice implements ThrowsAdvice
|
||||
{
|
||||
private static final Log log = LogFactory.getLog("org.alfresco.repo.cmis.ws");
|
||||
private static final Log LOGGER = LogFactory.getLog("org.alfresco.repo.cmis.ws");
|
||||
|
||||
public void afterThrowing(AccessDeniedException e)
|
||||
throws PermissionDeniedException
|
||||
private CmisObjectsUtils cmisObjectsUtils;
|
||||
|
||||
public void setCmisObjectsUtils(CmisObjectsUtils cmisObjectsUtils)
|
||||
{
|
||||
if (log.isInfoEnabled())
|
||||
{
|
||||
log.info(e);
|
||||
}
|
||||
|
||||
throw new PermissionDeniedException("Access denied. Message: " + e.getMessage(), e);
|
||||
this.cmisObjectsUtils = cmisObjectsUtils;
|
||||
}
|
||||
|
||||
public void afterThrowing(java.lang.RuntimeException e)
|
||||
throws RuntimeException
|
||||
public void afterThrowing(AccessDeniedException e) throws CmisException
|
||||
{
|
||||
if (log.isErrorEnabled())
|
||||
if (LOGGER.isInfoEnabled())
|
||||
{
|
||||
log.error(e);
|
||||
LOGGER.error(e.toString(), e);
|
||||
}
|
||||
|
||||
throw new RuntimeException("Runtime error. Message: " + e.getMessage(), e);
|
||||
throw cmisObjectsUtils.createCmisException(("Access denied. Message: " + e.toString()), e);
|
||||
}
|
||||
|
||||
public void afterThrowing(java.lang.RuntimeException e) throws CmisException
|
||||
{
|
||||
if (LOGGER.isErrorEnabled())
|
||||
{
|
||||
LOGGER.error(e.toString(), e);
|
||||
}
|
||||
|
||||
throw cmisObjectsUtils.createCmisException(("Runtime error. Message: " + e.toString()), e);
|
||||
}
|
||||
|
||||
public void afterThrowing(java.lang.Exception e) throws CmisException
|
||||
{
|
||||
if (LOGGER.isInfoEnabled())
|
||||
{
|
||||
LOGGER.error(e.toString(), e);
|
||||
}
|
||||
|
||||
if (!(e instanceof CmisException))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException(("Some error occured during last service invokation. Message: " + e.toString()), e);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw (CmisException) e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
@@ -46,7 +47,7 @@ import org.alfresco.service.cmr.version.VersionType;
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "VersioningServicePort", serviceName = "VersioningService", portName = "VersioningServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.VersioningServicePort")
|
||||
@javax.jws.WebService(name = "VersioningServicePort", serviceName = "VersioningService", portName = "VersioningServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200901", endpointInterface = "org.alfresco.repo.cmis.ws.VersioningServicePort")
|
||||
public class DMVersioningServicePort extends DMAbstractServicePort implements VersioningServicePort
|
||||
{
|
||||
private LockService lockService;
|
||||
@@ -56,22 +57,16 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
this.lockService = lockService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverses the effect of a check-out. Removes the private working copy of the checked-out document object, allowing other documents in the version series to be checked out
|
||||
* again.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param documentId document Id
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void cancelCheckOut(String repositoryId, String documentId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
public void cancelCheckOut(String repositoryId, String documentId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef workingCopyNodeRef = cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
@@ -88,18 +83,11 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* @param properties CMIS properties
|
||||
* @param contentStream content stream
|
||||
* @param checkinComment check in comment
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws StorageException
|
||||
* @throws StreamNotSupportedException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* STREAM_NOT_SUPPORTED, UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void checkIn(String repositoryId, Holder<String> documentId, Boolean major, CmisPropertiesType properties, CmisContentStreamType contentStream, String checkinComment)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef workingCopyNodeRef = cmisObjectsUtils.getIdentifierInstance(documentId.value, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
@@ -115,16 +103,17 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException("Exception while updating content stream");
|
||||
throw cmisObjectsUtils.createCmisException("Exception while updating content stream", EnumServiceException.RUNTIME, e);
|
||||
}
|
||||
}
|
||||
|
||||
NodeRef nodeRef = checkOutCheckInService.checkin(workingCopyNodeRef,
|
||||
createVersionProperties(checkinComment, major != null && major ? VersionType.MAJOR : VersionType.MINOR));
|
||||
|
||||
if (properties != null)
|
||||
{
|
||||
setProperties(workingCopyNodeRef, properties);
|
||||
setProperties(nodeRef, properties);
|
||||
}
|
||||
|
||||
NodeRef nodeRef = checkOutCheckInService.checkin(workingCopyNodeRef, createVersionProperties(checkinComment, major != null && major ? VersionType.MAJOR : VersionType.MINOR));
|
||||
documentId.value = (String) cmisService.getProperty(nodeRef, CMISDictionaryModel.PROP_OBJECT_ID);
|
||||
}
|
||||
|
||||
@@ -135,16 +124,10 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* @param documentId ObjectID of document version to checkout
|
||||
* @param contentCopied
|
||||
* @return ObjectID of private working copy as documentId; True if succeed, False otherwise as contentCopied
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void checkOut(String repositoryId, Holder<String> documentId, Holder<Boolean> contentCopied)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void checkOut(String repositoryId, Holder<String> documentId, Holder<Boolean> contentCopied) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
@@ -153,7 +136,7 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
|
||||
if (lockStatus.equals(LockStatus.LOCKED) || lockStatus.equals(LockStatus.LOCK_OWNER) || nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
throw new OperationNotSupportedException("Object is already checked out");
|
||||
throw cmisObjectsUtils.createCmisException("Object is already checked out", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
NodeRef pwcNodeRef = checkoutNode(documentNodeRef);
|
||||
@@ -166,16 +149,9 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param versionSeriesId version series Id
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public void deleteAllVersions(String repositoryId, String versionSeriesId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void deleteAllVersions(String repositoryId, String versionSeriesId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(versionSeriesId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
@@ -187,17 +163,9 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; versionSeriesId: version series Id; filter: property filter; includeAllowableActions; includeRelationships;
|
||||
* @return list of CmisObjectType
|
||||
* @throws PermissionDeniedException
|
||||
* @throws UpdateConflictException
|
||||
* @throws FilterNotValidException
|
||||
* @throws ObjectNotFoundException
|
||||
* @throws OperationNotSupportedException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetAllVersionsResponse getAllVersions(GetAllVersions parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public GetAllVersionsResponse getAllVersions(GetAllVersions parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
@@ -234,9 +202,9 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* @param parameters repositoryId: repository Id; versionSeriesId: version series Id; majorVersion: whether or not to return the latest major version. Default=FALSE; filter:
|
||||
* property filter
|
||||
* @return CmisObjectType with properties
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public GetPropertiesOfLatestVersionResponse getPropertiesOfLatestVersion(GetPropertiesOfLatestVersion parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
public GetPropertiesOfLatestVersionResponse getPropertiesOfLatestVersion(GetPropertiesOfLatestVersion parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
@@ -244,10 +212,15 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
NodeRef latestVersionNodeRef = getLatestNode(documentNodeRef, parameters.isMajorVersion());
|
||||
|
||||
Serializable property = cmisService.getProperty(latestVersionNodeRef, CMISDictionaryModel.PROP_IS_MAJOR_VERSION);
|
||||
if (parameters.isMajorVersion() && ((property == null) || !((Boolean)property)))
|
||||
{
|
||||
throw cmisObjectsUtils.createCmisException("Object that was specified has no latest major version", EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
GetPropertiesOfLatestVersionResponse response = new GetPropertiesOfLatestVersionResponse();
|
||||
response.setObject(new CmisObjectType());
|
||||
CmisObjectType object = response.getObject();
|
||||
object.setProperties(getPropertiesType(latestVersionNodeRef.toString(), propertyFilter));
|
||||
response.getObject().setProperties(getPropertiesType(latestVersionNodeRef.toString(), propertyFilter));
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -261,11 +234,11 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
}
|
||||
}
|
||||
|
||||
private void assertWorkingCopy(NodeRef nodeRef) throws OperationNotSupportedException
|
||||
private void assertWorkingCopy(NodeRef nodeRef) throws CmisException
|
||||
{
|
||||
if (!cmisObjectsUtils.isWorkingCopy(nodeRef))
|
||||
{
|
||||
throw new OperationNotSupportedException("Object isn't checked out");
|
||||
throw cmisObjectsUtils.createCmisException("Object isn't checked out", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -129,30 +129,36 @@ public class PropertyUtil
|
||||
|
||||
if (cmisProperty instanceof CmisPropertyBoolean)
|
||||
{
|
||||
value = ((CmisPropertyBoolean) cmisProperty).isValue();
|
||||
value = ((CmisPropertyBoolean) cmisProperty).getValue() != null && ((CmisPropertyBoolean) cmisProperty).getValue().size() > 0 ? ((CmisPropertyBoolean) cmisProperty)
|
||||
.getValue().get(0) : null;
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyDateTime)
|
||||
{
|
||||
// value = ((CmisPropertyDateTime) cmisProperty).getValue().;
|
||||
value = ((CmisPropertyDateTime) cmisProperty).getValue() != null && ((CmisPropertyDateTime) cmisProperty).getValue().size() > 0 ? ((CmisPropertyDateTime) cmisProperty)
|
||||
.getValue().get(0).toXMLFormat() : null;
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyDecimal)
|
||||
{
|
||||
value = ((CmisPropertyDecimal) cmisProperty).getValue().doubleValue();
|
||||
value = ((CmisPropertyDecimal) cmisProperty).getValue() != null && ((CmisPropertyDecimal) cmisProperty).getValue().size() > 0 ? ((CmisPropertyDecimal) cmisProperty)
|
||||
.getValue().get(0) : null;
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyHtml)
|
||||
{
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyId)
|
||||
{
|
||||
value = ((CmisPropertyId) cmisProperty).getValue();
|
||||
value = ((CmisPropertyId) cmisProperty).getValue() != null && ((CmisPropertyId) cmisProperty).getValue().size() > 0 ? ((CmisPropertyId) cmisProperty).getValue().get(0)
|
||||
: null;
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyInteger)
|
||||
{
|
||||
value = ((CmisPropertyInteger) cmisProperty).getValue();
|
||||
value = ((CmisPropertyInteger) cmisProperty).getValue() != null && ((CmisPropertyInteger) cmisProperty).getValue().size() > 0 ? ((CmisPropertyInteger) cmisProperty)
|
||||
.getValue().get(0) : null;
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyString)
|
||||
{
|
||||
value = ((CmisPropertyString) cmisProperty).getValue();
|
||||
value = ((CmisPropertyString) cmisProperty).getValue() != null && ((CmisPropertyString) cmisProperty).getValue().size() > 0 ? ((CmisPropertyString) cmisProperty)
|
||||
.getValue().get(0) : null;
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyUri)
|
||||
{
|
||||
|
@@ -24,20 +24,23 @@
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws.utils;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryService;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.ws.CmisException;
|
||||
import org.alfresco.repo.cmis.ws.CmisFaultType;
|
||||
import org.alfresco.repo.cmis.ws.EnumObjectType;
|
||||
import org.alfresco.repo.cmis.ws.InvalidArgumentException;
|
||||
import org.alfresco.repo.cmis.ws.ObjectNotFoundException;
|
||||
import org.alfresco.repo.cmis.ws.OperationNotSupportedException;
|
||||
import org.alfresco.repo.cmis.ws.EnumServiceException;
|
||||
import org.alfresco.repo.cmis.ws.utils.DescendantsQueueManager.DescendantElement;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
@@ -67,6 +70,15 @@ public class CmisObjectsUtils
|
||||
DOCUMENT_AND_FOLDER_TYPES.add(ContentModel.TYPE_FOLDER);
|
||||
}
|
||||
|
||||
private static final Map<String, EnumServiceException> CLASS_TO_ENUM_EXCEPTION_MAPPING;
|
||||
static
|
||||
{
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING = new HashMap<String, EnumServiceException>();
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(AccessDeniedException.class.getName(), EnumServiceException.PERMISSION_DENIED);
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(java.lang.RuntimeException.class.getName(), EnumServiceException.RUNTIME);
|
||||
// TODO: insert CLASS_TO_ENUM_EXCEPTION_MAPPING.put(<Concreate_Exception_Type>.class.getName(), EnumServiceException.<Appropriate_Enum_value>);
|
||||
}
|
||||
|
||||
private CheckOutCheckInService checkOutCheckInService;
|
||||
private CMISDictionaryService cmisDictionaryService;
|
||||
private FileFolderService fileFolderService;
|
||||
@@ -76,7 +88,6 @@ public class CmisObjectsUtils
|
||||
|
||||
private Throwable lastOperationException;
|
||||
|
||||
|
||||
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
|
||||
{
|
||||
this.cmisDictionaryService = cmisDictionaryService;
|
||||
@@ -106,13 +117,46 @@ public class CmisObjectsUtils
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
|
||||
public IdentifierConversionResults getIdentifierInstance(String identifier, AlfrescoObjectType expectedType) throws InvalidArgumentException
|
||||
|
||||
public CmisException createCmisException(String message, EnumServiceException exceptionType)
|
||||
{
|
||||
return createCmisException(message, exceptionType, null, 0);
|
||||
}
|
||||
|
||||
public CmisException createCmisException(String message, Throwable cause)
|
||||
{
|
||||
EnumServiceException exceptionType = null;
|
||||
|
||||
if (CLASS_TO_ENUM_EXCEPTION_MAPPING.containsKey(cause.getClass().getName()))
|
||||
{
|
||||
exceptionType = CLASS_TO_ENUM_EXCEPTION_MAPPING.get(cause.getClass().getName());
|
||||
}
|
||||
|
||||
exceptionType = (exceptionType == null) ? (EnumServiceException.RUNTIME) : (exceptionType);
|
||||
|
||||
return createCmisException(message, exceptionType, cause, 0);
|
||||
}
|
||||
|
||||
public CmisException createCmisException(String message, EnumServiceException exceptionType, Throwable cause)
|
||||
{
|
||||
return createCmisException(message, exceptionType, cause, 0);
|
||||
}
|
||||
|
||||
public CmisException createCmisException(String message, EnumServiceException exceptionType, Throwable cause, int errorCode)
|
||||
{
|
||||
CmisFaultType fault = new CmisFaultType();
|
||||
fault.setMessage(message);
|
||||
fault.setType(exceptionType);
|
||||
fault.setCode(BigInteger.valueOf(errorCode));
|
||||
|
||||
return new CmisException(message, fault, cause);
|
||||
}
|
||||
|
||||
public IdentifierConversionResults getIdentifierInstance(String identifier, AlfrescoObjectType expectedType) throws CmisException
|
||||
{
|
||||
if (!(identifier instanceof String))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid Object Identifier was specified");
|
||||
throw createCmisException("Invalid Object Identifier was specified", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
IdentifierConversionResults result;
|
||||
@@ -135,11 +179,10 @@ public class CmisObjectsUtils
|
||||
return result;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Unexpected object type of the specified Object Identifier " + identifier);
|
||||
throw createCmisException(("Unexpected object type of the specified Object Identifier " + identifier), EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
public void deleteFolder(NodeRef folderNodeReference, boolean continueOnFailure, boolean totalDeletion, List<String> resultList)
|
||||
throws OperationNotSupportedException
|
||||
public void deleteFolder(NodeRef folderNodeReference, boolean continueOnFailure, boolean totalDeletion, List<String> resultList) throws CmisException
|
||||
{
|
||||
DescendantsQueueManager queueManager = new DescendantsQueueManager(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, null, null, folderNodeReference));
|
||||
|
||||
@@ -159,7 +202,8 @@ public class CmisObjectsUtils
|
||||
} while (!queueManager.isEmpty() && (continueOnFailure || resultList.isEmpty()));
|
||||
}
|
||||
|
||||
private void processUnlinkStatus(DescendantElement currentElement, UnlinkOperationStatus unlinkStatus, DescendantsQueueManager queueManager, List<String> resultList, boolean addAllFailedToDelete)
|
||||
private void processUnlinkStatus(DescendantElement currentElement, UnlinkOperationStatus unlinkStatus, DescendantsQueueManager queueManager, List<String> resultList,
|
||||
boolean addAllFailedToDelete)
|
||||
{
|
||||
if (!unlinkStatus.getChildren().isEmpty())
|
||||
{
|
||||
@@ -174,7 +218,7 @@ public class CmisObjectsUtils
|
||||
queueManager.removeParents(currentElement, resultList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean deleteObject(NodeRef objectNodeReference)
|
||||
{
|
||||
return canLock(objectNodeReference) && performNodeDeletion(objectNodeReference);
|
||||
@@ -202,7 +246,8 @@ public class CmisObjectsUtils
|
||||
{
|
||||
try
|
||||
{
|
||||
QName name = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName((String)nodeService.getProperty(objectNodeRef, ContentModel.PROP_NAME)));
|
||||
QName name = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName((String) nodeService.getProperty(objectNodeRef,
|
||||
ContentModel.PROP_NAME)));
|
||||
nodeService.addChild(parentFolderNodeRef, objectNodeRef, ContentModel.ASSOC_CONTAINS, name);
|
||||
return true;
|
||||
}
|
||||
@@ -277,7 +322,7 @@ public class CmisObjectsUtils
|
||||
|
||||
public boolean isChildOfThisFolder(NodeRef objectNodeReference, NodeRef folderNodeReference)
|
||||
{
|
||||
NodeRef searchedObjectNodeReference = fileFolderService.searchSimple(folderNodeReference, (String)nodeService.getProperty(objectNodeReference, ContentModel.PROP_NAME));
|
||||
NodeRef searchedObjectNodeReference = fileFolderService.searchSimple(folderNodeReference, (String) nodeService.getProperty(objectNodeReference, ContentModel.PROP_NAME));
|
||||
return (searchedObjectNodeReference != null) && searchedObjectNodeReference.equals(objectNodeReference);
|
||||
}
|
||||
|
||||
@@ -333,12 +378,12 @@ public class CmisObjectsUtils
|
||||
}
|
||||
else
|
||||
{
|
||||
objectUnlinked = !isPrimaryObjectParent(parentFolderNodeReference, objectNodeReference) && removeObject(objectNodeReference, parentFolderNodeReference);
|
||||
objectUnlinked = !isPrimaryObjectParent(parentFolderNodeReference, objectNodeReference) && removeObject(objectNodeReference, parentFolderNodeReference);
|
||||
}
|
||||
return new UnlinkOperationStatus(objectUnlinked, new LinkedList<ChildAssociationRef>());
|
||||
}
|
||||
|
||||
private NodeRef safeGetNodeRef(String nodeIdentifier) throws InvalidArgumentException
|
||||
private NodeRef safeGetNodeRef(String nodeIdentifier) throws CmisException
|
||||
{
|
||||
if (NodeRef.isNodeRef(nodeIdentifier))
|
||||
{
|
||||
@@ -349,7 +394,8 @@ public class CmisObjectsUtils
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Invalid Object Identifier was specified: Identifier is incorrect or Object with the specified Identifier does not exist", new ObjectNotFoundException());
|
||||
throw createCmisException("Invalid Object Identifier was specified: Identifier is incorrect or Object with the specified Identifier does not exist",
|
||||
EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
private String cutNodeVersionIfNecessary(String identifier, String[] splitNodeIdentifier, int startIndex)
|
||||
@@ -357,7 +403,8 @@ public class CmisObjectsUtils
|
||||
String withoutVersionSuffix = identifier;
|
||||
if (splitNodeIdentifier.length == NODE_REFERENCE_WITH_SUFFIX_DELIMETERS_COUNT)
|
||||
{
|
||||
withoutVersionSuffix = splitNodeIdentifier[startIndex++ - 1] + DOUBLE_NODE_REFERENCE_ID_DELIMETER + splitNodeIdentifier[startIndex++] + NODE_REFERENCE_ID_DELIMETER + splitNodeIdentifier[startIndex];
|
||||
withoutVersionSuffix = splitNodeIdentifier[startIndex++ - 1] + DOUBLE_NODE_REFERENCE_ID_DELIMETER + splitNodeIdentifier[startIndex++] + NODE_REFERENCE_ID_DELIMETER
|
||||
+ splitNodeIdentifier[startIndex];
|
||||
}
|
||||
return withoutVersionSuffix;
|
||||
}
|
||||
@@ -382,6 +429,7 @@ public class CmisObjectsUtils
|
||||
{
|
||||
return new IdentifierConversionResults()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
public AssociationRef getConvertedIdentifier()
|
||||
{
|
||||
return new AssociationRef(identifier);
|
||||
@@ -393,6 +441,7 @@ public class CmisObjectsUtils
|
||||
{
|
||||
return new IdentifierConversionResults()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
public NodeRef getConvertedIdentifier()
|
||||
{
|
||||
return identifier;
|
||||
@@ -430,10 +479,10 @@ public class CmisObjectsUtils
|
||||
return this.children;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Throwable getLastOperationException()
|
||||
{
|
||||
return lastOperationException;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public class DescendantsQueueManager
|
||||
protected DescendantsQueueManager()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.queue.isEmpty();
|
||||
@@ -62,7 +62,7 @@ public class DescendantsQueueManager
|
||||
queue.remove(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void addFirst(DescendantElement parent, List<ChildAssociationRef> children)
|
||||
{
|
||||
for (ChildAssociationRef child : children)
|
||||
@@ -70,7 +70,7 @@ public class DescendantsQueueManager
|
||||
queue.addFirst(createElement(parent, child));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private DescendantElement createElement(DescendantElement parent, ChildAssociationRef child)
|
||||
{
|
||||
return new DescendantElement(parent, child);
|
||||
@@ -80,7 +80,7 @@ public class DescendantsQueueManager
|
||||
{
|
||||
queue.addLast(element);
|
||||
}
|
||||
|
||||
|
||||
public void removeParents(DescendantElement element, List<String> undeletedNodes)
|
||||
{
|
||||
|
||||
@@ -134,5 +134,5 @@ public class DescendantsQueueManager
|
||||
return (childAssoc != null) ? (childAssoc.equals(currentElement.getChildAssoc())) : (currentElement.getChildAssoc() == null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user