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:de.kp.ames.web.function.ns.NsLCM.java

/**
 * Submit a certain namespace to an optional parent namespace 
 * //w  ww .  ja  v  a 2s  .co  m
 * @param data
 * @param parent
 * @return
 * @throws Exception
 */
public String submitNamespace(String data, String parent) throws Exception {

    /*
     * Create or retrieve registry package that is 
     * responsible for managing this namespace
     */
    RegistryPackageImpl container = null;
    JaxrDQM dqm = new JaxrDQM(jaxrHandle);

    if (parent == null) {
        /*
         * root namespace
         */
        List<RegistryPackageImpl> list = dqm
                .getRegistryPackage_ByClasNode(ClassificationConstants.FNC_ID_Namespace);
        if (list.size() == 0) {
            /*
             * Create container
             */
            container = createNamespacePackage();

        } else {
            /*
             * Retrieve container
             */
            container = list.get(0);

        }
    } else {
        /*
         * given namespace parent
         */
        container = (RegistryPackageImpl) dqm.getRegistryObjectById(parent);
        if (container == null)
            throw new JAXRException("[NsLCM] RegistryPackage with id <" + parent + "> not found.");

    }

    /*
     * Initialize transaction
     */
    JaxrTransaction transaction = new JaxrTransaction();

    /*
     * Submit NamespaceObject
     */
    NamespaceObject namespaceObject = new NamespaceObject(jaxrHandle, this);
    RegistryObjectImpl ro = namespaceObject.submit(data);

    transaction.addObjectToSave(ro);
    if (namespaceObject.isCreated())
        container.addRegistryObject(ro);

    /*
     * Save objects
     */
    transaction.addObjectToSave(container);
    saveObjects(transaction.getObjectsToSave(), false, false);

    /*
     * Supply reactor
     */
    ReactorParams reactorParams = new ReactorParams(jaxrHandle, ro, ClassificationConstants.FNC_ID_Folder,
            RAction.C_INDEX_RSS);
    ReactorImpl.onSubmit(reactorParams);

    /*
     * Retrieve response
     */
    JSONObject jResponse = transaction.getJResponse(ro.getId(),
            namespaceObject.isCreated() ? FncMessages.FOLDER_CREATED : FncMessages.FOLDER_UPDATED);
    return jResponse.toString();

}

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

public String toXML() throws JAXRException {
    try {//from  www  . j  a v  a  2s . co m
        StringWriter sw = new StringWriter();
        Marshaller marshaller = BindingUtility.getInstance().getJAXBContext().createMarshaller();
        marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        JAXBElement<IdentifiableType> ebIdentifiable = bu.rimFac
                .createIdentifiable((IdentifiableType) toBindingObject());
        marshaller.marshal(ebIdentifiable, sw);

        return sw.toString();
    } catch (javax.xml.bind.JAXBException e) {
        throw new JAXRException(e);
    }
}

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

public ExtrinsicObjectImpl(LifeCycleManagerImpl lcm, ExtrinsicObjectType ebExtrinsicObj) throws JAXRException {
    super(lcm, ebExtrinsicObj);

    mimeType = ebExtrinsicObj.getMimeType();
    opaque = ebExtrinsicObj.isIsOpaque();
    contentVersionInfo = ebExtrinsicObj.getContentVersionInfo();

    try {//from  ww  w  . ja  v  a2s .com
        HashMap<String, Serializable> slotsMap = BindingUtility.getInstance()
                .getSlotsFromRegistryObject(ebExtrinsicObj);
        @SuppressWarnings("static-access")
        String slotName = BindingUtility.getInstance().CANONICAL_SLOT_EXTRINSIC_OBJECT_REPOSITORYITEM_URL;
        if (slotsMap.containsKey(slotName)) {
            String riURLStr = (String) slotsMap.get(slotName);
            File riFile = new File(riURLStr);
            repositoryItem = new DataHandler(new FileDataSource(riFile));

            //Remove transient slot
            this.removeSlot(slotName);
        }
    } catch (JAXBException e) {
        throw new JAXRException(e);
    }
}

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

public Graph getTreeGraph() throws JAXRException {
    if (treeGraph == null) {
        try {/*from   w w w .  j  a v  a  2 s . c  o m*/
            rootFolder = bqm.getRegistryObject(CanonicalConstants.CANONICAL_ROOT_FOLDER_ID, "RegistryPackage");
        } catch (Throwable t) {
            log.error(t.getMessage());
            throw new JAXRException(t);
        }
        if (rootFolder instanceof RegistryPackage) {
            pkg = (RegistryPackage) rootFolder;
        } else {
            throw new JAXRException(
                    WebUIResourceBundle.getInstance().getString("excRegistryPack") + ro.getClass());
        }
        root = new RegistryObjectNode(pkg);

        treeGraph = new Graph(root);
        root.setHasChild(true);
    }
    return treeGraph;
}

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

public void registerUser(User user, String alias, String keypass) throws JAXRException {
    ConnectionImpl c = ((ConnectionImpl) getConnection());
    if (c == null) {
        throw new JAXRException("setEndpoint MUST be called before registerUser is called.");
    }/*from   ww  w  . j  av  a  2 s.  c  om*/
    UserRegistrationInfo userRegInfo = new UserRegistrationInfo(user);

    try {
        //Just in case previous logon session existed.
        logoff();

        userRegInfo.setAlias(alias);
        userRegInfo.setKeyPassword(keypass.toCharArray());
        char[] storepass = ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.storepass")
                .toCharArray();

        if (!CertificateUtil.certificateExists(alias, storepass)) {
            CertificateUtil.generateRegistryIssuedCertificate(userRegInfo);
        }

        logon(alias, keypass);

        // Now save the User
        ArrayList<RegistryObject> objects = new ArrayList<RegistryObject>();
        objects.add(userRegInfo.getUser());
        getLifeCycleManager().saveObjects(objects, dontVersionSlotsMap);
    } catch (Exception e) {
        // Remove the self-signed certificate from the keystore, if one
        // was created during the self-registration process
        try {
            if (alias != null) {
                CertificateUtil.removeCertificate(alias, userRegInfo.getStorePassword());
            }
        } catch (Exception removeCertException) {
            log.warn(removeCertException);
        }

        if (e instanceof JAXRException) {
            throw (JAXRException) e;
        } else {
            throw new JAXRException(e);
        }
    } finally {
        File tmpFile = new File(userRegInfo.getP12File());
        if (tmpFile.exists()) {
            tmpFile.delete();
        }
    }
}

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

public X500PrivateCredential aliasToX500PrivateCredential(String alias, String keypass) throws JAXRException {
    getKeyStore();/*w ww.  j a v  a2 s .  co m*/
    try {
        X509Certificate cert = (X509Certificate) keyStore.getCertificate(alias);

        if (cert == null) {
            //It may be that keystore h snot been reloaded since it was updated on disk.
            //Retry cert lookup after reloading keyStore.
            keyStore = loadKeyStore();
            cert = (X509Certificate) keyStore.getCertificate(alias);

            if (cert == null) {
                throw new JAXRException(
                        JAXRResourceBundle.getInstance().getString("message.error.failed.entry.alias.keystore",
                                new Object[] { alias, KeystoreUtil.getKeystoreFile().getAbsolutePath() }));
            }
        }

        // if keypass has not been provided, use property value
        if (keypass == null) {
            keypass = ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.keypass");
            // if still null, use alias
            if (keypass == null) {
                keypass = alias;
            }
        }

        // keytool utility requires a six character minimum password.
        // pad passwords with < six chars
        for (int i = 1; 0 < 6 - keypass.length(); i++) {
            keypass += String.valueOf(i);
        }

        if (log.isTraceEnabled()) {
            StringBuffer sb = new StringBuffer("Retrieving key entry with alias '");
            sb.append(alias).append("' with keypass '");
            for (int i = 0; i < keypass.length(); i++) {
                sb.append('*');
            }
            sb.append("' from keystore loaded from '");
            sb.append(KeystoreUtil.getKeystoreFile().getAbsolutePath());
            sb.append("'.");
            log.trace(sb.toString());
        }

        PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, keypass.toCharArray());

        return new X500PrivateCredential(cert, privateKey, alias);
    } catch (GeneralSecurityException x) {
        throw new JAXRException(x);
    }
}

From source file:it.cnr.icar.eric.client.ui.common.UIUtility.java

public BusinessQueryManager getBusinessQueryManager() throws JAXRException {
    if (connection == null) {
        throw new JAXRException(
                UICommonResourceBundle.getInstance().getString("message.mustCallsetConnection"));
    } else {/*from   w w w.j a v a 2s.  co  m*/
        return connection.getRegistryService().getBusinessQueryManager();
    }
}

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

/**
 * Logs off the current user from this RegistryFacade.
 *  /*  w ww . j ava 2  s .c om*/
 */
public void logoff() throws JAXRException {
    if (getConnection() == null) {
        throw new JAXRException("setEndpoint MUST be called before logoff is called.");
    }
    ((it.cnr.icar.eric.client.xml.registry.ConnectionImpl) getConnection()).logoff();
}

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

/**
 * Logs on with a new user context using the credentials specified. The
 * credentials are used to look up the user's public/private keys in teh client keystore
 * and use then to sign client requests to the server.
 *
 * @param alias the alias for user in the client keystore
 * @param keypass the key password for user's private key in the client keystore
 *
 * @throws JAXRException an exception thrown by JAXR Provider.
 *
 */// w ww  .j a  v  a 2  s . co  m
public void logon(String alias, String keypass) throws JAXRException {
    if (getConnection() == null) {
        throw new JAXRException("setEndpoint MUST be called before logon is called.");
    }
    // Set credentials
    HashSet<X500PrivateCredential> creds = new HashSet<X500PrivateCredential>();
    creds.add(securityUtil.aliasToX500PrivateCredential(alias, keypass));
    getConnection().setCredentials(creds);
}

From source file:it.cnr.icar.eric.common.AbstractProperties.java

/**
 * Loads properties from resourceName (from classpath) to 'properties'.
 *
 * @param classLoader the ClassLoader to use when getting resource
 * @param properties existing properties (might get overwritten)
 * @param resourceName the resource name, to be loaded from classpath
 * @return True if load ok. False otherwise.
 *//*from  w w w  .j a va2  s  .  c o m*/
protected static boolean loadResourceProperties(ClassLoader classLoader, Properties properties,
        String resourceName) {
    log.trace(CommonResourceBundle.getInstance().getString("message.LoadPropsFromClasspath",
            new Object[] { resourceName }));
    try {
        InputStream is = classLoader.getResourceAsStream(resourceName);
        if (is == null) {
            throw new JAXRException(CommonResourceBundle.getInstance().getString("message.resourceNotFound",
                    new String[] { resourceName }));
        }
        properties.load(is);
        is.close();
        return true;
    } catch (Exception e) {
        log.debug(CommonResourceBundle.getInstance().getString("message.IgnoringDueToException",
                new Object[] { resourceName, e.toString() }));
        return false;
    }
}