mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Dictionary REST API refactoring and bug fixing
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18574 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,22 +1,8 @@
|
||||
<#import "propertydefinition.lib.ftl" as propertyDefLib/>
|
||||
<#if propertydefs?exists>
|
||||
<#if individualproperty?exists == false>
|
||||
[
|
||||
</#if>
|
||||
<#list propertydefs as propertydefinitions>
|
||||
<#if individualproperty?exists>
|
||||
<#if propertydefinitions.name == individualproperty.name>
|
||||
<@propertyDefLib.propertyDefJSON propertydefs=propertydefinitions/>
|
||||
<#break>
|
||||
</#if>
|
||||
<#else>
|
||||
<@propertyDefLib.propertyDefJSON propertydefs=propertydefinitions/>
|
||||
<#if propertydefinitions_has_next>,</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<#if individualproperty?exists == false>
|
||||
]
|
||||
</#if>
|
||||
<#else>
|
||||
{}
|
||||
</#if>
|
||||
|
@@ -544,9 +544,9 @@
|
||||
<!-- DICTIONARY Service REST API -->
|
||||
<!-- -->
|
||||
|
||||
<bean id="webscript.dictionary" abstract="true" parent="webscript">
|
||||
<bean id="webscript.dictionary" abstract="true" parent="webscript" init-method="init">
|
||||
<property name="dictionaryService" ref="DictionaryService"/>
|
||||
<property name="dictionaryHelper" ref="dictionaryWebScriptHelper"/>
|
||||
<property name="namespaceService" ref="NamespaceService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="webscript.org.alfresco.repository.dictionary.classes.get" class="org.alfresco.repo.web.scripts.dictionary.ClassesGet" parent="webscript.dictionary"/>
|
||||
@@ -557,12 +557,6 @@
|
||||
<bean id="webscript.org.alfresco.repository.dictionary.association.get" class="org.alfresco.repo.web.scripts.dictionary.AssociationGet" parent="webscript.dictionary"/>
|
||||
<bean id="webscript.org.alfresco.repository.dictionary.associations.get" class="org.alfresco.repo.web.scripts.dictionary.AssociationsGet" parent="webscript.dictionary"/>
|
||||
|
||||
<!-- Dictionary Service Web Script Helper Class -->
|
||||
<bean id="dictionaryWebScriptHelper" class="org.alfresco.repo.web.scripts.dictionary.DictionaryHelper" init-method="init">
|
||||
<property name="namespaceService" ref="NamespaceService"/>
|
||||
<property name="dictionaryService" ref="DictionaryService"/>
|
||||
</bean>
|
||||
|
||||
<!-- GET IMAP SERVER STATUS -->
|
||||
<bean id="webscript.org.alfresco.repository.imap.imap-enabled.get" class="org.alfresco.repo.imap.scripts.ServerStatusWebScript" parent="webscript">
|
||||
<property name="imapServerEnabled"><value>${imap.server.enabled}</value></property>
|
||||
|
@@ -24,51 +24,26 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* Webscript to get the Associationdefinition for a given classname and association-name
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class AssociationGet extends DeclarativeWebScript
|
||||
public class AssociationGet extends DictionaryWebServiceBase
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs";
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
private static final String DICTIONARY_ASSOCIATION_NAME = "assocname";
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryhelper class
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryHelper(DictionaryHelper dictionaryhelper)
|
||||
{
|
||||
this.dictionaryhelper = dictionaryhelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
@@ -81,19 +56,19 @@ public class AssociationGet extends DeclarativeWebScript
|
||||
QName associationQname = null;
|
||||
|
||||
//validate the classname
|
||||
if(this.dictionaryhelper.isValidClassname(className) == false)
|
||||
if(isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
classQname = QName.createQName(getFullNamespaceURI(className));
|
||||
|
||||
if(associationName == null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter association name in the URL");
|
||||
}
|
||||
|
||||
associationQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(associationName));
|
||||
associationQname = QName.createQName(getFullNamespaceURI(associationName));
|
||||
|
||||
if(this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname) != null)
|
||||
{
|
||||
|
@@ -24,28 +24,23 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Webscript to get the Associationdefinitions for a given classname
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class AssociationsGet extends DeclarativeWebScript
|
||||
public class AssociationsGet extends DictionaryWebServiceBase
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs";
|
||||
private static final String MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS = "individualproperty";
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
@@ -53,26 +48,6 @@ public class AssociationsGet extends DeclarativeWebScript
|
||||
private static final String REQ_URL_TEMPL_VAR_NAME = "n";
|
||||
private static final String REQ_URL_TEMPL_VAR_ASSOCIATION_FILTER = "af";
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryhelper class
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryHelper(DictionaryHelper dictionaryhelper)
|
||||
{
|
||||
this.dictionaryhelper = dictionaryhelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
@@ -94,15 +69,15 @@ public class AssociationsGet extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
//validate association filter
|
||||
if(this.dictionaryhelper.isValidAssociationFilter(associationFilter) == false)
|
||||
if(isValidAssociationFilter(associationFilter) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the associationFilter - " + associationFilter + " - parameter in the URL");
|
||||
}
|
||||
|
||||
//validate classname
|
||||
if(this.dictionaryhelper.isValidClassname(className) == true)
|
||||
if(isValidClassname(className) == true)
|
||||
{
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
classQname = QName.createQName(getFullNamespaceURI(className));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -140,13 +115,8 @@ public class AssociationsGet extends DeclarativeWebScript
|
||||
// if both namespaceprefix and name parameters are given then, the combination namespaceprefix_name is used as the index to create the qname
|
||||
if(name != null && namespacePrefix != null)
|
||||
{
|
||||
if(this.dictionaryhelper.isValidPrefix(namespacePrefix) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespacePrefix + " - parameter in the URL");
|
||||
}
|
||||
|
||||
// validate the class combination namespaceprefix_name
|
||||
associationQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
associationQname = QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
|
||||
if(this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname)== null)
|
||||
{
|
||||
|
@@ -24,56 +24,30 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
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
|
||||
*/
|
||||
|
||||
public class ClassGet extends DeclarativeWebScript
|
||||
public class ClassGet extends DictionaryWebServiceBase
|
||||
{
|
||||
|
||||
private DictionaryService dictionaryservice;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_CLASS_DETAILS = "classdefs";
|
||||
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
|
||||
private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs";
|
||||
private static final String DICTIONARY_CLASS_NAME = "className";
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryhelper class
|
||||
*
|
||||
* @param dictionaryHelper The dictionary helper instance to set
|
||||
*/
|
||||
public void setDictionaryHelper(DictionaryHelper dictionaryhelper)
|
||||
{
|
||||
this.dictionaryhelper = dictionaryhelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
@@ -88,9 +62,9 @@ public class ClassGet extends DeclarativeWebScript
|
||||
Map<QName, Collection<AssociationDefinition>> assocdef = new HashMap<QName, Collection<AssociationDefinition>>();
|
||||
|
||||
//validate the classname and throw appropriate error message
|
||||
if(this.dictionaryhelper.isValidClassname(className) == true)
|
||||
if(isValidClassname(className) == true)
|
||||
{
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
classQname = QName.createQName(getFullNamespaceURI(className));
|
||||
classdef.put(classQname, this.dictionaryservice.getClass(classQname));
|
||||
propdef.put(classQname, this.dictionaryservice.getClass(classQname).getProperties().values());
|
||||
assocdef.put(classQname, this.dictionaryservice.getClass(classQname).getAssociations().values());
|
||||
|
@@ -24,32 +24,28 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Webscript to get the Classdefinitions using classfilter , namespaceprefix and name
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class ClassesGet extends DeclarativeWebScript
|
||||
public class ClassesGet extends DictionaryWebServiceBase
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_CLASS_DEFS = "classdefs";
|
||||
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
|
||||
private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs";
|
||||
@@ -62,34 +58,14 @@ public class ClassesGet extends DeclarativeWebScript
|
||||
private static final String REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX = "nsp";
|
||||
private static final String REQ_URL_TEMPL_VAR_NAME = "n";
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryhelper class
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryHelper(DictionaryHelper dictionaryhelper)
|
||||
{
|
||||
this.dictionaryhelper = dictionaryhelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String classFilter = this.dictionaryhelper.getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_CLASS_FILTER));
|
||||
String namespacePrefix = this.dictionaryhelper.getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX));
|
||||
String name = this.dictionaryhelper.getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAME));
|
||||
String classFilter = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_CLASS_FILTER));
|
||||
String namespacePrefix = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX));
|
||||
String name = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAME));
|
||||
String className = null;
|
||||
|
||||
Map<QName, ClassDefinition> classdef = new HashMap<QName, ClassDefinition>();
|
||||
@@ -108,7 +84,7 @@ public class ClassesGet extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
//validate classfilter
|
||||
if(this.dictionaryhelper.isValidClassFilter(classFilter) == false)
|
||||
if(isValidClassFilter(classFilter) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classfilter - " + classFilter + " provided in the URL");
|
||||
}
|
||||
@@ -122,20 +98,15 @@ public class ClassesGet extends DeclarativeWebScript
|
||||
//validate the namespaceprefix and name parameters => if namespaceprefix is given, then name has to be validated along with it
|
||||
if(namespacePrefix != null)
|
||||
{
|
||||
if(this.dictionaryhelper.isValidPrefix(namespacePrefix) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespacePrefix + " parameter in the URL");
|
||||
}
|
||||
|
||||
//validate name parameter if present along with the namespaceprefix
|
||||
if(name != null)
|
||||
{
|
||||
className = namespacePrefix + "_" + name;
|
||||
if(this.dictionaryhelper.isValidClassname(className) == false)
|
||||
if(isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + "parameter in the URL");
|
||||
}
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
classQname = QName.createQName(getFullNamespaceURI(className));
|
||||
classdef.put(classQname, this.dictionaryservice.getClass(classQname));
|
||||
propdef.put(classQname, this.dictionaryservice.getClass(classQname).getProperties().values());
|
||||
assocdef.put(classQname, this.dictionaryservice.getClass(classQname).getAssociations().values());
|
||||
@@ -143,13 +114,13 @@ public class ClassesGet extends DeclarativeWebScript
|
||||
else
|
||||
{
|
||||
//if name is not given then the model is extracted from the namespaceprefix, there can be more than one model associated with one namespaceprefix
|
||||
String namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(namespacePrefix);
|
||||
String namespaceUri = namespaceService.getNamespaceURI(namespacePrefix);
|
||||
for(QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if(qnameObj.getNamespaceURI().equals(namespaceUri))
|
||||
{
|
||||
name = qnameObj.getLocalName();
|
||||
myModel = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
myModel = QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
|
||||
// check the classfilter to pull out either all or type or aspects
|
||||
if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1))
|
||||
|
@@ -210,27 +210,18 @@ public class DictionaryRestApiTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
Response response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
JSONObject resultSet = new JSONObject(response.getContentAsString());
|
||||
validatePropertyDef(resultSet);
|
||||
|
||||
// both name and namespaceprefix parameters are needed
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "cm");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
//JSONObject resultSet = new JSONObject(response.getContentAsString());
|
||||
//validatePropertyDef(resultSet);
|
||||
|
||||
// both name and namespaceprefix parameters are needed
|
||||
arguments.clear();
|
||||
arguments.put("n", "created");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
JSONArray result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(200,response.getStatus());
|
||||
assertEquals(5, result.length());
|
||||
|
||||
//validate with no parameter => returns an array of property definitions
|
||||
arguments.clear();
|
||||
response = sendRequest(req, 200);
|
||||
JSONArray result = new JSONArray(response.getContentAsString());
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(200,response.getStatus());
|
||||
assertEquals(result.length()>0, true);
|
||||
for(int i=0; i<result.length(); i++)
|
||||
@@ -241,46 +232,6 @@ public class DictionaryRestApiTest extends BaseWebScriptTest
|
||||
}
|
||||
}
|
||||
|
||||
//wrong data
|
||||
arguments.clear();
|
||||
response = sendRequest(new GetRequest("/api/classes/cm_welcome/properties"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//ask for a property which is not present in cm_auditable => results a null object
|
||||
arguments.clear();
|
||||
arguments.put("n", "dublincore");
|
||||
arguments.put("nsp", "cm");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
resultSet = new JSONObject(response.getContentAsString());
|
||||
assertEquals(0,resultSet.length());
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
|
||||
// with invalid namespace parameter
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "sara");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
// with invalid name parameter => results a null json object
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "cm");
|
||||
arguments.put("n", "create");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
resultSet = new JSONObject(response.getContentAsString());
|
||||
assertEquals(0,resultSet.length());
|
||||
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "wcm");
|
||||
arguments.put("n", "created");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
resultSet = new JSONObject(response.getContentAsString());
|
||||
assertEquals(0,resultSet.length());
|
||||
|
||||
}
|
||||
|
||||
public void testGetClassDetail() throws Exception
|
||||
@@ -604,14 +555,6 @@ public class DictionaryRestApiTest extends BaseWebScriptTest
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//check for all data under cm without option=>name
|
||||
arguments.clear();
|
||||
arguments.put("cf", "all");
|
||||
arguments.put("nsp", "cmbb");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//check for all dictionary data without option=>name and option=>namespaceprefix
|
||||
arguments.clear();
|
||||
arguments.put("cf", "a<EFBFBD>&llsara");
|
||||
@@ -633,13 +576,6 @@ public class DictionaryRestApiTest extends BaseWebScriptTest
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//check with an invalid namespaceprefix
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "cmsd");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//check for all types dictionary data without option=>name and option=>namespaceprefix and option=>classfilter
|
||||
arguments.clear();
|
||||
req.setArgs(arguments);
|
||||
@@ -727,15 +663,6 @@ public class DictionaryRestApiTest extends BaseWebScriptTest
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//wrong data
|
||||
// invalid namespaceprefix
|
||||
arguments.clear();
|
||||
arguments.put("r", "true");
|
||||
arguments.put("nsp", "wcms");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404); // need to have an option to filter by name as well
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
// invalid name and namespaceprefix
|
||||
arguments.clear();
|
||||
arguments.put("r", "true");
|
||||
|
@@ -24,29 +24,35 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.InvalidQNameException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Helper class for Dictionary Service webscripts
|
||||
* Base class for Dictionary web scripts
|
||||
*
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class DictionaryHelper
|
||||
public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
{
|
||||
private static final String NAME_DELIMITER = "_";
|
||||
private NamespaceService namespaceservice;
|
||||
|
||||
private Map<String, String> prefixesAndUrlsMap;
|
||||
private Map<String, String> urlsAndPrefixesMap;
|
||||
private Collection<String> prefixes;
|
||||
private DictionaryService dictionaryservice;
|
||||
|
||||
/** 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";
|
||||
@@ -63,7 +69,7 @@ public class DictionaryHelper
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceservice)
|
||||
{
|
||||
this.namespaceservice = namespaceservice;
|
||||
this.namespaceService = namespaceservice;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,17 +87,41 @@ public class DictionaryHelper
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
this.prefixes = this.namespaceservice.getPrefixes();
|
||||
Collection<String> prefixes = this.namespaceService.getPrefixes();
|
||||
this.prefixesAndUrlsMap = new HashMap<String, String>(prefixes.size());
|
||||
this.urlsAndPrefixesMap = new HashMap<String, String>(prefixes.size());
|
||||
for (String prefix : prefixes)
|
||||
{
|
||||
String url = this.namespaceservice.getNamespaceURI(prefix);
|
||||
String url = this.namespaceService.getNamespaceURI(prefix);
|
||||
this.prefixesAndUrlsMap.put(prefix, url);
|
||||
this.urlsAndPrefixesMap.put(url, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
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 qname
|
||||
@@ -124,23 +154,6 @@ public class DictionaryHelper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param className the class name as cm_person
|
||||
* @return String the full name in the following format {namespaceuri}shorname
|
||||
*/
|
||||
public String getNamespaceURIfromPrefix(String prefix)
|
||||
{
|
||||
if(this.isValidPrefix(prefix) == true)
|
||||
{
|
||||
return this.prefixesAndUrlsMap.get(prefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param classname - checks whether the classname is valid , gets the classname as input e.g cm_person
|
||||
@@ -152,8 +165,8 @@ public class DictionaryHelper
|
||||
try
|
||||
{
|
||||
qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||
if ((this.isValidPrefix(this.getPrefix(classname)) == true) &&
|
||||
this.dictionaryservice.getClass(qname) != null)
|
||||
if (//(isValidPrefix(getPrefix(classname)) == true) &&
|
||||
dictionaryservice.getClass(qname) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -170,17 +183,19 @@ public class DictionaryHelper
|
||||
* @param prefix - checks whether the prefix is a valid one
|
||||
* @return true if the prefix is valid or false
|
||||
*/
|
||||
public boolean isValidPrefix(String prefix)
|
||||
{
|
||||
if(this.prefixes.contains(prefix) == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// public boolean isValidPrefix(String prefix)
|
||||
// {
|
||||
// this.namespaceservice.
|
||||
//
|
||||
// if(this.prefixes.contains(prefix) == true)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
@@ -24,16 +24,17 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -42,37 +43,11 @@ import java.util.Map;
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class PropertiesGet extends DeclarativeWebScript
|
||||
public class PropertiesGet extends DictionaryWebServiceBase
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
|
||||
private static final String MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS = "individualproperty";
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
private static final String REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX = "nsp";
|
||||
private static final String REQ_URL_TEMPL_VAR_NAME = "n";
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryhelper class
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryHelper(DictionaryHelper dictionaryhelper)
|
||||
{
|
||||
this.dictionaryhelper = dictionaryhelper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
@@ -80,51 +55,41 @@ public class PropertiesGet extends DeclarativeWebScript
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String name = req.getParameter(REQ_URL_TEMPL_VAR_NAME);
|
||||
String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName classQname = null;
|
||||
QName propertyQname = null;
|
||||
|
||||
//validate the className
|
||||
if(this.dictionaryhelper.isValidClassname(className) == true)
|
||||
if (className == null || className.length() == 0)
|
||||
{
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
// Error
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL");
|
||||
|
||||
}
|
||||
else
|
||||
QName classQName = createClassQName(className);
|
||||
if (classQName == null)
|
||||
{
|
||||
// Error
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
// validate for the presence of both name and namespaceprefix
|
||||
if((name == null && namespacePrefix != null) ||
|
||||
(name != null && namespacePrefix == null))
|
||||
String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
|
||||
|
||||
String namespaceURI = null;
|
||||
if (namespacePrefix != null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing either name or namespacePrefix parameter in the URL - both combination of name and namespacePrefix is needed");
|
||||
namespaceURI = this.namespaceService.getNamespaceURI(namespacePrefix);
|
||||
}
|
||||
|
||||
// if both namespacePrefix and name parameters are given then, the combination namespacePrefix_name is used as the index to create the propertyqname
|
||||
if(name != null && namespacePrefix != null)
|
||||
Map<QName, PropertyDefinition> propMap = dictionaryservice.getClass(classQName).getProperties();
|
||||
List<PropertyDefinition> props = new ArrayList<PropertyDefinition>(propMap.size());
|
||||
for (Map.Entry<QName, PropertyDefinition> entry : propMap.entrySet())
|
||||
{
|
||||
if(this.dictionaryhelper.isValidPrefix(namespacePrefix) == false)
|
||||
if ((namespaceURI != null &&
|
||||
namespaceURI.equals(entry.getKey().getNamespaceURI()) == true) ||
|
||||
namespaceURI == null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " - parameter in the URL");
|
||||
}
|
||||
|
||||
// validate the class combination namespacePrefix_name
|
||||
propertyQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
if(this.dictionaryservice.getClass(classQname).getProperties().get(propertyQname) != null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(classQname).getProperties().get(propertyQname));
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.dictionaryservice.getClass(classQname).getProperties().values());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.dictionaryservice.getClass(classQname).getProperties().values());
|
||||
props.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, props);
|
||||
return model;
|
||||
|
||||
}
|
||||
|
@@ -24,16 +24,14 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Webscript to get the Propertydefinition for a given classname and propname
|
||||
@@ -41,35 +39,12 @@ import java.util.Map;
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class PropertyGet extends DeclarativeWebScript
|
||||
public class PropertyGet extends DictionaryWebServiceBase
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
private static final String DICTIONARY_PROPERTY_NAME = "propname";
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryhelper class
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryHelper(DictionaryHelper dictionaryhelper)
|
||||
{
|
||||
this.dictionaryhelper = dictionaryhelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
@@ -82,12 +57,12 @@ public class PropertyGet extends DeclarativeWebScript
|
||||
QName propertyQname = null;
|
||||
|
||||
//validate the classname
|
||||
if(this.dictionaryhelper.isValidClassname(className) == false)
|
||||
if(isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
classQname = QName.createQName(getFullNamespaceURI(className));
|
||||
|
||||
//validate the presence of property name
|
||||
if(propertyName == null)
|
||||
@@ -95,7 +70,7 @@ public class PropertyGet extends DeclarativeWebScript
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter propertyname in the URL");
|
||||
}
|
||||
|
||||
propertyQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(propertyName));
|
||||
propertyQname = QName.createQName(getFullNamespaceURI(propertyName));
|
||||
|
||||
if(this.dictionaryservice.getClass(classQname).getProperties().get(propertyQname) != null)
|
||||
{
|
||||
|
@@ -24,31 +24,27 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
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
|
||||
*/
|
||||
|
||||
public class SubClassesGet extends DeclarativeWebScript
|
||||
public class SubClassesGet extends DictionaryWebServiceBase
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_CLASS_DEFS = "classdefs";
|
||||
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
|
||||
private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs";
|
||||
@@ -59,26 +55,6 @@ public class SubClassesGet extends DeclarativeWebScript
|
||||
private static final String REQ_URL_TEMPL_VAR_NAME = "n";
|
||||
private static final String DICTIONARY_CLASS_NAME = "classname";
|
||||
|
||||
/**
|
||||
* Set the dictionaryService property.
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryservice = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionaryhelper class
|
||||
*
|
||||
* @param dictionaryService The dictionary service instance to set
|
||||
*/
|
||||
public void setDictionaryHelper(DictionaryHelper dictionaryhelper)
|
||||
{
|
||||
this.dictionaryhelper = dictionaryhelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
@@ -87,7 +63,7 @@ public class SubClassesGet extends DeclarativeWebScript
|
||||
String name = req.getParameter(REQ_URL_TEMPL_VAR_NAME);
|
||||
String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String recursiveValue = this.dictionaryhelper.getValidInput(req.getParameter(REQ_URL_TEMPL_IMMEDIATE_SUB_TYPE_CHILDREN));
|
||||
String recursiveValue = getValidInput(req.getParameter(REQ_URL_TEMPL_IMMEDIATE_SUB_TYPE_CHILDREN));
|
||||
|
||||
boolean recursive = true;
|
||||
|
||||
@@ -121,10 +97,10 @@ public class SubClassesGet extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
//validate the className
|
||||
if(this.dictionaryhelper.isValidClassname(className) == true)
|
||||
if(isValidClassname(className) == true)
|
||||
{
|
||||
classQName = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
if(this.dictionaryhelper.isValidTypeorAspect(className) == true)
|
||||
classQName = QName.createQName(getFullNamespaceURI(className));
|
||||
if(isValidTypeorAspect(className) == true)
|
||||
{
|
||||
isAspect = true;
|
||||
}
|
||||
@@ -144,19 +120,10 @@ public class SubClassesGet extends DeclarativeWebScript
|
||||
qname = this.dictionaryservice.getSubTypes(classQName, recursive);
|
||||
}
|
||||
|
||||
//validate the namespaceprefix parameter
|
||||
if(namespacePrefix != null)
|
||||
{
|
||||
if(this.dictionaryhelper.isValidPrefix(namespacePrefix) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " - parameter in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
//validate the name parameter
|
||||
if(name != null)
|
||||
{
|
||||
if(this.dictionaryhelper.isValidModelName(name) == false)
|
||||
if(isValidModelName(name) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name parameter - " + name + " in the URL");
|
||||
}
|
||||
@@ -165,12 +132,12 @@ public class SubClassesGet extends DeclarativeWebScript
|
||||
//validate the name parameter
|
||||
if (namespacePrefix == null && name != null)
|
||||
{
|
||||
namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(this.dictionaryhelper.getPrefixFromModelName(name));
|
||||
namespaceUri = namespaceService.getNamespaceURI(getPrefixFromModelName(name));
|
||||
}
|
||||
|
||||
if (namespacePrefix != null && name == null)
|
||||
{
|
||||
namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(namespacePrefix);
|
||||
namespaceUri = namespaceService.getNamespaceURI(namespacePrefix);
|
||||
}
|
||||
|
||||
if(namespacePrefix == null && name == null)
|
||||
@@ -181,11 +148,11 @@ public class SubClassesGet extends DeclarativeWebScript
|
||||
|
||||
if (namespacePrefix != null && name != null)
|
||||
{
|
||||
if(this.dictionaryhelper.isValidClassname(namespacePrefix + "_" + name) == false)
|
||||
if(isValidClassname(namespacePrefix + "_" + name) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " and name - "+ name + " - parameter in the URL");
|
||||
}
|
||||
namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(namespacePrefix);
|
||||
namespaceUri = namespaceService.getNamespaceURI(namespacePrefix);
|
||||
}
|
||||
|
||||
for(QName qnameObj: qname)
|
||||
|
Reference in New Issue
Block a user