Java Code Examples for org.springframework.extensions.webscripts.Status#STATUS_NOT_FOUND
The following examples show how to use
org.springframework.extensions.webscripts.Status#STATUS_NOT_FOUND .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DictionaryWebServiceBase.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
/** * @param classname the class name as cm_person * @return String the full name in the following format {namespaceuri}shorname */ public String getFullNamespaceURI(String classname) { try { String result = null; String prefix = this.getPrefix(classname); String url = this.namespaceService.getNamespaceURI(prefix); String name = this.getShortName(classname); result = "{" + url + "}"+ name; return result; } catch (Exception e) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "The exact classname - " + classname + " parameter has not been provided in the URL"); } }
Example 2
Source File: PropertiesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected QName getClassQName(WebScriptRequest req) { QName classQName = null; String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME); if (className != null && className.length() != 0) { classQName = createClassQName(className); if (classQName == null) { // Error throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL"); } } return classQName; }
Example 3
Source File: LinkGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> executeImpl(SiteInfo site, String linkName, WebScriptRequest req, JSONObject json, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); // Try to find the link LinkInfo link = linksService.getLink(site.getShortName(), linkName); if (link == null) { String message = "No link found with that name"; throw new WebScriptException(Status.STATUS_NOT_FOUND, message); } // Build the model model.put(PARAM_ITEM, renderLink(link)); model.put("node", link.getNodeRef()); model.put("link", link); model.put("site", site); model.put("siteId", site.getShortName()); // All done return model; }
Example 4
Source File: PropertyGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected QName getPropertyQname(WebScriptRequest req) { String propertyName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_SHORTPROPERTY_NAME); String propertyPrefix = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PROPERTY_FREFIX); //validate the presence of property name if(propertyName == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter short propertyname in the URL"); } //validate the presence of property prefix if(propertyPrefix == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing parameter propertyprefix in the URL"); } return QName.createQName(getFullNamespaceURI(propertyPrefix, propertyName)); }
Example 5
Source File: PropertiesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected QName getClassQName(WebScriptRequest req) { QName classQName = null; String prefix = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PREFIX); String shortName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_SHORT_CLASS_NAME); if (prefix != null && prefix.length() != 0 && shortName != null && shortName.length()!= 0) { classQName = createClassQName(prefix, shortName); if (classQName == null) { // Error throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + prefix + ":" + shortName + " - parameter in the URL"); } } return classQName; }
Example 6
Source File: AbstractSiteWebScript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { // Grab the site String siteName = req.getServiceMatch().getTemplateVars().get("shortname"); SiteInfo site = siteService.getSite(siteName); if (site == null) { throw new WebScriptException( Status.STATUS_NOT_FOUND, "No Site found with that short name"); } // Process return executeImpl(site, req, status, cache); }
Example 7
Source File: SubClassesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Collection<QName> getQNameCollection(WebScriptRequest req, boolean recursive) { QName classQName = null; boolean isAspect = false; String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME); //validate the className if(isValidClassname(className) == true) { classQName = QName.createQName(getFullNamespaceURI(className)); if(isValidTypeorAspect(className) == true) { isAspect = true; } } else { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " parameter in the URL"); } // collect the subaspects or subtypes of the class if(isAspect == true) { return this.dictionaryservice.getSubAspects(classQName, recursive); } else { return this.dictionaryservice.getSubTypes(classQName, recursive); } }
Example 8
Source File: AssociationsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected QName getClassQname(WebScriptRequest req) { String prefix = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PREFIX); String shortClassName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_SHORT_CLASS_NAME); //validate classname if (isValidClassname(prefix, shortClassName) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + prefix + ":" + shortClassName + " - parameter in the URL"); } return QName.createQName(getFullNamespaceURI(prefix, shortClassName)); }
Example 9
Source File: PropertyGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected QName getClassQname(WebScriptRequest req) { String prefix = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PREFIX); String shortClassName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_SHORT_CLASS_NAME); // validate the classname if (isValidClassname(prefix, shortClassName) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + prefix + ":" + shortClassName + " - parameter in the URL"); } return QName.createQName(getFullNamespaceURI(prefix, shortClassName)); }
Example 10
Source File: SubClassesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void validateClassname(String namespacePrefix, String name) { if(isValidClassname(namespacePrefix, name) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " and name - "+ name + " - parameter in the URL"); } }
Example 11
Source File: SubClassesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Collection<QName> getQNameCollection(WebScriptRequest req, boolean recursive) { String prefix = req.getServiceMatch().getTemplateVars().get(DICTIONARY_PREFIX); String shortClassName = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_SHORTNAME); QName classQName = null; boolean isAspect = false; //validate the className if(isValidClassname(prefix, shortClassName) == true) { classQName = QName.createQName(getFullNamespaceURI(prefix, shortClassName)); if(isValidTypeorAspect(prefix, shortClassName) == true) { isAspect = true; } } else { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + prefix + ":" + shortClassName + " parameter in the URL"); } // collect the subaspects or subtypes of the class if(isAspect == true) { return this.dictionaryservice.getSubAspects(classQName, recursive); } else { return this.dictionaryservice.getSubTypes(classQName, recursive); } }
Example 12
Source File: SolrFacetConfigAdminGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> unprotectedExecuteImpl(WebScriptRequest req, Status status, Cache cache) { // get the filterID parameter. Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); String filterID = templateVars.get("filterID"); Map<String, Object> model = new HashMap<String, Object>(1); if (filterID == null) { model.put("filters", facetService.getFacets()); } else { SolrFacetProperties fp = facetService.getFacet(filterID); if (fp == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Filter not found"); } model.put("filter", fp); } if (logger.isDebugEnabled()) { logger.debug("Retrieved all available facets: " + model.values()); } return model; }
Example 13
Source File: AuditControlGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(7); String appName = getParamAppName(req); String path = getParamPath(req); boolean enabledGlobal = auditService.isAuditEnabled(); Map<String, AuditApplication> appsByName = auditService.getAuditApplications(); // Check that the application exists if (appName != null) { if (path == null) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "audit.err.path.notProvided"); } AuditApplication app = appsByName.get(appName); if (app == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "audit.err.app.notFound", appName); } // Discard all the other applications appsByName = Collections.singletonMap(appName, app); } model.put(JSON_KEY_ENABLED, enabledGlobal); model.put(JSON_KEY_APPLICATIONS, appsByName.values()); // Done if (logger.isDebugEnabled()) { logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model); } return model; }
Example 14
Source File: SubClassesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void validateClassname(String namespacePrefix, String name) { if(isValidClassname(namespacePrefix + "_" + name) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the namespacePrefix - " + namespacePrefix + " and name - "+ name + " - parameter in the URL"); } }
Example 15
Source File: ClassesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected QName getClassQname(String namespacePrefix, String name) { String className = namespacePrefix + "_" + name; if(isValidClassname(className) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + "parameter in the URL"); } return QName.createQName(getFullNamespaceURI(className)); }
Example 16
Source File: AuditClearPost.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(7); String appName = getParamAppName(req); if (appName == null) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "audit.err.app.notProvided"); } AuditApplication app = auditService.getAuditApplications().get(appName); if (app == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "audit.err.app.notFound", appName); } // Get from/to times Long fromTime = getParamFromTime(req); // might be null Long toTime = getParamToTime(req); // might be null // Clear int cleared = auditService.clearAudit(appName, fromTime, toTime); model.put(JSON_KEY_CLEARED, cleared); // Done if (logger.isDebugEnabled()) { logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model); } return model; }
Example 17
Source File: PropertyGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected QName getClassQname(WebScriptRequest req) { String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME); // validate the classname if (isValidClassname(className) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classname - " + className + " - parameter in the URL"); } return QName.createQName(getFullNamespaceURI(className)); }
Example 18
Source File: SolrFacetConfigAdminPut.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected Map<String, Object> unprotectedExecuteImpl(WebScriptRequest req, Status status, Cache cache) { final String relativePosString = req.getParameter(PARAM_RELATIVE_POS); try { if (relativePosString != null) { // This is a request to 'move' (reposition) the specified facet. // We need the relative position that the facet will move. final int relativePos; try { relativePos = Integer.parseInt(relativePosString); } catch (NumberFormatException nfe) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Cannot move facet as could not parse relative position: '" + relativePosString + "'"); } // And we need the filterID for the facet we're moving. final Map<String, String> templateVars = req.getServiceMatch().getTemplateVars(); String filterId = templateVars.get(URL_PARAM_FILTER_ID); if (filterId == null) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Illegal null filterId"); } // So let's move the filter... try { // Get the current sequence of filter IDs. List<SolrFacetProperties> facets = facetService.getFacets(); List<String> facetIDs = CollectionUtils.transform(facets, new Function<SolrFacetProperties, String>() { @Override public String apply(SolrFacetProperties value) { return value.getFilterID(); } }); List<String> reorderedIDs = CollectionUtils.moveRight(relativePos, filterId, facetIDs); this.facetService.reorderFacets(reorderedIDs); if (logger.isDebugEnabled()) { logger.debug("Moved facet " + filterId + " to relative position: " + relativePos); } } catch (UnrecognisedFacetId ufi) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Unrecognised filter ID: " + ufi.getFacetId()); } } // TODO Allow for simultaneous move and update of facet. else { SolrFacetProperties fp = parseRequestForFacetProperties(req); facetService.updateFacet(fp); if (logger.isDebugEnabled()) { logger.debug("Updated facet node: " + fp); } } } catch (Throwable t) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not update the facet configuration.", t); } Map<String, Object> model = new HashMap<String, Object>(1); return model; }
Example 19
Source File: AbstractSubClassesGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
/** * Override method from DeclarativeWebScript */ protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { String name = req.getParameter(REQ_URL_TEMPL_VAR_NAME); String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX); String recursiveValue = getValidInput(req.getParameter(REQ_URL_TEMPL_IMMEDIATE_SUB_TYPE_CHILDREN)); boolean recursive = true; Map<QName, ClassDefinition> classdef = new HashMap<QName, ClassDefinition>(); Map<QName, Collection<PropertyDefinition>> propdef = new HashMap<QName, Collection<PropertyDefinition>>(); Map<QName, Collection<AssociationDefinition>> assocdef = new HashMap<QName, Collection<AssociationDefinition>>(); Map<String, Object> model = new HashMap<String, Object>(); String namespaceUri = null; Collection<QName> qname = null; boolean ignoreCheck = false; // validate recursive parameter => can be either true or false or null if (recursiveValue == null) { recursive = true; } else if (recursiveValue.equalsIgnoreCase("true")) { recursive = true; } else if (recursiveValue.equalsIgnoreCase("false")) { recursive = false; } else { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the value for the parameter recursive=> " + recursiveValue + " can only be either true or false"); } qname = getQNameCollection(req, recursive); // validate the name parameter if (name != null) { if (isValidModelName(name) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name parameter - " + name + " in the URL"); } } // validate the name parameter if (namespacePrefix == null && name != null) { namespaceUri = namespaceService.getNamespaceURI(getPrefixFromModelName(name)); } if (namespacePrefix != null && name == null) { namespaceUri = namespaceService.getNamespaceURI(namespacePrefix); } if (namespacePrefix == null && name == null) { namespaceUri = null; ignoreCheck = true; } if (namespacePrefix != null && name != null) { validateClassname(namespacePrefix, name); namespaceUri = namespaceService.getNamespaceURI(namespacePrefix); } for (QName qnameObj : qname) { if ((ignoreCheck == true) || (qnameObj.getNamespaceURI().equals(namespaceUri))) { classdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj)); propdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getProperties().values()); assocdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getAssociations().values()); } } List<ClassDefinition> classDefinitions = new ArrayList<ClassDefinition>(classdef.values()); Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator(dictionaryservice)); model.put(MODEL_PROP_KEY_CLASS_DEFS, classDefinitions); model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, reorderedValues(classDefinitions, propdef)); model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, reorderedValues(classDefinitions, assocdef)); model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice); return model; }
Example 20
Source File: AbstractAssociationsGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
/** * Override method from DeclarativeWebScript */ protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { String associationFilter = req.getParameter(REQ_URL_TEMPL_VAR_ASSOCIATION_FILTER); String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX); String name = req.getParameter(REQ_URL_TEMPL_VAR_NAME); Map<String, Object> model = new HashMap<String, Object>(); Map<QName, AssociationDefinition> assocdef = new HashMap<QName, AssociationDefinition>(); QName associationQname = null; QName classQname = getClassQname(req); if(associationFilter == null) { associationFilter = "all"; } //validate association filter if(isValidAssociationFilter(associationFilter) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the associationFilter - " + associationFilter + " - parameter in the URL"); } // validate for the presence of both name and namespaceprefix if((name == null && namespacePrefix != null) || (name != null && namespacePrefix == null)) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing either name or namespaceprefix parameter in the URL - both combination of name and namespaceprefix is needed"); } // check for association filters if(associationFilter.equals("child")) { model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(classQname).getChildAssociations().values()); } else if(associationFilter.equals("general")) { for(AssociationDefinition assocname:this.dictionaryservice.getClass(classQname).getAssociations().values()) { if(assocname.isChild() == false) { assocdef.put(assocname.getName(), assocname); } } model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values()); } else if(associationFilter.equals("all")) { model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(classQname).getAssociations().values()); } // if both namespaceprefix and name parameters are given then, the combination namespaceprefix_name is used as the index to create the qname if(name != null && namespacePrefix != null) { // validate the class combination namespaceprefix_name associationQname = getAssociationQname(namespacePrefix, name); if(this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname)== null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "not a Valid - namespaceprefix_name combination"); } model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname)); } model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice); return model; }