Example usage for javax.xml.registry RegistryException RegistryException

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

Introduction

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

Prototype

public RegistryException(Throwable cause) 

Source Link

Document

Constructs a JAXRException object initialized with the given Throwable object.

Usage

From source file:org.freebxml.omar.server.cache.ObjectCache.java

void putRegistryObjects(List registryObjects) throws RegistryException {
    Iterator iter = registryObjects.iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj != null) {
            if (obj instanceof RegistryObjectType) {
                RegistryObjectType ro = (RegistryObjectType) obj;
                putRegistryObject(ro);//from  w w w . jav  a 2 s.c om
            } else {
                throw new RegistryException(CommonResourceBundle.getInstance().getString(
                        "message.unexpectedObjectType", new Object[] { obj.getClass(), "RegistryObject" }));
            }
        }
    }
}

From source file:org.freebxml.omar.server.cache.RoleCache.java

/**
 * Gets the roles associated with the user associated with specified
 * ServerRequestContext.//ww  w .j a v  a2  s  .  c  o m
 */
public Set getRoles(ServerRequestContext context) throws RegistryException {

    Set roles = null;

    try {
        UserType user = context.getUser();
        if (user != null) {
            Element elem = internalCache.get(user.getId());
            if (elem == null) {
                //Cache miss. Get from registry
                //log.trace("RoleCache: cache miss for id: " + id);                            
                roles = getRoles(context, user);
                putRoles(user.getId(), roles);
            } else {
                roles = (Set) elem.getValue();
            }
        } else {
            roles = new HashSet();
        }
    } catch (CacheException e) {
        throw new RegistryException(e);
    }
    return roles;
}

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

/** Creates a new instance of RequestContext */
public ServerRequestContext(String contextId, RegistryRequestType request) throws RegistryException {
    super(contextId, request);

    //Call RequestInterceptors
    //Only intercept top level requests.
    /* HIEOS/BHT (REMOVED):
    if (request != null) {//from  ww w  .j  a  va2 s  .  c o m
    RequestInterceptorManager.getInstance().preProcessRequest(this);
    }
    */

    try {
        setErrorList(BindingUtility.getInstance().rsFac.createRegistryErrorList());

        objectRefs = new ArrayList();

    } catch (JAXBException e) {
        throw new RegistryException(e);
    }
}

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

private void createEvents() throws RegistryException {
    try {/*www .j  a  va 2 s.  com*/
        UserType user = getUser();

        if (user != null) {
            createEvent = bu.rimFac.createAuditableEvent();
            createEvent.setEventType(BindingUtility.CANONICAL_EVENT_TYPE_ID_Created);
            createEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            createEvent.setRequestId("//TODO");
            createEvent.setUser(user.getId());
            ObjectRefListType createRefList = bu.rimFac.createObjectRefListType();
            createEvent.setAffectedObjects(createRefList);

            updateEvent = bu.rimFac.createAuditableEvent();
            updateEvent.setEventType(BindingUtility.CANONICAL_EVENT_TYPE_ID_Updated);
            updateEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            updateEvent.setRequestId("//TODO");
            updateEvent.setUser(user.getId());
            ObjectRefListType updateRefList = bu.rimFac.createObjectRefListType();
            updateEvent.setAffectedObjects(updateRefList);

            versionEvent = bu.rimFac.createAuditableEvent();
            versionEvent.setEventType(BindingUtility.CANONICAL_EVENT_TYPE_ID_Versioned);
            versionEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            versionEvent.setRequestId("//TODO");
            versionEvent.setUser(user.getId());
            ObjectRefListType versionRefList = bu.rimFac.createObjectRefListType();
            versionEvent.setAffectedObjects(versionRefList);

            setStatusEvent = bu.rimFac.createAuditableEvent();
            setStatusEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            setStatusEvent.setRequestId("//TODO");
            setStatusEvent.setUser(user.getId());
            ObjectRefListType setStatusRefList = bu.rimFac.createObjectRefListType();
            setStatusEvent.setAffectedObjects(setStatusRefList);

            approveEvent = bu.rimFac.createAuditableEvent();
            approveEvent.setEventType(BindingUtility.CANONICAL_EVENT_TYPE_ID_Approved);
            approveEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            approveEvent.setRequestId("//TODO");
            approveEvent.setUser(user.getId());
            ObjectRefListType approveRefList = bu.rimFac.createObjectRefListType();
            approveEvent.setAffectedObjects(approveRefList);

            deprecateEvent = bu.rimFac.createAuditableEvent();
            deprecateEvent.setEventType(BindingUtility.CANONICAL_EVENT_TYPE_ID_Deprecated);
            deprecateEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            deprecateEvent.setRequestId("//TODO");
            deprecateEvent.setUser(user.getId());
            ObjectRefListType deprecateRefList = bu.rimFac.createObjectRefListType();
            deprecateEvent.setAffectedObjects(deprecateRefList);

            unDeprecateEvent = bu.rimFac.createAuditableEvent();
            unDeprecateEvent.setEventType(BindingUtility.CANONICAL_EVENT_TYPE_ID_Undeprecated);
            unDeprecateEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            unDeprecateEvent.setRequestId("//TODO");
            unDeprecateEvent.setUser(user.getId());
            ObjectRefListType unDeprecateRefList = bu.rimFac.createObjectRefListType();
            unDeprecateEvent.setAffectedObjects(unDeprecateRefList);

            deleteEvent = bu.rimFac.createAuditableEvent();
            deleteEvent.setEventType(BindingUtility.CANONICAL_EVENT_TYPE_ID_Deleted);
            deleteEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            deleteEvent.setRequestId("//TODO");
            deleteEvent.setUser(user.getId());
            ObjectRefListType deleteRefList = bu.rimFac.createObjectRefListType();
            deleteEvent.setAffectedObjects(deleteRefList);

            relocateEvent = bu.rimFac.createAuditableEvent();
            relocateEvent.setEventType(BindingUtility.CANONICAL_EVENT_TYPE_ID_Relocated);
            relocateEvent.setId(org.freebxml.omar.common.Utility.getInstance().createId());
            relocateEvent.setRequestId("//TODO");
            relocateEvent.setUser(user.getId());
            ObjectRefListType relocateRefList = bu.rimFac.createObjectRefListType();
            relocateEvent.setAffectedObjects(relocateRefList);
        }
    } catch (JAXBException e) {
        throw new RegistryException(e);
    }
}

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

/**
 * Checks each object including composed objects.
 *///from   w w  w .  ja v a  2s. c  om
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.common.ServerRequestContext.java

private void resolveObjectReferences() throws RegistryException {

    try {/*from  w ww.  j  a v a2s . c o  m*/
        //Get Set of ids for objects referenced from obj
        Set refInfos = this.referencedInfos;

        //Check that each ref is resolvable
        Iterator iter = refInfos.iterator();
        Set unresolvedRefIds = new HashSet();
        while (iter.hasNext()) {
            ReferenceInfo refInfo = (ReferenceInfo) iter.next();
            String refId = refInfo.targetObject;

            // only check referenced id once per request
            if (getCheckedRefs().contains(refId)) {
                continue;
            } else {
                getCheckedRefs().add(refId);
            }

            ObjectRefType ref = (ObjectRefType) getObjectRefsMap().get(refId);

            //Remote references already resolved by creating local replica by now
            //First check if resolved within submittedIds
            if (!(getSubmittedObjectsMap().containsKey(refId))) {
                //ref not resolved within submitted objects

                //See if exists in the registry
                if (!(getIdToLidMap().keySet().contains(refId))) {
                    unresolvedRefIds.add(refId);
                }

            }
        }

        if (unresolvedRefIds.size() > 0) {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.unresolvedReferences", new Object[] { unresolvedRefIds }));
        }
    } catch (JAXRException e) {
        throw new RegistryException(e);
    }
}

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

public ResponseOptionType getResponseOption() throws RegistryException {
    try {/*from  www  .j  a v  a  2s .  c  o  m*/
        if (responseOption == null) {
            responseOption = bu.queryFac.createResponseOption();
            responseOption.setReturnType(ReturnType.LEAF_CLASS);
            responseOption.setReturnComposedObjects(true);
        }
    } catch (JAXBException e) {
        throw new RegistryException(e);
    }
    return responseOption;
}

From source file:org.freebxml.omar.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 {/*from   w  w  w .j a va  2  s  .  com*/
            //Save auditable events prior to commit

            /* HIEOS/BHT (REMOVED)
            saveAuditableEvents();
            */

            //Only commit if LCM_DO_NOT_COMMIT is unspecified or false
            String dontCommit = null;
            if (getRegistryRequestStack().size() > 0) {
                HashMap 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 {
                    /* HIEOS/BHT (REMOVED):
                    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);
        }
    }
}

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

public Set getReferenceInfos() throws RegistryException {
    if (referencedInfos == null) {
        try {//from ww w  .  j a v  a 2  s.  co m
            referencedInfos = new HashSet();

            Iterator iter = getSubmittedObjectsMap().entrySet().iterator();
            while (iter.hasNext()) {
                Object o = ((java.util.Map.Entry) iter.next()).getValue();

                if (o instanceof RegistryObjectType) {
                    RegistryObjectType ro = (RegistryObjectType) o;
                    //Get Set of ids for objects referenced from obj
                    Set refInfos = bu.getObjectRefsInRegistryObject(ro, getIdMap(), new HashSet(), -1);

                    Iterator refInfosIter = refInfos.iterator();
                    while (refInfosIter.hasNext()) {
                        referencedInfos.add(refInfosIter.next());
                    }
                }
            }
        } catch (JAXRException e) {
            throw new RegistryException(e);
        }
    }

    return referencedInfos;
}

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

/**
 *         Return ArrayList of ExternalLink that points to unresolvable Http URLs. Any
 *         non-Http URLs will not be checked. Any non-Http URLs and other types
 *         of URIs will not be checked. If the http response code is smaller than 200
 *         or bigger than 299, the http URL is considered invalid.
 *//*w w  w.jav  a 2s .  co m*/
public ArrayList validateURIs(ArrayList sourceRegistryObjects) throws RegistryException {
    ArrayList invalidURLROs = new ArrayList();
    Iterator iter = sourceRegistryObjects.iterator();

    while (iter.hasNext()) {
        Object ro = iter.next();
        String uRI = null;

        if (ro instanceof org.oasis.ebxml.registry.bindings.rim.ExternalLink) {
            uRI = ((org.oasis.ebxml.registry.bindings.rim.ExternalLink) ro).getExternalURI();
        } else if (ro instanceof ServiceBinding) {
            uRI = ((ServiceBinding) ro).getAccessURI();
        } else {
            throw new RegistryException(
                    ServerResourceBundle.getInstance().getString("message.unknownRegistryObjectType"));
        }

        if (!org.freebxml.omar.common.Utility.getInstance().isValidURI(uRI)) {
            invalidURLROs.add(ro);
        }
    }

    return invalidURLROs;
}