Example usage for javax.xml.registry JAXRException JAXRException

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

Introduction

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

Prototype

public JAXRException(Throwable cause) 

Source Link

Document

Constructs a JAXRException object initialized with the given Throwable object.

Usage

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

/**
 * Return location of keystore file defined in jaxr-ebxml properties
 *
 * @return Path to keystore file/*  w ww  .j a v a  2  s.c  o m*/
 * @throws JAXRException Thrown if properties are not set
 */
public static File getKeystoreFile() throws JAXRException {
    String jaxrHomeFileName = ProviderProperties.getInstance().getProperty("jaxr-ebxml.home");

    if ((jaxrHomeFileName == null) || (jaxrHomeFileName.length() == 0)) {
        throw new JAXRException(
                JAXRResourceBundle.getInstance().getString("message.error.no.property.jaxr-ebxml.home"));
    }

    File jaxrHomeFile = new File(jaxrHomeFileName);

    String keystoreFileName = ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.keystore");

    if ((keystoreFileName == null) || (keystoreFileName.length() == 0)) {
        throw new JAXRException(JAXRResourceBundle.getInstance()
                .getString("message.error.no.property.jaxr-ebxml.security.keystore"));
    }

    return new File(jaxrHomeFile.getAbsolutePath(), keystoreFileName);
}

From source file:de.kp.ames.web.core.domain.model.RegistryPackage.java

/**
 * Create RegistryPackage from JSON representation
 * /*from ww  w  .j a v a  2 s  .com*/
 * @param jForm
 * @return
 * @throws Exception
 */
public RegistryObjectImpl create(JSONObject jForm) throws Exception {

    /* 
     * Create registry package 
     */
    String name = jForm.getString(RIM_NAME);

    // 
    RegistryPackageImpl rp = jaxrLCM.createRegistryPackage(jaxrLCM.createInternationalString(name));
    if (rp == null)
        throw new JAXRException("[RegistryPackage] Creation of RegistryPackage failed.");

    /*
     * Create metadata
     */
    createMetadata(rp, jForm, FncConstants.CORE_PRE);

    /*
     * Indicate as created
     */
    this.created = true;

    return rp;
}

From source file:de.kp.ames.web.core.domain.model.ExternalLink.java

/**
 * Create RegistryObject from JSON representation
 * /*ww  w. ja v a 2  s .com*/
 * @param jForm
 * @return
 * @throws Exception
 */
public RegistryObjectImpl create(JSONObject jForm) throws Exception {

    /*
     * Create external link
     */
    String uri = jForm.getString(RIM_URI);

    ExternalLinkImpl el = jaxrLCM.createExternalLink(uri);
    if (el == null)
        throw new JAXRException("[ExternalLink] Creation of ExternalLink failed.");

    /*
     * Create metadata
     */
    createMetadata(el, jForm, FncConstants.CORE_PRE);

    /*
     * Indicate as created
     */
    this.created = true;

    return el;

}

From source file:de.kp.ames.web.function.ns.NsDQM.java

/**
 * Get either single namespace or all registered
 * namespaces of a certain parent/* w  w w  .j a  va  2  s.co m*/
 * 
 * @param item
 * @return
 * @throws Exception
 */
public JSONArray getNamespaces(String item, String parent) throws Exception {

    List<RegistryObjectImpl> folders = new ArrayList<RegistryObjectImpl>();

    if (item == null) {

        if (parent == null) {

            List<RegistryPackageImpl> list = getRegistryPackage_ByClasNode(
                    ClassificationConstants.FNC_ID_Namespace);
            if (list.size() == 0)
                throw new JAXRException("[NsDQM] Namespace container does not exist.");

            RegistryPackageImpl container = list.get(0);
            parent = container.getId();

        }

        /*
         * Retrieve all packages that are members of a parent package
         */
        folders = getPackageMembers(parent);

    } else {

        /*
         * Determine folder
         */
        RegistryPackageImpl folder = (RegistryPackageImpl) getRegistryObjectById(item);
        if (folder == null)
            throw new JAXRException("[NsDQM] RegistryObject with id <" + item + "> not found.");

        folders.add(folder);

    }

    /*
     * Build JSON representation
     */
    return JsonBusinessProvider.getNamespaces(jaxrHandle, folders);

}

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

/**
 * Returns if keystore file can be read, throws an exception otherwise
 *
 * @param keystoreFile Path to keystore file
 * @throws JAXRException Thrown if keystore file can not be read
 *//*from   w ww . j  a v  a2s . com*/
public static void canReadKeystoreFile(File keystoreFile) throws JAXRException {
    try {
        if (!keystoreFile.exists()) {
            throw new JAXRException(JAXRResourceBundle.getInstance().getString(
                    "message.error.keystore.file.not.exist", new Object[] { keystoreFile.getAbsolutePath() }));
        }

        if (!keystoreFile.canRead()) {
            throw new JAXRException(JAXRResourceBundle.getInstance().getString(
                    "message.error.read.keysore.file", new Object[] { keystoreFile.getAbsolutePath() }));
        }
    } catch (SecurityException e) {
        log.error(e);
        throw new JAXRException(JAXRResourceBundle.getInstance().getString("message.error.read.keysore.file",
                new Object[] { keystoreFile.getAbsolutePath() }));
    }
}

From source file:de.kp.ames.web.function.domain.model.ProductObject.java

/**
 * Create ProductObject/*from w  w w . j  av  a 2s.  c  o m*/
 * 
 * @param data
 * @param stream
 * @return
 * @throws Exception
 */
public RegistryObjectImpl create(String data, InputStream stream) throws Exception {

    /*
     * Initialize data
     */
    JSONObject jForm = new JSONObject(data);

    /* 
     * Create extrinsic object that serves as a wrapper 
     * for the respective product
     */
    // 
    ExtrinsicObjectImpl eo = jaxrLCM.createExtrinsicObject();
    if (eo == null)
        throw new JAXRException("[ProductObject] Creation of ExtrinsicObject failed.");

    /* 
     * Identifier
     */
    String eid = JaxrIdentity.getInstance().getPrefixUID(FncConstants.PRODUCT_PRE);

    eo.setLid(eid);
    eo.getKey().setId(eid);

    /* 
     * Home url
     */
    String home = jaxrHandle.getEndpoint().replace("/saml", "");
    eo.setHome(home);

    /*
     * Name & description
     */
    String name = jForm.getString(RIM_NAME);
    String desc = jForm.getString(RIM_DESC);

    String dtime = jForm.getString(RIM_DATE);
    name = name.trim() + ", " + dtime.trim();

    eo.setName(jaxrLCM.createInternationalString(name));
    eo.setDescription(jaxrLCM.createInternationalString(desc));

    /*
     * Classifications
     */
    ClassificationImpl classification = jaxrLCM.createClassification(ClassificationConstants.FNC_ID_Product);
    eo.addClassification(classification);

    /*
     * Mimetype & repository item
     */
    String mimetype = GlobalConstants.MT_XML;
    eo.setMimeType(mimetype);

    byte[] bytes = FileUtil.getByteArrayFromInputStream(stream);

    DataHandler handler = new DataHandler(FileUtil.createByteArrayDataSource(bytes, mimetype));
    eo.setRepositoryItem(handler);

    /*
    * Indicate as created
    */
    this.created = true;

    return eo;

}

From source file:de.kp.ames.web.function.domain.model.ImageObject.java

/**
 * Create RegistryObject representation of ImageObject
 * /*ww  w.  j  a  va2  s.c  o  m*/
 * @param data
 * @return
 * @throws Exception
 */
public RegistryObjectImpl create(JSONObject jForm) throws Exception {

    /* 
     * Create extrinsic object that serves as a wrapper 
     * for the respective image
     */
    // 
    ExtrinsicObjectImpl eo = jaxrLCM.createExtrinsicObject();
    if (eo == null)
        throw new JAXRException("[ImageObject] Creation of ExtrinsicObject failed.");

    /* 
     * Identifier
     */
    String eid = JaxrIdentity.getInstance().getPrefixUID(FncConstants.IMAGE_PRE);

    eo.setLid(eid);
    eo.getKey().setId(eid);

    /* 
     * Home url
     */
    String home = jaxrHandle.getEndpoint().replace("/saml", "");
    eo.setHome(home);

    /* 
     * The document is actually transient and managed by the image cache
     */

    ImageCacheManager cacheManager = ImageCacheManager.getInstance();

    String key = jForm.getString(JsonConstants.J_KEY);
    DmsImage image = (DmsImage) cacheManager.getFromCache(key);

    if (image == null)
        throw new Exception("[ImageObject] Image with id <" + key + "> not found.");

    /*
     * Name & description
     */
    String name = jForm.has(RIM_NAME) ? jForm.getString(RIM_NAME) : null;
    String desc = jForm.has(RIM_DESC) ? jForm.getString(RIM_DESC) : null;

    name = (name == null) ? image.getName() : name;

    int pos = name.lastIndexOf(".");
    if (pos != -1)
        name = name.substring(0, pos);

    eo.setName(jaxrLCM.createInternationalString(name));

    desc = (desc == null) ? FncMessages.NO_DESCRIPTION_DESC : desc;
    eo.setDescription(jaxrLCM.createInternationalString(desc));

    /*
     * Classifications
     */
    JSONArray jClases = jForm.has(RIM_CLAS) ? new JSONArray(jForm.getString(RIM_CLAS)) : null;
    if (jClases != null) {

        List<ClassificationImpl> classifications = createClassifications(jClases);
        /*
         * Set composed object
         */
        eo.addClassifications(classifications);

    }

    /*
     * Mimetype & repository item
     */
    String mimetype = image.getMimetype();
    DataHandler handler = new DataHandler(FileUtil.createByteArrayDataSource(image.getBytes(), mimetype));

    eo.setMimeType(mimetype);
    eo.setRepositoryItem(handler);

    /*
     * Indicate as created
     */
    this.created = true;

    return eo;

}

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

/**
 * Save a key to client keystore. /*from   www  .j  ava2 s .co m*/
 *
 * @throw Exception relate to keystore manipulation
 */
public static void saveKey(KeyModel keyModel) throws Exception {
    try {
        if (CertificateUtil.certificateExists(keyModel.getAlias(), keyModel.getStorePassword())) {
            throw new JAXRException(JavaUIResourceBundle.getInstance().getString("error.keyAliasAlreadyExists",
                    new Object[] { keyModel.getAlias() }));
        } else {
            CertificateUtil.importCAIssuedCert(keyModel);
            RegistryBrowser
                    .displayInfo(JavaUIResourceBundle.getInstance().getString("message.certificateImported"));
        }
    } finally {
        RegistryBrowser.setDefaultCursor();
    }
}

From source file:de.kp.ames.web.function.comm.CommDQM.java

/**
 * Get either single chat message or all registered
 * products//  w  ww.j  ava 2s  . c om
 * 
 * @param item
 * @return
 * @throws Exception
 */
public JSONArray getChatMessages(String item) throws Exception {

    if (item == null) {
        /*
         * Determine chat messages (metadata)
         */
        List<RegistryObjectImpl> messages = getRegistryObjects_ByClasNode(item,
                ClassificationConstants.FNC_ID_Chat);

        /*
         * Build JSON representation
         */
        return JsonBusinessProvider.getChatMessages(jaxrHandle, messages);

    } else {
        /*
         * Determine content of chat message
         */
        ExtrinsicObjectImpl eo = (ExtrinsicObjectImpl) getRegistryObjectById(item);
        if (eo == null)
            throw new JAXRException("[CommDQM] RegistryObject with id <" + item + "> not found.");

        DataHandler handler = eo.getRepositoryItem();
        InputStream stream = handler.getInputStream();

        byte[] bytes = FileUtil.getByteArrayFromInputStream(stream);

        JSONObject jChatMessage = new JSONObject(new String(bytes));
        return new JSONArray().put(jChatMessage);

    }

}

From source file:de.kp.ames.web.function.domain.model.DocumentObject.java

/**
 * Create RegistryObject representation of DocumentObject
 * //  w w w .  ja v a 2s.  com
 * @param data
 * @return
 * @throws Exception
 */
public RegistryObjectImpl create(JSONObject jForm) throws Exception {

    /* 
     * Create extrinsic object that serves as a wrapper 
     * for the respective document
     */
    // 
    ExtrinsicObjectImpl eo = jaxrLCM.createExtrinsicObject();
    if (eo == null)
        throw new JAXRException("[DocumentObject] Creation of ExtrinsicObject failed.");

    /* 
     * Identifier
     */
    String eid = JaxrIdentity.getInstance().getPrefixUID(FncConstants.DOCUMENT_PRE);

    eo.setLid(eid);
    eo.getKey().setId(eid);

    /* 
     * Home url
     */
    String home = jaxrHandle.getEndpoint().replace("/saml", "");
    eo.setHome(home);

    /* 
     * The document is actually transient and managed by the document cache
     */

    DocumentCacheManager cacheManager = DocumentCacheManager.getInstance();

    String key = jForm.getString(JsonConstants.J_KEY);
    DmsDocument document = (DmsDocument) cacheManager.getFromCache(key);

    if (document == null)
        throw new Exception("[DocumentObject] Document with id <" + key + "> not found.");

    /*
     * Name & description
     */
    String name = jForm.has(RIM_NAME) ? jForm.getString(RIM_NAME) : null;
    String desc = jForm.has(RIM_DESC) ? jForm.getString(RIM_DESC) : null;

    name = (name == null) ? document.getName() : name;

    int pos = name.lastIndexOf(".");
    if (pos != -1)
        name = name.substring(0, pos);

    eo.setName(jaxrLCM.createInternationalString(name));

    desc = (desc == null) ? FncMessages.NO_DESCRIPTION_DESC : desc;
    eo.setDescription(jaxrLCM.createInternationalString(desc));

    /*
     * Classifications
     */
    JSONArray jClases = jForm.has(RIM_CLAS) ? new JSONArray(jForm.getString(RIM_CLAS)) : null;
    if (jClases != null) {

        List<ClassificationImpl> classifications = createClassifications(jClases);
        /*
         * Set composed object
         */
        eo.addClassifications(classifications);

    }

    /* 
     * Create slots
     */
    JSONObject jSlots = jForm.has(RIM_SLOT) ? new JSONObject(jForm.getString(RIM_SLOT)) : null;
    if (jSlots != null) {

        List<SlotImpl> slots = createSlots(jSlots);
        /*
         * Set composed object
         */
        eo.addSlots(slots);

    }

    /*
     * Mimetype & repository item
     */
    String mimetype = document.getMimetype();
    DataHandler handler = new DataHandler(FileUtil.createByteArrayDataSource(document.getBytes(), mimetype));

    eo.setMimeType(mimetype);
    eo.setRepositoryItem(handler);

    /*
     * Indicate as created
     */
    this.created = true;

    return eo;

}