mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
First iteration of Dictionaryservice REST API - readonly webscripts for dictionaryservice
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11656 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<#macro assocDefJSON assocdefs>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
<#if assocdefs.name?exists>
|
||||
"name" : "${assocdefs.name}",
|
||||
</#if>
|
||||
<#if assocdefs.title?exists>
|
||||
"title" : "${assocdefs.title}",
|
||||
</#if>
|
||||
<#if assocdefs.description?exists>
|
||||
"description" : "${assocdefs.description}",
|
||||
</#if>
|
||||
<#if assocdefs.isChild() == true>
|
||||
"isChild" : true,
|
||||
<#else>
|
||||
"isChild" : false,
|
||||
</#if>
|
||||
<#if assocdefs.isProtected() == true>
|
||||
"protected" : true,
|
||||
<#else>
|
||||
"protected" : false,
|
||||
</#if>
|
||||
"source" :
|
||||
{
|
||||
"class" : "${assocdefs.getSourceClass().name}",
|
||||
"isSourceMandatory" : ${assocdefs.isSourceMandatory()?string},
|
||||
"isSourceMany" : ${assocdefs.isSourceMany()?string}
|
||||
},
|
||||
"target" :
|
||||
{
|
||||
"class" : "${assocdefs.getTargetClass()}",
|
||||
"isTargetMandatory" : ${assocdefs.isTargetMandatory()?string},
|
||||
"isTargetMany" : ${assocdefs.isTargetMany()?string}
|
||||
},
|
||||
"url" : "${url.serviceContext + "/api/classes" + assocdefs.name}"
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
@@ -0,0 +1,46 @@
|
||||
<#import "propertydefinition.lib.ftl" as propertyDefLib/>
|
||||
<#import "assocdefinition.lib.ftl" as assocDefLib/>
|
||||
<#macro classDefJSON classdefs>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
<#if classdefs.name?exists>
|
||||
"name" : "${classdefs.name}",
|
||||
</#if>
|
||||
<#if classdefs.isAspect() == true>
|
||||
"isAspect" : true,
|
||||
<#else>
|
||||
"isAspect" : false,
|
||||
</#if>
|
||||
<#if classdefs.title?exists>
|
||||
"title" : "${classdefs.title}",
|
||||
</#if>
|
||||
<#if classdefs.description?exists>
|
||||
"description" : "${classdefs.description}",
|
||||
</#if>
|
||||
"properties" :
|
||||
[
|
||||
<#list propertydefs as propertydefs>
|
||||
<@propertyDefLib.propertyDefJSON propertydefs=propertydefs/>
|
||||
<#if propertydefs_has_next>,</#if>
|
||||
</#list>
|
||||
],
|
||||
"associations" :
|
||||
[
|
||||
<#list assocdefs as assocdefs>
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
||||
<#if assocdefs_has_next>,</#if>
|
||||
</#list>
|
||||
],
|
||||
"childassociations" :
|
||||
[
|
||||
<#list assocdefs as assocdefs>
|
||||
<#if assocdefs.isChild() == true>
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
||||
<#if assocdefs_has_next>,</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
],
|
||||
"url" : "${url.serviceContext + "/api/classes" + classdefs.name}"
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
@@ -0,0 +1,18 @@
|
||||
<#macro classDefJSON classdefs>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
<#if classdefs.name?exists>
|
||||
"name" : "${classdefs.name}",
|
||||
</#if>
|
||||
<#if classdefs.title?exists>
|
||||
"title" : "${classdefs.title}",
|
||||
</#if>
|
||||
<#if classdefs.description?exists>
|
||||
"description" : "${classdefs.description}",
|
||||
</#if>
|
||||
<#if classdefs.isAspect?exists>
|
||||
"isAspect" : "it does exist"
|
||||
</#if>
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Association Definitions</shortname>
|
||||
<description>Get the collection of association definitions</description>
|
||||
<url>/api/classes/{classname}/association/{assocname}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,3 @@
|
||||
<#import "assocdefinition.lib.ftl" as assocDefLib/>
|
||||
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Association Definitions</shortname>
|
||||
<description>Get the collection of association definitions for a given classname </description>
|
||||
<url>/api/classes/{classname}/associations</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,9 @@
|
||||
<#import "assocdefinition.lib.ftl" as assocDefLib/>
|
||||
[
|
||||
<#list assocdefs as assocdefs>
|
||||
<#if assocdefs.isChild() == false>
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
||||
<#if assocdefs_has_next>,</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
]
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Child Association Definitions</shortname>
|
||||
<description>Get the collection of child association definitions</description>
|
||||
<url>/api/classes/{classname}/childassociation/{assocname}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,3 @@
|
||||
<#import "assocdefinition.lib.ftl" as assocDefLib/>
|
||||
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Child Assocation Definitions</shortname>
|
||||
<description>Get the collection of child association definitions for a given classname</description>
|
||||
<url>/api/classes/{classname}/childassociations</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,9 @@
|
||||
<#import "assocdefinition.lib.ftl" as assocDefLib/>
|
||||
[
|
||||
<#list assocdefs as assocdefs>
|
||||
<#if assocdefs.isChild() == true>
|
||||
<@assocDefLib.assocDefJSON assocdefs=assocdefs/>
|
||||
<#if assocdefs_has_next>,</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
]
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Class Definitions</shortname>
|
||||
<description>Get the collection of class definitions </description>
|
||||
<url>/api/classes?cf={classFilter?}&nsp={namespacePrefix?}&n={name?}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,4 @@
|
||||
<#import "definitions.lib.ftl" as classDefLib/>
|
||||
|
||||
<@classDefLib.classDefJSON classdefs=classdefs/>
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Class Definitions</shortname>
|
||||
<description>Get the collection of class definitions for a given classname</description>
|
||||
<url>/api/classes/{className}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,4 @@
|
||||
<#import "classdetails.lib.ftl" as classdetailsDefLib/>
|
||||
|
||||
<@classdetailsDefLib.classDefJSON classdefs=classdefs/>
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Property Definitions</shortname>
|
||||
<description>Get the collection of property definitions</description>
|
||||
<url>/api/classes/{classname}/properties</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,7 @@
|
||||
<#import "propertydefinition.lib.ftl" as propertyDefLib/>
|
||||
[
|
||||
<#list propertydefs as propertydefs>
|
||||
<@propertyDefLib.propertyDefJSON propertydefs=propertydefs/>
|
||||
<#if propertydefs_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Property Definitions</shortname>
|
||||
<description>Get the collection of property definitions for a given classname and property name</description>
|
||||
<url>/api/classes/{classname}/property/{propname}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,3 @@
|
||||
<#import "propertydefinition.lib.ftl" as propertyDefLib/>
|
||||
|
||||
<@propertyDefLib.propertyDefJSON propertydefs=propertydefs/>
|
@@ -0,0 +1,38 @@
|
||||
<#macro propertyDefJSON propertydefs>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
<#if propertydefs.name?exists>
|
||||
"name" : "${propertydefs.name}",
|
||||
</#if>
|
||||
<#if propertydefs.title?exists>
|
||||
"title" : "${propertydefs.title}",
|
||||
</#if>
|
||||
<#if propertydefs.description?exists>
|
||||
"description" : "${propertydefs.description}",
|
||||
</#if>
|
||||
<#if propertydefs.defaultValues?exists>
|
||||
"defaultValues" : "${propertydefs.defaultValues}",
|
||||
<#else>
|
||||
"defaultValues" : "",
|
||||
</#if>
|
||||
<#if propertydefs.dataType?exists>
|
||||
"dataType" : "${propertydefs.dataType.title}",
|
||||
</#if>
|
||||
"multiValued" : "${propertydefs.multiValued?string}",
|
||||
"mandatory" : "${propertydefs.mandatory?string}",
|
||||
"enforced" : "${propertydefs.mandatoryEnforced?string}",
|
||||
"protected" : "${propertydefs.protected?string}",
|
||||
"indexed" : "${propertydefs.indexed?string}",
|
||||
"indexedAtomically" : "${propertydefs.indexedAtomically?string}",
|
||||
"constraints" :
|
||||
[
|
||||
<#if propertydefs.constraints?exists>
|
||||
<#list propertydefs.constraints as constraintdefs>
|
||||
"name" : "${constraintdefs.name}"
|
||||
</#list>
|
||||
</#if>
|
||||
],
|
||||
"url" : "${url.serviceContext + "/api/classes" + propertydefs.name}"
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* Helper class for Dictionary Service webscripts
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class DictionaryHelper
|
||||
{
|
||||
private static final String NAME_DELIMITER = "_";
|
||||
private NamespaceService namespaceservice;
|
||||
private Map<String, String> prefixesAndUrlsMap;
|
||||
private Map<String, String> urlsAndPrefixesMap;
|
||||
private Collection<String> prefixes;
|
||||
|
||||
/**
|
||||
* Set the namespaceService property.
|
||||
*
|
||||
* @param namespaceService The namespace service instance to set
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceservice)
|
||||
{
|
||||
this.namespaceservice = namespaceservice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method.
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
this.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);
|
||||
this.prefixesAndUrlsMap.put(prefix, url);
|
||||
this.urlsAndPrefixesMap.put(url, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param className the class name as cm_person
|
||||
* @return String the full name in the following format {namespaceuri}shorname
|
||||
*/
|
||||
public String getFullNamespaceURI(String classname)
|
||||
{
|
||||
String result = null;
|
||||
String prefix = this.getPrefix(classname);
|
||||
String url = this.prefixesAndUrlsMap.get(prefix);
|
||||
String name = this.getShortName(classname);
|
||||
result = "{" + url + "}"+ name;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* checks whether the classname (eg.cm_author) is a valid one
|
||||
*/
|
||||
public boolean isValidClassname(String classname)
|
||||
{
|
||||
boolean result = false;
|
||||
if(this.isValidPrefix(this.getPrefix(classname))) result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* checks whether the prefix is a valid one
|
||||
*/
|
||||
public boolean isValidPrefix(String prefix)
|
||||
{
|
||||
boolean result = false;
|
||||
if(this.prefixes.contains(prefix)) result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* returns the prefix from the classname of the format cm_person
|
||||
* here cm represents the prefix
|
||||
*/
|
||||
public String getPrefix(String classname)
|
||||
{
|
||||
String prefix = null;
|
||||
int index = classname.indexOf(NAME_DELIMITER);
|
||||
if (index > 0)
|
||||
{
|
||||
prefix = classname.substring(0, index);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the shortname from the classname of the format cm_person
|
||||
* here person represents the shortname
|
||||
*/
|
||||
public String getShortName(String classname)
|
||||
{
|
||||
String shortname = null;
|
||||
int index = classname.indexOf(NAME_DELIMITER);
|
||||
if (index > 0)
|
||||
{
|
||||
shortname = classname.substring(index+1);
|
||||
}
|
||||
return shortname;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns a string map or prefixes and urls - with prefix as the key
|
||||
*/
|
||||
public Map<String, String> prefixesAndUrlsMap()
|
||||
{
|
||||
return prefixesAndUrlsMap;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns a string map of urls and prefixes - with url as the key
|
||||
*/
|
||||
public Map<String, String> urlsAndPrefixesMap()
|
||||
{
|
||||
return urlsAndPrefixesMap;
|
||||
}
|
||||
}
|
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||
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;
|
||||
|
||||
/*
|
||||
* Unit Test for Dictionaryervice
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class DictionaryServiceTest extends BaseWebScriptTest
|
||||
{
|
||||
private static final String URL_SITES = "/api/classes";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
}
|
||||
//TODO individual check of all elements
|
||||
public void testGetPropertyDef() throws Exception
|
||||
{
|
||||
Response response = sendRequest(new GetRequest("/api/classes/cm_auditable/property/cm_created"), 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
assertEquals("{http://www.alfresco.org/model/content/1.0}created", result.get("name"));
|
||||
assertEquals("Created Date", result.get("title"));
|
||||
assertEquals("Created Date", result.get("description"));
|
||||
assertEquals("Date and Time", result.get("dataType"));
|
||||
assertEquals("false", result.get("multiValued"));
|
||||
assertEquals("true", result.get("mandatory"));
|
||||
assertEquals("true", result.get("enforced"));
|
||||
assertEquals("true", result.get("protected"));
|
||||
assertEquals("true", result.get("indexed"));
|
||||
assertEquals("true", result.get("indexedAtomically"));
|
||||
response = sendRequest(new GetRequest("/api/classes/cm_hi/property/cm_welcome"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
|
||||
}
|
||||
|
||||
//TODO individual check of all elements
|
||||
public void testGetPropertyDefs() throws Exception
|
||||
{
|
||||
Response response = sendRequest(new GetRequest("/api/classes/cm_auditable/properties"), 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
response = sendRequest(new GetRequest("/api/classes/cm_welcome/properties"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
}
|
||||
|
||||
//TODO individual check of all elements
|
||||
public void testGetClassDetail() throws Exception
|
||||
{
|
||||
GetRequest req = new GetRequest(URL_SITES + "/cm_auditable");
|
||||
Response response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
response = sendRequest(new GetRequest("/api/classes/cmsara_hi"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
}
|
||||
|
||||
//TODO individual check of all elements
|
||||
public void testGetAssociatoinDef() throws Exception
|
||||
{
|
||||
GetRequest req = new GetRequest(URL_SITES + "/cm_person/association/cm_avatar");
|
||||
Response response = sendRequest(req, 200);
|
||||
JSONObject result = new JSONObject(response.getContentAsString());
|
||||
assertEquals("{http://www.alfresco.org/model/content/1.0}avatar", result.get("name"));
|
||||
assertEquals(false, result.get("isChild"));
|
||||
assertEquals(false, result.get("protected"));
|
||||
assertEquals(200,response.getStatus());
|
||||
response = sendRequest(new GetRequest(URL_SITES +"/cm_personalbe/association/cms_avatarsara"), 404);
|
||||
assertEquals(404,response.getStatus());
|
||||
}
|
||||
|
||||
//TODO individual check of all elements
|
||||
public void testGetAssociatoinDefs() throws Exception
|
||||
{
|
||||
GetRequest req = new GetRequest(URL_SITES + "/cm_person/associations");
|
||||
Response response = sendRequest(req, 200);
|
||||
assertEquals(200,response.getStatus());
|
||||
response = sendRequest(new GetRequest(URL_SITES +"/cmsa_personalbe/associations"), 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);
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Webscript to get the Associationdefinition for a given classname and association-name
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class GetAssociationDef extends DeclarativeWebScript
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
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
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
{
|
||||
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);
|
||||
|
||||
if(classnameGiven && assocnameGiven)
|
||||
{
|
||||
classqname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
assocqname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(assocname));
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(classqname);
|
||||
|
||||
if(this.classdefinition != 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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Webscript to get the Associationdefinitions for a given classname
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class GetAssociationDefs extends DeclarativeWebScript
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
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 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)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName classqname = null;
|
||||
boolean classnameGiven = (classname != null) && (classname.length() > 0);
|
||||
|
||||
if(classnameGiven)
|
||||
{
|
||||
classqname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(classqname);
|
||||
|
||||
if(this.classdefinition != null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.classdefinition.getAssociations().values());
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Webscript to get the ChildAssociationdefinitions for a given classname and child-association-name
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class GetChildAssociationDef extends DeclarativeWebScript
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs";
|
||||
private static final String DICTIONARY_ASSOCIATION_NAME = "assocname";
|
||||
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
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
{
|
||||
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);
|
||||
|
||||
if(classnameGiven && assocnameGiven)
|
||||
{
|
||||
classqname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
assocqname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(assocname));
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(classqname);
|
||||
|
||||
if(this.classdefinition != null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.classdefinition.getChildAssociations().get(assocqname));
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
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;
|
||||
|
||||
public class GetChildAssociationDefs extends DeclarativeWebScript{
|
||||
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
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 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)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName classqname = null;
|
||||
boolean classnameGiven = (classname != null) && (classname.length() > 0);
|
||||
|
||||
if(classnameGiven){
|
||||
classqname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(classqname);
|
||||
if(this.classdefinition != null){
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.classdefinition.getChildAssociations().values());
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Webscript to get the Classdefinitions using classfilter , namespaceprefix and name
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class GetClassDetail extends DeclarativeWebScript
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
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";
|
||||
private static final String REQ_URL_TEMPL_VAR_CLASS_FILTER = "cf";
|
||||
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)
|
||||
{
|
||||
String classfilter = req.getParameter(REQ_URL_TEMPL_VAR_CLASS_FILTER);
|
||||
String namespaceprefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
|
||||
String name = req.getParameter(REQ_URL_TEMPL_VAR_NAME);
|
||||
String classname = null;
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName qname = null;
|
||||
boolean cfGiven = (classfilter != null) && (classfilter.length() > 0);
|
||||
boolean nspGiven = (namespaceprefix != null) && (namespaceprefix.length() > 0);
|
||||
boolean nameGiven = (name != null) && (name.length() > 0);
|
||||
|
||||
if(cfGiven && nspGiven && nameGiven)
|
||||
{
|
||||
classname = namespaceprefix + "_" + name;
|
||||
qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(qname);
|
||||
|
||||
if(this.classdefinition != null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_CLASS_DEFS, this.classdefinition);
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Webscript to get the Classdefinitions for a classname eg. =>cm_author
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class GetClassDetails extends DeclarativeWebScript
|
||||
{
|
||||
|
||||
private DictionaryService dictionaryservice;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
private ClassDefinition classdefinition;
|
||||
|
||||
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
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName qname = null;
|
||||
boolean classnameGiven = (classname != null) && (classname.length() > 0);
|
||||
|
||||
if(classnameGiven)
|
||||
{
|
||||
qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
}
|
||||
|
||||
classdefinition = this.dictionaryservice.getClass(qname);
|
||||
if(this.classdefinition != null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_CLASS_DETAILS, this.classdefinition);
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.classdefinition.getProperties().values());
|
||||
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.classdefinition.getAssociations().values());
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Webscript to get the Propertydefinition for a given classname and propname
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class GetPropertyDef extends DeclarativeWebScript
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
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
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
{
|
||||
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);
|
||||
|
||||
if(classnameGiven && propertynameGiven)
|
||||
{
|
||||
qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
propname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(propertyname));
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(qname);
|
||||
|
||||
if(this.classdefinition != 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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.dictionary;
|
||||
|
||||
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;
|
||||
|
||||
/*
|
||||
* Webscript to get the Propertydefinitions for a given classname eg. =>cm_person
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
|
||||
public class GetPropertyDefs extends DeclarativeWebScript
|
||||
{
|
||||
private DictionaryService dictionaryservice;
|
||||
private ClassDefinition classdefinition;
|
||||
private DictionaryHelper dictionaryhelper;
|
||||
|
||||
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
|
||||
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
|
||||
*/
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||
{
|
||||
String classname = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
QName qname = null;
|
||||
boolean classnameGiven = (classname != null) && (classname.length() > 0);
|
||||
|
||||
if(classnameGiven)
|
||||
{
|
||||
qname = QName.createQName(this.dictionaryhelper.getFullNamespaceURI(classname));
|
||||
}
|
||||
classdefinition = this.dictionaryservice.getClass(qname);
|
||||
if(this.classdefinition != null)
|
||||
{
|
||||
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, this.classdefinition.getProperties().values());
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact parameter has not been provided in the URL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user