mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for build failure and minor changes to dictionary service
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12079 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -49,14 +49,12 @@
|
||||
"requiredChildName" : "${assocdefs.getRequiredChildName()}",
|
||||
</#if>
|
||||
<#if assocdefs.getDuplicateChildNamesAllowed() == true>
|
||||
"duplicateChildNameAllowed" : true,
|
||||
"duplicateChildNameAllowed" : true,
|
||||
<#else>
|
||||
"duplicateChildNameAllowed" : false,
|
||||
"duplicateChildNameAllowed" : false,
|
||||
</#if>
|
||||
"url" : "${"/api/classes/" + url.templateArgs.classname + "/childassociation/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
||||
<#else>
|
||||
"url" : "${"/api/classes/" + url.templateArgs.classname + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
||||
</#if>
|
||||
"url" : "${"/api/classes/" + url.templateArgs.classname + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
@@ -94,7 +94,7 @@
|
||||
<#if assocdefs.title?exists>
|
||||
"title" : "${assocdefs.title}",
|
||||
</#if>
|
||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/childassociation/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
|
@@ -1,3 +1,6 @@
|
||||
<#import "assocdefinition.lib.ftl" as assocDefLib/>
|
||||
|
||||
<#if assocdefs?exists>
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
||||
<#else>
|
||||
{}
|
||||
</#if>
|
@@ -4,6 +4,7 @@
|
||||
<#if individualproperty?exists>
|
||||
<#if assocdefs.name == individualproperty.name>
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
||||
<#break>
|
||||
</#if>
|
||||
<#else>
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
||||
|
@@ -1,14 +1,22 @@
|
||||
<#import "propertydefinition.lib.ftl" as propertyDefLib/>
|
||||
[
|
||||
<#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 propertydefs?exists>
|
||||
<#if individualproperty?exists == false>
|
||||
[
|
||||
</#if>
|
||||
</#list>
|
||||
]
|
||||
<#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>
|
@@ -1,3 +1,6 @@
|
||||
<#import "propertydefinition.lib.ftl" as propertyDefLib/>
|
||||
|
||||
<@propertyDefLib.propertyDefJSON propertydefs=propertydefs/>
|
||||
<#if propertydefs?exists>
|
||||
<@propertyDefLib.propertyDefJSON propertydefs=propertydefs/>
|
||||
<#else>
|
||||
{}
|
||||
</#if>
|
@@ -120,7 +120,7 @@ public class DictionaryHelper
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact classname - " + classname + " parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,27 +182,6 @@ public class DictionaryHelper
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param namespaceprefix - gets a valid namespaceprefix as input
|
||||
* @return modelname from namespaceprefix - returns null if invalid namespaceprefix is given
|
||||
*/
|
||||
public String getModelNameFromPrefix(String namespaceprefix)
|
||||
{
|
||||
String name = null;
|
||||
for(QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
{
|
||||
String prefix = this.getUrlsAndPrefixesMap().get(qnameObj.getNamespaceURI());
|
||||
if(prefix.equals(namespaceprefix))
|
||||
{
|
||||
name = qnameObj.getLocalName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param namespaceprefix - gets a valid namespaceprefix as input
|
||||
@@ -358,8 +337,9 @@ public class DictionaryHelper
|
||||
return prefixesAndUrlsMap;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns a string map of urls and prefixes - with url as the key
|
||||
/**
|
||||
*
|
||||
* @return- a string map of urls and prefixes - with url as the key
|
||||
*/
|
||||
public Map<String, String> getUrlsAndPrefixesMap()
|
||||
{
|
||||
|
@@ -29,6 +29,7 @@ import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
|
||||
import org.alfresco.web.scripts.TestWebScriptServer.Response;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONArray;
|
||||
|
||||
@@ -67,7 +68,6 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
assertEquals(true, result.get("protected"));
|
||||
assertEquals(true, result.get("indexed"));
|
||||
assertEquals(true, result.get("indexedAtomically"));
|
||||
//assertEquals check is yet to be made on constraints
|
||||
assertEquals("/api/classes/cm_auditable/property/cm_created", result.get("url"));
|
||||
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
assertEquals(false, result.getJSONObject("target").get("mandatory"));
|
||||
assertEquals(false, result.getJSONObject("target").get("many"));
|
||||
|
||||
assertEquals("/api/classes/wca_form/childassociation/wca_formworkflowdefaults", result.get("url"));
|
||||
assertEquals("/api/classes/wca_form/association/wca_formworkflowdefaults", result.get("url"));
|
||||
}
|
||||
|
||||
private void validateAssociation(JSONObject result) throws Exception
|
||||
@@ -180,7 +180,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
assertEquals(0, result.getJSONObject("associations").length());
|
||||
|
||||
assertEquals("cm:thumbnails", result.getJSONObject("childassociations").getJSONObject("cm:thumbnails").get("name"));
|
||||
assertEquals("/api/classes/cm_thumbnailed/childassociation/cm_thumbnails", result.getJSONObject("childassociations").getJSONObject("cm:thumbnails").get("url"));
|
||||
assertEquals("/api/classes/cm_thumbnailed/association/cm_thumbnails", result.getJSONObject("childassociations").getJSONObject("cm:thumbnails").get("url"));
|
||||
|
||||
}
|
||||
|
||||
@@ -190,10 +190,16 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
assertEquals(200,response.getStatus());
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
validatePropertyDef(result);
|
||||
// TODO Constraint data has to be added... yet to do
|
||||
|
||||
assertEquals(13, result.length());
|
||||
response = sendRequest(new GetRequest("/api/classes/cm_hi/property/cm_welcome"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//invalid property name , returns a null JsonObject as such a property doesn't exist under cm_auditable
|
||||
response = sendRequest(new GetRequest("/api/classes/cm_auditable/property/cm_welcome"), 200);
|
||||
result = new JSONObject(response.getContentAsString());
|
||||
assertEquals(0, result.length());
|
||||
assertEquals(200,response.getStatus());
|
||||
}
|
||||
|
||||
public void testGetPropertyDefs() throws Exception
|
||||
@@ -206,45 +212,27 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
Response response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
JSONArray result = new JSONArray(response.getContentAsString());
|
||||
validatePropertyDef(result.getJSONObject(0));
|
||||
JSONObject resultSet = new JSONObject(response.getContentAsString());
|
||||
validatePropertyDef(resultSet);
|
||||
|
||||
// validate without name parameter => returns an array of property definitions
|
||||
// both name and namespaceprefix parameters are needed
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "cm");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(200,response.getStatus());
|
||||
assertEquals(5, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if(result.getJSONObject(i).get("name").equals("cm:created"))
|
||||
{
|
||||
validatePropertyDef(result.getJSONObject(i));
|
||||
}
|
||||
}
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
// validate without namespaceprefix parameter
|
||||
// both name and namespaceprefix parameters are needed
|
||||
arguments.clear();
|
||||
arguments.put("n", "created");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(200,response.getStatus());
|
||||
assertEquals(1, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if(result.getJSONObject(i).get("name").equals("cm:created"))
|
||||
{
|
||||
validatePropertyDef(result.getJSONObject(i));
|
||||
}
|
||||
}
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//validate with no parameter => returns an array of property definitions
|
||||
arguments.clear();
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
JSONArray result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(200,response.getStatus());
|
||||
assertEquals(5, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
@@ -260,13 +248,16 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
response = sendRequest(new GetRequest("/api/classes/cm_welcome/properties"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//with invalid name parameter
|
||||
//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, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
response = sendRequest(req, 200);
|
||||
resultSet = new JSONObject(response.getContentAsString());
|
||||
assertEquals(0,resultSet.length());
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
|
||||
// with invalid namespace parameter
|
||||
arguments.clear();
|
||||
@@ -275,21 +266,23 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
// with invalid name parameter
|
||||
// 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, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
response = sendRequest(req, 200);
|
||||
resultSet = new JSONObject(response.getContentAsString());
|
||||
assertEquals(0,resultSet.length());
|
||||
|
||||
// name is valid here, but the namespaceprefix is different from the classname i.e classname is of cm and given namespaceprefix is wcm - which contradicts
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "wcm");
|
||||
arguments.put("n", "created");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
response = sendRequest(req, 200);
|
||||
resultSet = new JSONObject(response.getContentAsString());
|
||||
assertEquals(0,resultSet.length());
|
||||
|
||||
}
|
||||
|
||||
public void testGetClassDetail() throws Exception
|
||||
@@ -311,6 +304,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
assertEquals(404,response.getStatus());
|
||||
}
|
||||
|
||||
|
||||
public void testGetClassDetails() throws Exception
|
||||
{
|
||||
/**
|
||||
@@ -384,7 +378,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
}
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
/*//check for a type under cm without options=>name, namespaceprefix [case-type:2]
|
||||
//check for a type under cm without options=>name, namespaceprefix [case-type:2]
|
||||
arguments.clear();
|
||||
arguments.put("cf", "type");
|
||||
arguments.put("nsp", "cm");
|
||||
@@ -409,7 +403,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(34, result.length());
|
||||
assertEquals(37, result.length());
|
||||
// the above result has all the aspects under cm, so now check for the presence aspect cm:thumnailed in the array of classes of all aspects
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
@@ -426,7 +420,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(47, result.length());
|
||||
assertEquals(50, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed"))
|
||||
@@ -536,7 +530,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(47, result.length());
|
||||
assertEquals(50, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if (result.getJSONObject(i).get("name").equals("cm:thumbnailed"))
|
||||
@@ -552,7 +546,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(47, result.length());
|
||||
assertEquals(50, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if (result.getJSONObject(i).get("name").equals("cm:cmobject"))
|
||||
@@ -568,7 +562,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(47, result.length());
|
||||
assertEquals(50, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if (result.getJSONObject(i).get("name").equals("cm:cmobject"))
|
||||
@@ -651,7 +645,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
arguments.clear();
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());*/
|
||||
assertEquals(200,response.getStatus());
|
||||
}
|
||||
|
||||
public void testSubClassDetails() throws Exception
|
||||
@@ -698,7 +692,6 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(2, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
@@ -716,7 +709,6 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(13, result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
@@ -728,6 +720,23 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
}
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//wrong data
|
||||
// invalid namespaceprefix
|
||||
arguments.clear();
|
||||
arguments.put("r", "true");
|
||||
arguments.put("nsp", "wcms");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
// invalid name and namespaceprefix
|
||||
arguments.clear();
|
||||
arguments.put("r", "true");
|
||||
arguments.put("n", "dublincore"); //name should only be a valid content model and not an aspect or a type name
|
||||
arguments.put("nsp", "cm");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
}
|
||||
|
||||
@@ -736,9 +745,30 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
GetRequest req = new GetRequest(URL_SITES + "/cm_person/association/cm_avatar");
|
||||
Response response = sendRequest(req, 200);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
assertEquals(200,response.getStatus());
|
||||
validateAssociationDef(result);
|
||||
|
||||
req = new GetRequest(URL_SITES + "/wca_form/association/wca_formworkflowdefaults");
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONObject(response.getContentAsString());
|
||||
validateChildAssociation(result);
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
req = new GetRequest(URL_SITES + "/wca_form/association/wca_renderingenginetemplates");
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONObject(response.getContentAsString());
|
||||
validateAssociation(result);
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//wrong data
|
||||
response = sendRequest(new GetRequest(URL_SITES +"/cm_personalbe/association/cms_avatarsara"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//ask for an invalid association under wca_form , which returns a null array
|
||||
response = sendRequest(new GetRequest(URL_SITES +"/wca_form/association/cmsavatarsara"), 200);
|
||||
result = new JSONObject(response.getContentAsString());
|
||||
assertEquals(0,result.length());
|
||||
assertEquals(200,response.getStatus());
|
||||
}
|
||||
|
||||
public void testGetAssociatoinDefs() throws Exception
|
||||
@@ -777,7 +807,7 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
}
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//validate with associationfilter=>general and classname=>wca_form
|
||||
//validate with associationfilter=>general(that means an association and not child) and classname=>wca_form
|
||||
arguments.clear();
|
||||
arguments.put("af", "general");
|
||||
req.setArgs(arguments);
|
||||
@@ -789,8 +819,9 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
if(result.getJSONObject(i).get("name").equals("wca:renderingenginetemplates"))
|
||||
validateAssociation(result.getJSONObject(i));
|
||||
}
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//look for association wca_renderingenginetemplates in the class wca_form
|
||||
//look for association wca_renderingenginetemplates in the class wca_form => returns a single valid class
|
||||
arguments.clear();
|
||||
arguments.put("af", "general");
|
||||
arguments.put("nsp", "wca");
|
||||
@@ -804,8 +835,9 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
if(result.getJSONObject(i).get("name").equals("wca:renderingenginetemplates"))
|
||||
validateAssociation(result.getJSONObject(i));
|
||||
}
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//look for childassociation wca_formworkflowdefaults in the class wca_form
|
||||
//look for childassociation wca_formworkflowdefaults in the class wca_form =>returns a single valid class
|
||||
arguments.clear();
|
||||
arguments.put("af", "child");
|
||||
arguments.put("nsp", "wca");
|
||||
@@ -819,8 +851,9 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
if(result.getJSONObject(i).get("name").equals("wca:formworkflowdefaults"))
|
||||
validateChildAssociation(result.getJSONObject(i));
|
||||
}
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//look for details on wca_formworkflowdefaults in the class wca_form
|
||||
//look for details on wca_formworkflowdefaults in the class wca_form , with no classfilter
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "wca");
|
||||
arguments.put("n", "formworkflowdefaults");
|
||||
@@ -833,69 +866,59 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
if(result.getJSONObject(i).get("name").equals("wca:formworkflowdefaults"))
|
||||
validateChildAssociation(result.getJSONObject(i));
|
||||
}
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//look for childassociation in the class wca_form , with a name parameter
|
||||
// wca_formworkflowdefaults has a child_assoc relation with wca_form , but ask for general association, this then returns a null array
|
||||
arguments.clear();
|
||||
arguments.put("af", "child");
|
||||
arguments.put("af", "general");
|
||||
arguments.put("nsp", "wca");
|
||||
arguments.put("n", "formworkflowdefaults");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(1,result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if(result.getJSONObject(i).get("name").equals("wca:formworkflowdefaults"))
|
||||
validateChildAssociation(result.getJSONObject(i));
|
||||
}
|
||||
assertEquals(0,result.length());
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//look for childassociation in the class wca_form , with no name parameter
|
||||
// wca_renderingenginetemplates has a general association relation with wca_form , but ask for child association, this then returns a null array
|
||||
arguments.clear();
|
||||
arguments.put("af", "child");
|
||||
arguments.put("nsp", "wca");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(1,result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if(result.getJSONObject(i).get("name").equals("wca:formworkflowdefaults"))
|
||||
validateChildAssociation(result.getJSONObject(i));
|
||||
}
|
||||
|
||||
//ask for an invalid childassociation => name alone is given , a check is made to ensure renderingenginetemplates is in the associations list, if present check whether its a valid
|
||||
// child association otherwise returns a null array
|
||||
arguments.clear();
|
||||
arguments.put("af", "child");
|
||||
arguments.put("n", "renderingenginetemplates");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(0,result.length());
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//look for childassociation in the class wca_form , with no name parameter =>both name and namespaceprefix are needed
|
||||
arguments.clear();
|
||||
arguments.put("af", "child");
|
||||
arguments.put("nsp", "wca");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
arguments.clear();
|
||||
arguments.put("af", "child");
|
||||
arguments.put("n", "renderingenginetemplates");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//ask for an invalid general-association => name alone is given , a check is made to ensure formworkflowdefaults is in the associations list, if present check whether its a valid
|
||||
// general association otherwise returns a null array
|
||||
arguments.clear();
|
||||
arguments.put("af", "general");
|
||||
arguments.put("n", "formworkflowdefaults");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(0,result.length());
|
||||
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//look for associations (excluding child assocs) in the class wca_form , with no name parameter
|
||||
arguments.clear();
|
||||
arguments.put("af", "general");
|
||||
arguments.put("nsp", "wca");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 200);
|
||||
result = new JSONArray(response.getContentAsString());
|
||||
assertEquals(1,result.length());
|
||||
for(int i=0; i<result.length(); i++)
|
||||
{
|
||||
if(result.getJSONObject(i).get("name").equals("wca:renderingenginetemplates"))
|
||||
validateAssociation(result.getJSONObject(i));
|
||||
}
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
//wrong data
|
||||
response = sendRequest(new GetRequest(URL_SITES +"/cmsa_personalbe/associations"), 404);
|
||||
@@ -907,16 +930,16 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
arguments.put("nsp", "wca");
|
||||
arguments.put("n", "renderingenginetemplates");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
arguments.clear();
|
||||
arguments.put("af", "general");
|
||||
arguments.put("nsp", "cm"); // invalid namespaceprefix => should be of class-type wca
|
||||
arguments.put("nsp", "wca"); // invalid namespaceprefix => should be of class-type wca
|
||||
arguments.put("n", "renderingenginetemplates");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
|
||||
//data without name parameter
|
||||
arguments.clear();
|
||||
@@ -941,27 +964,14 @@ public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
}
|
||||
|
||||
//TODO individual check of all elements
|
||||
public void testGetChildAssociatoinDef() throws Exception
|
||||
{
|
||||
GetRequest req = new GetRequest(URL_SITES + "/cm_thumbnailed/childassociation/cm_thumbnails");
|
||||
Response response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
response = sendRequest(new GetRequest(URL_SITES +"/cm_thumbnailed:sara/childassociation/cm:thumbnails"), 404);
|
||||
//data with invalid class in wca_form
|
||||
arguments.clear();
|
||||
arguments.put("nsp", "wca");
|
||||
arguments.put("n", "dublincore");
|
||||
req.setArgs(arguments);
|
||||
response = sendRequest(req, 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
}
|
||||
|
||||
//TODO individual check of all elements
|
||||
public void testGetChildAssociatoinDefs() throws Exception
|
||||
{
|
||||
GetRequest req = new GetRequest(URL_SITES + "/cm_thumbnailed/childassociations");
|
||||
Response response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
response = sendRequest(new GetRequest(URL_SITES +"/cm_thumbnailed:sara/childassociations"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -24,13 +24,14 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.web.scripts.Cache;
|
||||
import org.alfresco.web.scripts.DeclarativeWebScript;
|
||||
import org.alfresco.web.scripts.Status;
|
||||
import org.alfresco.web.scripts.WebScriptException;
|
||||
import org.alfresco.web.scripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -42,7 +43,6 @@ import java.util.Map;
|
||||
public class GetAssociationDef extends DeclarativeWebScript
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs";
|
||||
@@ -72,32 +72,35 @@ public class GetAssociationDef extends DeclarativeWebScript
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String assocname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_ASSOCIATION_NAME);
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName classqname = null;
|
||||
QName assocqname = null;
|
||||
boolean classnameGiven = (classname != null) && (classname.length() > 0);
|
||||
boolean assocnameGiven = (assocname != null) && (assocname.length() > 0);
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String associationName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_ASSOCIATION_NAME);
|
||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||
QName classQname = null;
|
||||
QName associationQname = null;
|
||||
|
||||
if(classnameGiven && assocnameGiven)
|
||||
//validate the classname
|
||||
if(this.dictionaryhelper.isValidClassname(className) == false)
|
||||
{
|
||||
classqname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
assocqname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(assocname));
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(classqname);
|
||||
|
||||
if(this.classdefinition != null)
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
|
||||
if(associationName == null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.classdefinition.getAssociations().get(assocqname));
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter association name in the URL");
|
||||
}
|
||||
|
||||
associationQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(associationName));
|
||||
|
||||
if(this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname) != null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname));
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.web.scripts.Cache;
|
||||
import org.alfresco.web.scripts.DeclarativeWebScript;
|
||||
import org.alfresco.web.scripts.Status;
|
||||
import org.alfresco.web.scripts.WebScriptException;
|
||||
@@ -75,17 +76,17 @@ public class GetAssociationDefs extends DeclarativeWebScript
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String associationFilter = req.getParameter(REQ_URL_TEMPL_VAR_ASSOCIATION_FILTER);
|
||||
String namespaceprefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
|
||||
String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
|
||||
String name = req.getParameter(REQ_URL_TEMPL_VAR_NAME);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
Map<QName, AssociationDefinition> assocdef = new HashMap<QName, AssociationDefinition>();
|
||||
QName assoc_qname = null;
|
||||
QName class_qname = null;
|
||||
QName associationQname = null;
|
||||
QName classQname = null;
|
||||
|
||||
if(associationFilter == null)
|
||||
{
|
||||
@@ -99,88 +100,62 @@ public class GetAssociationDefs extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
//validate classname
|
||||
if(this.dictionaryhelper.isValidClassname(classname) == true)
|
||||
if(this.dictionaryhelper.isValidClassname(className) == true)
|
||||
{
|
||||
class_qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + classname + " - parameter in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
//validate namespaceprefix
|
||||
if(namespaceprefix != null)
|
||||
// validate for the presence of both name and namespaceprefix
|
||||
if((name == null && namespacePrefix != null) ||
|
||||
(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 whether the namespaceprefix is same of classname prefix
|
||||
if(!this.dictionaryhelper.getPrefix(classname).equalsIgnoreCase(namespaceprefix))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespaceprefix + " parameter in the URL, namespaceprefix should be of class-type "+ classname);
|
||||
}
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing either name or namespaceprefix parameter in the URL - both combination of name and namespaceprefix is needed");
|
||||
}
|
||||
|
||||
// validate the condition, if name is present and namespaceprefix is null
|
||||
if(name !=null && namespaceprefix == null)
|
||||
{
|
||||
assoc_qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(this.dictionaryhelper.getPrefix(classname) + "_" + name));
|
||||
if(this.dictionaryservice.getClass(class_qname).getAssociations().get(assoc_qname)== null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the parameter name - "+ name +" in the URL ");
|
||||
}
|
||||
model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(class_qname).getAssociations().get(assoc_qname));
|
||||
// check for association filters
|
||||
if(associationFilter.equals("child"))
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(classQname).getChildAssociations().values());
|
||||
}
|
||||
else if(associationFilter.equals("general"))
|
||||
{
|
||||
for(AssociationDefinition assocname:this.dictionaryservice.getClass(classQname).getAssociations().values())
|
||||
{
|
||||
if(assocname.isChild() == false)
|
||||
{
|
||||
assocdef.put(assocname.getName(), assocname);
|
||||
}
|
||||
}
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values());
|
||||
}
|
||||
else if(associationFilter.equals("all"))
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(classQname).getAssociations().values());
|
||||
}
|
||||
|
||||
// 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(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
|
||||
assoc_qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(namespaceprefix + "_" + name));
|
||||
if(this.dictionaryservice.getClass(class_qname).getAssociations().get(assoc_qname)== null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespaceprefix + " and name - "+ name + " - parameter in the URL =>has no valid Association with class - "+ classname);
|
||||
}
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(class_qname).getAssociations().values());
|
||||
associationQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
|
||||
if(associationFilter.equals("child"))
|
||||
if(this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname)== null)
|
||||
{
|
||||
if(this.dictionaryservice.getClass(class_qname).getChildAssociations().get(assoc_qname)== null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespaceprefix + " and name - "+ name + " - parameter in the URL => not a valid childassociation for class - "+ classname);
|
||||
}
|
||||
model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(class_qname).getChildAssociations().get(assoc_qname));
|
||||
}
|
||||
else
|
||||
{ //association filter is either general or all
|
||||
model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(class_qname).getAssociations().get(assoc_qname));
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "not a Valid - namespaceprefix_name combination");
|
||||
}
|
||||
|
||||
model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname));
|
||||
}
|
||||
else
|
||||
{ // this point is always reached, if both name and namespaceprefix are not given OR Just namespaceprefix is alone given
|
||||
if(associationFilter.equals("child"))
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(class_qname).getChildAssociations().values());
|
||||
}
|
||||
|
||||
if(associationFilter.equals("general"))
|
||||
{
|
||||
for(AssociationDefinition assocname:this.dictionaryservice.getClass(class_qname).getAssociations().values())
|
||||
{
|
||||
if(assocname.isChild() == false){
|
||||
assocdef.put(assocname.getName(), assocname);
|
||||
}
|
||||
}
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values());
|
||||
}
|
||||
|
||||
if(associationFilter.equals("all"))
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(class_qname).getAssociations().values());
|
||||
}
|
||||
}
|
||||
return model;
|
||||
|
||||
}
|
||||
|
@@ -37,6 +37,8 @@ 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
|
||||
@@ -85,103 +87,104 @@ public class GetClassDetail extends 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 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 classname = null;
|
||||
String className = null;
|
||||
|
||||
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>>();
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
|
||||
Collection <QName> qnames = null;
|
||||
QName class_qname = null;
|
||||
List<QName> qnames = new ArrayList<QName>();
|
||||
QName classQname = null;
|
||||
QName myModel = null;
|
||||
|
||||
//if classfilter is not given, then it defaults to all
|
||||
if(classfilter == null)
|
||||
if(classFilter == null)
|
||||
{
|
||||
classfilter = "all";
|
||||
classFilter = "all";
|
||||
}
|
||||
|
||||
//validate classfilter
|
||||
if(this.dictionaryhelper.isValidClassFilter(classfilter) == false)
|
||||
if(this.dictionaryhelper.isValidClassFilter(classFilter) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classfilter - " + classfilter + " provided in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classfilter - " + classFilter + " provided in the URL");
|
||||
}
|
||||
|
||||
if(namespaceprefix == null && name != null)
|
||||
//name alone has no meaning without namespaceprefix
|
||||
if(namespacePrefix == null && name != null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing namespaceprefix parameter in the URL - both combination of name and namespaceprefix is needed");
|
||||
}
|
||||
|
||||
//validate the namespaceprefix and name parameters => if namespaceprefix is given, then name has to be validated along with it
|
||||
if(namespaceprefix != null)
|
||||
if(namespacePrefix != null)
|
||||
{
|
||||
if(this.dictionaryhelper.isValidPrefix(namespaceprefix) == false)
|
||||
if(this.dictionaryhelper.isValidPrefix(namespacePrefix) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespaceprefix + " parameter in the URL");
|
||||
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)
|
||||
className = namespacePrefix + "_" + name;
|
||||
if(this.dictionaryhelper.isValidClassname(className) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + "parameter in the URL");
|
||||
}
|
||||
class_qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
classdef.put(class_qname, this.dictionaryservice.getClass(class_qname));
|
||||
propdef.put(class_qname, this.dictionaryservice.getClass(class_qname).getProperties().values());
|
||||
assocdef.put(class_qname, this.dictionaryservice.getClass(class_qname).getAssociations().values());
|
||||
classQname = QName.createQName(this.dictionaryhelper.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());
|
||||
}
|
||||
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 namespaceQname = this.dictionaryhelper.getNamespaceURIfromPrefix(namespaceprefix);
|
||||
String namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(namespacePrefix);
|
||||
for(QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if(qnameObj.getNamespaceURI().equals(namespaceQname))
|
||||
if(qnameObj.getNamespaceURI().equals(namespaceUri))
|
||||
{
|
||||
name = qnameObj.getLocalName();
|
||||
myModel = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(namespaceprefix + "_" + name));
|
||||
qnames.clear();
|
||||
myModel = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(namespacePrefix + "_" + name));
|
||||
|
||||
// check the classfilter to pull out either all or type or aspects
|
||||
if (classfilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1))
|
||||
if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1))
|
||||
{
|
||||
qnames.addAll(this.dictionaryservice.getAspects(myModel));
|
||||
qnames.addAll(this.dictionaryservice.getTypes(myModel));
|
||||
}
|
||||
else if (classfilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3))
|
||||
else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3))
|
||||
{
|
||||
qnames.addAll(this.dictionaryservice.getTypes(myModel));
|
||||
}
|
||||
else if (classfilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2))
|
||||
{
|
||||
else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2))
|
||||
{
|
||||
qnames.addAll(this.dictionaryservice.getAspects(myModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if namespaceprefix is null, then check the classfilter to pull out either all or type or aspects
|
||||
// if namespacePrefix is null, then check the classfilter to pull out either all or type or aspects
|
||||
if(myModel == null)
|
||||
{
|
||||
if (classfilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1))
|
||||
if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1))
|
||||
{
|
||||
qnames = this.dictionaryservice.getAllAspects();
|
||||
qnames.addAll(this.dictionaryservice.getAllTypes());
|
||||
qnames.addAll(this.dictionaryservice.getAllAspects());
|
||||
qnames.addAll(this.dictionaryservice.getAllTypes());
|
||||
}
|
||||
else if (classfilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3))
|
||||
else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3))
|
||||
{
|
||||
qnames = this.dictionaryservice.getAllTypes();
|
||||
qnames.addAll(this.dictionaryservice.getAllTypes());
|
||||
}
|
||||
else if (classfilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2))
|
||||
else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2))
|
||||
{
|
||||
qnames = this.dictionaryservice.getAllAspects();
|
||||
qnames.addAll(this.dictionaryservice.getAllAspects());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -79,36 +79,33 @@ public class GetClassDetails extends DeclarativeWebScript
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>(3);
|
||||
QName qname = null;
|
||||
QName classQname = null;
|
||||
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>>();
|
||||
boolean classnameGiven = (classname != null) && (classname.length() > 0);
|
||||
boolean hasData = false;
|
||||
|
||||
if(classnameGiven && this.dictionaryhelper.isValidClassname(classname))
|
||||
//validate the classname and throw appropriate error message
|
||||
if(this.dictionaryhelper.isValidClassname(className) == true)
|
||||
{
|
||||
qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
hasData = true;
|
||||
classdef.put(qname, this.dictionaryservice.getClass(qname));
|
||||
propdef.put(qname, this.dictionaryservice.getClass(qname).getProperties().values());
|
||||
assocdef.put(qname, this.dictionaryservice.getClass(qname).getAssociations().values());
|
||||
}
|
||||
|
||||
if(hasData)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_CLASS_DETAILS, classdef.values());
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, propdef.values());
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values());
|
||||
return model;
|
||||
classQname = QName.createQName(this.dictionaryhelper.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());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
model.put(MODEL_PROP_KEY_CLASS_DETAILS, classdef.values());
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, propdef.values());
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values());
|
||||
|
||||
return model;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -24,13 +24,14 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.web.scripts.Cache;
|
||||
import org.alfresco.web.scripts.DeclarativeWebScript;
|
||||
import org.alfresco.web.scripts.Status;
|
||||
import org.alfresco.web.scripts.WebScriptException;
|
||||
import org.alfresco.web.scripts.WebScriptRequest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -43,7 +44,6 @@ import java.util.Map;
|
||||
public class GetPropertyDef extends DeclarativeWebScript
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
|
||||
@@ -73,32 +73,37 @@ public class GetPropertyDef extends DeclarativeWebScript
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String propertyname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PROPERTY_NAME);
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName qname = null;
|
||||
QName propname = null;
|
||||
boolean classnameGiven = (classname != null) && (classname.length() > 0);
|
||||
boolean propertynameGiven = (propertyname != null) && (propertyname.length() > 0);
|
||||
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
String propertyName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PROPERTY_NAME);
|
||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||
QName classQname = null;
|
||||
QName propertyQname = null;
|
||||
|
||||
if(classnameGiven && propertynameGiven)
|
||||
//validate the classname
|
||||
if(this.dictionaryhelper.isValidClassname(className) == false)
|
||||
{
|
||||
qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
propname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(propertyname));
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL");
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(qname);
|
||||
|
||||
if(this.classdefinition != null)
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
|
||||
//validate the presence of property name
|
||||
if(propertyName == null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.classdefinition.getProperties().get(propname));
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter propertyname in the URL");
|
||||
}
|
||||
|
||||
propertyQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(propertyName));
|
||||
|
||||
if(this.dictionaryservice.getClass(classQname).getProperties().get(propertyQname) != null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.dictionaryservice.getClass(classQname).getProperties().get(propertyQname));
|
||||
}
|
||||
|
||||
return model;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.web.scripts.Cache;
|
||||
import org.alfresco.web.scripts.DeclarativeWebScript;
|
||||
import org.alfresco.web.scripts.Status;
|
||||
import org.alfresco.web.scripts.WebScriptException;
|
||||
@@ -76,68 +77,52 @@ public class GetPropertyDefs extends DeclarativeWebScript
|
||||
/**
|
||||
* @Override method from DeclarativeWebScript
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
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);
|
||||
String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName class_qname = null;
|
||||
QName property_qname = null;
|
||||
QName classQname = null;
|
||||
QName propertyQname = null;
|
||||
|
||||
//validate the classname
|
||||
if(this.dictionaryhelper.isValidClassname(classname) == true)
|
||||
//validate the className
|
||||
if(this.dictionaryhelper.isValidClassname(className) == true)
|
||||
{
|
||||
class_qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
classQname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + classname + " - parameter in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL");
|
||||
}
|
||||
|
||||
//validate namespaceprefix
|
||||
if(namespaceprefix != null)
|
||||
// validate for the presence of both name and namespaceprefix
|
||||
if((name == null && namespacePrefix != null) ||
|
||||
(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 whether the namespaceprefix is same of classname prefix
|
||||
if(!this.dictionaryhelper.getPrefix(classname).equalsIgnoreCase(namespaceprefix))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespaceprefix + " parameter in the URL, namespaceprefix should be of type "+ classname);
|
||||
}
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing either name or namespacePrefix parameter in the URL - both combination of name and namespacePrefix is needed");
|
||||
}
|
||||
|
||||
// validate the condition, if name is present and namespaceprefix is null
|
||||
if(name !=null && namespaceprefix == null)
|
||||
// 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)
|
||||
{
|
||||
property_qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(this.dictionaryhelper.getPrefix(classname) + "_" + name));
|
||||
if(this.dictionaryservice.getClass(class_qname).getProperties().get(property_qname)== null)
|
||||
if(this.dictionaryhelper.isValidPrefix(namespacePrefix) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the parameter name - "+ name +" in the URL ");
|
||||
}
|
||||
model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(class_qname).getProperties().get(property_qname));
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
// validate the class combination namespaceprefix_name
|
||||
property_qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(namespaceprefix + "_" + name));
|
||||
if(this.dictionaryservice.getClass(class_qname).getProperties().get(property_qname)== null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + " - parameter in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " - parameter in the URL");
|
||||
}
|
||||
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.dictionaryservice.getClass(class_qname).getProperties().values());
|
||||
model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(class_qname).getProperties().get(property_qname));
|
||||
// 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
|
||||
{ // if no name and namespaceprefix parameters are given then pull all properties pertaining to the classname
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.dictionaryservice.getClass(class_qname).getProperties().values());
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.dictionaryservice.getClass(classQname).getProperties().values());
|
||||
}
|
||||
|
||||
return model;
|
||||
|
@@ -40,7 +40,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* Webscript to get the Sub-Classdefinitions using classfilter , namespaceprefix and name
|
||||
* Webscript to get the Sub-Classdefinitions using classfilter , namespacePrefix and name
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
@@ -85,9 +85,9 @@ public class GetSubClassesDef extends DeclarativeWebScript
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
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 recursive_value = this.dictionaryhelper.getValidInput(req.getParameter(REQ_URL_TEMPL_IMMEDIATE_SUB_TYPE_CHILDREN));
|
||||
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));
|
||||
|
||||
boolean recursive = true;
|
||||
|
||||
@@ -103,35 +103,35 @@ public class GetSubClassesDef extends DeclarativeWebScript
|
||||
boolean ignoreCheck = false;
|
||||
|
||||
// validate recursive parameter => can be either true or false or null
|
||||
if(recursive_value == null)
|
||||
if(recursiveValue == null)
|
||||
{
|
||||
recursive = true;
|
||||
}
|
||||
else if(recursive_value.equalsIgnoreCase("true"))
|
||||
else if(recursiveValue.equalsIgnoreCase("true"))
|
||||
{
|
||||
recursive = true;
|
||||
}
|
||||
else if (recursive_value.equalsIgnoreCase("false"))
|
||||
else if (recursiveValue.equalsIgnoreCase("false"))
|
||||
{
|
||||
recursive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the value for the parameter recursive=> " + recursive_value +" can only be either true or false");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the value for the parameter recursive=> " + recursiveValue +" can only be either true or false");
|
||||
}
|
||||
|
||||
//validate the classname
|
||||
if(this.dictionaryhelper.isValidClassname(classname) == true)
|
||||
//validate the className
|
||||
if(this.dictionaryhelper.isValidClassname(className) == true)
|
||||
{
|
||||
classQName = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
if(this.dictionaryhelper.isValidTypeorAspect(classname) == true)
|
||||
classQName = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(className));
|
||||
if(this.dictionaryhelper.isValidTypeorAspect(className) == true)
|
||||
{
|
||||
isAspect = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + classname + " parameter in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " parameter in the URL");
|
||||
}
|
||||
|
||||
// collect the subaspects or subtypes of the class
|
||||
@@ -145,11 +145,11 @@ public class GetSubClassesDef extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
//validate the namespaceprefix parameter
|
||||
if(namespaceprefix != null)
|
||||
if(namespacePrefix != null)
|
||||
{
|
||||
if(this.dictionaryhelper.isValidPrefix(namespaceprefix) == false)
|
||||
if(this.dictionaryhelper.isValidPrefix(namespacePrefix) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespaceprefix + " - parameter in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " - parameter in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,34 +163,35 @@ public class GetSubClassesDef extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
//validate the name parameter
|
||||
if (namespaceprefix == null && name != null)
|
||||
if (namespacePrefix == null && name != null)
|
||||
{
|
||||
namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(this.dictionaryhelper.getPrefixFromModelName(name));
|
||||
}
|
||||
|
||||
if (namespaceprefix != null && name == null)
|
||||
if (namespacePrefix != null && name == null)
|
||||
{
|
||||
namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(namespaceprefix);
|
||||
namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(namespacePrefix);
|
||||
}
|
||||
|
||||
if(namespaceprefix == null && name == null)
|
||||
if(namespacePrefix == null && name == null)
|
||||
{
|
||||
namespaceUri = null;
|
||||
ignoreCheck = true;
|
||||
}
|
||||
|
||||
if (namespaceprefix != null && name != null)
|
||||
if (namespacePrefix != null && name != null)
|
||||
{
|
||||
if(this.dictionaryhelper.isValidClassname(namespaceprefix + "_" + name) == false)
|
||||
if(this.dictionaryhelper.isValidClassname(namespacePrefix + "_" + name) == false)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespaceprefix - " + namespaceprefix + " and name - "+ name + " - parameter in the URL");
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " and name - "+ name + " - parameter in the URL");
|
||||
}
|
||||
namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(namespaceprefix);
|
||||
namespaceUri = this.dictionaryhelper.getNamespaceURIfromPrefix(namespacePrefix);
|
||||
}
|
||||
|
||||
for(QName qnameObj: qname)
|
||||
{
|
||||
if(ignoreCheck || qnameObj.getNamespaceURI().equals(namespaceUri))
|
||||
if((ignoreCheck == true) ||
|
||||
(qnameObj.getNamespaceURI().equals(namespaceUri)))
|
||||
{
|
||||
classdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj));
|
||||
propdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getProperties().values());
|
||||
|
Reference in New Issue
Block a user