Example usage for javax.xml.registry JAXRException getMessage

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message for this JAXRException object.

Usage

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

/** Get the credentials for the specified principal.
 *
 * @param alias//from w  w  w . ja va  2s.co  m
 *     The principal of the user making the request on the registry.
 *     This value will be obtained from the web container hosting the
 *     registry client by calling HttpServletRequest.getUserPrincipal().
 *     If this value is <code>null</code>, or if <code>principal.getName()</code>
 *     is <code>null</code>, then the default principal name, as specified
 *     by the <i>jaxr-ebxml.security.defaultPrincipalName</i> property
 *     will be used. If this property is not set, then an empty Set will
 *     be returned.
 * @return
 *     A Set of X500PrivateCredential objects representing the user's
 *     credentials. If this set is empty or null, no credentials will
 *     be passed to the registry with the request. The registry treats
 *     such requests as coming from the Registry Guest user.
 * @throws JAXRException
 *     Thrown if an error occurs while trying to map the principal
 *     to its credentials. An exception should not be thrown if there are
 *     no credentials associated with the principal. In this case, an
 *     empty Set should be returned.
 */
public Set<Object> getCredentials(String alias) throws JAXRException {

    HashSet<Object> credentials = new HashSet<Object>();

    if (alias == null) {
        return credentials;
    }

    log.debug("Getting credentials for '" + alias + "'");

    try {
        credentials.add(it.cnr.icar.eric.client.xml.registry.util.SecurityUtil.getInstance()
                .aliasToX500PrivateCredential(alias));
    } catch (JAXRException je) {
        // aliasToX500PrivateCredential() throws an exception if no certificate
        // can be found for the specified alias. For our purposes, this
        // is not an exception, so we just ignore such exceptions and
        // propogate all others.
        if (je.getMessage().equals("Alias unknown in keystore")
                || je.getMessage().startsWith("KeyStore file not found")
                || je.getMessage().startsWith("Failed to find an entry with the alias")) {
            log.warn(WebUIResourceBundle.getInstance().getString("message.FailedToGetCredentialsForException",
                    new Object[] { alias }), je);
            throw je;
        } else {
            throw je;
        }
    }

    return credentials;
}

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

/**
* This method will upload file in registry for Extrensic Objects 
* 
*///from  w  ww .ja v  a2s .  c o  m
public String doUpload(File file, String contentType) {
    String status = "failure";
    RegistryObject ro = getCurrentRegistryObjectBean().getRegistryObject();
    if (ro instanceof ExtrinsicObject) {
        if (file == null) {
            append(WebUIResourceBundle.getInstance().getString("messgeFileUpload"));
            log.error(WebUIResourceBundle.getInstance()
                    .getString("message.NullFileObjectPassedToDoUploadMethod"));
        } else {
            try {
                DataHandler handler = new DataHandler(new FileDataSource(file));
                ((ExtrinsicObject) ro).setRepositoryItem(handler);
                if (contentType == null) {
                    log.error(WebUIResourceBundle.getInstance()
                            .getString("message.NullContentTypePassedToDoUploadMethod"));
                } else {
                    ((ExtrinsicObject) ro).setMimeType(contentType);
                }
                status = "success";
            } catch (JAXRException ex) {
                String errMsg = WebUIResourceBundle.getInstance().getString("errorUploadingFile");
                append(errMsg + " " + ex.getMessage());
                log.error(errMsg + " " + ex.getMessage());
            }
        }
    }
    return status;
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

/**
 * Gets the RegistryObjects owned by the caller. The objects
 * are returned as their concrete type (e.g. Organization, User etc.)
 *
 *  TODO - need to figure out what the set are.  This is just to get some
 *  basic functionality//from www .  j a  va2s  .c  o  m
 *
 * @return BulkResponse
 * @throws JAXRException
 */
public BulkResponse getRegistryObjects() throws JAXRException {
    String types[] = { LifeCycleManager.ORGANIZATION, LifeCycleManager.SERVICE };

    LinkedHashSet<Object> c = new LinkedHashSet<Object>();

    for (int i = 0; i < types.length; i++) {
        try {
            BulkResponse bk = getRegistryObjects(types[i]);

            if (bk.getCollection() != null) {
                c.addAll(bk.getCollection());
            }
        } catch (JAXRException e) {
            log.debug("ignore - just a problem with that type? " + e.getMessage(), e);
        }
    }

    return new BulkResponseImpl(c);
}