mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +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/>
|
||||
<#list classdefs as classdefs>
|
||||
<@classdetailsDefLib.classDefJSON classdefs=classdefs key = classdefs_index/>
|
||||
<#if classdefs_has_next>,</#if>
|
||||
</#list>
|
||||
<#list classdefs as classdef>
|
||||
<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/><#if classdef_has_next>,</#if>
|
||||
</#list>
|
@@ -1,105 +1,111 @@
|
||||
<#macro classDefJSON classdefs key>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
<#macro classDefJSON classdef key>
|
||||
<#local classdefprefix=classdef.name.toPrefixString()?replace(":","_")>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
<#if classdefs.name?exists>
|
||||
"name" : "${classdefs.name.toPrefixString()}",
|
||||
</#if>
|
||||
<#if classdefs.isAspect() == true>
|
||||
"isAspect" : true,
|
||||
<#else>
|
||||
"isAspect" : false,
|
||||
</#if>
|
||||
<#if classdefs.title?exists>
|
||||
"title" : "${classdefs.title}",
|
||||
<#else>
|
||||
"title" : "",
|
||||
</#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>
|
||||
<#if classdef.name??>"name": "${classdef.name.toPrefixString()}",</#if>
|
||||
"isAspect": ${classdef.isAspect()?string},
|
||||
"isContainer": ${classdef.isContainer()?string},
|
||||
"title": "${classdef.title!""}",
|
||||
"description": "${classdef.description!""}",
|
||||
"parent":
|
||||
{
|
||||
<#if classdef.parentName??>
|
||||
"name": "${classdef.parentName.toPrefixString()}",
|
||||
"title": "${classdef.parentName.getLocalName()}",
|
||||
"url": "/api/classes/${classdef.parentName.toPrefixString()?replace(":","_")}"
|
||||
</#if>
|
||||
},
|
||||
"defaultValues" : {
|
||||
<#if classdefs.defaultValues?exists>
|
||||
<#assign keys = classdefs.defaultValues?keys>
|
||||
<#list keys as key>
|
||||
"${key.toPrefixString()}" : {
|
||||
"name" : "${key.toPrefixString()}",
|
||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + key.toPrefixString()?replace(":","_")}"
|
||||
}<#if key_has_next>,</#if>
|
||||
</#list>
|
||||
</#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>
|
||||
"defaultAspects":
|
||||
{
|
||||
<#if classdef.defaultAspects??>
|
||||
<#list classdef.defaultAspects as aspectdef>
|
||||
"${aspectdef.name.toPrefixString()}":
|
||||
{
|
||||
"name": "${aspectdef.name.toPrefixString()}",
|
||||
"title": "${aspectdef.title!""}",
|
||||
"url": "/api/classes/${classdefprefix}/property/${aspectdef.name.toPrefixString()?replace(":","_")}"
|
||||
}<#if aspectdef_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
</#if>
|
||||
},
|
||||
"properties" : {
|
||||
<#list propertydefs[key] as propertydefs>
|
||||
"${propertydefs.name.toPrefixString()}": {
|
||||
<#if propertydefs.name?exists>
|
||||
"name" : "${propertydefs.name.toPrefixString()}",
|
||||
</#if>
|
||||
<#if propertydefs.title?exists>
|
||||
"title" : "${propertydefs.title}",
|
||||
</#if>
|
||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + propertydefs.name.toPrefixString()?replace(":","_")}"
|
||||
}<#if propertydefs_has_next>,</#if>
|
||||
</#list>
|
||||
},
|
||||
"associations" : {
|
||||
<#assign flag = false>
|
||||
<#list assocdefs[key] as assocdefs>
|
||||
<#if (assocdefs.isChild()==false)&&(flag== true)><#assign flag = false>,</#if>
|
||||
<#if assocdefs.isChild() == false>
|
||||
<#assign flag=true>
|
||||
"${assocdefs.name.toPrefixString()}": {
|
||||
<#if assocdefs.name?exists>
|
||||
"name" : "${assocdefs.name.toPrefixString()}",
|
||||
</#if>
|
||||
<#if assocdefs.title?exists>
|
||||
"title" : "${assocdefs.title}",
|
||||
</#if>
|
||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
},
|
||||
"childassociations" : {
|
||||
<#assign flag = false>
|
||||
<#list assocdefs[key] as assocdefs>
|
||||
<#if (assocdefs.isChild()==true)&&(flag== true)><#assign flag = false>,</#if>
|
||||
<#if assocdefs.isChild() == true>
|
||||
<#assign flag=true>
|
||||
"${assocdefs.name.toPrefixString()}": {
|
||||
<#if assocdefs.name?exists>
|
||||
"name" : "${assocdefs.name.toPrefixString()}",
|
||||
</#if>
|
||||
<#if assocdefs.title?exists>
|
||||
"title" : "${assocdefs.title}",
|
||||
</#if>
|
||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}"
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
},
|
||||
"url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_")}"
|
||||
}
|
||||
</#escape>
|
||||
</#macro>
|
||||
"properties":
|
||||
{
|
||||
<#list propertydefs[key] as propertydef>
|
||||
"${propertydef.name.toPrefixString()}":
|
||||
{
|
||||
"name": "${propertydef.name.toPrefixString()}",
|
||||
"title": "${propertydef.title!""}",
|
||||
"description": "${propertydef.description!""}",
|
||||
"dataType": <#if propertydef.dataType??>"${propertydef.dataType.name.toPrefixString()}"<#else>"<unknown>"</#if>,
|
||||
"defaultValue": <#if propertydef.defaultValue??>"${propertydef.defaultValue}"<#else>null</#if>,
|
||||
"multiValued": ${propertydef.multiValued?string},
|
||||
"mandatory": ${propertydef.mandatory?string},
|
||||
"enforced": ${propertydef.mandatoryEnforced?string},
|
||||
"protected": ${propertydef.protected?string},
|
||||
"indexed": ${propertydef.indexed?string},
|
||||
"url": "/api/classes/${classdefprefix}/property/${propertydef.name.toPrefixString()?replace(":","_")}"
|
||||
}<#if propertydef_has_next>,</#if>
|
||||
</#list>
|
||||
},
|
||||
"associations":
|
||||
{
|
||||
<#assign isfirst=true>
|
||||
<#list assocdefs[key] as assocdef>
|
||||
<#if !isfirst && !assocdef.isChild()>,</#if>
|
||||
<#if !assocdef.isChild()>
|
||||
<#assign isfirst=false>
|
||||
"${assocdef.name.toPrefixString()}":
|
||||
{
|
||||
"name": "${assocdef.name.toPrefixString()}",
|
||||
"title": "${assocdef.title!""}",
|
||||
"url": "/api/classes/${classdefprefix}/association/${assocdef.name.toPrefixString()?replace(":","_")}",
|
||||
"source":
|
||||
{
|
||||
<#if assocdef.getSourceClass().name??>"class": "${assocdef.getSourceClass().name.toPrefixString()}",</#if>
|
||||
<#if assocdef.getSourceRoleName()??>"role": "${assocdef.getSourceRoleName().toPrefixString()}",</#if>
|
||||
"mandatory": ${assocdef.isSourceMandatory()?string},
|
||||
"many": ${assocdef.isSourceMany()?string}
|
||||
},
|
||||
"target":
|
||||
{
|
||||
<#if assocdef.getTargetClass().name??>"class": "${assocdef.getTargetClass().name.toPrefixString()}",</#if>
|
||||
<#if assocdef.getTargetRoleName()??>"role": "${assocdef.getTargetRoleName().toPrefixString()}",</#if>
|
||||
"mandatory": ${assocdef.isTargetMandatory()?string},
|
||||
"many": ${assocdef.isTargetMany()?string}
|
||||
}
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
},
|
||||
"childassociations":
|
||||
{
|
||||
<#assign isfirst=true>
|
||||
<#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/>
|
||||
[
|
||||
<#list classdefs as classdefs>
|
||||
<@classdetailsDefLib.classDefJSON classdefs=classdefs key = classdefs_index/>
|
||||
<#if classdefs_has_next>,</#if>
|
||||
<#list classdefs as classdef>
|
||||
<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/><#if classdef_has_next>,</#if>
|
||||
</#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/>
|
||||
[
|
||||
<#list classdefs as classdefs>
|
||||
<@classdetailsDefLib.classDefJSON classdefs=classdefs key = classdefs_index/>
|
||||
<#if classdefs_has_next>,</#if>
|
||||
<#list classdefs as classdef>
|
||||
<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/>
|
||||
<#if classdef_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
]
|
@@ -705,12 +705,12 @@
|
||||
<!-- -->
|
||||
<!-- DICTIONARY Service REST API -->
|
||||
<!-- -->
|
||||
|
||||
|
||||
<bean id="webscript.dictionary" abstract="true" parent="webscript" init-method="init">
|
||||
<property name="dictionaryService" ref="DictionaryService"/>
|
||||
<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.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"/>
|
||||
@@ -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.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.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 -->
|
||||
<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
|
||||
*
|
||||
@@ -30,14 +30,14 @@ import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Base class for Dictionary web scripts
|
||||
*
|
||||
* @author Saravanan Sellathurai
|
||||
*/
|
||||
public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
{
|
||||
private static final String NAME_DELIMITER = "_";
|
||||
private static final String NAME_DELIMITER = "_";
|
||||
|
||||
private Map<String, String> prefixesAndUrlsMap;
|
||||
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_TYPE3 = "child";
|
||||
|
||||
|
||||
/**
|
||||
* Set the namespaceService property.
|
||||
*
|
||||
@@ -63,7 +64,7 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceservice)
|
||||
{
|
||||
this.namespaceService = namespaceservice;
|
||||
this.namespaceService = namespaceservice;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,17 +118,15 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param qname
|
||||
* @return the namespaceuri from a qname
|
||||
*/
|
||||
public String getNamespaceURIfromQname(QName qname)
|
||||
{
|
||||
return qname.getNamespaceURI();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param className the class name as cm_person
|
||||
* @return String the full name in the following format {namespaceuri}shorname
|
||||
*/
|
||||
@@ -142,14 +141,13 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
result = "{" + url + "}"+ name;
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@@ -159,13 +157,9 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
try
|
||||
{
|
||||
qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||
if (//(isValidPrefix(getPrefix(classname)) == true) &&
|
||||
dictionaryservice.getClass(qname) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return (dictionaryservice.getClass(qname) != null);
|
||||
}
|
||||
catch(InvalidQNameException e)
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
//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
|
||||
* @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)
|
||||
{
|
||||
if(af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE1) ||
|
||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE2) ||
|
||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE3))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE1) ||
|
||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE2) ||
|
||||
af.equalsIgnoreCase(ASSOCIATION_FILTER_OPTION_TYPE3));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param classname as the input
|
||||
* @return true if it is a aspect or false if it is a Type
|
||||
*/
|
||||
@@ -234,34 +200,26 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
try
|
||||
{
|
||||
QName qname = QName.createQName(this.getFullNamespaceURI(classname));
|
||||
if( (this.dictionaryservice.getClass(qname)!=null) &&
|
||||
(this.dictionaryservice.getClass(qname).isAspect() == true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ((this.dictionaryservice.getClass(qname) != null) &&
|
||||
(this.dictionaryservice.getClass(qname).isAspect()));
|
||||
}
|
||||
catch(InvalidQNameException e)
|
||||
catch (InvalidQNameException e)
|
||||
{
|
||||
//ignore
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param modelname - gets the modelname as the input (modelname is without prefix ie. cm:contentmodel => where modelname = contentmodel)
|
||||
* @return true if valid or false
|
||||
*/
|
||||
public boolean isValidModelName(String modelname)
|
||||
{
|
||||
boolean value = false;
|
||||
for(QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
for (QName qnameObj:this.dictionaryservice.getAllModels())
|
||||
{
|
||||
if(qnameObj.getLocalName().equalsIgnoreCase(modelname))
|
||||
if (qnameObj.getLocalName().equalsIgnoreCase(modelname))
|
||||
{
|
||||
value = true;
|
||||
break;
|
||||
@@ -269,8 +227,8 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param classname - returns the prefix from the classname of the format namespaceprefix:name eg. cm_person
|
||||
* @return prefix - returns the prefix of the classname
|
||||
*/
|
||||
@@ -303,12 +261,11 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
|
||||
/**
|
||||
* @param input -gets a string input and validates it
|
||||
*
|
||||
* @return null if invalid or the string itself if its valid
|
||||
*/
|
||||
public String getValidInput(String input)
|
||||
{
|
||||
if((input != null) && (input.length() > 0))
|
||||
if ((input != null) && (input.length() != 0))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
@@ -319,26 +276,17 @@ public abstract class DictionaryWebServiceBase extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param classfilter =>valid class filters are all,apect or type
|
||||
* @return true if valid or false if invalid
|
||||
*/
|
||||
public boolean isValidClassFilter(String classfilter)
|
||||
{
|
||||
if(classfilter.equals(CLASS_FILTER_OPTION_TYPE1) ||
|
||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE2) ||
|
||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE3))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (classfilter.equals(CLASS_FILTER_OPTION_TYPE1) ||
|
||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE2) ||
|
||||
classfilter.equals(CLASS_FILTER_OPTION_TYPE3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param
|
||||
* @return a string map or prefixes and urls - with prefix as the key
|
||||
*/
|
||||
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()
|
||||
{
|
||||
|
Reference in New Issue
Block a user