Example usage for javax.xml.registry BusinessLifeCycleManager deleteConcepts

List of usage examples for javax.xml.registry BusinessLifeCycleManager deleteConcepts

Introduction

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

Prototype

BulkResponse deleteConcepts(Collection conceptKeys) throws JAXRException;

Source Link

Document

Deletes the Concepts corresponding to the specified Keys.

Usage

From source file:JAXRDeleteConcept.java

/**
     * Removes the organization with the specified key value.
     *//w  w  w .  j a  v  a2  s .c  om
     * @param key        the Key of the organization
     * @param username  the username for the registry
     * @param password  the password for the registry
     */
    public void executeRemove(Key key, String username, String password) {
        BusinessLifeCycleManager blcm = null;

        try {
            blcm = rs.getBusinessLifeCycleManager();

            // Get authorization from the registry
            PasswordAuthentication passwdAuth = new PasswordAuthentication(username, password.toCharArray());

            HashSet<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
            creds.add(passwdAuth);
            connection.setCredentials(creds);
            System.out.println("Established security credentials");

            String id = key.getId();
            System.out.println("Deleting concept with id " + id);

            Collection<Key> keys = new ArrayList<Key>();
            keys.add(key);

            BulkResponse response = blcm.deleteConcepts(keys);
            Collection exceptions = response.getExceptions();

            if (exceptions == null) {
                System.out.println("Concept deleted");

                Collection retKeys = response.getCollection();

                for (Object k : retKeys) {
                    Key concKey = (Key) k;
                    id = concKey.getId();
                    System.out.println("Concept key was " + id);
                }
            } else {
                for (Object e : exceptions) {
                    Exception exception = (Exception) e;
                    System.err.println("Exception on delete: " + exception.toString());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // At end, close connection to registry
            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }