List of usage examples for javax.xml.registry InvalidRequestException InvalidRequestException
public InvalidRequestException(Throwable cause)
JAXRException
object initialized with the given Throwable
object. From source file:it.cnr.icar.eric.client.xml.registry.infomodel.ClassificationSchemeImpl.java
/** * This constructor is to do a type-safe cast from a Concept with no parent to a scheme. * This has history in UDDI and we are not sure what value it has in ebXML. * We are implementing it as it is required by the JAXR API. * Needs evaluation for relevance in JAXR 2.0?? **//*from www .j a v a2 s . c om*/ public ClassificationSchemeImpl(LifeCycleManagerImpl lcm, Concept concept) throws JAXRException { super(lcm); if (concept.getParent() != null) { throw new InvalidRequestException(JAXRResourceBundle.getInstance() .getString("message.error.cannot.create.concept.parent.classScheme")); } setName(concept.getName()); setDescription(concept.getDescription()); addClassifications(concept.getClassifications()); addExternalIdentifiers(concept.getExternalIdentifiers()); //??incomplete }
From source file:it.cnr.icar.eric.server.interfaces.rest.FilePathURLHandler.java
/** * Processes a Get Request/* w w w . j ava 2 s . c om*/ */ void processGetRequest() throws IOException, RegistryException, InvalidRequestException, UnimplementedException, ObjectNotFoundException { String getRepositoryItem = request.getParameter("getRepositoryItem"); getRegistryObjectByPackageHierarchy(); if (matchedObjects.size() == 1) { RegistryObjectType ro = (RegistryObjectType) matchedObjects.get(0); if ((getRepositoryItem != null) && (getRepositoryItem.equalsIgnoreCase("true"))) { if (ro instanceof ExtrinsicObjectType) { writeRepositoryItem((ExtrinsicObjectType) ro); } else { throw new InvalidRequestException(ServerResourceBundle.getInstance() .getString("message.expectExtrinsicObject", new Object[] { ro.getClass() })); } } else { String pathInfo = request.getPathInfo(); if ((ro instanceof RegistryPackageType) && (pathInfo.endsWith("/"))) { //Matched 1 object that is a RegistryPackage and path ends in '/'. //Write directory listing with all member objects shown writeDirectoryListing(pathInfo, (RegistryPackageType) ro); } else { //Matched 1 object and path does not end in '/' //Write XML for the matched object writeRegistryObject(ro); } } } else { //Matched multiple objects. //Write directory listing with only matched objects shown writeDirectoryListing(modifiedPathInfo, parentFolder, matchedObjects); } }
From source file:it.cnr.icar.eric.client.xml.registry.ConnectionImpl.java
/** * Creates a new ConnectionImpl object./*from www . j av a2 s . c o m*/ * * @param factory DOCUMENT ME! * * @throws JAXRException DOCUMENT ME! */ ConnectionImpl(ConnectionFactoryImpl factory) throws JAXRException { this.factory = factory; Properties props = factory.getProperties(); queryManagerURL = props.getProperty("javax.xml.registry.queryManagerURL"); lifeCycleManagerURL = props.getProperty("javax.xml.registry.lifeCycleManagerURL"); localCallMode = Boolean .valueOf(props.getProperty("it.cnr.icar.eric.client.xml.registry.localCall", "false")) .booleanValue(); if (queryManagerURL == null) { throw new InvalidRequestException( JAXRResourceBundle.getInstance().getString("queryManagerURL.property.null")); } if (lifeCycleManagerURL == null) { lifeCycleManagerURL = queryManagerURL; } loginModuleMgr = new LoginModuleManager(); }
From source file:it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl.java
/** * Creates a Query object given a queryType (e.g. SQL) * that represents a query in the syntax appropriate for queryType. * No query string is passed to this method. So, user must call * DeclarativeQueryManager.executeQuery(query, queryParams) * Must throw an InvalidRequestException if the sqlQuery is not valid. * * * <p><DL><DT><B>Capability Level: 0 (optional) </B></DL> * * @see Query#QUERY_TYPE_SQL/*from w w w.j a va 2 s . c o m*/ * @see Query#QUERY_TYPE_XQUERY * @see DeclarativeQueryManager#executeQuery(Query query, Map queryParams) */ public Query createQuery(int queryType) throws InvalidRequestException, JAXRException { if (queryType != Query.QUERY_TYPE_SQL) { throw new InvalidRequestException("Type must be Query.QUERY_TYPE_SQL"); } return new QueryImpl(queryType); }
From source file:it.cnr.icar.eric.server.interfaces.rest.QueryManagerURLHandler.java
/** Process the QueryManager request and sends the response back to the client * @param/* w w w .j a va 2s .c o m*/ * */ void processGetRequest() throws IOException, RegistryException, InvalidRequestException, UnimplementedException, ObjectNotFoundException { String method = request.getParameter("method"); String id = request.getParameter("param-id"); String lid = request.getParameter("param-lid"); String versionName = request.getParameter("param-versionName"); @SuppressWarnings("unused") String flavor = request.getParameter("flavor"); if ((method == null) || method.equals("")) { throw new InvalidRequestException( ServerResourceBundle.getInstance().getString("message.methodCannotBeNull")); } else if (method.equalsIgnoreCase("getRegistryObject")) { try { response.setContentType("text/xml; charset=UTF-8"); String queryString = getQueryStringForFindByIdLidVersion(id, lid, versionName); List<RegistryObjectType> results = submitQueryAs(queryString, currentUser); if (results.isEmpty()) { throw new ObjectNotFoundException(getNotFoundExceptionMsg(id, lid, versionName)); } else { if (results.size() > 1) { writeDirectoryListing(results); } else { RegistryObjectType ebRegistryObjectType = results.get(0); writeRegistryObject(ebRegistryObjectType); } } } catch (NullPointerException e) { log.error(e.toString(), e); throw new RegistryException( it.cnr.icar.eric.server.common.Utility.getInstance().getStackTraceFromThrowable(e)); } } else if (method.equalsIgnoreCase("getRepositoryItem")) { try { String queryString = getQueryStringForFindByIdLidVersion(id, lid, versionName); List<RegistryObjectType> results = submitQueryAs(queryString, currentUser); if (results.isEmpty()) { throw new ObjectNotFoundException(getNotFoundExceptionMsg(id, lid, versionName)); } else { // RegistryObjectType ro = (RegistryObjectType)results.get(0); // take ComplexType from Element //RegistryObjectType ebRegistryObjectType = ((JAXBElement<RegistryObjectType>)(results.get(0))).getValue(); RegistryObjectType ebRegistryObjectType = results.get(0); // check the first ComplexType in result if (!(ebRegistryObjectType instanceof ExtrinsicObjectType)) { //return the error code throw new InvalidRequestException(ServerResourceBundle.getInstance().getString( "message.expectedExtrinsicObjectNotFound", new Object[] { ebRegistryObjectType.getClass() })); } if (results.size() > 1) { writeDirectoryListing(results); } else { ExtrinsicObjectType ebExtrinsicObjectType = (ExtrinsicObjectType) ebRegistryObjectType; writeRepositoryItem(ebExtrinsicObjectType); } } } catch (NullPointerException e) { log.error(e.toString(), e); throw new RegistryException( it.cnr.icar.eric.server.common.Utility.getInstance().getStackTraceFromThrowable(e)); } } else if (method.equalsIgnoreCase("submitAdhocQuery")) { try { String startIndex = request.getParameter("startIndex"); if (startIndex == null) { startIndex = "0"; } String maxResults = request.getParameter("maxResults"); if (maxResults == null) { maxResults = "-1"; } String queryId = request.getParameter("queryId"); if (queryId == null) { queryId = "urn:freebxml:registry:query:BusinessQuery"; } //Create and populate queryParamsMap from request params map Map<String, String> queryParams = new HashMap<String, String>(); Iterator<String> iter = request.getParameterMap().keySet().iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof String) { String paramName = (String) obj; //Only use params whose names begin with '$' char if (paramName.charAt(0) == '$') { String paramValue = request.getParameter(paramName); queryParams.put(paramName, paramValue); } } } ServerRequestContext context = new ServerRequestContext( "QueryManagerURLHandler.processGetRequest.submitAdhocQuery", null); List<IdentifiableType> ebIdentifiableTypeResultList = invokeParameterizedQuery(context, queryId, queryParams, currentUser, Integer.parseInt(startIndex), Integer.parseInt(maxResults)); String getRepositoryItem = request.getParameter("getRepositoryItem"); if ((getRepositoryItem != null) && ((getRepositoryItem.equalsIgnoreCase("true")) || (getRepositoryItem.equals("1")))) { writeRepositoryItemList(ebIdentifiableTypeResultList); } else { writeRegistryObjectList(ebIdentifiableTypeResultList); } } catch (NullPointerException e) { log.error(e.toString(), e); throw new RegistryException( it.cnr.icar.eric.server.common.Utility.getInstance().getStackTraceFromThrowable(e)); } } else if (method.equalsIgnoreCase("newUUID")) { response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); UUIDFactory uuidFac = UUIDFactory.getInstance(); out.print(uuidFac.newUUID().toString()); out.close(); } else { //return the error code throw new InvalidRequestException( ServerResourceBundle.getInstance().getString("message.unknownMethod", new Object[] { method })); } }
From source file:it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl.java
/** * Creates a Query object given a queryType (e.g. SQL) and a String * that represents a query in the syntax appropriate for queryType. * Must throw and InvalidRequestException if the sqlQuery is not valid. * * * <p><DL><DT><B>Capability Level: 0 (optional) </B></DL> * * @see Query#QUERY_TYPE_SQL/* ww w .j av a 2s . c om*/ * @see Query#QUERY_TYPE_XQUERY */ public Query createQuery(int queryType, String queryString) throws InvalidRequestException, JAXRException { if ((queryType != Query.QUERY_TYPE_SQL) && (queryType != Query.QUERY_TYPE_EBXML_FILTER_QUERY)) { throw new InvalidRequestException("Type must be Query.QUERY_TYPE_SQL or QUERY_TYPE_EBXML_FILTER_QUERY"); } // TODO: check queryString syntax return new QueryImpl(queryType, queryString); }
From source file:it.cnr.icar.eric.server.interfaces.rest.FilePathURLHandler.java
/** * Attempt to get a RegistryObject by its URI by matching it against the package * membership hierarchy it is contained in. * *///from www . ja v a2 s. c om private void getRegistryObjectByPackageHierarchy() throws IOException, RegistryException, ObjectNotFoundException, InvalidRequestException { String pathInfo = request.getPathInfo(); String[] pathElements = getPathElements(pathInfo); if (pathElements.length == 0) { throw new InvalidRequestException(ServerResourceBundle.getInstance().getString("message.URLContextPath", new Object[] { pathInfo })); } else { //Iterate and retrieve each object along path. //Remember parentFolder as we iterate. for (int i = 0; i < pathElements.length; i++) { String pathElement = pathElements[i]; modifiedPathInfo += "/" + pathElement; matchedObjects = getRegistryObjectForPathElement(pathElement, parentFolder); if (matchedObjects.size() > 1) { //Multiple objects matched. Stop here and show partial directory listing break; } else if (matchedObjects.size() == 1) { //Matched 1 object. If not last in path then must be a RegistryPackage if (i != pathElements.length - 1) { RegistryObjectType ro = (RegistryObjectType) matchedObjects.get(0); if (ro instanceof RegistryPackageType) { parentFolder = (RegistryPackageType) ro; } else { throw new InvalidRequestException(ServerResourceBundle.getInstance().getString( "message.expectedRegistryPackage", new Object[] { ro.getClass(), pathInfo })); } } } } } }
From source file:it.cnr.icar.eric.client.xml.registry.RegistryFacadeImpl.java
@SuppressWarnings({ "unused", "static-access" }) public ExtrinsicObject publishFilesAsZip(String baseDirectory, String[] relativeFilePaths, Map<?, ?> metadata) throws JAXRException { ExtrinsicObjectImpl eo = null;//www. java 2 s .co m if (getLifeCycleManager() == null) { throw new JAXRException("setEndpoint MUST be called before setCredentials is called."); } try { //Create the zip file File zipFile = File.createTempFile("eric-RegistryFacadeImpl", ".zip"); zipFile.deleteOnExit(); FileOutputStream fos = new FileOutputStream(zipFile); ZipOutputStream zos = Utility.createZipOutputStream(baseDirectory, relativeFilePaths, fos); zos.close(); javax.activation.DataSource ds = new javax.activation.FileDataSource(zipFile); javax.activation.DataHandler dh = new javax.activation.DataHandler(ds); if (dh == null) { throw new JAXRException("Error processing zip file" + zipFile.getAbsolutePath()); } eo = (ExtrinsicObjectImpl) getLifeCycleManager().createExtrinsicObject(dh); String id = (String) metadata.remove(bu.CANONICAL_SLOT_IDENTIFIABLE_ID); String name = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_NAME); String description = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_DESCRIPTION); String objectType = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_OBJECTTYPE); //If id is specified then use it. if (id != null) { eo.setKey(lcm.createKey(id)); eo.setLid(id); } String eoId = eo.getKey().getId(); //If name is specified then use it. if (name != null) { eo.setName(lcm.createInternationalString(name)); } //If description is specified then use it. if (description != null) { eo.setDescription(lcm.createInternationalString(description)); } if (objectType == null) { throw new InvalidRequestException( JAXRResourceBundle.getInstance().getString("message.error.missingMetadata", new Object[] { bu.CANONICAL_SLOT_REGISTRY_OBJECT_OBJECTTYPE })); } eo.setMimeType("application/zip"); eo.setObjectTypeRef(new RegistryObjectRef(getLifeCycleManager(), objectType)); ArrayList<RegistryObject> objects = new ArrayList<RegistryObject>(); objects.add(eo); //??Turn of versioning on save as it creates problems BulkResponse br = getLifeCycleManager().saveObjects(objects, dontVersionSlotsMap); if (br.getExceptions() != null) { throw new JAXRException("Error publishing to registry", (Exception) (br.getExceptions().toArray()[0])); } if (br.getStatus() != BulkResponse.STATUS_SUCCESS) { throw new JAXRException("Error publishing to registry. See server logs for detils."); } } catch (IOException e) { throw new JAXRException(e); } return eo; }
From source file:it.cnr.icar.eric.client.xml.registry.infomodel.RegistryObjectImpl.java
/** * Internal method to set the objectType *///from w ww. ja v a 2 s . co m @SuppressWarnings("static-access") void setObjectTypeInternal(Concept objectType) throws JAXRException { if (objectType == null) { throw new InvalidRequestException( JAXRResourceBundle.getInstance().getString("message.objectTypeConceptMustNotBeNull")); } if (!objectType.getClassificationScheme().getKey().getId() .equals(bu.CANONICAL_CLASSIFICATION_SCHEME_ID_ObjectType)) { throw new InvalidRequestException( JAXRResourceBundle.getInstance().getString("message.mustBeObjectTypeConcept")); } objectTypeRef = new RegistryObjectRef(lcm, objectType); setModified(true); }
From source file:it.cnr.icar.eric.client.xml.registry.RegistryFacadeImpl.java
/** * Publishes a repositoryItem and the metadata that describes it. * * @param repositoryItem the URL to the repositoryItem being published. * @param metadata describing the repositoryItem * * @return the ExtrinsicObject published as metadata. * @see it.cnr.icar.eric.common.CanonicalConstants for constants that may be used to identify keys in metadaat HashMap *///from w w w. j a v a 2s . c o m @SuppressWarnings("static-access") public ExtrinsicObject publish(URL repositoryItem, Map<?, ?> metadata) throws JAXRException { ExtrinsicObjectImpl eo = null; if (lcm == null) { throw new JAXRException("setEndpoint MUST be called before setCredentials is called."); } javax.activation.DataSource ds = new javax.activation.URLDataSource(repositoryItem); javax.activation.DataHandler dh = new javax.activation.DataHandler(ds); eo = (ExtrinsicObjectImpl) lcm.createExtrinsicObject(dh); String id = (String) metadata.remove(bu.CANONICAL_SLOT_IDENTIFIABLE_ID); String name = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_NAME); String description = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_DESCRIPTION); String objectType = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_OBJECTTYPE); String mimeType = (String) metadata.remove(bu.CANONICAL_SLOT_EXTRINSIC_OBJECT_MIMETYPE); //If id is specified then use it. if (id != null) { eo.setKey(lcm.createKey(id)); eo.setLid(id); } @SuppressWarnings("unused") String eoId = eo.getKey().getId(); //If name is specified then use it. if (name != null) { eo.setName(lcm.createInternationalString(name)); } //If description is specified then use it. if (description != null) { eo.setDescription(lcm.createInternationalString(description)); } if (objectType == null) { throw new InvalidRequestException( JAXRResourceBundle.getInstance().getString("message.error.missingMetadata", new Object[] { bu.CANONICAL_SLOT_REGISTRY_OBJECT_OBJECTTYPE })); } if (mimeType == null) { throw new InvalidRequestException(JAXRResourceBundle.getInstance().getString( "message.error.missingMetadata", new Object[] { bu.CANONICAL_SLOT_EXTRINSIC_OBJECT_MIMETYPE })); } eo.setMimeType(mimeType); eo.setObjectTypeRef(new RegistryObjectRef(lcm, objectType)); //Set any remaining metadata properties as Slots JAXRUtility.addSlotsToRegistryObject(eo, metadata); ArrayList<RegistryObject> objects = new ArrayList<RegistryObject>(); objects.add(eo); BulkResponse br = lcm.saveObjects(objects, dontVersionSlotsMap); if (br.getExceptions() != null) { throw new JAXRException("Error publishing to registry", (Exception) (br.getExceptions().toArray()[0])); } if (br.getStatus() != BulkResponse.STATUS_SUCCESS) { throw new JAXRException("Error publishing to registry. See server logs for detils."); } return eo; }