mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Complete 1.3 Dictionary Web Service implementation.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3208 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -615,25 +615,7 @@ public class Utils
|
||||
int pos = 0;
|
||||
for (org.alfresco.service.cmr.dictionary.PropertyDefinition ddPropDef : props.values())
|
||||
{
|
||||
PropertyDefinition propDef = new PropertyDefinition();
|
||||
propDef.setName(ddPropDef.getName().toString());
|
||||
propDef.setDataType(ddPropDef.getDataType().getName().toString());
|
||||
propDef.setMandatory(ddPropDef.isMandatory());
|
||||
propDef.setReadOnly(ddPropDef.isProtected());
|
||||
if (ddPropDef.getDefaultValue() != null)
|
||||
{
|
||||
propDef.setDefaultValue(ddPropDef.getDefaultValue());
|
||||
}
|
||||
if (ddPropDef.getTitle() != null)
|
||||
{
|
||||
propDef.setTitle(ddPropDef.getTitle());
|
||||
}
|
||||
if (ddPropDef.getDescription() != null)
|
||||
{
|
||||
propDef.setDescription(ddPropDef.getDescription());
|
||||
}
|
||||
|
||||
// add it to the array
|
||||
PropertyDefinition propDef = setupPropertyDefObject(ddPropDef);
|
||||
propDefs[pos] = propDef;
|
||||
pos++;
|
||||
}
|
||||
@@ -642,8 +624,6 @@ public class Utils
|
||||
classDef.setProperties(propDefs);
|
||||
}
|
||||
|
||||
// TODO need to get the child associations as well !!
|
||||
|
||||
// represent the associations
|
||||
Map<QName, org.alfresco.service.cmr.dictionary.AssociationDefinition> assocs = ddClassDef.getAssociations();
|
||||
if (assocs != null)
|
||||
@@ -652,35 +632,7 @@ public class Utils
|
||||
int pos = 0;
|
||||
for (org.alfresco.service.cmr.dictionary.AssociationDefinition ddAssocDef : assocs.values())
|
||||
{
|
||||
AssociationDefinition assocDef = new AssociationDefinition();
|
||||
assocDef.setName(ddAssocDef.getName().toString());
|
||||
assocDef.setIsChild(ddAssocDef.isChild());
|
||||
if (ddAssocDef.getTitle() != null)
|
||||
{
|
||||
assocDef.setTitle(ddAssocDef.getTitle());
|
||||
}
|
||||
if (ddAssocDef.getDescription() != null)
|
||||
{
|
||||
assocDef.setDescription(ddAssocDef.getDescription());
|
||||
}
|
||||
|
||||
RoleDefinition sourceRole = new RoleDefinition();
|
||||
if (ddAssocDef.getSourceRoleName() != null)
|
||||
{
|
||||
sourceRole.setName(ddAssocDef.getSourceRoleName().toString());
|
||||
}
|
||||
sourceRole.setCardinality(setupSourceCardinalityObject(ddAssocDef));
|
||||
assocDef.setSourceRole(sourceRole);
|
||||
|
||||
RoleDefinition targetRole = new RoleDefinition();
|
||||
if (ddAssocDef.getTargetRoleName() != null)
|
||||
{
|
||||
targetRole.setName(ddAssocDef.getTargetRoleName().toString());
|
||||
}
|
||||
targetRole.setCardinality(setupTargetCardinalityObject(ddAssocDef));;
|
||||
assocDef.setTargetRole(targetRole);
|
||||
assocDef.setTargetClass(ddAssocDef.getTargetClass().getName().toString());
|
||||
|
||||
AssociationDefinition assocDef = setupAssociationDefObject(ddAssocDef);
|
||||
assocDefs[pos] = assocDef;
|
||||
pos++;
|
||||
}
|
||||
@@ -691,6 +643,76 @@ public class Utils
|
||||
return classDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a PropertyDefinition web service type object for the given
|
||||
* repository PropertyDefinition
|
||||
*
|
||||
* @param ddPropertyDef The repository PropertyDefinition to generate
|
||||
* @return The web service PropertyDefinition representation
|
||||
*/
|
||||
public static PropertyDefinition setupPropertyDefObject(org.alfresco.service.cmr.dictionary.PropertyDefinition ddPropDef)
|
||||
{
|
||||
PropertyDefinition propDef = new PropertyDefinition();
|
||||
propDef.setName(ddPropDef.getName().toString());
|
||||
propDef.setDataType(ddPropDef.getDataType().getName().toString());
|
||||
propDef.setMandatory(ddPropDef.isMandatory());
|
||||
propDef.setReadOnly(ddPropDef.isProtected());
|
||||
if (ddPropDef.getDefaultValue() != null)
|
||||
{
|
||||
propDef.setDefaultValue(ddPropDef.getDefaultValue());
|
||||
}
|
||||
if (ddPropDef.getTitle() != null)
|
||||
{
|
||||
propDef.setTitle(ddPropDef.getTitle());
|
||||
}
|
||||
if (ddPropDef.getDescription() != null)
|
||||
{
|
||||
propDef.setDescription(ddPropDef.getDescription());
|
||||
}
|
||||
return propDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AssociationDefinition web service type object for the given
|
||||
* repository AssociationDefinition
|
||||
*
|
||||
* @param ddAssociationDef The repository AssociationDefinition to generate
|
||||
* @return The web service AssociationDefinition representation
|
||||
*/
|
||||
public static AssociationDefinition setupAssociationDefObject(org.alfresco.service.cmr.dictionary.AssociationDefinition ddAssocDef)
|
||||
{
|
||||
AssociationDefinition assocDef = new AssociationDefinition();
|
||||
assocDef.setName(ddAssocDef.getName().toString());
|
||||
assocDef.setIsChild(ddAssocDef.isChild());
|
||||
if (ddAssocDef.getTitle() != null)
|
||||
{
|
||||
assocDef.setTitle(ddAssocDef.getTitle());
|
||||
}
|
||||
if (ddAssocDef.getDescription() != null)
|
||||
{
|
||||
assocDef.setDescription(ddAssocDef.getDescription());
|
||||
}
|
||||
|
||||
RoleDefinition sourceRole = new RoleDefinition();
|
||||
if (ddAssocDef.getSourceRoleName() != null)
|
||||
{
|
||||
sourceRole.setName(ddAssocDef.getSourceRoleName().toString());
|
||||
}
|
||||
sourceRole.setCardinality(setupSourceCardinalityObject(ddAssocDef));
|
||||
assocDef.setSourceRole(sourceRole);
|
||||
|
||||
RoleDefinition targetRole = new RoleDefinition();
|
||||
if (ddAssocDef.getTargetRoleName() != null)
|
||||
{
|
||||
targetRole.setName(ddAssocDef.getTargetRoleName().toString());
|
||||
}
|
||||
targetRole.setCardinality(setupTargetCardinalityObject(ddAssocDef));;
|
||||
assocDef.setTargetRole(targetRole);
|
||||
assocDef.setTargetClass(ddAssocDef.getTargetClass().getName().toString());
|
||||
|
||||
return assocDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a web service Cardinality type for the source from the given repository AssociationDefinition
|
||||
*
|
||||
|
@@ -23,12 +23,16 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.webservice.AbstractWebService;
|
||||
import org.alfresco.repo.webservice.Utils;
|
||||
import org.alfresco.repo.webservice.dictionary.ClassPredicate;
|
||||
import org.alfresco.repo.webservice.dictionary.DictionaryFault;
|
||||
import org.alfresco.repo.webservice.dictionary.DictionaryServiceSoapPort;
|
||||
import org.alfresco.repo.webservice.types.AssociationDefinition;
|
||||
import org.alfresco.repo.webservice.types.ClassDefinition;
|
||||
import org.alfresco.repo.webservice.types.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.InvalidClassException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
@@ -102,6 +106,99 @@ public class DictionaryWebService extends AbstractWebService implements Dictiona
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.webservice.dictionary.DictionaryServiceSoapPort#getProperties(java.lang.String[])
|
||||
*/
|
||||
public PropertyDefinition[] getProperties(String[] propertyNames) throws RemoteException, DictionaryFault
|
||||
{
|
||||
try
|
||||
{
|
||||
PropertyDefinition[] propDefs = new PropertyDefinition[propertyNames.length];
|
||||
|
||||
int i = 0;
|
||||
for (String propertyName : propertyNames)
|
||||
{
|
||||
QName propertyQName = QName.createQName(propertyName, namespaceService);
|
||||
org.alfresco.service.cmr.dictionary.PropertyDefinition ddPropDef = dictionaryService.getProperty(propertyQName);
|
||||
if (ddPropDef == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property propertyName does not exist.");
|
||||
}
|
||||
propDefs[i++] = Utils.setupPropertyDefObject(ddPropDef);
|
||||
}
|
||||
|
||||
return propDefs;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.error("Unexpected error occurred", e);
|
||||
}
|
||||
throw new DictionaryFault(0, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.webservice.dictionary.DictionaryServiceSoapPort#getAssociations(java.lang.String[])
|
||||
*/
|
||||
public AssociationDefinition[] getAssociations(String[] associationNames) throws RemoteException, DictionaryFault
|
||||
{
|
||||
try
|
||||
{
|
||||
AssociationDefinition[] assocDefs = new AssociationDefinition[associationNames.length];
|
||||
|
||||
int i = 0;
|
||||
for (String associationName : associationNames)
|
||||
{
|
||||
QName associationQName = QName.createQName(associationName, namespaceService);
|
||||
org.alfresco.service.cmr.dictionary.AssociationDefinition ddAssocDef = dictionaryService.getAssociation(associationQName);
|
||||
if (ddAssocDef == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property propertyName does not exist.");
|
||||
}
|
||||
assocDefs[i++] = Utils.setupAssociationDefObject(ddAssocDef);
|
||||
}
|
||||
|
||||
return assocDefs;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.error("Unexpected error occurred", e);
|
||||
}
|
||||
throw new DictionaryFault(0, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.webservice.dictionary.DictionaryServiceSoapPort#isSubClass(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public boolean isSubClass(String className, String isSubClassOfName) throws RemoteException, DictionaryFault
|
||||
{
|
||||
try
|
||||
{
|
||||
QName classQName = QName.createQName(className, namespaceService);
|
||||
QName isSubClassOfQName = QName.createQName(isSubClassOfName, namespaceService);
|
||||
return dictionaryService.isSubClass(classQName, isSubClassOfQName);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.error("Unexpected error occurred", e);
|
||||
}
|
||||
throw new DictionaryFault(0, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve class definitions that match the provided class predicate
|
||||
*
|
||||
@@ -211,5 +308,5 @@ public class DictionaryWebService extends AbstractWebService implements Dictiona
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user