mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged DEV/SWIFT to HEAD
27981: SE.S16 Share - Web-tier lightweight data dictionary - WIP of web-tier lightweight data dictionary impl - WebScript to return JSON representation of basic data dictionary (based on existing DD webscripts) - Share tier now retrieves a single DD representation for each Alfresco tenant (on first user request for DD query) - DictionaryQuery script object with the start of a DD query API; isSubType, isAspect, hasProperty etc. - Clean up and improved templates for some of the existing DD webscripts 28014: SE.S16 Share - Web-tier lightweight data dictionary: - Adding more APIs to web-tier DD; isAspect, isType, hasProperty, hasPropertyResolved, getTitle, getDescription, getParent, isContainer - Improvements to remote api json response for dictionary - Code cleanup 28075: SE.S16 Share - Web-tier lightweight data dictionary - Get Property and Get Properties APIs - Some cleanup 28120: SE.S16 Share - Web-tier lightweight data dictionary - Get Default Aspects, Get Associations and Get Child Associations APIs - JavaDoc and code cleanup git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28160 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
<#import "classdetails.lib.ftl" as classdetailsDefLib/>
|
<#import "classdetails.lib.ftl" as classdetailsDefLib/>
|
||||||
<#list classdefs as classdefs>
|
<#list classdefs as classdef>
|
||||||
<@classdetailsDefLib.classDefJSON classdefs=classdefs key = classdefs_index/>
|
<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/><#if classdef_has_next>,</#if>
|
||||||
<#if classdefs_has_next>,</#if>
|
</#list>
|
||||||
</#list>
|
|
@@ -1,105 +1,111 @@
|
|||||||
<#macro classDefJSON classdefs key>
|
<#macro classDefJSON classdef key>
|
||||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
<#local classdefprefix=classdef.name.toPrefixString()?replace(":","_")>
|
||||||
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
<#if classdefs.name?exists>
|
<#if classdef.name??>"name": "${classdef.name.toPrefixString()}",</#if>
|
||||||
"name" : "${classdefs.name.toPrefixString()}",
|
"isAspect": ${classdef.isAspect()?string},
|
||||||
</#if>
|
"isContainer": ${classdef.isContainer()?string},
|
||||||
<#if classdefs.isAspect() == true>
|
"title": "${classdef.title!""}",
|
||||||
"isAspect" : true,
|
"description": "${classdef.description!""}",
|
||||||
<#else>
|
"parent":
|
||||||
"isAspect" : false,
|
{
|
||||||
</#if>
|
<#if classdef.parentName??>
|
||||||
<#if classdefs.title?exists>
|
"name": "${classdef.parentName.toPrefixString()}",
|
||||||
"title" : "${classdefs.title}",
|
"title": "${classdef.parentName.getLocalName()}",
|
||||||
<#else>
|
"url": "/api/classes/${classdef.parentName.toPrefixString()?replace(":","_")}"
|
||||||
"title" : "",
|
</#if>
|
||||||
</#if>
|
|
||||||
<#if classdefs.description?exists>
|
|
||||||
"description" : "${classdefs.description}",
|
|
||||||
<#else>
|
|
||||||
"description" : "",
|
|
||||||
</#if>
|
|
||||||
"parent" : {
|
|
||||||
<#if classdefs.parentName?exists>
|
|
||||||
"name" : "${classdefs.parentName.toPrefixString()}",
|
|
||||||
"title" : "${classdefs.parentName.getLocalName()}",
|
|
||||||
"url" : "${"/api/classes/" + classdefs.parentName.toPrefixString()?replace(":","_")}"
|
|
||||||
</#if>
|
|
||||||
},
|
},
|
||||||
"defaultValues" : {
|
"defaultAspects":
|
||||||
<#if classdefs.defaultValues?exists>
|
{
|
||||||
<#assign keys = classdefs.defaultValues?keys>
|
<#if classdef.defaultAspects??>
|
||||||
<#list keys as key>
|
<#list classdef.defaultAspects as aspectdef>
|
||||||
"${key.toPrefixString()}" : {
|
"${aspectdef.name.toPrefixString()}":
|
||||||
"name" : "${key.toPrefixString()}",
|
{
|
||||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + key.toPrefixString()?replace(":","_")}"
|
"name": "${aspectdef.name.toPrefixString()}",
|
||||||
}<#if key_has_next>,</#if>
|
"title": "${aspectdef.title!""}",
|
||||||
</#list>
|
"url": "/api/classes/${classdefprefix}/property/${aspectdef.name.toPrefixString()?replace(":","_")}"
|
||||||
</#if>
|
}<#if aspectdef_has_next>,</#if>
|
||||||
},
|
|
||||||
"defaultAspects" : {
|
|
||||||
<#if classdefs.defaultAspects?exists>
|
|
||||||
<#list classdefs.defaultAspects as aspectdef>
|
|
||||||
"${aspectdef.name.toPrefixString()}" : {
|
|
||||||
"name" : "${aspectdef.name.toPrefixString()}",
|
|
||||||
<#if aspectdef.title?exists>
|
|
||||||
"title" : "${aspectdef.title}",
|
|
||||||
</#if>
|
|
||||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + aspectdef.name.toPrefixString()?replace(":","_")}"
|
|
||||||
}<#if aspectdef_has_next>,</#if>
|
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
},
|
},
|
||||||
"properties" : {
|
"properties":
|
||||||
<#list propertydefs[key] as propertydefs>
|
{
|
||||||
"${propertydefs.name.toPrefixString()}": {
|
<#list propertydefs[key] as propertydef>
|
||||||
<#if propertydefs.name?exists>
|
"${propertydef.name.toPrefixString()}":
|
||||||
"name" : "${propertydefs.name.toPrefixString()}",
|
{
|
||||||
</#if>
|
"name": "${propertydef.name.toPrefixString()}",
|
||||||
<#if propertydefs.title?exists>
|
"title": "${propertydef.title!""}",
|
||||||
"title" : "${propertydefs.title}",
|
"description": "${propertydef.description!""}",
|
||||||
</#if>
|
"dataType": <#if propertydef.dataType??>"${propertydef.dataType.name.toPrefixString()}"<#else>"<unknown>"</#if>,
|
||||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + propertydefs.name.toPrefixString()?replace(":","_")}"
|
"defaultValue": <#if propertydef.defaultValue??>"${propertydef.defaultValue}"<#else>null</#if>,
|
||||||
}<#if propertydefs_has_next>,</#if>
|
"multiValued": ${propertydef.multiValued?string},
|
||||||
</#list>
|
"mandatory": ${propertydef.mandatory?string},
|
||||||
},
|
"enforced": ${propertydef.mandatoryEnforced?string},
|
||||||
"associations" : {
|
"protected": ${propertydef.protected?string},
|
||||||
<#assign flag = false>
|
"indexed": ${propertydef.indexed?string},
|
||||||
<#list assocdefs[key] as assocdefs>
|
"url": "/api/classes/${classdefprefix}/property/${propertydef.name.toPrefixString()?replace(":","_")}"
|
||||||
<#if (assocdefs.isChild()==false)&&(flag== true)><#assign flag = false>,</#if>
|
}<#if propertydef_has_next>,</#if>
|
||||||
<#if assocdefs.isChild() == false>
|
</#list>
|
||||||
<#assign flag=true>
|
},
|
||||||
"${assocdefs.name.toPrefixString()}": {
|
"associations":
|
||||||
<#if assocdefs.name?exists>
|
{
|
||||||
"name" : "${assocdefs.name.toPrefixString()}",
|
<#assign isfirst=true>
|
||||||
</#if>
|
<#list assocdefs[key] as assocdef>
|
||||||
<#if assocdefs.title?exists>
|
<#if !isfirst && !assocdef.isChild()>,</#if>
|
||||||
"title" : "${assocdefs.title}",
|
<#if !assocdef.isChild()>
|
||||||
</#if>
|
<#assign isfirst=false>
|
||||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
"${assocdef.name.toPrefixString()}":
|
||||||
}
|
{
|
||||||
</#if>
|
"name": "${assocdef.name.toPrefixString()}",
|
||||||
</#list>
|
"title": "${assocdef.title!""}",
|
||||||
},
|
"url": "/api/classes/${classdefprefix}/association/${assocdef.name.toPrefixString()?replace(":","_")}",
|
||||||
"childassociations" : {
|
"source":
|
||||||
<#assign flag = false>
|
{
|
||||||
<#list assocdefs[key] as assocdefs>
|
<#if assocdef.getSourceClass().name??>"class": "${assocdef.getSourceClass().name.toPrefixString()}",</#if>
|
||||||
<#if (assocdefs.isChild()==true)&&(flag== true)><#assign flag = false>,</#if>
|
<#if assocdef.getSourceRoleName()??>"role": "${assocdef.getSourceRoleName().toPrefixString()}",</#if>
|
||||||
<#if assocdefs.isChild() == true>
|
"mandatory": ${assocdef.isSourceMandatory()?string},
|
||||||
<#assign flag=true>
|
"many": ${assocdef.isSourceMany()?string}
|
||||||
"${assocdefs.name.toPrefixString()}": {
|
},
|
||||||
<#if assocdefs.name?exists>
|
"target":
|
||||||
"name" : "${assocdefs.name.toPrefixString()}",
|
{
|
||||||
</#if>
|
<#if assocdef.getTargetClass().name??>"class": "${assocdef.getTargetClass().name.toPrefixString()}",</#if>
|
||||||
<#if assocdefs.title?exists>
|
<#if assocdef.getTargetRoleName()??>"role": "${assocdef.getTargetRoleName().toPrefixString()}",</#if>
|
||||||
"title" : "${assocdefs.title}",
|
"mandatory": ${assocdef.isTargetMandatory()?string},
|
||||||
</#if>
|
"many": ${assocdef.isTargetMany()?string}
|
||||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
}
|
||||||
}
|
}
|
||||||
</#if>
|
</#if>
|
||||||
</#list>
|
</#list>
|
||||||
},
|
},
|
||||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_")}"
|
"childassociations":
|
||||||
}
|
{
|
||||||
</#escape>
|
<#assign isfirst=true>
|
||||||
</#macro>
|
<#list assocdefs[key] as assocdef>
|
||||||
|
<#if !isfirst && assocdef.isChild()>,</#if>
|
||||||
|
<#if assocdef.isChild()>
|
||||||
|
<#assign isfirst=false>
|
||||||
|
"${assocdef.name.toPrefixString()}":
|
||||||
|
{
|
||||||
|
<#if assocdef.name??>"name": "${assocdef.name.toPrefixString()}",</#if>
|
||||||
|
"title": "${assocdef.title!""}",
|
||||||
|
"url": "/api/classes/${classdefprefix}/association/${assocdef.name.toPrefixString()?replace(":","_")}",
|
||||||
|
"source":
|
||||||
|
{
|
||||||
|
<#if assocdef.getSourceClass().name??>"class": "${assocdef.getSourceClass().name.toPrefixString()}",</#if>
|
||||||
|
"mandatory": ${assocdef.isSourceMandatory()?string},
|
||||||
|
"many": ${assocdef.isSourceMany()?string}
|
||||||
|
},
|
||||||
|
"target":
|
||||||
|
{
|
||||||
|
<#if assocdef.getTargetClass().name??>"class": "${assocdef.getTargetClass().name.toPrefixString()}",</#if>
|
||||||
|
"mandatory": ${assocdef.isTargetMandatory()?string},
|
||||||
|
"many": ${assocdef.isTargetMany()?string}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</#if>
|
||||||
|
</#list>
|
||||||
|
},
|
||||||
|
"url": "/api/classes/${classdefprefix}"
|
||||||
|
}
|
||||||
|
</#escape>
|
||||||
|
</#macro>
|
@@ -1,7 +1,6 @@
|
|||||||
<#import "classdetails.lib.ftl" as classdetailsDefLib/>
|
<#import "classdetails.lib.ftl" as classdetailsDefLib/>
|
||||||
[
|
[
|
||||||
<#list classdefs as classdefs>
|
<#list classdefs as classdef>
|
||||||
<@classdetailsDefLib.classDefJSON classdefs=classdefs key = classdefs_index/>
|
<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/><#if classdef_has_next>,</#if>
|
||||||
<#if classdefs_has_next>,</#if>
|
|
||||||
</#list>
|
</#list>
|
||||||
]
|
]
|
@@ -0,0 +1,8 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Get remote dictionary definitions</shortname>
|
||||||
|
<description>Gets all apspect and class definitions that form the dictionary - to enable a lightweight remote dictionary.</description>
|
||||||
|
<url>/api/dictionary</url>
|
||||||
|
<format default="json">argument</format>
|
||||||
|
<authentication>user</authentication>
|
||||||
|
<transaction allow="readonly">required</transaction>
|
||||||
|
</webscript>
|
@@ -0,0 +1,6 @@
|
|||||||
|
<#import "classdetails.lib.ftl" as classdetailsDefLib/>
|
||||||
|
[
|
||||||
|
<#list classdefs as classdef>
|
||||||
|
<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index /><#if classdef_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
]
|
@@ -1,7 +1,7 @@
|
|||||||
<#import "classdetails.lib.ftl" as classdetailsDefLib/>
|
<#import "classdetails.lib.ftl" as classdetailsDefLib/>
|
||||||
[
|
[
|
||||||
<#list classdefs as classdefs>
|
<#list classdefs as classdef>
|
||||||
<@classdetailsDefLib.classDefJSON classdefs=classdefs key = classdefs_index/>
|
<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/>
|
||||||
<#if classdefs_has_next>,</#if>
|
<#if classdef_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
]
|
]
|
@@ -705,12 +705,12 @@
|
|||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- DICTIONARY Service REST API -->
|
<!-- DICTIONARY Service REST API -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
|
||||||
<bean id="webscript.dictionary" abstract="true" parent="webscript" init-method="init">
|
<bean id="webscript.dictionary" abstract="true" parent="webscript" init-method="init">
|
||||||
<property name="dictionaryService" ref="DictionaryService"/>
|
<property name="dictionaryService" ref="DictionaryService"/>
|
||||||
<property name="namespaceService" ref="NamespaceService"/>
|
<property name="namespaceService" ref="NamespaceService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="webscript.org.alfresco.repository.dictionary.classes.get" class="org.alfresco.repo.web.scripts.dictionary.ClassesGet" parent="webscript.dictionary"/>
|
<bean id="webscript.org.alfresco.repository.dictionary.classes.get" class="org.alfresco.repo.web.scripts.dictionary.ClassesGet" parent="webscript.dictionary"/>
|
||||||
<bean id="webscript.org.alfresco.repository.dictionary.class.get" class="org.alfresco.repo.web.scripts.dictionary.ClassGet" parent="webscript.dictionary"/>
|
<bean id="webscript.org.alfresco.repository.dictionary.class.get" class="org.alfresco.repo.web.scripts.dictionary.ClassGet" parent="webscript.dictionary"/>
|
||||||
<bean id="webscript.org.alfresco.repository.dictionary.subclasses.get" class="org.alfresco.repo.web.scripts.dictionary.SubClassesGet" parent="webscript.dictionary"/>
|
<bean id="webscript.org.alfresco.repository.dictionary.subclasses.get" class="org.alfresco.repo.web.scripts.dictionary.SubClassesGet" parent="webscript.dictionary"/>
|
||||||
@@ -718,6 +718,22 @@
|
|||||||
<bean id="webscript.org.alfresco.repository.dictionary.properties.get" class="org.alfresco.repo.web.scripts.dictionary.PropertiesGet" parent="webscript.dictionary"/>
|
<bean id="webscript.org.alfresco.repository.dictionary.properties.get" class="org.alfresco.repo.web.scripts.dictionary.PropertiesGet" parent="webscript.dictionary"/>
|
||||||
<bean id="webscript.org.alfresco.repository.dictionary.association.get" class="org.alfresco.repo.web.scripts.dictionary.AssociationGet" parent="webscript.dictionary"/>
|
<bean id="webscript.org.alfresco.repository.dictionary.association.get" class="org.alfresco.repo.web.scripts.dictionary.AssociationGet" parent="webscript.dictionary"/>
|
||||||
<bean id="webscript.org.alfresco.repository.dictionary.associations.get" class="org.alfresco.repo.web.scripts.dictionary.AssociationsGet" parent="webscript.dictionary"/>
|
<bean id="webscript.org.alfresco.repository.dictionary.associations.get" class="org.alfresco.repo.web.scripts.dictionary.AssociationsGet" parent="webscript.dictionary"/>
|
||||||
|
|
||||||
|
<bean id="webscript.org.alfresco.repository.dictionary.dictionary.get" class="org.alfresco.repo.web.scripts.dictionary.DictionaryGet" parent="webscript.dictionary">
|
||||||
|
<property name="ignoreNamespaces">
|
||||||
|
<set>
|
||||||
|
<value>http://www.alfresco.org/model/dictionary/1.0</value>
|
||||||
|
<value>http://www.alfresco.org/model/wcmmodel/1.0</value>
|
||||||
|
<value>http://www.alfresco.org/model/wcmappmodel/1.0</value>
|
||||||
|
<value>http://www.alfresco.org/model/wcmworkflow/1.0</value>
|
||||||
|
<value>http://www.alfresco.org/model/rendition/1.0</value>
|
||||||
|
<value>http://www.alfresco.org/model/versionstore/1.0</value>
|
||||||
|
<value>http://www.alfresco.org/model/versionstore/2.0</value>
|
||||||
|
<value>http://www.jcp.org/jcr/1.0</value>
|
||||||
|
</set>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<!-- GET IMAP SERVER STATUS -->
|
<!-- GET IMAP SERVER STATUS -->
|
||||||
<bean id="webscript.org.alfresco.repository.imap.imap-enabled.get" class="org.alfresco.repo.imap.scripts.ServerStatusWebScript" parent="webscript">
|
<bean id="webscript.org.alfresco.repository.imap.imap-enabled.get" class="org.alfresco.repo.imap.scripts.ServerStatusWebScript" parent="webscript">
|
||||||
|
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco 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 Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.web.scripts.dictionary;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WebScript implementation to retrieve a complete dictionary required to implement
|
||||||
|
* a lightweight remote web-tier dictionary.
|
||||||
|
*
|
||||||
|
* @author Kevin Roast
|
||||||
|
*/
|
||||||
|
public class DictionaryGet extends DictionaryWebServiceBase
|
||||||
|
{
|
||||||
|
private static final String MODEL_CLASS_DEFS = "classdefs";
|
||||||
|
private static final String MODEL_PROPERTY_DEFS = "propertydefs";
|
||||||
|
private static final String MODEL_ASSOCIATION_DEFS = "assocdefs";
|
||||||
|
|
||||||
|
/** Set of model namespaces to ignore when outputing dictionary classes and aspects */
|
||||||
|
private Set<String> ignoreNamespaces = Collections.<String>emptySet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of model namespaces to ignore when outputing dictionary classes and aspects
|
||||||
|
*
|
||||||
|
* @param namespaces Set of model namespaces to ignore
|
||||||
|
*/
|
||||||
|
public void setIgnoreNamespaces(Set<String> namespaces)
|
||||||
|
{
|
||||||
|
this.ignoreNamespaces = namespaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the webscript
|
||||||
|
*
|
||||||
|
* @param req WebScriptRequest
|
||||||
|
* @param status Status
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
|
||||||
|
{
|
||||||
|
List<QName> qnames = new ArrayList<QName>(256);
|
||||||
|
Set<String> namespaces = new HashSet<String>();
|
||||||
|
Map<QName, ClassDefinition> classdef = new HashMap<QName, ClassDefinition>();
|
||||||
|
Map<QName, Collection<PropertyDefinition>> propdef = new HashMap<QName, Collection<PropertyDefinition>>();
|
||||||
|
Map<QName, Collection<AssociationDefinition>> assocdef = new HashMap<QName, Collection<AssociationDefinition>>();
|
||||||
|
|
||||||
|
// check configured list of model namespaces to ignore i.e. wcm
|
||||||
|
for (String ns : this.namespaceService.getURIs())
|
||||||
|
{
|
||||||
|
if (!ignoreNamespaces.contains(ns))
|
||||||
|
{
|
||||||
|
namespaces.add(ns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// walk the models and extract the aspects and types
|
||||||
|
for (QName qname : this.dictionaryservice.getAllModels())
|
||||||
|
{
|
||||||
|
if (namespaces.contains(qname.getNamespaceURI()))
|
||||||
|
{
|
||||||
|
qnames.addAll(this.dictionaryservice.getAspects(qname));
|
||||||
|
qnames.addAll(this.dictionaryservice.getTypes(qname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// get the class definitions and the properties and associations
|
||||||
|
for (QName qname : qnames)
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
|
model.put(MODEL_CLASS_DEFS, classdef.values());
|
||||||
|
model.put(MODEL_PROPERTY_DEFS, propdef.values());
|
||||||
|
model.put(MODEL_ASSOCIATION_DEFS, assocdef.values());
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -30,14 +30,14 @@ import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
|||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Base class for Dictionary web scripts
|
* Base class for Dictionary web scripts
|
||||||
*
|
*
|
||||||
* @author Saravanan Sellathurai
|
* @author Saravanan Sellathurai
|
||||||
*/
|
*/
|
||||||
public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||||
{
|
{
|
||||||
private static final String NAME_DELIMITER = "_";
|
private static final String NAME_DELIMITER = "_";
|
||||||
|
|
||||||
private Map<String, String> prefixesAndUrlsMap;
|
private Map<String, String> prefixesAndUrlsMap;
|
||||||
private Map<String, String> urlsAndPrefixesMap;
|
private Map<String, String> urlsAndPrefixesMap;
|
||||||
@@ -56,6 +56,7 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
private static final String ASSOCIATION_FILTER_OPTION_TYPE2 = "general";
|
private static final String ASSOCIATION_FILTER_OPTION_TYPE2 = "general";
|
||||||
private static final String ASSOCIATION_FILTER_OPTION_TYPE3 = "child";
|
private static final String ASSOCIATION_FILTER_OPTION_TYPE3 = "child";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the namespaceService property.
|
* Set the namespaceService property.
|
||||||
*
|
*
|
||||||
@@ -63,7 +64,7 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
*/
|
*/
|
||||||
public void setNamespaceService(NamespaceService namespaceservice)
|
public void setNamespaceService(NamespaceService namespaceservice)
|
||||||
{
|
{
|
||||||
this.namespaceService = namespaceservice;
|
this.namespaceService = namespaceservice;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,17 +118,15 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param qname
|
* @param qname
|
||||||
* @return the namespaceuri from a qname
|
* @return the namespaceuri from a qname
|
||||||
*/
|
*/
|
||||||
public String getNamespaceURIfromQname(QName qname)
|
public String getNamespaceURIfromQname(QName qname)
|
||||||
{
|
{
|
||||||
return qname.getNamespaceURI();
|
return qname.getNamespaceURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param className the class name as cm_person
|
* @param className the class name as cm_person
|
||||||
* @return String the full name in the following format {namespaceuri}shorname
|
* @return String the full name in the following format {namespaceuri}shorname
|
||||||
*/
|
*/
|
||||||
@@ -142,14 +141,13 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
result = "{" + url + "}"+ name;
|
result = "{" + url + "}"+ name;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact classname - " + classname + " 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param classname - checks whether the classname is valid , gets the classname as input e.g cm_person
|
* @param classname - checks whether the classname is valid , gets the classname as input e.g cm_person
|
||||||
* @return true - if the class is valid , false - if the class is invalid
|
* @return true - if the class is valid , false - if the class is invalid
|
||||||
*/
|
*/
|
||||||
@@ -159,13 +157,9 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
qname = QName.createQName(this.getFullNamespaceURI(classname));
|
qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||||
if (//(isValidPrefix(getPrefix(classname)) == true) &&
|
return (dictionaryservice.getClass(qname) != null);
|
||||||
dictionaryservice.getClass(qname) != null)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(InvalidQNameException e)
|
catch (InvalidQNameException e)
|
||||||
{
|
{
|
||||||
//just ignore
|
//just ignore
|
||||||
}
|
}
|
||||||
@@ -173,26 +167,6 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param prefix - checks whether the prefix is a valid one
|
|
||||||
* @return true if the prefix is valid or false
|
|
||||||
*/
|
|
||||||
// public boolean isValidPrefix(String prefix)
|
|
||||||
// {
|
|
||||||
// this.namespaceservice.
|
|
||||||
//
|
|
||||||
// if(this.prefixes.contains(prefix) == true)
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param namespaceprefix - gets a valid namespaceprefix as input
|
* @param namespaceprefix - gets a valid namespaceprefix as input
|
||||||
* @return modelname from namespaceprefix - returns null if invalid namespaceprefix is given
|
* @return modelname from namespaceprefix - returns null if invalid namespaceprefix is given
|
||||||
*/
|
*/
|
||||||
@@ -212,20 +186,12 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
|
|
||||||
public boolean isValidAssociationFilter(String af)
|
public boolean isValidAssociationFilter(String af)
|
||||||
{
|
{
|
||||||
if(af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE1) ||
|
return (af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE1) ||
|
||||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE2) ||
|
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE2) ||
|
||||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE3))
|
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE3));
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param classname as the input
|
* @param classname as the input
|
||||||
* @return true if it is a aspect or false if it is a Type
|
* @return true if it is a aspect or false if it is a Type
|
||||||
*/
|
*/
|
||||||
@@ -234,34 +200,26 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
QName qname = QName.createQName(this.getFullNamespaceURI(classname));
|
QName qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||||
if( (this.dictionaryservice.getClass(qname)!=null) &&
|
return ((this.dictionaryservice.getClass(qname) != null) &&
|
||||||
(this.dictionaryservice.getClass(qname).isAspect() == true))
|
(this.dictionaryservice.getClass(qname).isAspect()));
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(InvalidQNameException e)
|
catch (InvalidQNameException e)
|
||||||
{
|
{
|
||||||
//ignore
|
// ignore
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param modelname - gets the modelname as the input (modelname is without prefix ie. cm:contentmodel => where modelname = contentmodel)
|
* @param modelname - gets the modelname as the input (modelname is without prefix ie. cm:contentmodel => where modelname = contentmodel)
|
||||||
* @return true if valid or false
|
* @return true if valid or false
|
||||||
*/
|
*/
|
||||||
public boolean isValidModelName(String modelname)
|
public boolean isValidModelName(String modelname)
|
||||||
{
|
{
|
||||||
boolean value = false;
|
boolean value = false;
|
||||||
for(QName qnameObj:this.dictionaryservice.getAllModels())
|
for (QName qnameObj:this.dictionaryservice.getAllModels())
|
||||||
{
|
{
|
||||||
if(qnameObj.getLocalName().equalsIgnoreCase(modelname))
|
if (qnameObj.getLocalName().equalsIgnoreCase(modelname))
|
||||||
{
|
{
|
||||||
value = true;
|
value = true;
|
||||||
break;
|
break;
|
||||||
@@ -269,8 +227,8 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param classname - returns the prefix from the classname of the format namespaceprefix:name eg. cm_person
|
* @param classname - returns the prefix from the classname of the format namespaceprefix:name eg. cm_person
|
||||||
* @return prefix - returns the prefix of the classname
|
* @return prefix - returns the prefix of the classname
|
||||||
*/
|
*/
|
||||||
@@ -303,12 +261,11 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param input -gets a string input and validates it
|
* @param input -gets a string input and validates it
|
||||||
*
|
|
||||||
* @return null if invalid or the string itself if its valid
|
* @return null if invalid or the string itself if its valid
|
||||||
*/
|
*/
|
||||||
public String getValidInput(String input)
|
public String getValidInput(String input)
|
||||||
{
|
{
|
||||||
if((input != null) && (input.length() > 0))
|
if ((input != null) && (input.length() != 0))
|
||||||
{
|
{
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
@@ -319,26 +276,17 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param classfilter =>valid class filters are all,apect or type
|
* @param classfilter =>valid class filters are all,apect or type
|
||||||
* @return true if valid or false if invalid
|
* @return true if valid or false if invalid
|
||||||
*/
|
*/
|
||||||
public boolean isValidClassFilter(String classfilter)
|
public boolean isValidClassFilter(String classfilter)
|
||||||
{
|
{
|
||||||
if(classfilter.equals(CLASS_FILTER_OPTION_TYPE1) ||
|
return (classfilter.equals(CLASS_FILTER_OPTION_TYPE1) ||
|
||||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE2) ||
|
classfilter.equals(CLASS_FILTER_OPTION_TYPE2) ||
|
||||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE3))
|
classfilter.equals(CLASS_FILTER_OPTION_TYPE3));
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param
|
|
||||||
* @return a string map or prefixes and urls - with prefix as the key
|
* @return a string map or prefixes and urls - with prefix as the key
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getPrefixesAndUrlsMap()
|
public Map<String, String> getPrefixesAndUrlsMap()
|
||||||
@@ -347,8 +295,7 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return 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()
|
public Map<String, String> getUrlsAndPrefixesMap()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user