Example usage for javax.xml.registry InvalidRequestException InvalidRequestException

List of usage examples for javax.xml.registry InvalidRequestException InvalidRequestException

Introduction

In this page you can find the example usage for javax.xml.registry InvalidRequestException InvalidRequestException.

Prototype

public InvalidRequestException(Throwable cause) 

Source Link

Document

Constructs a JAXRException object initialized with the given Throwable object.

Usage

From source file:org.freebxml.omar.server.common.ServerRequestContext.java

/**
 * Checks each object including composed objects.
 *///from w w  w. j ava  2  s .  c o  m
public void checkObjects() throws RegistryException {
    try {
        //Process ObjectRefs and create local replicas of any remote ObjectRefs
        createReplicasOfRemoteObjectRefs();

        //Get all submitted objects including composed objects that are part of the submission
        //so that they can be used to resolve references
        getSubmittedObjectsMap().putAll(getTopLevelObjectsMap());

        Set composedObjects = bu.getComposedRegistryObjects(getTopLevelObjectsMap().values(), -1);
        getSubmittedObjectsMap().putAll(bu.getRegistryObjectMap(composedObjects));

        pm.updateIdToLidMap(this, getSubmittedObjectsMap().keySet(), "RegistryObject");

        getNewSubmittedObjectIds();

        //Check id of each object (top level or composed)
        Iterator iter = getSubmittedObjectsMap().values().iterator();
        while (iter.hasNext()) {
            RegistryObjectType ro = (RegistryObjectType) iter.next();

            //AuditableEvents are not allowed to be submitted by clients
            if (ro instanceof AuditableEventType) {
                throw new InvalidRequestException(
                        ServerResourceBundle.getInstance().getString("message.auditableEventsNotAllowed"));
            }

            checkId(ro);
        }

        //Get RegistryObjects referenced by submittedObjects.
        this.getReferenceInfos();

        //Append the references to the IdToLidMap

        iter = this.referencedInfos.iterator();
        Set referencedIds = new HashSet();
        while (iter.hasNext()) {
            ReferenceInfo refInfo = (ReferenceInfo) iter.next();
            referencedIds.add(refInfo.targetObject);
        }

        pm.updateIdToLidMap(this, referencedIds, "RegistryObject");

        //Iterate over idMap and replace keys in various structures that use id as key
        //that are based on temporary ids with their permanent id.
        iter = getIdMap().keySet().iterator();
        while (iter.hasNext()) {
            String idOld = (String) iter.next();
            String idNew = (String) getIdMap().get(idOld);

            //replace in all RequestContext data structures
            Object obj = getTopLevelObjectsMap().remove(idOld);
            if (obj != null) {
                getTopLevelObjectsMap().put(idNew, obj);
            }
            obj = getSubmittedObjectsMap().remove(idOld);
            if (obj != null) {
                getSubmittedObjectsMap().put(idNew, obj);
            }
            if (getNewSubmittedObjectIds().remove(idOld)) {
                getNewSubmittedObjectIds().add(idNew);
            }

            RepositoryItem ri = (RepositoryItem) getRepositoryItemsMap().remove(idOld);
            if (ri != null) {
                ri.setId(idNew);
                getRepositoryItemsMap().put(idNew, ri);
            }
        }

        //Now replace any old versions of RegistryObjects with new versions
        iter = getNewROVersionMap().keySet().iterator();
        while (iter.hasNext()) {
            RegistryObjectType roOld = (RegistryObjectType) iter.next();
            RegistryObjectType roNew = (RegistryObjectType) getNewROVersionMap().get(roOld);

            //replace in all data structures
            getSubmittedObjectsMap().remove(roOld.getId());
            getSubmittedObjectsMap().put(roNew.getId(), roNew);
            getTopLevelObjectsMap().remove(roOld.getId());
            getTopLevelObjectsMap().put(roNew.getId(), roNew);
        }

        //Now replace any old versions of RepositoryItems with new versions
        iter = getNewRIVersionMap().keySet().iterator();
        while (iter.hasNext()) {
            RepositoryItem riOld = (RepositoryItem) iter.next();
            RepositoryItem riNew = (RepositoryItem) getNewRIVersionMap().get(riOld);

            //replace in all RequestContext data structures
            getRepositoryItemsMap().remove(riOld.getId());
            getRepositoryItemsMap().put(riNew.getId(), riNew);
        }

        //resolve references from each object
        resolveObjectReferences();
    } catch (JAXRException 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 .ja v  a2 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);
    }
}