List of usage examples for javax.xml.registry RegistryException RegistryException
public RegistryException(Throwable cause)
JAXRException
object initialized with the given Throwable
object. From source file:org.freebxml.omar.server.common.Utility.java
/** * Check if id is a proper UUID. If not make a proper UUID based * URN and add a mapping in idMap between old and new Id. The * parent attribute of ClassificationNode will be also fixed here * according to their hierarchy if the parent attributes are not * provided explicitly by the clients./*from w w w .jav a2 s . c o m*/ * * @param ids The List holding all the UUIDs in the SubmitObjectsRequest * document * @throws UUIDNotUniqueException if any UUID is not unique within a * SubmitObjectsRequest */ private void checkId(List ids, HashMap idMap, RegistryObjectType ro) throws RegistryException { try { String id = ro.getId(); // Check for uniqueness if ((ids != null) && ids.contains(id)) { throw new DuplicateIdException(id); } if (id != null) { ids.add(id); } if ((id == null) || !id.startsWith("urn:uuid:")) { // Generate UUID if the request does not provide ID for a RO // or it does not start with urn:uuid: java.util.UUID uuid = uf.newUUID(); String newId = "urn:uuid:" + uuid; ro.setId(newId); idMap.put(id, newId); } else { // id starts with "urn:uuid:" String uuidStr = id.substring(9); if (!uf.isValidUUID(uuidStr)) { // but invalid java.util.UUID uuid = uf.newUUID(); String newId = "urn:uuid:" + uuid; idMap.put(id, newId); } } //Now checkId for all composed objects Set composedObjects = BindingUtility.getInstance().getComposedRegistryObjects(ro, -1); Iterator iter = composedObjects.iterator(); while (iter.hasNext()) { RegistryObjectType obj = (RegistryObjectType) iter.next(); checkId(ids, idMap, ro); } } catch (JAXRException e) { throw new RegistryException(e); } }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
/** * Submits one or more RegistryObjects and one or more repository items. * <br>// w w w . ja v a 2 s .co m * <br> * Note: One more special feature that is not in the RS spec. version 2. * The SubmitObjectsRequest allows updating objects.If a object of a particular * id already exist, it is updated instead of trying to be inserted. * @param idToRepositoryItemMap is a HashMap with key that is id of a RegistryObject and value that is a RepositoryItem instance. */ public RegistryResponse submitObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); SubmitObjectsRequest req = (SubmitObjectsRequest) context.getCurrentRegistryRequest(); UserType user = context.getUser(); Map idToRepositoryItemMap = context.getRepositoryItemsMap(); String errorCodeContext = "LifeCycleManagerImpl.submitObjects"; String errorCode = "unknown"; RegistryResponse resp = null; try { calculateEffectiveUser(((ServerRequestContext) context)); RegistryObjectListType objs = req.getRegistryObjectList(); // insert member objects of RegistryPackages int objsSize = objs.getIdentifiable().size(); for (int i = 0; i < objsSize; i++) { Object identObj = objs.getIdentifiable().get(i); if (identObj instanceof RegistryPackage) { insertPackageMembers(objs, (RegistryPackage) identObj); } } //Split Identifiables by RegistryObjects and ObjectRefs bu.getObjectRefsAndRegistryObjects(objs, ((ServerRequestContext) context).getTopLevelObjectsMap(), ((ServerRequestContext) context).getObjectRefsMap()); processConfirmationAssociations(((ServerRequestContext) context)); ((ServerRequestContext) context).checkObjects(); //Auth check must be after checkObjects as it needs objectRefsMap etc. //for doing Access Control on references checkAuthorizedAll(((ServerRequestContext) context)); /* HIEOS/BHT (REMOVED): if (!bypassCMS) { //Now perform any content cataloging and validation for ExtrinsicObjects log.trace(ServerResourceBundle.getInstance().getString("message.CallingInvokeServicesAt", new Object[]{new Long(System.currentTimeMillis())})); cmsm.invokeServices(((ServerRequestContext) context)); log.trace(ServerResourceBundle.getInstance().getString("message.DoneCallingInvokeServicesAt", new Object[]{new Long(System.currentTimeMillis())})); } */ /* * For RegistryObjects, the DAO will take care which objects already * exist and update them instead */ log.trace(ServerResourceBundle.getInstance().getString("message.CallingPminsertAt", new Object[] { new Long(System.currentTimeMillis()) })); ArrayList list = new ArrayList(); list.addAll(((ServerRequestContext) context).getTopLevelObjectsMap().values()); pm.insert(((ServerRequestContext) context), list); log.trace(ServerResourceBundle.getInstance().getString("message.DoneCallingPminsertAt", new Object[] { new Long(System.currentTimeMillis()) })); resp = bu.rsFac.createRegistryResponse(); resp.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists resp.setRegistryErrorList(((ServerRequestContext) context).getErrorList()); } //Must be after CMS since CMS could generate more repository items. if ((((ServerRequestContext) context).getRepositoryItemsMap() != null) && (!(((ServerRequestContext) context).getRepositoryItemsMap().isEmpty()))) { submitRepositoryItems(((ServerRequestContext) context)); } } catch (RegistryException e) { ((ServerRequestContext) context).rollback(); throw e; } catch (IllegalStateException e) { //?? This is a JAXR spec bug that we do not send an UnauthorizedRequestException ((ServerRequestContext) context).rollback(); throw e; } catch (Exception e) { ((ServerRequestContext) context).rollback(); throw new RegistryException(e); } ((ServerRequestContext) context).commit(); return resp; }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
/** * Processes Associations looking for Associations that already exist and are being * submitted by source or target owner and are identical in state to existing * Association in registry. // w w w. j a v a2 s. co m * * ebXML Registry 3.0 hasber discarded association confirmation in favour of * Role Based access control. However, freebXML Registry supports it in an * impl specific manner as this is required by JAXR 1.0 API. * This SHOULD be removed once JAXR 2.0 no longer requires it for ebXML Registry * in future. * * The processing updates the Association to add a special Impl specific slot to * remember the confirmation state change. * * TODO: Need to do unconfirm when src or target owner removes an Association they had * previously confirmed. */ private void processConfirmationAssociations(ServerRequestContext context) throws RegistryException { try { //Make a copy to avoid ConcurrentModificationException ArrayList topLevelObjects = new ArrayList( ((ServerRequestContext) context).getTopLevelObjectsMap().values()); Iterator iter = topLevelObjects.iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof AssociationType1) { AssociationType1 ass = (AssociationType1) obj; HashMap slotsMap = bu.getSlotsFromRegistryObject(ass); String beingConfirmed = (String) slotsMap.remove(bu.IMPL_SLOT_ASSOCIATION_IS_BEING_CONFIRMED); if ((beingConfirmed != null) && (beingConfirmed.equalsIgnoreCase("true"))) { //Need to set slotMap again ass.getSlot().clear(); bu.addSlotsToRegistryObject(ass, slotsMap); ((ServerRequestContext) context).getConfirmationAssociations().put(ass.getId(), ass); } } } } catch (javax.xml.bind.JAXBException e) { throw new RegistryException(e); } }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
/** * Calculates the effective user to be used as the identity of the requestor. * Implements ability to re-assign user to a different user than the caller * if://from w w w . j a v a 2 s. c o m * * a) The actual caller is a RegistryAdministrator role, and * b) The request specifies the CANONICAL_SLOT_LCM_OWNER. * */ void calculateEffectiveUser(ServerRequestContext context) throws RegistryException { try { UserType caller = ((ServerRequestContext) context).getUser(); //See if CANONICAL_SLOT_LCM_OWNER defined on request HashMap slotsMap = bu.getSlotsFromRequest(((ServerRequestContext) context).getCurrentRegistryRequest()); String effectiveUserId = (String) slotsMap.get(bu.CANONICAL_SLOT_LCM_OWNER); if (effectiveUserId != null) { if (ac.hasRegistryAdministratorRole(caller)) { UserType effectiveUser = (UserType) pm.getRegistryObject(((ServerRequestContext) context), effectiveUserId, "User"); if (effectiveUser == null) { throw new RegistryException(ServerResourceBundle.getInstance() .getString("message.specifiedUserNotOwner", new Object[] { effectiveUserId })); } ((ServerRequestContext) context).setUser(effectiveUser); } else { throw new InvalidRequestException(ServerResourceBundle.getInstance() .getString("message.requestSlotInvalid", new Object[] { bu.CANONICAL_SLOT_LCM_OWNER })); } } } catch (javax.xml.bind.JAXBException e) { throw new RegistryException(e); } catch (InvalidRequestException e) { throw new RegistryException(e); } }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
/** Approves one or more previously submitted objects */ public RegistryResponse approveObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); ApproveObjectsRequest req = (ApproveObjectsRequest) context.getCurrentRegistryRequest(); UserType user = context.getUser();//from w w w. java 2 s . c o m String errorCodeContext = "LifeCycleManagerImpl.approveObjects"; String errorCode = "unknown"; RegistryResponse resp = null; try { context = new ServerRequestContext("LifeCycleManagerImpl.approveObjects", req); ((ServerRequestContext) context).setUser(user); checkAuthorizedAll(((ServerRequestContext) context)); List idList = new java.util.ArrayList(); //Add explicitly specified oref params List orefs = bu.getObjectRefsFromObjectRefList(req.getObjectRefList()); //Append those orefs specified via ad hoc query param orefs.addAll(((ServerRequestContext) context).getObjectsRefsFromQueryResults(req.getAdhocQuery())); Iterator orefsIter = orefs.iterator(); while (orefsIter.hasNext()) { ObjectRefType oref = (ObjectRefType) orefsIter.next(); idList.add(oref.getId()); } pm.updateStatus(((ServerRequestContext) context), idList, bu.CANONICAL_STATUS_TYPE_ID_Approved); resp = bu.rsFac.createRegistryResponse(); resp.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists resp.setRegistryErrorList(((ServerRequestContext) context).getErrorList()); } } catch (RegistryException e) { ((ServerRequestContext) context).rollback(); throw e; } catch (Exception e) { ((ServerRequestContext) context).rollback(); throw new RegistryException(e); } ((ServerRequestContext) context).commit(); return resp; }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
public RegistryResponse updateObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); RegistryResponse resp = null;/*from w w w . jav a2s . c o m*/ UpdateObjectsRequest req = (UpdateObjectsRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); Map idToRepositoryMap = ((ServerRequestContext) context).getRepositoryItemsMap(); UserType user = ((ServerRequestContext) context).getUser(); try { calculateEffectiveUser(((ServerRequestContext) context)); ((ServerRequestContext) context).setRepositoryItemsMap(idToRepositoryMap); RegistryObjectListType objs = req.getRegistryObjectList(); //Split Identifiables by RegistryObjects and ObjectRefs bu.getObjectRefsAndRegistryObjects(objs, ((ServerRequestContext) context).getTopLevelObjectsMap(), ((ServerRequestContext) context).getObjectRefsMap()); ((ServerRequestContext) context).checkObjects(); //Auth check must be after checkObjects as it needs //objectRefsMap etc. for doing Access Control on //references checkAuthorizedAll(((ServerRequestContext) context)); if ((((ServerRequestContext) context).getRepositoryItemsMap() != null) && (!(((ServerRequestContext) context).getRepositoryItemsMap().isEmpty()))) { updateRepositoryItems(((ServerRequestContext) context), ((ServerRequestContext) context).getRepositoryItemsMap()); } ArrayList list = new ArrayList(); list.addAll(((ServerRequestContext) context).getTopLevelObjectsMap().values()); pm.update(((ServerRequestContext) context), list); resp = bu.rsFac.createRegistryResponse(); resp.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists resp.setRegistryErrorList(((ServerRequestContext) context).getErrorList()); } } catch (RegistryException e) { ((ServerRequestContext) context).rollback(); throw e; } catch (IllegalStateException e) { //?? This is a JAXR spec bug that we do not send an UnauthorizedRequestException ((ServerRequestContext) context).rollback(); throw e; } catch (Exception e) { ((ServerRequestContext) context).rollback(); throw new RegistryException(e); } ((ServerRequestContext) context).commit(); return resp; }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
/** Sets the status of specified objects. This is an extension request that will be adde to ebRR 3.1?? */ public RegistryResponse setStatusOnObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); RegistryResponse resp = null;/*w w w .j a va 2 s. c o m*/ SetStatusOnObjectsRequest req = (SetStatusOnObjectsRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); Map idToRepositoryMap = ((ServerRequestContext) context).getRepositoryItemsMap(); UserType user = ((ServerRequestContext) context).getUser(); try { checkAuthorizedAll(((ServerRequestContext) context)); List idList = new java.util.ArrayList(); //Add explicitly specified oref params List orefs = bu.getObjectRefsFromObjectRefList(req.getObjectRefList()); //Append those orefs specified via ad hoc query param orefs.addAll(((ServerRequestContext) context).getObjectsRefsFromQueryResults(req.getAdhocQuery())); Iterator orefsIter = orefs.iterator(); while (orefsIter.hasNext()) { ObjectRefType oref = (ObjectRefType) orefsIter.next(); idList.add(oref.getId()); } String statusId = req.getStatus(); pm.updateStatus(((ServerRequestContext) context), idList, statusId); resp = bu.rsFac.createRegistryResponse(); resp.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists resp.setRegistryErrorList(((ServerRequestContext) context).getErrorList()); } } catch (RegistryException e) { ((ServerRequestContext) context).rollback(); throw e; } catch (Exception e) { ((ServerRequestContext) context).rollback(); throw new RegistryException(e); } ((ServerRequestContext) context).commit(); return resp; }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
/** Deprecates one or more previously submitted objects */ public RegistryResponse deprecateObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); RegistryResponse resp = null;//from www . j a va 2s . co m DeprecateObjectsRequest req = (DeprecateObjectsRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); Map idToRepositoryMap = ((ServerRequestContext) context).getRepositoryItemsMap(); UserType user = ((ServerRequestContext) context).getUser(); try { checkAuthorizedAll(((ServerRequestContext) context)); List idList = new java.util.ArrayList(); //Add explicitly specified oref params List orefs = bu.getObjectRefsFromObjectRefList(req.getObjectRefList()); //Append those orefs specified via ad hoc query param orefs.addAll(((ServerRequestContext) context).getObjectsRefsFromQueryResults(req.getAdhocQuery())); Iterator orefsIter = orefs.iterator(); while (orefsIter.hasNext()) { ObjectRefType oref = (ObjectRefType) orefsIter.next(); idList.add(oref.getId()); } pm.updateStatus(((ServerRequestContext) context), idList, bu.CANONICAL_STATUS_TYPE_ID_Deprecated); resp = bu.rsFac.createRegistryResponse(); resp.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists resp.setRegistryErrorList(((ServerRequestContext) context).getErrorList()); } } catch (RegistryException e) { ((ServerRequestContext) context).rollback(); throw e; } catch (Exception e) { ((ServerRequestContext) context).rollback(); throw new RegistryException(e); } ((ServerRequestContext) context).commit(); return resp; }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
public RegistryResponse unDeprecateObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); RegistryResponse resp = null;//w w w . j ava2 s . co m UndeprecateObjectsRequest req = (UndeprecateObjectsRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); Map idToRepositoryMap = ((ServerRequestContext) context).getRepositoryItemsMap(); UserType user = ((ServerRequestContext) context).getUser(); try { checkAuthorizedAll(((ServerRequestContext) context)); List idList = new java.util.ArrayList(); //Add explicitly specified oref params List orefs = bu.getObjectRefsFromObjectRefList(req.getObjectRefList()); //Append those orefs specified via ad hoc query param orefs.addAll(((ServerRequestContext) context).getObjectsRefsFromQueryResults(req.getAdhocQuery())); Iterator orefsIter = orefs.iterator(); while (orefsIter.hasNext()) { ObjectRefType oref = (ObjectRefType) orefsIter.next(); idList.add(oref.getId()); } pm.updateStatus(((ServerRequestContext) context), idList, bu.CANONICAL_STATUS_TYPE_ID_Submitted); resp = bu.rsFac.createRegistryResponse(); resp.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists resp.setRegistryErrorList(((ServerRequestContext) context).getErrorList()); } } catch (RegistryException e) { ((ServerRequestContext) context).rollback(); throw e; } catch (Exception e) { ((ServerRequestContext) context).rollback(); throw new RegistryException(e); } ((ServerRequestContext) context).commit(); return resp; }
From source file:org.freebxml.omar.server.lcm.LifeCycleManagerImpl.java
/** * Removes one or more previously submitted objects from the registry. If the * deletionScope is "DeleteRepositoryItemOnly", it will assume all the * ObjectRef under ObjectRefList is referencing repository items. If the * deletionScope is "DeleteAll", the reference may be either RegistryObject * or repository item. In both case, if the referenced object cannot be found, * RegistryResponse with errors list will be returned. *///from w w w . j a v a 2 s . com public RegistryResponse removeObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); ServerRequestContext _context = (ServerRequestContext) context; RegistryResponse resp = null; RemoveObjectsRequest req = (RemoveObjectsRequest) _context.getCurrentRegistryRequest(); Map idToRepositoryMap = _context.getRepositoryItemsMap(); UserType user = _context.getUser(); //This request option instructs the server to delete objects even if references exist to them boolean forceDelete = false; //This request option instructs the server to also delete the network of objects reachable by //reference from the objects being deleted. This option is not implemented yet. boolean cascadeDelete = false; try { //Get relevant request slots if any HashMap requestSlots = bu.getSlotsFromRequest(req); if (requestSlots.containsKey(bu.CANONICAL_SLOT_DELETE_MODE_FORCE)) { String val = (String) requestSlots.get(bu.CANONICAL_SLOT_DELETE_MODE_FORCE); if (val.trim().equalsIgnoreCase("true")) { forceDelete = true; } } if (requestSlots.containsKey(bu.CANONICAL_SLOT_DELETE_MODE_CASCADE)) { String val = (String) requestSlots.get(bu.CANONICAL_SLOT_DELETE_MODE_CASCADE); if (val.trim().equalsIgnoreCase("true")) { cascadeDelete = true; } } List orefs = null; if (req.getObjectRefList() == null) { org.oasis.ebxml.registry.bindings.rim.ObjectRefList orList = bu.rimFac.createObjectRefList(); req.setObjectRefList(orList); } //Add explicitly specified oref params orefs = bu.getObjectRefsFromObjectRefList(req.getObjectRefList()); //Append those orefs specified via ad hoc query param orefs.addAll(_context.getObjectsRefsFromQueryResults(req.getAdhocQuery())); Iterator orefsIter = orefs.iterator(); while (orefsIter.hasNext()) { ObjectRefType oref = (ObjectRefType) orefsIter.next(); _context.getObjectRefsMap().put(oref.getId(), oref); } List idList = new ArrayList(_context.getObjectRefsMap().keySet()); pm.updateIdToLidMap(_context, _context.getObjectRefsMap().keySet(), "RegistryObject"); Set idsNotInRegistry = _context.getIdsNotInRegistry(_context.getObjectRefsMap().keySet()); if (idsNotInRegistry.size() > 0) { throw new ObjectsNotFoundException(new ArrayList(idsNotInRegistry)); } checkAuthorizedAll(_context); String deletionScope = BindingUtility.CANONICAL_DELETION_SCOPE_TYPE_ID_DeleteAll; if (req.getDeletionScope() != null) { deletionScope = req.getDeletionScope(); } //DeletionScope=DeleteRepositoryItemOnly. If any repository item //does not exist, it will stop if (deletionScope.equals(BindingUtility.CANONICAL_DELETION_SCOPE_TYPE_ID_DeleteRepositoryItemOnly)) { List notExist = rm.itemsExist(idList); if (notExist.size() > 0) { throw new ObjectsNotFoundException(notExist); } //Should RepositoryItem be deleted even when referencesExist?? //if (!forceDelete) { // pm.checkIfReferencesExist((ServerRequestContext) context, idList); //} rm.delete(idList); } else if (deletionScope.equals(BindingUtility.CANONICAL_DELETION_SCOPE_TYPE_ID_DeleteAll)) { //find out which id is not an id of a repository item (i.e. //referencing RO only List nonItemsIds = rm.itemsExist(idList); //find out which id is an id of a repository item List itemsIds = new java.util.ArrayList(); Iterator idListIt = idList.iterator(); while (idListIt.hasNext()) { Object id = idListIt.next(); if (!nonItemsIds.contains(id)) { itemsIds.add(id); } } if (!forceDelete) { pm.checkIfReferencesExist((ServerRequestContext) context, idList); } // Delete the repository items rm.delete(itemsIds); //Delete all ROs with the ids pm.delete(_context, orefs); } else { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.undefinedDeletionScope")); } resp = bu.rsFac.createRegistryResponse(); resp.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); } catch (RegistryException e) { ((ServerRequestContext) context).rollback(); throw e; } catch (Exception e) { ((ServerRequestContext) context).rollback(); throw new RegistryException(e); } ((ServerRequestContext) context).commit(); return resp; }