Example usage for javax.xml.registry BulkResponse getExceptions

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

Introduction

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

Prototype

Collection getExceptions() throws JAXRException;

Source Link

Document

Get the Collection of RegistryException instances in case of partial commit.

Usage

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

/**
 * Throws exception if BulkResponse contains any exceptions.
 *
 * @param response/*from   w w w .  j  a va  2s . c  o m*/
 * @throws JAXRException
 */
public static void checkBulkResponse(BulkResponse response) throws JAXRException {
    Collection<?> exes = response.getExceptions();
    if (exes == null) {
        return;
    }
    throw new JAXRException((JAXRException) getFirstObject(exes));
}

From source file:JAXRDeleteConcept.java

/**
     * Removes the organization with the specified key value.
     */*from w ww.  j  a va2 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) {
                }
            }
        }
    }

From source file:JAXRDelete.java

/**
     * Removes the organization with the specified key value.
     *//from w  w w . j av  a 2  s  .  c o  m
     * @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 organization with id " + id);

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

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

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

                Collection retKeys = response.getCollection();

                for (Object k : retKeys) {
                    Key orgKey = (Key) k;
                    id = orgKey.getId();
                    System.out.println("Organization 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) {
                }
            }
        }
    }

From source file:JAXRDeleteScheme.java

/**
     * Removes the classification scheme with the specified key value.
     */*  ww  w. ja va  2s  .  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 classification scheme with id " + id);

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

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

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

                Collection retKeys = response.getCollection();

                for (Object k : retKeys) {
                    Key schemeKey = (Key) k;
                    id = schemeKey.getId();
                    System.out.println("Classification scheme 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) {
                }
            }
        }
    }

From source file:JAXRPublishConcept.java

/**
     * Creates a concept and saves it to the registry.
     */*  ww  w .j  av a 2s  . c  o m*/
     * @param username  the username for the registry
     * @param password  the password for the registry
     */
    public void executePublish(String username, String password) {
        RegistryService rs = null;
        BusinessLifeCycleManager blcm = null;
        BusinessQueryManager bqm = null;
        ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");

        try {
            rs = connection.getRegistryService();
            blcm = rs.getBusinessLifeCycleManager();
            bqm = rs.getBusinessQueryManager();
            System.out.println("Got registry service, query " + "manager, and life cycle manager");

            // 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");

            InternationalString s = blcm.createInternationalString(bundle.getString("concept.name"));
            Concept specConcept = blcm.createConcept(null, s, "");
            s = blcm.createInternationalString(bundle.getString("concept.description"));
            specConcept.setDescription(s);

            s = blcm.createInternationalString(bundle.getString("link.description"));

            ExternalLink wsdlLink = blcm.createExternalLink(bundle.getString("link.uri"), s);
            specConcept.addExternalLink(wsdlLink);

            /*
             * Find the uddi-org:types classification scheme defined
             * by the UDDI specification, using well-known key id.
             */
            String uuid_types = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
            ClassificationScheme uddiOrgTypes = (ClassificationScheme) bqm.getRegistryObject(uuid_types,
                    LifeCycleManager.CLASSIFICATION_SCHEME);

            /*
             * Create a classification, specifying the scheme
             *  and the taxonomy name and value defined for WSDL
             *  documents by the UDDI specification. Add to
             *  concept.
             */
            Classification wsdlSpecClassification = blcm.createClassification(uddiOrgTypes,
                    blcm.createInternationalString("wsdlSpec"), "wsdlSpec");
            specConcept.addClassification(wsdlSpecClassification);

            // Save the concept and retrieve the key.
            Collection<Concept> concepts = new ArrayList<Concept>();
            concepts.add(specConcept);

            BulkResponse response = blcm.saveConcepts(concepts);
            Collection exceptions = response.getExceptions();

            if (exceptions == null) {
                System.out.println("WSDL Specification Concept saved");

                Collection keys = response.getCollection();

                for (Object k : keys) {
                    Key concKey = (Key) k;

                    String id = concKey.getId();
                    System.out.println("Concept key is " + id);
                    System.out.println("Use this key as the argument " + "to JAXRPublishHelloOrg");
                }
            } else {
                for (Object e : exceptions) {
                    Exception exception = (Exception) e;
                    System.err.println("Exception on save: " + exception.toString());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // At end, close connection to registry
            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:it.cnr.icar.eric.client.ui.swing.JAXRClient.java

/**
 * DOCUMENT ME!//from  w w  w. j  a  va 2 s .c  om
 *
 * @param resp DOCUMENT ME!
 */
public void checkBulkResponse(BulkResponse resp) {
    try {
        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();
                    RegistryBrowser.displayError(e);
                }
            }
        }
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }
}

From source file:JAXRPublish.java

/**
     * Creates an organization, its classification, and its
     * services, and saves it to the registry.
     *//  www.ja v a2 s . co m
     * @param username  the username for the registry
     * @param password  the password for the registry
     */
    public void executePublish(String username, String password) {
        RegistryService rs = null;
        BusinessLifeCycleManager blcm = null;
        BusinessQueryManager bqm = null;

        try {
            rs = connection.getRegistryService();
            blcm = rs.getBusinessLifeCycleManager();
            bqm = rs.getBusinessQueryManager();
            System.out.println("Got registry service, query " + "manager, and life cycle manager");

            // 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");

            ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");

            // Create organization name and description
            InternationalString s = blcm.createInternationalString(bundle.getString("org.name"));
            Organization org = blcm.createOrganization(s);
            s = blcm.createInternationalString(bundle.getString("org.description"));
            org.setDescription(s);

            // Create primary contact, set name
            User primaryContact = blcm.createUser();
            PersonName pName = blcm.createPersonName(bundle.getString("person.name"));
            primaryContact.setPersonName(pName);

            // Set primary contact phone number
            TelephoneNumber tNum = blcm.createTelephoneNumber();
            tNum.setNumber(bundle.getString("phone.number"));

            Collection<TelephoneNumber> phoneNums = new ArrayList<TelephoneNumber>();
            phoneNums.add(tNum);
            primaryContact.setTelephoneNumbers(phoneNums);

            // Set primary contact email address
            EmailAddress emailAddress = blcm.createEmailAddress(bundle.getString("email.address"));
            Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
            emailAddresses.add(emailAddress);
            primaryContact.setEmailAddresses(emailAddresses);

            // Set primary contact for organization
            org.setPrimaryContact(primaryContact);

            // Set classification scheme to NAICS, using
            // well-known UUID of ntis-gov:naics:1997
            String uuid_naics = "uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2";
            ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(uuid_naics,
                    LifeCycleManager.CLASSIFICATION_SCHEME);

            if (cScheme != null) {
                // Create and add classification
                InternationalString sn = blcm.createInternationalString(bundle.getString("classification.name"));
                Classification classification = blcm.createClassification(cScheme, sn,
                        bundle.getString("classification.value"));
                Collection<Classification> classifications = new ArrayList<Classification>();
                classifications.add(classification);
                org.addClassifications(classifications);
            } else {
                System.out.println("Classification scheme not found, " + "not classifying organization");
            }

            // Create services and service
            Collection<Service> services = new ArrayList<Service>();
            s = blcm.createInternationalString(bundle.getString("service.name"));

            Service service = blcm.createService(s);
            s = blcm.createInternationalString(bundle.getString("service.description"));
            service.setDescription(s);

            // Create service bindings
            Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
            ServiceBinding binding = blcm.createServiceBinding();
            s = blcm.createInternationalString(bundle.getString("svcbinding.description"));
            binding.setDescription(s);

            // Allow us to publish a fictitious URI without an error
            binding.setValidateURI(false);
            binding.setAccessURI(bundle.getString("svcbinding.accessURI"));
            serviceBindings.add(binding);

            // Add service bindings to service
            service.addServiceBindings(serviceBindings);

            // Add service to services, then add services to organization
            services.add(service);
            org.addServices(services);

            // Add organization and submit to registry
            // Retrieve key if successful
            Collection<Organization> orgs = new ArrayList<Organization>();
            orgs.add(org);

            BulkResponse response = blcm.saveOrganizations(orgs);
            Collection exceptions = response.getExceptions();

            if (exceptions == null) {
                System.out.println("Organization saved");

                Collection keys = response.getCollection();

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

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

/**
 * Publishes a repositoryItem and the metadata that describes it.    
 *
 * @param repositoryItem the URL to the repositoryItem being published.
 * @param metadata describing the repositoryItem
 *
 * @return the ExtrinsicObject published as metadata.
 * @see it.cnr.icar.eric.common.CanonicalConstants for constants that may be used to identify keys in metadaat HashMap 
 *///from  w  w  w .j ava2 s. c o  m
@SuppressWarnings("static-access")
public ExtrinsicObject publish(URL repositoryItem, Map<?, ?> metadata) throws JAXRException {
    ExtrinsicObjectImpl eo = null;

    if (lcm == null) {
        throw new JAXRException("setEndpoint MUST be called before setCredentials is called.");
    }

    javax.activation.DataSource ds = new javax.activation.URLDataSource(repositoryItem);
    javax.activation.DataHandler dh = new javax.activation.DataHandler(ds);

    eo = (ExtrinsicObjectImpl) lcm.createExtrinsicObject(dh);

    String id = (String) metadata.remove(bu.CANONICAL_SLOT_IDENTIFIABLE_ID);
    String name = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_NAME);
    String description = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_DESCRIPTION);
    String objectType = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_OBJECTTYPE);
    String mimeType = (String) metadata.remove(bu.CANONICAL_SLOT_EXTRINSIC_OBJECT_MIMETYPE);

    //If id is specified then use it.
    if (id != null) {
        eo.setKey(lcm.createKey(id));
        eo.setLid(id);
    }

    @SuppressWarnings("unused")
    String eoId = eo.getKey().getId();

    //If name is specified then use it.
    if (name != null) {
        eo.setName(lcm.createInternationalString(name));
    }

    //If description is specified then use it.
    if (description != null) {
        eo.setDescription(lcm.createInternationalString(description));
    }

    if (objectType == null) {
        throw new InvalidRequestException(
                JAXRResourceBundle.getInstance().getString("message.error.missingMetadata",
                        new Object[] { bu.CANONICAL_SLOT_REGISTRY_OBJECT_OBJECTTYPE }));
    }

    if (mimeType == null) {
        throw new InvalidRequestException(JAXRResourceBundle.getInstance().getString(
                "message.error.missingMetadata", new Object[] { bu.CANONICAL_SLOT_EXTRINSIC_OBJECT_MIMETYPE }));
    }

    eo.setMimeType(mimeType);
    eo.setObjectTypeRef(new RegistryObjectRef(lcm, objectType));

    //Set any remaining metadata properties as Slots
    JAXRUtility.addSlotsToRegistryObject(eo, metadata);

    ArrayList<RegistryObject> objects = new ArrayList<RegistryObject>();
    objects.add(eo);

    BulkResponse br = lcm.saveObjects(objects, dontVersionSlotsMap);
    if (br.getExceptions() != null) {
        throw new JAXRException("Error publishing to registry", (Exception) (br.getExceptions().toArray()[0]));
    }

    if (br.getStatus() != BulkResponse.STATUS_SUCCESS) {
        throw new JAXRException("Error publishing to registry. See server logs for detils.");
    }

    return eo;
}

From source file:JAXRPublishPostal.java

/**
     * Creates an organization, its classification, and its
     * services, and saves it to the registry.  The primary
     * contact has a postal address.//from  w  ww .  ja  v  a  2  s . c  o m
     *
     * @param username  the username for the registry
     * @param password  the password for the registry
     */
    public void executePublish(String username, String password) {
        RegistryService rs = null;
        BusinessLifeCycleManager blcm = null;
        BusinessQueryManager bqm = null;

        try {
            rs = connection.getRegistryService();
            blcm = rs.getBusinessLifeCycleManager();
            bqm = rs.getBusinessQueryManager();
            System.out.println("Got registry service, query " + "manager, and life cycle manager");

            // 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");

            ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");

            // Create organization name and description
            InternationalString s = blcm.createInternationalString(bundle.getString("postal.org.name"));
            Organization org = blcm.createOrganization(s);
            s = blcm.createInternationalString(bundle.getString("org.description"));
            org.setDescription(s);

            // Create primary contact, set name
            User primaryContact = blcm.createUser();
            PersonName pName = blcm.createPersonName(bundle.getString("postal.person.name"));
            primaryContact.setPersonName(pName);

            // Set primary contact phone number
            TelephoneNumber tNum = blcm.createTelephoneNumber();
            tNum.setNumber(bundle.getString("phone.number"));

            Collection<TelephoneNumber> phoneNums = new ArrayList<TelephoneNumber>();
            phoneNums.add(tNum);
            primaryContact.setTelephoneNumbers(phoneNums);

            // Set primary contact email address
            EmailAddress emailAddress = blcm.createEmailAddress(bundle.getString("postal.email.address"));
            Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
            emailAddresses.add(emailAddress);
            primaryContact.setEmailAddresses(emailAddresses);

            // create postal address for primary contact
            String streetNumber = bundle.getString("postal.streetNumber");
            String street = bundle.getString("postal.street");
            String city = bundle.getString("postal.city");
            String state = bundle.getString("postal.state");
            String country = bundle.getString("postal.country");
            String postalCode = bundle.getString("postal.postalCode");
            String type = bundle.getString("postal.type");
            PostalAddress postAddr = blcm.createPostalAddress(streetNumber, street, city, state, country,
                    postalCode, type);
            Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
            postalAddresses.add(postAddr);
            primaryContact.setPostalAddresses(postalAddresses);

            // Set primary contact for organization
            org.setPrimaryContact(primaryContact);

            // Set classification scheme to NAICS, using
            // well-known UUID of ntis-gov:naics:1997
            String uuid_naics = "uuid:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2";
            ClassificationScheme cScheme = (ClassificationScheme) bqm.getRegistryObject(uuid_naics,
                    LifeCycleManager.CLASSIFICATION_SCHEME);

            // Create and add classification
            if (cScheme != null) {
                InternationalString sn = blcm.createInternationalString(bundle.getString("classification.name"));
                Classification classification = blcm.createClassification(cScheme, sn,
                        bundle.getString("classification.value"));
                Collection<Classification> classifications = new ArrayList<Classification>();
                classifications.add(classification);
                org.addClassifications(classifications);
            } else {
                System.out.println("Classification scheme not found, " + "not classifying organization");
            }

            // Create services and service
            Collection<Service> services = new ArrayList<Service>();
            s = blcm.createInternationalString(bundle.getString("service.name"));

            Service service = blcm.createService(s);
            s = blcm.createInternationalString(bundle.getString("service.description"));
            service.setDescription(s);

            // Create service bindings; don't validate this fake URL
            Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
            ServiceBinding binding = blcm.createServiceBinding();
            s = blcm.createInternationalString(bundle.getString("svcbinding.description"));
            binding.setDescription(s);

            // Allow us to publish a fictitious URI without an error
            binding.setValidateURI(false);
            binding.setAccessURI(bundle.getString("svcbinding.accessURI"));
            serviceBindings.add(binding);

            // Add service bindings to service
            service.addServiceBindings(serviceBindings);

            // Add service to services, then add services to organization
            services.add(service);
            org.addServices(services);

            // Add organization and submit to registry
            // Retrieve key if successful
            Collection<Organization> orgs = new ArrayList<Organization>();
            orgs.add(org);

            BulkResponse response = blcm.saveOrganizations(orgs);
            Collection exceptions = response.getExceptions();

            if (exceptions == null) {
                System.out.println("Organization saved");

                Collection keys = response.getCollection();

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

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

@SuppressWarnings({ "unused", "static-access" })
public ExtrinsicObject publishFilesAsZip(String baseDirectory, String[] relativeFilePaths, Map<?, ?> metadata)
        throws JAXRException {

    ExtrinsicObjectImpl eo = null;//ww  w .j  av a2  s  . c om
    if (getLifeCycleManager() == null) {
        throw new JAXRException("setEndpoint MUST be called before setCredentials is called.");
    }

    try {
        //Create the zip file
        File zipFile = File.createTempFile("eric-RegistryFacadeImpl", ".zip");
        zipFile.deleteOnExit();
        FileOutputStream fos = new FileOutputStream(zipFile);
        ZipOutputStream zos = Utility.createZipOutputStream(baseDirectory, relativeFilePaths, fos);
        zos.close();

        javax.activation.DataSource ds = new javax.activation.FileDataSource(zipFile);
        javax.activation.DataHandler dh = new javax.activation.DataHandler(ds);

        if (dh == null) {
            throw new JAXRException("Error processing zip file" + zipFile.getAbsolutePath());
        }

        eo = (ExtrinsicObjectImpl) getLifeCycleManager().createExtrinsicObject(dh);

        String id = (String) metadata.remove(bu.CANONICAL_SLOT_IDENTIFIABLE_ID);
        String name = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_NAME);
        String description = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_DESCRIPTION);
        String objectType = (String) metadata.remove(bu.CANONICAL_SLOT_REGISTRY_OBJECT_OBJECTTYPE);

        //If id is specified then use it.
        if (id != null) {
            eo.setKey(lcm.createKey(id));
            eo.setLid(id);
        }

        String eoId = eo.getKey().getId();

        //If name is specified then use it.
        if (name != null) {
            eo.setName(lcm.createInternationalString(name));
        }

        //If description is specified then use it.
        if (description != null) {
            eo.setDescription(lcm.createInternationalString(description));
        }

        if (objectType == null) {
            throw new InvalidRequestException(
                    JAXRResourceBundle.getInstance().getString("message.error.missingMetadata",
                            new Object[] { bu.CANONICAL_SLOT_REGISTRY_OBJECT_OBJECTTYPE }));
        }

        eo.setMimeType("application/zip");
        eo.setObjectTypeRef(new RegistryObjectRef(getLifeCycleManager(), objectType));

        ArrayList<RegistryObject> objects = new ArrayList<RegistryObject>();
        objects.add(eo);

        //??Turn of versioning on save as it creates problems

        BulkResponse br = getLifeCycleManager().saveObjects(objects, dontVersionSlotsMap);
        if (br.getExceptions() != null) {
            throw new JAXRException("Error publishing to registry",
                    (Exception) (br.getExceptions().toArray()[0]));
        }

        if (br.getStatus() != BulkResponse.STATUS_SUCCESS) {
            throw new JAXRException("Error publishing to registry. See server logs for detils.");
        }
    } catch (IOException e) {
        throw new JAXRException(e);
    }

    return eo;
}