Example usage for javax.xml.registry BulkResponse getStatus

List of usage examples for javax.xml.registry BulkResponse getStatus

Introduction

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

Prototype

public int getStatus() throws JAXRException;

Source Link

Document

Returns the status for this response.

Usage

From source file:it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl.java

private void initializeObjectTypesMap() {
    try {/*from   ww w  . j  ava  2s  . c om*/
        DeclarativeQueryManager dqm = getRegistryService().getDeclarativeQueryManager();
        //         String queryStr = "SELECT children.* FROM ClassificationNode children, ClassificationNode parent where (parent.path LIKE '/"
        //               + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType
        //               + "/RegistryObject%') AND (parent.path NOT LIKE '/"
        //               + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_ObjectType
        //               + "/RegistryObject/ExtrinsicObject/%') AND parent.id = children.parent";
        //         Query query = dqm.createQuery(Query.QUERY_TYPE_SQL, queryStr);

        Query query = SQLQueryProvider.initializeObjectTypesMap(dqm);

        BulkResponse resp = dqm.executeQuery(query);

        if ((resp != null) && (!(resp.getStatus() == JAXRResponse.STATUS_SUCCESS))) {
            Collection<?> exceptions = resp.getExceptions();

            if (exceptions != null) {
                Iterator<?> iter = exceptions.iterator();

                while (iter.hasNext()) {
                    Exception e = (Exception) iter.next();
                    e.printStackTrace();
                }
            }

            return;
        }

        objectTypesMap = new HashMap<String, Concept>();

        Collection<?> concepts = resp.getCollection();
        Iterator<?> iter = concepts.iterator();

        while (iter.hasNext()) {
            Concept concept = (Concept) iter.next();
            String value = concept.getValue();

            if (value.equals("ClassificationNode")) {
                value = "Concept";
            }

            objectTypesMap.put(value, concept);
        }
    } catch (JAXRException e) {
        e.printStackTrace();
    }
}

From source file:it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl.java

/**
 * Saves one or more Objects to the registry. An object may be a
 * RegistryObject. If an object is not in the registry, then it is created
 * in the registry. If it already exists in the registry and has been
 * modified, then its state is updated (replaced) in the registry.
 * //  w w  w . ja  v a2s. c o  m
 * <p>
 * <DL>
 * <DT><B>Capability Level: 0 </B>
 * </DL>
 * 
 * @return BulkResponse containing the Collection of keys for those objects
 *         that were saved successfully and any SaveException that was
 *         encountered in case of partial commit.
 */
@SuppressWarnings("unchecked")
public BulkResponse saveObjects(@SuppressWarnings("rawtypes") Collection objects,
        HashMap<String, String> slotsMap) throws JAXRException {
    if ((objects == null) || (objects.size() == 0)) {
        return new BulkResponseImpl();
    }

    /*
    if ((JAXRUtility.getFirstObject(objects) instanceof IdentifiableType) || (JAXRUtility.getFirstObject(objects) instanceof JAXBElement)) {
       ArrayList<Object> objectList = new ArrayList<Object>();
       objectList.addAll(objects);
       objects = JAXRUtility.getJAXRObjectsFromJAXBObjects(this, objectList, null);
    }
    */

    ClientRequestContext context = new ClientRequestContext(
            "it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl:saveObjects", null);
    context.setSlotsMap(slotsMap);
    context.getOriginalObjects().addAll(objects);

    String pad = "";

    for (Iterator<?> it = objects.iterator(); it.hasNext();) {
        Object obj = it.next();
        processObject(context, obj, pad);
    }

    if (log.isDebugEnabled()) {
        log.debug("candidateSubmitObjects = " + context.getCandidateSubmitObjects());
        log.debug("processedObjects = " + context.getProcessedObjects());
    }

    // Return value for this method
    BulkResponse response = null;

    // Do any final pruning / processing
    finalizeSubmitObjectList(context);

    if (context.getSubmitObjectsMap() != null) {
        response = doSubmitObjectsRequestInternal(context);

        if (response.getStatus() == BulkResponse.STATUS_SUCCESS) {
            // ROs are no longer new
            markRegistryObjectsClean(context);
        }
    }

    return response;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

private void internalDoApply(Collection<?> robs) throws Exception {
    handleRemovalOfRepositoryItems(robs);
    handleRegistryPackageMembers(robs);/*from w w  w  .  ja va  2 s. co  m*/
    checkApplyToDetailsPage();
    handleSavesToDrilldownObject();
    BulkResponse br = applyObjects(robs);
    if (br.getStatus() == 0) {
        handlePseudoComposedObjects();
    } else {
        handleExceptions(br);
    }
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

/**
* Set selected status on Registry Object.  Returns Failure/Success string for display.
* 
* @param none//from ww  w  .j a  v a 2 s.c  o  m
* @return String
*/
public String doStatusOnCurrentROB() {
    String status = "failure";
    if (!isUserAllowedToPublish()) {
        status = RegistryBrowser.getInstance().getAuthenticationStatus();
    } else {
        ArrayList<Key> roList = new ArrayList<Key>();
        BulkResponse br = null;
        try {
            RegistryObject ro = currentRegistryObject.getRegistryObject();
            roList.add(ro.getKey());

            LifeCycleManagerImpl lcm = (LifeCycleManagerImpl) ro.getLifeCycleManager();
            br = lcm.setStatusOnObjects(roList, getCurrentRegistryObjectBean().getStatusTypeConcept());

            if (br.getStatus() == 0) {
                this.refreshSearchPanel();
            }
            status = "publishSuccessful";
        } catch (Exception je) {
            log.error(
                    WebUIResourceBundle.getInstance().getString("message.ErrorInSettingStatusOfRegistryObject"),
                    je);
            append(WebUIResourceBundle.getInstance().getString("setStatusROError") + " "
                    + je.getLocalizedMessage());
        }
    }
    return status;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

/**
* This method return the Status of Undeprecate RegistryObjects 
* 
* @param none/*from  w w  w .  j  a v  a 2 s.  c om*/
* @return String
*/
@SuppressWarnings("static-access")
public String doUndeprecate() {
    String status = "failure";
    if (!isUserAllowedToPublish()) {
        status = RegistryBrowser.getInstance().getAuthenticationStatus();
        RegistryBrowser.getInstance().setPublishOperationMessage(
                WebUIResourceBundle.getInstance().getString("undeprecateButtonText"));
    } else {
        ArrayList<Key> roList = new ArrayList<Key>();
        BulkResponse br = null;
        try {
            BusinessLifeCycleManagerImpl blcm = RegistryBrowser.getInstance().getBLCM();
            Iterator<RegistryObject> iter = getSelectedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObject registryObject = iter.next();
                roList.add(registryObject.getKey());
            }

            iter = getSelectedPinnedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObjectBean registryObjectBean = (RegistryObjectBean) iter.next();
                roList.add(registryObjectBean.getRegistryObject().getKey());
            }

            br = blcm.unDeprecateObjects(roList);
            if (br.getStatus() == 0) {
                this.refreshSearchPanel();
            }
            status = WebUIResourceBundle.getInstance().getString("undeprecateSuccessful");
            append(status);
            status = "publishSuccessful";
        } catch (Exception ex) {
            log.error(WebUIResourceBundle.getInstance().getString("message.FailedToUndeprecateThisObject"), ex);
            append(WebUIResourceBundle.getInstance().getString("lcmUndeprecateError") + " "
                    + ex.getLocalizedMessage());
        }
    }
    return status;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

/**
* This method return the Status of Approve RegistryObjects 
* 
* @param none//from  w ww  . j  ava2  s.c om
* @return String
*/
public String doApprove() {
    String status = "failure";
    if (!isUserAllowedToPublish()) {
        status = RegistryBrowser.getInstance().getAuthenticationStatus();
        RegistryBrowser.getInstance()
                .setPublishOperationMessage(WebUIResourceBundle.getInstance().getString("approveButtonText"));
    } else {
        ArrayList<Key> roList = new ArrayList<Key>();
        BulkResponse br = null;
        try {
            @SuppressWarnings("static-access")
            BusinessLifeCycleManagerImpl blcm = RegistryBrowser.getInstance().getBLCM();
            Iterator<RegistryObject> iter = getSelectedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObject registryObject = iter.next();
                roList.add(registryObject.getKey());
            }

            iter = getSelectedPinnedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObjectBean registryObjectBean = (RegistryObjectBean) iter.next();
                roList.add(registryObjectBean.getRegistryObject().getKey());
            }

            br = blcm.approveObjects(roList);
            if (br.getStatus() == 0) {
                this.refreshSearchPanel();
            }
            status = WebUIResourceBundle.getInstance().getString("approveSuccessful");
            append(status);
            status = "publishSuccessful";
        } catch (Exception ex) {
            log.error(WebUIResourceBundle.getInstance().getString("message.FailedToApproveThisObject"), ex);
            append(WebUIResourceBundle.getInstance().getString("lcmApproveError") + " "
                    + ex.getLocalizedMessage());
        }
    }
    return status;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

/**
* This method return the Status of Deprecate RegistryObjects 
* 
* @param none//  ww w.java  2s  .  co  m
* @return String
*/
public String doDeprecate() {
    String status = "failure";
    if (!isUserAllowedToPublish()) {
        status = RegistryBrowser.getInstance().getAuthenticationStatus();
        RegistryBrowser.getInstance()
                .setPublishOperationMessage(WebUIResourceBundle.getInstance().getString("deprecateButtonText"));
    } else {
        ArrayList<Key> roList = new ArrayList<Key>();
        BulkResponse br = null;
        try {
            @SuppressWarnings("static-access")
            BusinessLifeCycleManagerImpl blcm = RegistryBrowser.getInstance().getBLCM();
            Iterator<RegistryObject> iter = getSelectedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObject registryObject = iter.next();
                roList.add(registryObject.getKey());
            }

            iter = getSelectedPinnedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObjectBean registryObjectBean = (RegistryObjectBean) iter.next();
                roList.add(registryObjectBean.getRegistryObject().getKey());
            }

            br = blcm.deprecateObjects(roList);
            if (br.getStatus() == 0) {
                this.refreshSearchPanel();
            }

            status = WebUIResourceBundle.getInstance().getString("deprecateSuccessful");
            append(status);
            status = "publishSuccessful";
        } catch (Exception ex) {
            log.error(WebUIResourceBundle.getInstance().getString("message.FailedToDeprecateThisObject"), ex);
            append(WebUIResourceBundle.getInstance().getString("lcmDeprecateError") + " "
                    + ex.getLocalizedMessage());
        }
    }
    return status;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

/**
* This method set the selected Status to selected RegistryObjects 
* 
* @param none/*from w  ww  .  j  av a2  s  .  co m*/
* @return String
*/
public String doSetStatus() {
    String status = "failure";
    if (!isUserAllowedToPublish()) {
        status = RegistryBrowser.getInstance().getAuthenticationStatus();
    } else if (statusTypeConceptId == null || statusTypeConceptId.equalsIgnoreCase("")) {
        String msg = WebUIResourceBundle.getInstance().getString("message.invalidStatus");
        append(msg);
        // Use this status to navigate back to the Search Results page rather
        // than showing the Error Page: fewer user clicks.
        status = "showSearchPanel";
    } else {
        List<Key> roList = new ArrayList<Key>();
        BulkResponse br = null;
        try {
            @SuppressWarnings("static-access")
            BusinessLifeCycleManagerImpl blcm = RegistryBrowser.getInstance().getBLCM();
            Iterator<RegistryObject> iter = getSelectedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObject registryObject = iter.next();
                roList.add(registryObject.getKey());
            }

            iter = getSelectedPinnedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObjectBean registryObjectBean = (RegistryObjectBean) iter.next();
                roList.add(registryObjectBean.getRegistryObject().getKey());
            }

            br = blcm.setStatusOnObjects(roList, statusTypeConceptId);
            if (br.getStatus() == 0) {
                statusTypeConceptId = "";
                this.refreshSearchPanel();
            }
            status = WebUIResourceBundle.getInstance().getString("statusSet");
            append(status);
            status = "publishSuccessful";
        } catch (Exception ex) {
            log.error(
                    WebUIResourceBundle.getInstance().getString("message.ErrorInSettingStatusOfRegistryObject"),
                    ex);
            append(WebUIResourceBundle.getInstance().getString("setStatusROError") + " "
                    + ex.getLocalizedMessage());
        }
    }
    return status;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

/**
* This method return the Status of Delete RegistryObjects 
* 
* @param none/*from ww w . j  a va 2 s.  co m*/
* @return String
*/
public String doDelete() {
    String status = "failure";
    if (!isUserAllowedToPublish()) {
        status = RegistryBrowser.getInstance().getAuthenticationStatus();
        RegistryBrowser.getInstance()
                .setPublishOperationMessage(WebUIResourceBundle.getInstance().getString("deleteButtonText"));
    } else {
        List<Key> roList = new ArrayList<Key>();
        List<RegistryObjectBean> pinnedDeleteObjects = new ArrayList<RegistryObjectBean>();
        BulkResponse br = null;
        @SuppressWarnings("unused")
        int size = 0;
        try {
            @SuppressWarnings("static-access")
            BusinessLifeCycleManagerImpl blcm = RegistryBrowser.getInstance().getBLCM();
            Iterator<?> iter = getSelectedRegistryObjectBeans().iterator();
            while (iter.hasNext()) {
                RegistryObjectBean bean = (RegistryObjectBean) iter.next();
                bean.setPinned(false);
                bean.setSelected(false);
                RegistryObject registryObject = bean.getRegistryObject();
                roList.add(registryObject.getKey());
            }

            iter = getSelectedPinnedRegistryObjects().iterator();
            while (iter.hasNext()) {
                RegistryObjectBean registryObjectBean = (RegistryObjectBean) iter.next();
                pinnedDeleteObjects.add(registryObjectBean);
                registryObjectBean.setPinned(false);
                registryObjectBean.setSelected(false);
                roList.add(registryObjectBean.getRegistryObject().getKey());
            }

            br = blcm.deleteObjects(roList, null, RegistryBrowser.getInstance().getDeletionScopeCode());
            if (br.getStatus() == 0) {
                @SuppressWarnings("unused")
                List<RegistryObjectBean> pinnedObjects = getPinnedRegistryObjectBeans();
                iter = pinnedDeleteObjects.iterator();
                while (iter.hasNext()) {
                    pinnedRegistryObjectBean.remove(((RegistryObjectBean) iter.next()));
                }
                this.refreshSearchExplore();
            }
            status = WebUIResourceBundle.getInstance().getString("deleteSuccessful");
            append(status);
            status = "publishSuccessful";
        } catch (ReferencesExistException ree) {
            log.error(WebUIResourceBundle.getInstance().getString("message.FailedToDeleteThisObject") + ":"
                    + ree.getLocalizedMessage());
            append(WebUIResourceBundle.getInstance().getString("lcmDeleteError") + " "
                    + ree.getLocalizedMessage());
        } catch (Exception ex) {
            log.error(WebUIResourceBundle.getInstance().getString("message.FailedToDeleteThisObject"), ex);
            append(WebUIResourceBundle.getInstance().getString("lcmDeleteError") + " "
                    + ex.getLocalizedMessage());
        }
    }
    return status;
}