From 2300403bb4084ef670bd7897a2ebfe023ee40407 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Thu, 2 Jun 2011 11:01:26 +0000 Subject: [PATCH] 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 --- .../repository/dictionary/class.get.json.ftl | 7 +- .../dictionary/classdetails.lib.ftl | 208 +++++++++--------- .../dictionary/classes.get.json.ftl | 7 +- .../dictionary/dictionary.get.desc.xml | 8 + .../dictionary/dictionary.get.json.ftl | 6 + .../dictionary/subclasses.get.json.ftl | 8 +- .../web-scripts-application-context.xml | 22 +- .../web/scripts/dictionary/DictionaryGet.java | 108 +++++++++ .../dictionary/DictionaryWebServiceBase.java | 101 ++------- 9 files changed, 282 insertions(+), 193 deletions(-) create mode 100644 config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/dictionary.get.desc.xml create mode 100644 config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/dictionary.get.json.ftl create mode 100644 source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryGet.java diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/class.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/class.get.json.ftl index 146af2830e..9ce7d992a0 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/class.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/class.get.json.ftl @@ -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>, - \ No newline at end of file +<#list classdefs as classdef> +<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/><#if classdef_has_next>, + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classdetails.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classdetails.lib.ftl index d022affadd..57c0ab58ef 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classdetails.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classdetails.lib.ftl @@ -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 classdefs.isAspect() == true> - "isAspect" : true, - <#else> - "isAspect" : false, - - <#if classdefs.title?exists> - "title" : "${classdefs.title}", - <#else> - "title" : "", - - <#if classdefs.description?exists> - "description" : "${classdefs.description}", - <#else> - "description" : "", - - "parent" : { - <#if classdefs.parentName?exists> - "name" : "${classdefs.parentName.toPrefixString()}", - "title" : "${classdefs.parentName.getLocalName()}", - "url" : "${"/api/classes/" + classdefs.parentName.toPrefixString()?replace(":","_")}" - + <#if classdef.name??>"name": "${classdef.name.toPrefixString()}", + "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(":","_")}" + }, - "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>, - - - }, - "defaultAspects" : { - <#if classdefs.defaultAspects?exists> - <#list classdefs.defaultAspects as aspectdef> - "${aspectdef.name.toPrefixString()}" : { - "name" : "${aspectdef.name.toPrefixString()}", - <#if aspectdef.title?exists> - "title" : "${aspectdef.title}", - - "url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + aspectdef.name.toPrefixString()?replace(":","_")}" - }<#if aspectdef_has_next>, + "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>, - + }, - "properties" : { - <#list propertydefs[key] as propertydefs> - "${propertydefs.name.toPrefixString()}": { - <#if propertydefs.name?exists> - "name" : "${propertydefs.name.toPrefixString()}", - - <#if propertydefs.title?exists> - "title" : "${propertydefs.title}", - - "url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/property/" + propertydefs.name.toPrefixString()?replace(":","_")}" - }<#if propertydefs_has_next>, - - }, - "associations" : { - <#assign flag = false> - <#list assocdefs[key] as assocdefs> - <#if (assocdefs.isChild()==false)&&(flag== true)><#assign flag = false>, - <#if assocdefs.isChild() == false> - <#assign flag=true> - "${assocdefs.name.toPrefixString()}": { - <#if assocdefs.name?exists> - "name" : "${assocdefs.name.toPrefixString()}", - - <#if assocdefs.title?exists> - "title" : "${assocdefs.title}", - - "url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}" - } - - - }, - "childassociations" : { - <#assign flag = false> - <#list assocdefs[key] as assocdefs> - <#if (assocdefs.isChild()==true)&&(flag== true)><#assign flag = false>, - <#if assocdefs.isChild() == true> - <#assign flag=true> - "${assocdefs.name.toPrefixString()}": { - <#if assocdefs.name?exists> - "name" : "${assocdefs.name.toPrefixString()}", - - <#if assocdefs.title?exists> - "title" : "${assocdefs.title}", - - "url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_") + "/association/" + assocdefs.name.toPrefixString()?replace(":","_")}" - } - - - }, - "url" : "${"/api/classes/" + classdefs.name.toPrefixString()?replace(":","_")}" - } - - + "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>"", + "defaultValue": <#if propertydef.defaultValue??>"${propertydef.defaultValue}"<#else>null, + "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>, + + }, + "associations": + { + <#assign isfirst=true> + <#list assocdefs[key] as assocdef> + <#if !isfirst && !assocdef.isChild()>, + <#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 assocdef.getSourceRoleName()??>"role": "${assocdef.getSourceRoleName().toPrefixString()}", + "mandatory": ${assocdef.isSourceMandatory()?string}, + "many": ${assocdef.isSourceMany()?string} + }, + "target": + { + <#if assocdef.getTargetClass().name??>"class": "${assocdef.getTargetClass().name.toPrefixString()}", + <#if assocdef.getTargetRoleName()??>"role": "${assocdef.getTargetRoleName().toPrefixString()}", + "mandatory": ${assocdef.isTargetMandatory()?string}, + "many": ${assocdef.isTargetMany()?string} + } + } + + + }, + "childassociations": + { + <#assign isfirst=true> + <#list assocdefs[key] as assocdef> + <#if !isfirst && assocdef.isChild()>, + <#if assocdef.isChild()> + <#assign isfirst=false> + "${assocdef.name.toPrefixString()}": + { + <#if assocdef.name??>"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()}", + "mandatory": ${assocdef.isSourceMandatory()?string}, + "many": ${assocdef.isSourceMany()?string} + }, + "target": + { + <#if assocdef.getTargetClass().name??>"class": "${assocdef.getTargetClass().name.toPrefixString()}", + "mandatory": ${assocdef.isTargetMandatory()?string}, + "many": ${assocdef.isTargetMany()?string} + } + } + + + }, + "url": "/api/classes/${classdefprefix}" + } + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classes.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classes.get.json.ftl index b6dd6516e2..c502a9fe75 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classes.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/classes.get.json.ftl @@ -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>, +<#list classdefs as classdef> +<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/><#if classdef_has_next>, -] +] \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/dictionary.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/dictionary.get.desc.xml new file mode 100644 index 0000000000..6365f6a11f --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/dictionary.get.desc.xml @@ -0,0 +1,8 @@ + + Get remote dictionary definitions + Gets all apspect and class definitions that form the dictionary - to enable a lightweight remote dictionary. + /api/dictionary + argument + user + required + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/dictionary.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/dictionary.get.json.ftl new file mode 100644 index 0000000000..65849f86d2 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/dictionary.get.json.ftl @@ -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>, + +] \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/subclasses.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/subclasses.get.json.ftl index b6dd6516e2..a6717a80a6 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/subclasses.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/dictionary/subclasses.get.json.ftl @@ -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>, +<#list classdefs as classdef> +<@classdetailsDefLib.classDefJSON classdef=classdef key=classdef_index/> +<#if classdef_has_next>, -] +] \ No newline at end of file diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index 9540c9e2ed..2bc7b340a4 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -705,12 +705,12 @@ - + - - + + @@ -718,6 +718,22 @@ + + + + + http://www.alfresco.org/model/dictionary/1.0 + http://www.alfresco.org/model/wcmmodel/1.0 + http://www.alfresco.org/model/wcmappmodel/1.0 + http://www.alfresco.org/model/wcmworkflow/1.0 + http://www.alfresco.org/model/rendition/1.0 + http://www.alfresco.org/model/versionstore/1.0 + http://www.alfresco.org/model/versionstore/2.0 + http://www.jcp.org/jcr/1.0 + + + + diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryGet.java b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryGet.java new file mode 100644 index 0000000000..b710870f66 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryGet.java @@ -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 . + */ +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 ignoreNamespaces = Collections.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 namespaces) + { + this.ignoreNamespaces = namespaces; + } + + /** + * Execute the webscript + * + * @param req WebScriptRequest + * @param status Status + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status) + { + List qnames = new ArrayList(256); + Set namespaces = new HashSet(); + Map classdef = new HashMap(); + Map> propdef = new HashMap>(); + Map> assocdef = new HashMap>(); + + // 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 model = new HashMap(); + model.put(MODEL_CLASS_DEFS, classdef.values()); + model.put(MODEL_PROPERTY_DEFS, propdef.values()); + model.put(MODEL_ASSOCIATION_DEFS, assocdef.values()); + return model; + } +} diff --git a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryWebServiceBase.java b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryWebServiceBase.java index 3694cd2f00..5706541492 100644 --- a/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryWebServiceBase.java +++ b/source/java/org/alfresco/repo/web/scripts/dictionary/DictionaryWebServiceBase.java @@ -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 prefixesAndUrlsMap; private Map 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 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 getUrlsAndPrefixesMap() {