mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,44 +1,44 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/*
|
||||
* Webscript to get the Associationdefinition for a given classname and association-name
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class AssociationGet extends AbstractAssociationGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
private static final String DICTIONARY_ASSOCIATION_NAME = "assocname";
|
||||
|
||||
@Override
|
||||
protected QName getAssociationQname(WebScriptRequest req)
|
||||
{
|
||||
String associationName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_ASSOCIATION_NAME);
|
||||
if(associationName == null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter association name in the URL");
|
||||
}
|
||||
|
||||
return QName.createQName(getFullNamespaceURI(associationName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getClassQname(WebScriptRequest req)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
// validate the classname
|
||||
if (isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/*
|
||||
* Webscript to get the Associationdefinition for a given classname and association-name
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class AssociationGet extends AbstractAssociationGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
private static final String DICTIONARY_ASSOCIATION_NAME = "assocname";
|
||||
|
||||
@Override
|
||||
protected QName getAssociationQname(WebScriptRequest req)
|
||||
{
|
||||
String associationName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_ASSOCIATION_NAME);
|
||||
if(associationName == null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter association name in the URL");
|
||||
}
|
||||
|
||||
return QName.createQName(getFullNamespaceURI(associationName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getClassQname(WebScriptRequest req)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
// validate the classname
|
||||
if (isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
}
|
@@ -1,35 +1,35 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Associationdefinitions for a given classname
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class AssociationsGet extends AbstractAssociationsGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
|
||||
@Override
|
||||
protected QName getClassQname(WebScriptRequest req)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
//validate classname
|
||||
if (isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getAssociationQname(String namespacePrefix, String name)
|
||||
{
|
||||
return QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
}
|
||||
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Associationdefinitions for a given classname
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class AssociationsGet extends AbstractAssociationsGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
|
||||
@Override
|
||||
protected QName getClassQname(WebScriptRequest req)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
//validate classname
|
||||
if (isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getAssociationQname(String namespacePrefix, String name)
|
||||
{
|
||||
return QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
}
|
||||
|
||||
}
|
@@ -1,32 +1,32 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Classdefinitions for a classname eg. =>cm_author
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class ClassGet extends AbstractClassGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "className";
|
||||
|
||||
/**
|
||||
* Override method from AbstractClassGet
|
||||
*/
|
||||
@Override
|
||||
protected QName getClassQname(WebScriptRequest req)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
//validate the classname and throw appropriate error message
|
||||
if (isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Classdefinitions for a classname eg. =>cm_author
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class ClassGet extends AbstractClassGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "className";
|
||||
|
||||
/**
|
||||
* Override method from AbstractClassGet
|
||||
*/
|
||||
@Override
|
||||
protected QName getClassQname(WebScriptRequest req)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
//validate the classname and throw appropriate error message
|
||||
if (isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
}
|
@@ -1,32 +1,32 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
/**
|
||||
* Webscript to get the Classdefinitions using classfilter , namespaceprefix and name
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class ClassesGet extends AbstractClassesGet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected QName getQNameForModel(String namespacePrefix, String name)
|
||||
{
|
||||
return QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getClassQname(String namespacePrefix, String name)
|
||||
{
|
||||
String className = namespacePrefix + "_" + name;
|
||||
if(isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + "parameter in the URL");
|
||||
}
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
/**
|
||||
* Webscript to get the Classdefinitions using classfilter , namespaceprefix and name
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class ClassesGet extends AbstractClassesGet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected QName getQNameForModel(String namespacePrefix, String name)
|
||||
{
|
||||
return QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getClassQname(String namespacePrefix, String name)
|
||||
{
|
||||
String className = namespacePrefix + "_" + name;
|
||||
if(isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + "parameter in the URL");
|
||||
}
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
}
|
@@ -1,109 +1,109 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* WebScript implementation to retrieve a complete dictionary required to implement
|
||||
* a lightweight remote web-tier dictionary.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class DictionaryGet extends DictionaryWebServiceBase
|
||||
{
|
||||
private static final String MODEL_CLASS_DEFS = "classdefs";
|
||||
private static final String MODEL_PROPERTY_DEFS = "propertydefs";
|
||||
private static final String MODEL_ASSOCIATION_DEFS = "assocdefs";
|
||||
|
||||
/** Set of model namespaces to ignore when outputing dictionary classes and aspects */
|
||||
private Set<String> ignoreNamespaces = Collections.<String>emptySet();
|
||||
|
||||
/**
|
||||
* Set of model namespaces to ignore when outputing dictionary classes and aspects
|
||||
*
|
||||
* @param namespaces Set of model namespaces to ignore
|
||||
*/
|
||||
public void setIgnoreNamespaces(Set<String> namespaces)
|
||||
{
|
||||
this.ignoreNamespaces = namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the webscript
|
||||
*
|
||||
* @param req WebScriptRequest
|
||||
* @param status Status
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
{
|
||||
List<QName> qnames = new ArrayList<QName>(256);
|
||||
Set<String> namespaces = new HashSet<String>();
|
||||
Map<QName, ClassDefinition> classdef = new HashMap<QName, ClassDefinition>();
|
||||
Map<QName, Collection<PropertyDefinition>> propdef = new HashMap<QName, Collection<PropertyDefinition>>();
|
||||
Map<QName, Collection<AssociationDefinition>> assocdef = new HashMap<QName, Collection<AssociationDefinition>>();
|
||||
|
||||
// check configured list of model namespaces to ignore when retrieving all models
|
||||
for (String ns : this.namespaceService.getURIs())
|
||||
{
|
||||
if (!ignoreNamespaces.contains(ns))
|
||||
{
|
||||
namespaces.add(ns);
|
||||
}
|
||||
}
|
||||
// specific model qname provided or will process all available models
|
||||
String strModel = req.getParameter("model");
|
||||
if (strModel != null && strModel.length() != 0)
|
||||
{
|
||||
// handle full QName and prefixed shortname of a model
|
||||
QName modelQName = (strModel.charAt(0) == QName.NAMESPACE_BEGIN ? QName.createQName(strModel) : QName.createQName(strModel, this.namespaceService));
|
||||
ModelDefinition modelDef = this.dictionaryservice.getModel(modelQName);
|
||||
if (modelDef != null)
|
||||
{
|
||||
qnames.addAll(this.dictionaryservice.getAspects(modelQName));
|
||||
qnames.addAll(this.dictionaryservice.getTypes(modelQName));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// walk all models and extract the aspects and types
|
||||
for (QName qname : this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if (namespaces.contains(qname.getNamespaceURI()))
|
||||
{
|
||||
qnames.addAll(this.dictionaryservice.getAspects(qname));
|
||||
qnames.addAll(this.dictionaryservice.getTypes(qname));
|
||||
}
|
||||
}
|
||||
}
|
||||
// get the class definitions and the properties and associations
|
||||
for (QName qname : qnames)
|
||||
{
|
||||
ClassDefinition classDef = this.dictionaryservice.getClass(qname);
|
||||
classdef.put(qname, classDef);
|
||||
propdef.put(qname, classDef.getProperties().values());
|
||||
assocdef.put(qname, classDef.getAssociations().values());
|
||||
}
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(MODEL_CLASS_DEFS, classdef.values());
|
||||
model.put(MODEL_PROPERTY_DEFS, propdef.values());
|
||||
model.put(MODEL_ASSOCIATION_DEFS, assocdef.values());
|
||||
model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ModelDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* WebScript implementation to retrieve a complete dictionary required to implement
|
||||
* a lightweight remote web-tier dictionary.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class DictionaryGet extends DictionaryWebServiceBase
|
||||
{
|
||||
private static final String MODEL_CLASS_DEFS = "classdefs";
|
||||
private static final String MODEL_PROPERTY_DEFS = "propertydefs";
|
||||
private static final String MODEL_ASSOCIATION_DEFS = "assocdefs";
|
||||
|
||||
/** Set of model namespaces to ignore when outputing dictionary classes and aspects */
|
||||
private Set<String> ignoreNamespaces = Collections.<String>emptySet();
|
||||
|
||||
/**
|
||||
* Set of model namespaces to ignore when outputing dictionary classes and aspects
|
||||
*
|
||||
* @param namespaces Set of model namespaces to ignore
|
||||
*/
|
||||
public void setIgnoreNamespaces(Set<String> namespaces)
|
||||
{
|
||||
this.ignoreNamespaces = namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the webscript
|
||||
*
|
||||
* @param req WebScriptRequest
|
||||
* @param status Status
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
{
|
||||
List<QName> qnames = new ArrayList<QName>(256);
|
||||
Set<String> namespaces = new HashSet<String>();
|
||||
Map<QName, ClassDefinition> classdef = new HashMap<QName, ClassDefinition>();
|
||||
Map<QName, Collection<PropertyDefinition>> propdef = new HashMap<QName, Collection<PropertyDefinition>>();
|
||||
Map<QName, Collection<AssociationDefinition>> assocdef = new HashMap<QName, Collection<AssociationDefinition>>();
|
||||
|
||||
// check configured list of model namespaces to ignore when retrieving all models
|
||||
for (String ns : this.namespaceService.getURIs())
|
||||
{
|
||||
if (!ignoreNamespaces.contains(ns))
|
||||
{
|
||||
namespaces.add(ns);
|
||||
}
|
||||
}
|
||||
// specific model qname provided or will process all available models
|
||||
String strModel = req.getParameter("model");
|
||||
if (strModel != null && strModel.length() != 0)
|
||||
{
|
||||
// handle full QName and prefixed shortname of a model
|
||||
QName modelQName = (strModel.charAt(0) == QName.NAMESPACE_BEGIN ? QName.createQName(strModel) : QName.createQName(strModel, this.namespaceService));
|
||||
ModelDefinition modelDef = this.dictionaryservice.getModel(modelQName);
|
||||
if (modelDef != null)
|
||||
{
|
||||
qnames.addAll(this.dictionaryservice.getAspects(modelQName));
|
||||
qnames.addAll(this.dictionaryservice.getTypes(modelQName));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// walk all models and extract the aspects and types
|
||||
for (QName qname : this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if (namespaces.contains(qname.getNamespaceURI()))
|
||||
{
|
||||
qnames.addAll(this.dictionaryservice.getAspects(qname));
|
||||
qnames.addAll(this.dictionaryservice.getTypes(qname));
|
||||
}
|
||||
}
|
||||
}
|
||||
// get the class definitions and the properties and associations
|
||||
for (QName qname : qnames)
|
||||
{
|
||||
ClassDefinition classDef = this.dictionaryservice.getClass(qname);
|
||||
classdef.put(qname, classDef);
|
||||
propdef.put(qname, classDef.getProperties().values());
|
||||
assocdef.put(qname, classDef.getAssociations().values());
|
||||
}
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(MODEL_CLASS_DEFS, classdef.values());
|
||||
model.put(MODEL_PROPERTY_DEFS, propdef.values());
|
||||
model.put(MODEL_ASSOCIATION_DEFS, assocdef.values());
|
||||
model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
@@ -1,357 +1,357 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.InvalidQNameException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
/**
|
||||
* Base class for Dictionary web scripts
|
||||
*
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
{
|
||||
private static final String NAME_DELIMITER = "_";
|
||||
protected static final String MODEL_PROP_KEY_MESSAGE_LOOKUP = "messages";
|
||||
|
||||
/** Namespace service */
|
||||
protected NamespaceService namespaceService;
|
||||
|
||||
/** Dictionary service */
|
||||
protected DictionaryService dictionaryservice;
|
||||
|
||||
private static final String CLASS_FILTER_OPTION_TYPE1 = "all";
|
||||
private static final String CLASS_FILTER_OPTION_TYPE2 = "aspect";
|
||||
private static final String CLASS_FILTER_OPTION_TYPE3 = "type";
|
||||
|
||||
private static final String ASSOCIATION_FILTER_OPTION_TYPE1 = "all";
|
||||
private static final String ASSOCIATION_FILTER_OPTION_TYPE2 = "general";
|
||||
private static final String ASSOCIATION_FILTER_OPTION_TYPE3 = "child";
|
||||
|
||||
|
||||
/**
|
||||
* Set the namespaceService property.
|
||||
*
|
||||
* @param namespaceservice The namespace service instance to set
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceservice)
|
||||
{
|
||||
this.namespaceService = namespaceservice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
protected QName createClassQName(String className)
|
||||
{
|
||||
QName result = null;
|
||||
int index = className.indexOf(NAME_DELIMITER);
|
||||
if (index > 0)
|
||||
{
|
||||
String prefix = className.substring(0, index);
|
||||
String shortName = className.substring(index+1);
|
||||
String url = namespaceService.getNamespaceURI(prefix);
|
||||
if (url != null && url.length() != 0 &&
|
||||
shortName != null && shortName.length() != 0)
|
||||
{
|
||||
QName classQName = QName.createQName(url, shortName);
|
||||
if (dictionaryservice.getClass(classQName) != null)
|
||||
{
|
||||
result = classQName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prefix - prefix for class name
|
||||
* @param shortName - short class name
|
||||
* @return qualified name for class name
|
||||
*/
|
||||
protected QName createClassQName(String prefix, String shortName)
|
||||
{
|
||||
QName result = null;
|
||||
String url = namespaceService.getNamespaceURI(prefix);
|
||||
if (url != null && url.length() != 0 && shortName != null && shortName.length() != 0)
|
||||
{
|
||||
QName classQName = QName.createQName(url, shortName);
|
||||
if (dictionaryservice.getClass(classQName) != null)
|
||||
{
|
||||
result = classQName;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param qname QName
|
||||
* @return the namespaceuri from a qname
|
||||
*/
|
||||
public String getNamespaceURIfromQname(QName qname)
|
||||
{
|
||||
return qname.getNamespaceURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname the class name as cm_person
|
||||
* @return String the full name in the following format {namespaceuri}shorname
|
||||
*/
|
||||
public String getFullNamespaceURI(String classname)
|
||||
{
|
||||
try
|
||||
{
|
||||
String result = null;
|
||||
String prefix = this.getPrefix(classname);
|
||||
String url = this.namespaceService.getNamespaceURI(prefix);
|
||||
String name = this.getShortName(classname);
|
||||
result = "{" + url + "}"+ name;
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact classname - " + classname + " parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prefix prefix for classname as cm
|
||||
* @param shorname the short class name as person
|
||||
* @return String the full name in the following format {namespaceuri}shorname
|
||||
*/
|
||||
public String getFullNamespaceURI(String prefix, String shorname)
|
||||
{
|
||||
try
|
||||
{
|
||||
String result = null;
|
||||
String url = this.namespaceService.getNamespaceURI(prefix);
|
||||
result = "{" + url + "}" + shorname;
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact classname - " + prefix + ":" + shorname + " parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname - checks whether the classname is valid , gets the classname as input e.g cm_person
|
||||
* @return true - if the class is valid , false - if the class is invalid
|
||||
*/
|
||||
public boolean isValidClassname(String classname)
|
||||
{
|
||||
QName qname = null;
|
||||
try
|
||||
{
|
||||
qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||
return (dictionaryservice.getClass(qname) != null);
|
||||
}
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
//just ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the classname is valid
|
||||
* @param prefix - gets the prefix as input e.g cm
|
||||
* @param shorname - gets the short classname as input e.g person
|
||||
* @return true - if the class is valid , false - if the class is invalid
|
||||
*/
|
||||
public boolean isValidClassname(String prefix, String shorname)
|
||||
{
|
||||
QName qname = null;
|
||||
try
|
||||
{
|
||||
qname = QName.createQName(this.getFullNamespaceURI(prefix, shorname));
|
||||
return (dictionaryservice.getClass(qname) != null);
|
||||
}
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
//just ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelname String
|
||||
* @return modelname from namespaceprefix - returns null if invalid namespaceprefix is given
|
||||
*/
|
||||
public String getPrefixFromModelName(String modelname)
|
||||
{
|
||||
String namespaceprefix = null;
|
||||
for(QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if(qnameObj.getLocalName().equals(modelname))
|
||||
{
|
||||
Collection<String> prefixes = this.namespaceService.getPrefixes(qnameObj.getNamespaceURI());
|
||||
if (!prefixes.isEmpty())
|
||||
{
|
||||
namespaceprefix = prefixes.iterator().next();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return namespaceprefix;
|
||||
}
|
||||
|
||||
public boolean isValidAssociationFilter(String af)
|
||||
{
|
||||
return (af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE1) ||
|
||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE2) ||
|
||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname as the input
|
||||
* @return true if it is a aspect or false if it is a Type
|
||||
*/
|
||||
public boolean isValidTypeorAspect(String classname)
|
||||
{
|
||||
try
|
||||
{
|
||||
QName qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||
return ((this.dictionaryservice.getClass(qname) != null) &&
|
||||
(this.dictionaryservice.getClass(qname).isAspect()));
|
||||
}
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prefix as the input
|
||||
* @param shorname as the input
|
||||
* @return true if it is a aspect or false if it is a Type
|
||||
*/
|
||||
public boolean isValidTypeorAspect(String prefix, String shorname)
|
||||
{
|
||||
try
|
||||
{
|
||||
QName qname = QName.createQName(this.getFullNamespaceURI(prefix, shorname));
|
||||
return ((this.dictionaryservice.getClass(qname) != null) &&
|
||||
(this.dictionaryservice.getClass(qname).isAspect()));
|
||||
}
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelname - gets the modelname as the input (modelname is without prefix ie. cm:contentmodel => where modelname = contentmodel)
|
||||
* @return true if valid or false
|
||||
*/
|
||||
public boolean isValidModelName(String modelname)
|
||||
{
|
||||
boolean value = false;
|
||||
for (QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if (qnameObj.getLocalName().equalsIgnoreCase(modelname))
|
||||
{
|
||||
value = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname - returns the prefix from the classname of the format namespaceprefix:name eg. cm_person
|
||||
* @return prefix - returns the prefix of the classname
|
||||
*/
|
||||
public String getPrefix(String classname)
|
||||
{
|
||||
String prefix = null;
|
||||
int index = classname.indexOf(NAME_DELIMITER);
|
||||
if (index > 0)
|
||||
{
|
||||
prefix = classname.substring(0, index);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname String
|
||||
* @return the shortname from the classname of the format cm_person
|
||||
* here person represents the shortname
|
||||
*/
|
||||
public String getShortName(String classname)
|
||||
{
|
||||
String shortname = null;
|
||||
int index = classname.indexOf(NAME_DELIMITER);
|
||||
if (index > 0)
|
||||
{
|
||||
shortname = classname.substring(index+1);
|
||||
}
|
||||
return shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param input -gets a string input and validates it
|
||||
* @return null if invalid or the string itself if its valid
|
||||
*/
|
||||
public String getValidInput(String input)
|
||||
{
|
||||
if ((input != null) && (input.length() != 0))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classfilter =>valid class filters are all,apect or type
|
||||
* @return true if valid or false if invalid
|
||||
*/
|
||||
public boolean isValidClassFilter(String classfilter)
|
||||
{
|
||||
return (classfilter.equals(CLASS_FILTER_OPTION_TYPE1) ||
|
||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE2) ||
|
||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns dependent collections (properties or associations)
|
||||
* in order that complies to order of class definitions
|
||||
* @param sortedClassDefs - list of sorted class definitions
|
||||
* @param dependent - collections that depend on class definitions
|
||||
* @return collection of dependent values
|
||||
*/
|
||||
protected <T> Collection<T> reorderedValues(List<ClassDefinition> sortedClassDefs, Map<QName, T> dependent)
|
||||
{
|
||||
Collection<T> result = new ArrayList<T>(sortedClassDefs.size());
|
||||
for (ClassDefinition classDef : sortedClassDefs)
|
||||
{
|
||||
result.add(dependent.get(classDef.getName()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.InvalidQNameException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
/**
|
||||
* Base class for Dictionary web scripts
|
||||
*
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
{
|
||||
private static final String NAME_DELIMITER = "_";
|
||||
protected static final String MODEL_PROP_KEY_MESSAGE_LOOKUP = "messages";
|
||||
|
||||
/** Namespace service */
|
||||
protected NamespaceService namespaceService;
|
||||
|
||||
/** Dictionary service */
|
||||
protected DictionaryService dictionaryservice;
|
||||
|
||||
private static final String CLASS_FILTER_OPTION_TYPE1 = "all";
|
||||
private static final String CLASS_FILTER_OPTION_TYPE2 = "aspect";
|
||||
private static final String CLASS_FILTER_OPTION_TYPE3 = "type";
|
||||
|
||||
private static final String ASSOCIATION_FILTER_OPTION_TYPE1 = "all";
|
||||
private static final String ASSOCIATION_FILTER_OPTION_TYPE2 = "general";
|
||||
private static final String ASSOCIATION_FILTER_OPTION_TYPE3 = "child";
|
||||
|
||||
|
||||
/**
|
||||
* Set the namespaceService property.
|
||||
*
|
||||
* @param namespaceservice The namespace service instance to set
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceservice)
|
||||
{
|
||||
this.namespaceService = namespaceservice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
protected QName createClassQName(String className)
|
||||
{
|
||||
QName result = null;
|
||||
int index = className.indexOf(NAME_DELIMITER);
|
||||
if (index > 0)
|
||||
{
|
||||
String prefix = className.substring(0, index);
|
||||
String shortName = className.substring(index+1);
|
||||
String url = namespaceService.getNamespaceURI(prefix);
|
||||
if (url != null && url.length() != 0 &&
|
||||
shortName != null && shortName.length() != 0)
|
||||
{
|
||||
QName classQName = QName.createQName(url, shortName);
|
||||
if (dictionaryservice.getClass(classQName) != null)
|
||||
{
|
||||
result = classQName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prefix - prefix for class name
|
||||
* @param shortName - short class name
|
||||
* @return qualified name for class name
|
||||
*/
|
||||
protected QName createClassQName(String prefix, String shortName)
|
||||
{
|
||||
QName result = null;
|
||||
String url = namespaceService.getNamespaceURI(prefix);
|
||||
if (url != null && url.length() != 0 && shortName != null && shortName.length() != 0)
|
||||
{
|
||||
QName classQName = QName.createQName(url, shortName);
|
||||
if (dictionaryservice.getClass(classQName) != null)
|
||||
{
|
||||
result = classQName;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param qname QName
|
||||
* @return the namespaceuri from a qname
|
||||
*/
|
||||
public String getNamespaceURIfromQname(QName qname)
|
||||
{
|
||||
return qname.getNamespaceURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname the class name as cm_person
|
||||
* @return String the full name in the following format {namespaceuri}shorname
|
||||
*/
|
||||
public String getFullNamespaceURI(String classname)
|
||||
{
|
||||
try
|
||||
{
|
||||
String result = null;
|
||||
String prefix = this.getPrefix(classname);
|
||||
String url = this.namespaceService.getNamespaceURI(prefix);
|
||||
String name = this.getShortName(classname);
|
||||
result = "{" + url + "}"+ name;
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact classname - " + classname + " parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prefix prefix for classname as cm
|
||||
* @param shorname the short class name as person
|
||||
* @return String the full name in the following format {namespaceuri}shorname
|
||||
*/
|
||||
public String getFullNamespaceURI(String prefix, String shorname)
|
||||
{
|
||||
try
|
||||
{
|
||||
String result = null;
|
||||
String url = this.namespaceService.getNamespaceURI(prefix);
|
||||
result = "{" + url + "}" + shorname;
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact classname - " + prefix + ":" + shorname + " parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname - checks whether the classname is valid , gets the classname as input e.g cm_person
|
||||
* @return true - if the class is valid , false - if the class is invalid
|
||||
*/
|
||||
public boolean isValidClassname(String classname)
|
||||
{
|
||||
QName qname = null;
|
||||
try
|
||||
{
|
||||
qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||
return (dictionaryservice.getClass(qname) != null);
|
||||
}
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
//just ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the classname is valid
|
||||
* @param prefix - gets the prefix as input e.g cm
|
||||
* @param shorname - gets the short classname as input e.g person
|
||||
* @return true - if the class is valid , false - if the class is invalid
|
||||
*/
|
||||
public boolean isValidClassname(String prefix, String shorname)
|
||||
{
|
||||
QName qname = null;
|
||||
try
|
||||
{
|
||||
qname = QName.createQName(this.getFullNamespaceURI(prefix, shorname));
|
||||
return (dictionaryservice.getClass(qname) != null);
|
||||
}
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
//just ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelname String
|
||||
* @return modelname from namespaceprefix - returns null if invalid namespaceprefix is given
|
||||
*/
|
||||
public String getPrefixFromModelName(String modelname)
|
||||
{
|
||||
String namespaceprefix = null;
|
||||
for(QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if(qnameObj.getLocalName().equals(modelname))
|
||||
{
|
||||
Collection<String> prefixes = this.namespaceService.getPrefixes(qnameObj.getNamespaceURI());
|
||||
if (!prefixes.isEmpty())
|
||||
{
|
||||
namespaceprefix = prefixes.iterator().next();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return namespaceprefix;
|
||||
}
|
||||
|
||||
public boolean isValidAssociationFilter(String af)
|
||||
{
|
||||
return (af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE1) ||
|
||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE2) ||
|
||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname as the input
|
||||
* @return true if it is a aspect or false if it is a Type
|
||||
*/
|
||||
public boolean isValidTypeorAspect(String classname)
|
||||
{
|
||||
try
|
||||
{
|
||||
QName qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||
return ((this.dictionaryservice.getClass(qname) != null) &&
|
||||
(this.dictionaryservice.getClass(qname).isAspect()));
|
||||
}
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prefix as the input
|
||||
* @param shorname as the input
|
||||
* @return true if it is a aspect or false if it is a Type
|
||||
*/
|
||||
public boolean isValidTypeorAspect(String prefix, String shorname)
|
||||
{
|
||||
try
|
||||
{
|
||||
QName qname = QName.createQName(this.getFullNamespaceURI(prefix, shorname));
|
||||
return ((this.dictionaryservice.getClass(qname) != null) &&
|
||||
(this.dictionaryservice.getClass(qname).isAspect()));
|
||||
}
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelname - gets the modelname as the input (modelname is without prefix ie. cm:contentmodel => where modelname = contentmodel)
|
||||
* @return true if valid or false
|
||||
*/
|
||||
public boolean isValidModelName(String modelname)
|
||||
{
|
||||
boolean value = false;
|
||||
for (QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if (qnameObj.getLocalName().equalsIgnoreCase(modelname))
|
||||
{
|
||||
value = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname - returns the prefix from the classname of the format namespaceprefix:name eg. cm_person
|
||||
* @return prefix - returns the prefix of the classname
|
||||
*/
|
||||
public String getPrefix(String classname)
|
||||
{
|
||||
String prefix = null;
|
||||
int index = classname.indexOf(NAME_DELIMITER);
|
||||
if (index > 0)
|
||||
{
|
||||
prefix = classname.substring(0, index);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classname String
|
||||
* @return the shortname from the classname of the format cm_person
|
||||
* here person represents the shortname
|
||||
*/
|
||||
public String getShortName(String classname)
|
||||
{
|
||||
String shortname = null;
|
||||
int index = classname.indexOf(NAME_DELIMITER);
|
||||
if (index > 0)
|
||||
{
|
||||
shortname = classname.substring(index+1);
|
||||
}
|
||||
return shortname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param input -gets a string input and validates it
|
||||
* @return null if invalid or the string itself if its valid
|
||||
*/
|
||||
public String getValidInput(String input)
|
||||
{
|
||||
if ((input != null) && (input.length() != 0))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classfilter =>valid class filters are all,apect or type
|
||||
* @return true if valid or false if invalid
|
||||
*/
|
||||
public boolean isValidClassFilter(String classfilter)
|
||||
{
|
||||
return (classfilter.equals(CLASS_FILTER_OPTION_TYPE1) ||
|
||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE2) ||
|
||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns dependent collections (properties or associations)
|
||||
* in order that complies to order of class definitions
|
||||
* @param sortedClassDefs - list of sorted class definitions
|
||||
* @param dependent - collections that depend on class definitions
|
||||
* @return collection of dependent values
|
||||
*/
|
||||
protected <T> Collection<T> reorderedValues(List<ClassDefinition> sortedClassDefs, Map<QName, T> dependent)
|
||||
{
|
||||
Collection<T> result = new ArrayList<T>(sortedClassDefs.size());
|
||||
for (ClassDefinition classDef : sortedClassDefs)
|
||||
{
|
||||
result.add(dependent.get(classDef.getName()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,35 +1,35 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Propertydefinitions for a given classname eg. =>cm_person
|
||||
*
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class PropertiesGet extends AbstractPropertiesGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
|
||||
@Override
|
||||
protected QName getClassQName(WebScriptRequest req)
|
||||
{
|
||||
QName classQName = null;
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
if (className != null && className.length() != 0)
|
||||
{
|
||||
classQName = createClassQName(className);
|
||||
if (classQName == null)
|
||||
{
|
||||
// Error
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL");
|
||||
}
|
||||
}
|
||||
return classQName;
|
||||
}
|
||||
|
||||
}
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Propertydefinitions for a given classname eg. =>cm_person
|
||||
*
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class PropertiesGet extends AbstractPropertiesGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
|
||||
@Override
|
||||
protected QName getClassQName(WebScriptRequest req)
|
||||
{
|
||||
QName classQName = null;
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
if (className != null && className.length() != 0)
|
||||
{
|
||||
classQName = createClassQName(className);
|
||||
if (classQName == null)
|
||||
{
|
||||
// Error
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL");
|
||||
}
|
||||
}
|
||||
return classQName;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,46 +1,46 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Propertydefinition for a given classname and propname
|
||||
*
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class PropertyGet extends AbstractPropertyGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
private static final String DICTIONARY_PROPERTY_NAME = "propname";
|
||||
|
||||
@Override
|
||||
protected QName getPropertyQname(WebScriptRequest req)
|
||||
{
|
||||
String propertyName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PROPERTY_NAME);
|
||||
//validate the presence of property name
|
||||
if(propertyName == null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter propertyname in the URL");
|
||||
}
|
||||
|
||||
return QName.createQName(getFullNamespaceURI(propertyName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getClassQname(WebScriptRequest req)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
// validate the classname
|
||||
if (isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Propertydefinition for a given classname and propname
|
||||
*
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class PropertyGet extends AbstractPropertyGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
private static final String DICTIONARY_PROPERTY_NAME = "propname";
|
||||
|
||||
@Override
|
||||
protected QName getPropertyQname(WebScriptRequest req)
|
||||
{
|
||||
String propertyName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PROPERTY_NAME);
|
||||
//validate the presence of property name
|
||||
if(propertyName == null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter propertyname in the URL");
|
||||
}
|
||||
|
||||
return QName.createQName(getFullNamespaceURI(propertyName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getClassQname(WebScriptRequest req)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
// validate the classname
|
||||
if (isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
return QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
|
||||
}
|
@@ -1,61 +1,61 @@
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Sub-Classdefinitions using classfilter , namespacePrefix and name
|
||||
*
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class SubClassesGet extends AbstractSubClassesGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
|
||||
@Override
|
||||
protected Collection<QName> getQNameCollection(WebScriptRequest req, boolean recursive)
|
||||
{
|
||||
QName classQName = null;
|
||||
boolean isAspect = false;
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
//validate the className
|
||||
if(isValidClassname(className) == true)
|
||||
{
|
||||
classQName = QName.createQName(getFullNamespaceURI(className));
|
||||
if(isValidTypeorAspect(className) == true)
|
||||
{
|
||||
isAspect = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " parameter in the URL");
|
||||
}
|
||||
|
||||
// collect the subaspects or subtypes of the class
|
||||
if(isAspect == true)
|
||||
{
|
||||
return this.dictionaryservice.getSubAspects(classQName, recursive);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.dictionaryservice.getSubTypes(classQName, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateClassname(String namespacePrefix, String name)
|
||||
{
|
||||
if(isValidClassname(namespacePrefix + "_" + name) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " and name - "+ name + " - parameter in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Webscript to get the Sub-Classdefinitions using classfilter , namespacePrefix and name
|
||||
*
|
||||
* @author Saravanan Sellathurai, Viachaslau Tsikhanovich
|
||||
*/
|
||||
|
||||
public class SubClassesGet extends AbstractSubClassesGet
|
||||
{
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
|
||||
@Override
|
||||
protected Collection<QName> getQNameCollection(WebScriptRequest req, boolean recursive)
|
||||
{
|
||||
QName classQName = null;
|
||||
boolean isAspect = false;
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
//validate the className
|
||||
if(isValidClassname(className) == true)
|
||||
{
|
||||
classQName = QName.createQName(getFullNamespaceURI(className));
|
||||
if(isValidTypeorAspect(className) == true)
|
||||
{
|
||||
isAspect = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " parameter in the URL");
|
||||
}
|
||||
|
||||
// collect the subaspects or subtypes of the class
|
||||
if(isAspect == true)
|
||||
{
|
||||
return this.dictionaryservice.getSubAspects(classQName, recursive);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.dictionaryservice.getSubTypes(classQName, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateClassname(String namespacePrefix, String name)
|
||||
{
|
||||
if(isValidClassname(namespacePrefix + "_" + name) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " and name - "+ name + " - parameter in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user