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:it.cnr.icar.eric.server.lcm.LifeCycleManagerImpl.java
public RegistryResponseType updateObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); RegistryResponseType ebRegistryResponseType = null; UpdateObjectsRequest req = (UpdateObjectsRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); HashMap<String, Object> idToRepositoryMap = ((ServerRequestContext) context).getRepositoryItemsMap(); @SuppressWarnings("unused") UserType user = ((ServerRequestContext) context).getUser(); try {/*from w w w. jav a 2 s. c om*/ calculateEffectiveUser(((ServerRequestContext) context)); ((ServerRequestContext) context).setRepositoryItemsMap(idToRepositoryMap); RegistryObjectListType objs = req.getRegistryObjectList(); // Split Identifiables by RegistryObjects and ObjectRefs bu.getObjectRefsAndRegistryObjects(objs, ((ServerRequestContext) context).getTopLevelRegistryObjectTypeMap(), ((ServerRequestContext) context).getObjectRefTypeMap()); ((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<IdentifiableType> list = new ArrayList<IdentifiableType>(); list.addAll(((ServerRequestContext) context).getTopLevelRegistryObjectTypeMap().values()); pm.update(((ServerRequestContext) context), list); ebRegistryResponseType = bu.rsFac.createRegistryResponseType(); ebRegistryResponseType.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists ebRegistryResponseType.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 ebRegistryResponseType; }
From source file:it.cnr.icar.eric.server.security.authorization.AuthorizationServiceImpl.java
private void checkObjectReferencesInResource(ServerRequestContext context, String id, Set<Subject> subjects, Set<Attribute> environment) throws RegistryException { try {/*www.j av a 2 s.c o m*/ // Check if object being submitted has any reference actions that // need to be checked. RegistryObjectType ro = (RegistryObjectType) context.getSubmittedObjectsMap().get(id); Set<ReferenceInfo> refInfos = bu.getObjectRefsInRegistryObject(ro, context.getIdMap(), new HashSet<RegistryObjectType>(), 1); Iterator<ReferenceInfo> iter = refInfos.iterator(); while (iter.hasNext()) { ReferenceInfo refInfo = iter.next(); Set<Attribute> actionAttributes = getReferenceActionAttributes(refInfo); if ((actionAttributes != null) && (actionAttributes.size() > 0)) { try { checkAuthorizationForResource(context, refInfo.targetObject, subjects, actionAttributes, environment); } catch (UnauthorizedRequestException e) { String msg = getExceptionMessage( "message.error.authorization.referenceToDeprecatedObjectDenied", id, context.getUser(), getActionString(actionAttributes)); // ?? This is a JAXR spec bug that we do not send an // UnauthorizedRequestException // IllegalStateException constructor changed to not // include the cause, since that won't compile under JDK // 1.4 // TODO: Use reflection to issue this call to account // for differences between JDK 1.4 and 1.5 constructor // parameters? // throw new IllegalStateException(msg, e); throw new IllegalStateException(msg); } } if (ro instanceof AssociationType1) { AssociationType1 ass = (AssociationType1) ro; String assocType = ass.getAssociationType(); // Check to prevent multiple AccessControlFileFor // associations with same targetObject if ((assocType != null) && assocType.equalsIgnoreCase( BindingUtility.CANONICAL_ASSOCIATION_TYPE_ID_AccessControlPolicyFor)) { checkAccessControlPolicyForAssociation(context, ass); } // Check to prevent HasFederationMember assoc to be // submitted by non-admin if ((assocType != null) && assocType .equalsIgnoreCase(BindingUtility.CANONICAL_ASSOCIATION_TYPE_ID_HasFederationMember)) { if (!(context.isRegistryAdministrator())) { String msg = getExceptionMessage( "message.error.authorization.allowedOnlyToAdmin.defineFederation", id, context.getUser(), getActionString(actionAttributes)); throw new UnauthorizedRequestException(id, context.getUser().getId(), getActionString(actionAttributes), msg); } } } } } catch (AuthorizationException e) { throw e; } catch (JAXRException e) { throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.lcm.LifeCycleManagerImpl.java
/** * Sets the status of specified objects. This is an extension request that * will be adde to ebRR 3.1??// www. jav a 2 s .com */ @SuppressWarnings({ "unused", "unchecked" }) public RegistryResponseType setStatusOnObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); RegistryResponseType ebRegistryResponseType = null; SetStatusOnObjectsRequest ebSetStatusOnObjectsRequest = (SetStatusOnObjectsRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); HashMap<String, Object> idToRepositoryMap = ((ServerRequestContext) context).getRepositoryItemsMap(); UserType ebUserType = ((ServerRequestContext) context).getUser(); try { checkAuthorizedAll(((ServerRequestContext) context)); List<String> idList = new java.util.ArrayList<String>(); // Add explicitly specified oref params List<ObjectRefType> ebObjectRefTypeList = bu .getObjectRefTypeListFromObjectRefListType(ebSetStatusOnObjectsRequest.getObjectRefList()); // Append those orefs specified via ad hoc query param ebObjectRefTypeList.addAll((List<ObjectRefType>) ((ServerRequestContext) context) .getObjectsRefTypeListFromQueryResults(ebSetStatusOnObjectsRequest.getAdhocQuery())); Iterator<ObjectRefType> ebObjectRefTypeIter = ebObjectRefTypeList.iterator(); while (ebObjectRefTypeIter.hasNext()) { ObjectRefType ebObjectRefType = ebObjectRefTypeIter.next(); idList.add(ebObjectRefType.getId()); } String statusId = ebSetStatusOnObjectsRequest.getStatus(); pm.updateStatus(((ServerRequestContext) context), idList, statusId); ebRegistryResponseType = bu.rsFac.createRegistryResponseType(); ebRegistryResponseType.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists ebRegistryResponseType.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 ebRegistryResponseType; }
From source file:it.cnr.icar.eric.server.security.authorization.AuthorizationServiceImpl.java
@SuppressWarnings({ "deprecation", "static-access" }) private Set<Attribute> getReferenceActionAttributes(ReferenceInfo refInfo) throws RegistryException { Set<Attribute> actionAttributes = new HashSet<Attribute>(); try {// ww w.ja v a 2 s. c om // The id for the "reference" action Attribute idAttr = new Attribute(new URI(ACTION_ATTRIBUTE_ID), new URI(StringAttribute.identifier), null, null, new StringAttribute(bu.ACTION_REFERENCE)); actionAttributes.add(idAttr); // The sourceObject for the "reference" action Attribute refSourceAttr = new Attribute(new URI(ACTION_ATTRIBUTE_REFERENCE_SOURCE), new URI(AnyURIAttribute.identifier), null, null, new AnyURIAttribute(new URI(refInfo.sourceObject))); actionAttributes.add(refSourceAttr); // The attribute within the source object for the "reference" // action. Attribute refSourceAttributeAttr = new Attribute(new URI(ACTION_ATTRIBUTE_REFERENCE_SOURCE_ATTRIBUTE), new URI(StringAttribute.identifier), null, null, new StringAttribute(refInfo.attributeName)); actionAttributes.add(refSourceAttributeAttr); } catch (URISyntaxException e) { throw new RegistryException(e); } return actionAttributes; }
From source file:it.cnr.icar.eric.server.lcm.LifeCycleManagerImpl.java
/** Deprecates one or more previously submitted objects */ @SuppressWarnings({ "unused", "unchecked", "static-access" }) public RegistryResponseType deprecateObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); RegistryResponseType ebRegistryResponseType = null; DeprecateObjectsRequest ebDeprecateObjectsRequest = (DeprecateObjectsRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); Map<?, ?> idToRepositoryMap = ((ServerRequestContext) context).getRepositoryItemsMap(); UserType ebUserType = ((ServerRequestContext) context).getUser(); try {/*from w w w . j ava 2s . co m*/ checkAuthorizedAll(((ServerRequestContext) context)); List<String> idList = new java.util.ArrayList<String>(); // Add explicitly specified oref params List<ObjectRefType> ebObjectRefTypeList = bu .getObjectRefTypeListFromObjectRefListType(ebDeprecateObjectsRequest.getObjectRefList()); // Append those orefs specified via ad hoc query param ebObjectRefTypeList.addAll((List<ObjectRefType>) ((ServerRequestContext) context) .getObjectsRefTypeListFromQueryResults(ebDeprecateObjectsRequest.getAdhocQuery())); Iterator<ObjectRefType> ebObjectRefTypeIter = ebObjectRefTypeList.iterator(); while (ebObjectRefTypeIter.hasNext()) { ObjectRefType ebObjectRefType = ebObjectRefTypeIter.next(); idList.add(ebObjectRefType.getId()); } pm.updateStatus(((ServerRequestContext) context), idList, bu.CANONICAL_STATUS_TYPE_ID_Deprecated); ebRegistryResponseType = bu.rsFac.createRegistryResponseType(); ebRegistryResponseType.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists ebRegistryResponseType.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 ebRegistryResponseType; }
From source file:it.cnr.icar.eric.server.persistence.rdb.SQLPersistenceManagerImpl.java
/** * Update the status of specified objects to the specified status. * /*from ww w. jav a2s .com*/ */ @SuppressWarnings("static-access") public void updateStatus(ServerRequestContext context, List<String> registryObjectsIds, String status) throws RegistryException { try { // Make sure that status is a ref to a StatusType ClassificationNode context.checkClassificationNodeRefConstraint(status, bu.CANONICAL_CLASSIFICATION_SCHEME_ID_StatusType, "status"); ObjectRefListType ebObjectRefListType = bu.rimFac.createObjectRefListType(); List<ObjectRefType> refs = bu.getObjectRefsFromRegistryObjectIds(registryObjectsIds); Iterator<ObjectRefType> iter = refs.iterator(); while (iter.hasNext()) { ObjectRefType ebObjectRefType = iter.next(); RegistryObjectType ebRegistryObjectType = getRegistryObject(context, ebObjectRefType); RegistryObjectDAO roDAO = (RegistryObjectDAO) getDAOForObject(ebRegistryObjectType, context); roDAO.updateStatus(ebRegistryObjectType, status); ebObjectRefListType.getObjectRef().add(ebObjectRefType); } // repeat behavior of DAO.prepareToXXX methods for direct/indirect // setStatus if (context.getCurrentRegistryRequest() instanceof ApproveObjectsRequest) { context.getApproveEvent().setAffectedObjects(ebObjectRefListType); context.addAffectedObjectsToAuditableEvent(context.getApproveEvent(), ebObjectRefListType); } else if (context.getCurrentRegistryRequest() instanceof DeprecateObjectsRequest) { context.getDeprecateEvent().setAffectedObjects(ebObjectRefListType); context.addAffectedObjectsToAuditableEvent(context.getDeprecateEvent(), ebObjectRefListType); } else if (context.getCurrentRegistryRequest() instanceof UndeprecateObjectsRequest) { context.getUnDeprecateEvent().setAffectedObjects(ebObjectRefListType); context.addAffectedObjectsToAuditableEvent(context.getUnDeprecateEvent(), ebObjectRefListType); } else if (context.getCurrentRegistryRequest() instanceof SetStatusOnObjectsRequest) { SetStatusOnObjectsRequest req = (SetStatusOnObjectsRequest) context.getCurrentRegistryRequest(); context.getSetStatusEvent().setAffectedObjects(ebObjectRefListType); context.getSetStatusEvent().setEventType(req.getStatus()); context.addAffectedObjectsToAuditableEvent(context.getSetStatusEvent(), ebObjectRefListType); } } catch (JAXRException e) { throw new RegistryException(e); } }
From source file:it.cnr.icar.eric.server.query.QueryManagerImpl.java
/** * Checks if supplied query is a parameterized query. If not return the same * query. If stored parameterized query then return a new query after * fetching the specified parameterized query from registry, replacing its * positional parameters with supplied parameters. If special parameterized * query then invoke special query and set its results on * context.getSpecialQueryResults(). If neither not a parameterized query at * all then simply return the original request. *//*from w w w. j a v a 2 s . c o m*/ private void processForParameterizedQuery(ServerRequestContext context) throws RegistryException { // First check if it is a AdhocQueryRequest ebAdhocQueryRequest = (AdhocQueryRequest) (context).getCurrentRegistryRequest(); getQueryParameters(context); String queryId = context.getQueryId(); @SuppressWarnings("unused") Map<?, ?> queryParamsMap = context.getQueryParamsMap(); @SuppressWarnings("unused") SlotListType slotList = ebAdhocQueryRequest.getRequestSlotList(); // If queryId is not null then get the AdhocQuery from registry, plug // the parameters // and set it as newReq if (queryId != null) { // This is a parameterized query QueryPlugin plugin = getQueryPlugin(context); if (plugin != null) { // Found a plugin for this queryId. invoke it plugin.processRequest(context); } else { // Must be a stored query since no plugin was found. // TODO: Assumes SQLQuery. Needs to support FilterQuery AdhocQueryType adhocQuery = (AdhocQueryType) ServerCache.getInstance().getRegistryObject(context, queryId, "AdhocQuery"); if (adhocQuery == null) { throw new ObjectNotFoundException(queryId, "AdhocQuery"); } try { // Need to make a copy of the query before // plugQueryParameters as the query may be cached and should // not be modified in place. adhocQuery = (AdhocQueryType) BindingUtility.getInstance().cloneRegistryObject(adhocQuery); adhocQuery = plugQueryParameters(adhocQuery, context.getQueryParamsMap(), context.getStoredQueryParams()); ebAdhocQueryRequest.setAdhocQuery(adhocQuery); } catch (JAXBException e) { throw new RegistryException(e); } catch (JAXRException e) { throw new RegistryException(e); } } } }
From source file:it.cnr.icar.eric.server.persistence.rdb.SQLPersistenceManagerImpl.java
/** * Given a Binding object returns the OMARDAO for that object. * /* w w w .j av a 2 s. c om*/ */ private OMARDAO getDAOForObject(RegistryObjectType ro, ServerRequestContext context) throws RegistryException { OMARDAO dao = null; try { @SuppressWarnings("unused") String bindingClassName = ro.getClass().getName(); // reuse same mapper as for tablenames // this handles Type1 endings correctly String daoClassName = Utility.getInstance().mapDAOName(ro); // Construct the corresponding DAO instance using reflections Class<?> daoClazz = Class.forName("it.cnr.icar.eric.server.persistence.rdb." + daoClassName + "DAO"); Class<?>[] conParameterTypes = new Class[1]; conParameterTypes[0] = context.getClass(); Object[] conParameterValues = new Object[1]; conParameterValues[0] = context; Constructor<?>[] cons = daoClazz.getDeclaredConstructors(); // Find the constructor that takes RequestContext as its only arg Constructor<?> con = null; for (int i = 0; i < cons.length; i++) { con = cons[i]; if ((con.getParameterTypes().length == 1) && (con.getParameterTypes()[0] == conParameterTypes[0])) { dao = (OMARDAO) con.newInstance(conParameterValues); break; } } } catch (Exception e) { throw new RegistryException(e); } return dao; }
From source file:it.cnr.icar.eric.server.lcm.LifeCycleManagerImpl.java
@SuppressWarnings({ "unused", "unchecked", "static-access" }) public RegistryResponseType unDeprecateObjects(RequestContext context) throws RegistryException { context = ServerRequestContext.convert(context); RegistryResponseType ebRegistryResponseType = null; UndeprecateObjectsRequest ebUndeprecateObjectsRequest = (UndeprecateObjectsRequest) ((ServerRequestContext) context) .getCurrentRegistryRequest(); HashMap<String, Object> idToRepositoryMap = ((ServerRequestContext) context).getRepositoryItemsMap(); UserType ebUserType = ((ServerRequestContext) context).getUser(); try {/*from www . ja v a 2 s .c o m*/ checkAuthorizedAll(((ServerRequestContext) context)); List<String> idList = new java.util.ArrayList<String>(); // Add explicitly specified oref params List<ObjectRefType> ebObjectRefTypeList = bu .getObjectRefTypeListFromObjectRefListType(ebUndeprecateObjectsRequest.getObjectRefList()); // Append those orefs specified via ad hoc query param ebObjectRefTypeList.addAll((List<ObjectRefType>) ((ServerRequestContext) context) .getObjectsRefTypeListFromQueryResults(ebUndeprecateObjectsRequest.getAdhocQuery())); Iterator<ObjectRefType> ebObjectRefTypeIter = ebObjectRefTypeList.iterator(); while (ebObjectRefTypeIter.hasNext()) { ObjectRefType ebObjectRefType = ebObjectRefTypeIter.next(); idList.add(ebObjectRefType.getId()); } pm.updateStatus(((ServerRequestContext) context), idList, bu.CANONICAL_STATUS_TYPE_ID_Submitted); ebRegistryResponseType = bu.rsFac.createRegistryResponseType(); ebRegistryResponseType.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); if (((ServerRequestContext) context).getErrorList().getRegistryError().size() > 0) { // warning exists ebRegistryResponseType.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 ebRegistryResponseType; }
From source file:it.cnr.icar.eric.server.common.ServerRequestContext.java
public void commit() throws RegistryException { //Dont commit unless this is the last request in stack. if ((connection != null) && (getRegistryRequestStack().size() <= 1)) { try {/*w w w .ja v a2 s. c o m*/ //Save auditable events prior to commit saveAuditableEvents(); //Only commit if LCM_DO_NOT_COMMIT is unspecified or false String dontCommit = null; if (getRegistryRequestStack().size() > 0) { HashMap<String, Object> slotsMap = bu.getSlotsFromRequest(this.getCurrentRegistryRequest()); dontCommit = (String) slotsMap.get(BindingUtility.CANONICAL_SLOT_LCM_DO_NOT_COMMIT); } if ((dontCommit == null) || (dontCommit.equalsIgnoreCase("false"))) { connection.commit(); pm.releaseConnection(this, connection); connection = null; //New connection can be created in sendEventsToEventManager() which must be released try { sendEventsToEventManager(); updateCache(); } catch (Exception e) { rollback(); log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e); } if (connection != null) { connection.commit(); pm.releaseConnection(this, connection); connection = null; } } else { rollback(); } } catch (RegistryException e) { rollback(); throw e; } catch (JAXBException e) { rollback(); throw new RegistryException(e); } catch (SQLException e) { rollback(); throw new RegistryException(e); } //Call RequestInterceptors if (getRegistryRequestStack().size() == 1) { //Only intercept top level requests. //Still causing infinite recursion and StackOverflow //RequestInterceptorManager.getInstance().postProcessRequest(this); } } }