Example usage for javax.xml.bind JAXBException getMessage

List of usage examples for javax.xml.bind JAXBException getMessage

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.talend.components.marketo.runtime.client.MarketoSOAPClient.java

public MarketoSyncResult listOperation(ListOperationType operationType, ListOperationParameters parameters) {
    LOG.debug("listOperation : {}", parameters);
    ParamsListOperation paramsListOperation = new ParamsListOperation();
    paramsListOperation.setListOperation(operationType);
    paramsListOperation.setStrict(objectFactory.createParamsListOperationStrict(parameters.getStrict()));
    ListKey listKey = new ListKey();
    listKey.setKeyValue(parameters.getListKeyValue());
    listKey.setKeyType(ListKeyType.valueOf(parameters.getListKeyType()));
    paramsListOperation.setListKey(listKey);
    ArrayOfLeadKey leadKeys = new ArrayOfLeadKey();
    for (String lkv : parameters.getLeadKeyValues()) {
        LeadKey lk = new LeadKey();
        lk.setKeyType(valueOf(parameters.getLeadKeyType()));
        lk.setKeyValue(lkv);/*w  w w  .  j a v  a 2 s. c o  m*/
        leadKeys.getLeadKeies().add(lk);
    }
    paramsListOperation.setListMemberList(leadKeys);

    MarketoSyncResult mkto = new MarketoSyncResult();
    mkto.setRequestId(SOAP + "::" + operationType.name());
    try {
        SuccessListOperation result = getPort().listOperation(paramsListOperation, header);
        if (LOG.isDebugEnabled()) {
            try {
                JAXBContext context = JAXBContext.newInstance(SuccessListOperation.class);
                Marshaller m = context.createMarshaller();
                m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
                m.marshal(result, System.out);
            } catch (JAXBException e) {
                LOG.error(e.getMessage());
            }
        }
        mkto.setSuccess(true);
        if (!result.getResult().getStatusList().isNil()) {
            mkto.setRecordCount(result.getResult().getStatusList().getValue().getLeadStatuses().size());
            List<LeadStatus> statuses = result.getResult().getStatusList().getValue().getLeadStatuses();
            List<SyncStatus> resultStatus = new ArrayList<>();
            for (LeadStatus status : statuses) {
                SyncStatus sts = new SyncStatus(Integer.parseInt(status.getLeadKey().getKeyValue()),
                        String.valueOf(status.isStatus()));
                if (!status.isStatus() && !ISMEMBEROFLIST.equals(operationType)) {
                    Map<String, String> reason = new HashMap<>();
                    reason.put("code", "20103");
                    reason.put("message", "Lead Not Found");
                    sts.setReasons(Collections.singletonList(reason));
                }
                resultStatus.add(sts);
            }
            mkto.setRecords(resultStatus);
        } else {
            LOG.debug("No detail about successed operation, building one...");
            String success = String.valueOf(result.getResult().isSuccess());
            mkto.setRecordCount(parameters.getLeadKeyValue().size());
            for (String leadk : parameters.getLeadKeyValue()) {
                SyncStatus status = new SyncStatus(Integer.parseInt(leadk), success);
                mkto.getRecords().add(status);
            }
        }
    } catch (Exception e) {
        LOG.error("[{}] error: {}", operationType.name(), e.getMessage());
        mkto.setSuccess(false);
        mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.toString())));
    }
    return mkto;
}

From source file:org.talend.components.marketo.runtime.client.MarketoSOAPClient.java

/**
 * Request<br/>/*ww w  .  j a v  a 2  s  . co m*/
 * 
 * Field Name <br/>
 * <code>leadRecord->Id</code> Required  Only when Email or foreignSysPersonId is not present The Marketo Id of the
 * lead record<br/>
 * <code>leadRecord->Email</code> Required  Only when Id or foreignSysPersonId is not present The email address
 * associated with the lead record<br/>
 * <code>leadRecord->foreignSysPersonId</code> Required  Only when Id or Email is not present The foreign system id
 * associated with the lead record<br/>
 * <code>leadRecord->foreignSysType</code> Optional  Only required when foreignSysPersonId is present The type of
 * foreign system. Possible values: CUSTOM, SFDC, NETSUITE<br/>
 * <code>leadRecord->leadAttributeList->attribute->attrName</code> Required The name of the lead attribute you want to
 * update the value of.<br/>
 * <code>leadRecord->leadAttributeList->attribute->attrValue</code> Required The value you want to set to the lead
 * attribute specificed in attrName. returnLead Required When true will return the complete updated lead record upon
 * update.<br/>
 * <code>marketoCookie</code> Optional The Munchkin javascript cookie<br/>
 */
@Override
public MarketoSyncResult syncLead(TMarketoOutputProperties parameters, IndexedRecord lead) {
    MarketoSyncResult mkto = new MarketoSyncResult();
    try {
        ParamsSyncLead request = new ParamsSyncLead();
        request.setReturnLead(false);
        //
        request.setLeadRecord(convertToLeadRecord(lead, parameters.mappingInput.getNameMappingsForMarketo()));
        MktowsContextHeader headerContext = new MktowsContextHeader();
        headerContext.setTargetWorkspace("default");
        SuccessSyncLead result = getPort().syncLead(request, header, headerContext);
        //
        if (LOG.isDebugEnabled()) {
            try {
                JAXBContext context = JAXBContext.newInstance(SuccessSyncLead.class);
                Marshaller m = context.createMarshaller();
                m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
                m.marshal(result, System.out);
            } catch (JAXBException e) {
                LOG.error(e.getMessage());
            }
        }
        //
        com.marketo.mktows.SyncStatus status = result.getResult().getSyncStatus();
        mkto.setSuccess(status.getError().isNil());
        if (mkto.isSuccess()) {
            mkto.setRecordCount(1);
            SyncStatus resultStatus = new SyncStatus(status.getLeadId(), status.getStatus().value());
            mkto.setRecords(Collections.singletonList(resultStatus));
        } else {
            mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, status.getError().getValue())));
        }
    } catch (Exception e) {
        LOG.error(e.toString());
        mkto.setSuccess(false);
        mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.getMessage())));
    }
    return mkto;
}

From source file:org.talend.components.marketo.runtime.client.MarketoSOAPClient.java

@Override
public MarketoSyncResult syncMultipleLeads(TMarketoOutputProperties parameters, List<IndexedRecord> leads) {
    MarketoSyncResult mkto = new MarketoSyncResult();
    try {/*from ww w.ja v  a2s . co m*/
        ParamsSyncMultipleLeads request = new ParamsSyncMultipleLeads();
        ArrayOfLeadRecord leadRecords = new ArrayOfLeadRecord();
        for (IndexedRecord r : leads) {
            leadRecords.getLeadRecords()
                    .add(convertToLeadRecord(r, parameters.mappingInput.getNameMappingsForMarketo()));
        }
        JAXBElement<Boolean> dedup = objectFactory
                .createParamsSyncMultipleLeadsDedupEnabled(parameters.deDupeEnabled.getValue());
        request.setDedupEnabled(dedup);
        request.setLeadRecordList(leadRecords);
        SuccessSyncMultipleLeads result = getPort().syncMultipleLeads(request, header);
        //
        if (LOG.isDebugEnabled()) {
            try {
                JAXBContext context = JAXBContext.newInstance(SuccessSyncLead.class);
                Marshaller m = context.createMarshaller();
                m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
                m.marshal(result, System.out);
            } catch (JAXBException e) {
                LOG.error(e.getMessage());
            }
        }
        //
        List<SyncStatus> records = new ArrayList<>();
        for (com.marketo.mktows.SyncStatus status : result.getResult().getSyncStatusList().getSyncStatuses()) {
            SyncStatus s = new SyncStatus(status.getLeadId(), status.getStatus().value());
            s.setErrorMessage(status.getError().getValue());
            records.add(s);
        }
        mkto.setSuccess(result.getResult().getSyncStatusList() != null);
        mkto.setRecords(records);
    } catch (Exception e) {
        LOG.error(e.toString());
        mkto.setSuccess(false);
        mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.getMessage())));
    }
    return mkto;
}

From source file:org.tinymediamanager.core.tvshow.connector.TvShowEpisodeToXbmcNfoConnector.java

private static JAXBContext initContext() {
    try {//from  w  ww  .  jav  a2 s .  co  m
        return JAXBContext.newInstance(TvShowEpisodeToXbmcNfoConnector.class, Actor.class);
    } catch (JAXBException e) {
        LOGGER.error(e.getMessage());
    }
    return null;
}

From source file:org.tinymediamanager.core.tvshow.connector.TvShowToXbmcNfoConnector.java

private static JAXBContext initContext() {
    try {/* w  w w. j a v  a  2  s . c  o  m*/
        return JAXBContext.newInstance(TvShowToXbmcNfoConnector.class, Actor.class);
    } catch (JAXBException e) {
        LOGGER.error(e.getMessage());
    }
    return null;
}

From source file:org.voltdb.compiler.VoltCompiler.java

/**
 * Read the project file and get the database object.
 * @param projectFileURL  project file URL/path
 * @return  database for project or null
 *//*from   w  w  w.  j a va  2 s . c o m*/
private DatabaseType getProjectDatabase(final VoltCompilerReader projectReader) {
    DatabaseType database = null;
    if (projectReader != null) {
        m_currentFilename = projectReader.getName();
        try {
            JAXBContext jc = JAXBContext.newInstance("org.voltdb.compiler.projectfile");
            // This schema shot the sheriff.
            SchemaFactory sf = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
            Schema schema = sf.newSchema(this.getClass().getResource("ProjectFileSchema.xsd"));
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            // But did not shoot unmarshaller!
            unmarshaller.setSchema(schema);
            @SuppressWarnings("unchecked")
            JAXBElement<ProjectType> result = (JAXBElement<ProjectType>) unmarshaller.unmarshal(projectReader);
            ProjectType project = result.getValue();
            database = project.getDatabase();
        } catch (JAXBException e) {
            // Convert some linked exceptions to more friendly errors.
            if (e.getLinkedException() instanceof java.io.FileNotFoundException) {
                addErr(e.getLinkedException().getMessage());
                compilerLog.error(e.getLinkedException().getMessage());
            } else {
                DeprecatedProjectElement deprecated = DeprecatedProjectElement.valueOf(e);
                if (deprecated != null) {
                    addErr("Found deprecated XML element \"" + deprecated.name() + "\" in project.xml file, "
                            + deprecated.getSuggestion());
                    addErr("Error schema validating project.xml file. " + e.getLinkedException().getMessage());
                    compilerLog.error(
                            "Found deprecated XML element \"" + deprecated.name() + "\" in project.xml file");
                    compilerLog.error(e.getMessage());
                    compilerLog.error(projectReader.getPath());
                } else if (e.getLinkedException() instanceof org.xml.sax.SAXParseException) {
                    addErr("Error schema validating project.xml file. " + e.getLinkedException().getMessage());
                    compilerLog.error(
                            "Error schema validating project.xml file: " + e.getLinkedException().getMessage());
                    compilerLog.error(e.getMessage());
                    compilerLog.error(projectReader.getPath());
                } else {
                    throw new RuntimeException(e);
                }
            }
        } catch (SAXException e) {
            addErr("Error schema validating project.xml file. " + e.getMessage());
            compilerLog.error("Error schema validating project.xml file. " + e.getMessage());
        }
    } else {
        // No project.xml - create a stub object.
        database = new DatabaseType();
    }

    return database;
}

From source file:org.wingsource.plugin.impl.gadget.bean.Gadget.java

public void load(String tokenId, String id, Map<String, String> requestParameters) {
    this.id = id;
    this.userId = tokenId;
    try {/* ww w . jav  a2  s.co  m*/
        URL url = gadgetService.getGadgetXmlUrl(this.id);
        this.gadgetUrl = url.toString();

        Module module = GADGET_MODULE_MAP.get(this.gadgetUrl);

        if (module == null) {
            //            long startTime = System.currentTimeMillis();
            JAXBContext context = JAXBContext.newInstance("org.wingsource.plugin.impl.gadget.xml");
            Unmarshaller unmarshaller = context.createUnmarshaller();
            module = (Module) unmarshaller.unmarshal(this.getContentStream(this.gadgetUrl));
            //            long endTime = System.currentTimeMillis();
            //            logger.finest("$GADGET_MODULE_URL : "+this.gadgetUrl+" TIME "+(endTime - startTime));
            GADGET_MODULE_MAP.put(this.gadgetUrl, module);
        }
        ModulePrefs mPrefs = module.getModulePrefs();
        this.title = mPrefs.getTitle();
        this.render = mPrefs.getRenderInline();
        List<Content> contents = module.getContent();
        Integer h = module.getModulePrefs().getHeight();
        if (h != null) {
            this.height = h;
        }
        for (Content c : contents) {
            String v = c.getView();
            String href = c.getHref();
            if ((this.render != null) && (this.render.equalsIgnoreCase(RENDER_INLINE))) {
                long startTime = Calendar.getInstance().getTimeInMillis();
                Response response = this.getResponse(tokenId, href, requestParameters);
                long endTime = Calendar.getInstance().getTimeInMillis();
                logger.finest("$GADGET_URL : " + this.gadgetUrl + " TIME " + (endTime - startTime));
                this.content = response.getContent();
                this.headers = response.getHeaders();
            }

            if (v != null && !v.equalsIgnoreCase("null") && !v.equalsIgnoreCase("")) {
                views.add(c.getView());
            }
        }

    } catch (JAXBException e) {
        logger.log(Level.SEVERE, e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.analytics.common.jmx.agent.profiles.ProfileManager.java

/**
 * Returns an array of all the profiles regardless of their state
 *
 * @return an array of all the profiles regardless of their state
 *//*w  w  w  .  j  a v  a 2s  .  c o m*/
public Profile[] getAllProfiles() throws JmxProfileException {

    Profile[] profiles = null;

    try {
        if (registry.resourceExists(PROFILE_SAVE_REG_LOCATION)) {

            Resource folder = registry.get(PROFILE_SAVE_REG_LOCATION);
            String[] content = (String[]) folder.getContent();

            //initiate the profiles array
            profiles = new Profile[content.length];
            int counter = 0;
            Profile profile;
            ByteArrayInputStream byteArrayInputStream;
            JAXBContext jaxbContext = JAXBContext.newInstance(Profile.class);
            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();

            //iterate through the profiles
            for (String path : content) {
                Resource res = registry.get(path);
                try {
                    byteArrayInputStream = new ByteArrayInputStream((byte[]) res.getContent());
                    profile = (Profile) jaxbUnmarshaller.unmarshal(byteArrayInputStream);
                } catch (JAXBException e) {
                    log.error("JAXB unmarshalling exception :" + e.getMessage(), e);
                    throw new JmxProfileException("JAXB unmarshalling exception :" + e.getMessage(), e);
                }

                try {
                    byteArrayInputStream.close();
                } catch (IOException e) {
                    // Just log the exception. Do nothing.
                    log.warn("Unable to close byte stream ...", e);
                }

                //decrypt data
                try {
                    profile = decryptData(profile);
                } catch (CryptoException e) {
                    log.error("Unable to decrypt profile", e);
                    throw new JmxProfileException("Unable to decrypt profile", e);
                }
                profiles[counter++] = profile;
            }
        }
    } catch (RegistryException e) {
        log.error("Unable to access to registry", e);
        throw new JmxProfileException("Unable to access to registry", e);
    } catch (JAXBException e) {
        log.error("JAXB unmarshalling exception :" + e.getMessage(), e);
        throw new JmxProfileException("JAXB unmarshalling exception :" + e.getMessage(), e);
    }

    return profiles;
}

From source file:org.wso2.carbon.analytics.dataservice.AnalyticsDataServiceComponent.java

private AnalyticsDataServiceConfiguration loadAnalyticsDataServiceConfig() throws AnalyticsException {
    try {//  ww  w  .j  a  v  a 2s.c om
        File confFile = new File(CarbonUtils.getCarbonConfigDirPath() + File.separator
                + AnalyticsDataSourceConstants.ANALYTICS_CONF_DIR + File.separator + ANALYTICS_DS_CONFIG_FILE);
        if (!confFile.exists()) {
            throw new AnalyticsException("Cannot initalize analytics data service, "
                    + "the analytics data service configuration file cannot be found at: "
                    + confFile.getPath());
        }
        JAXBContext ctx = JAXBContext.newInstance(AnalyticsDataServiceConfiguration.class);
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        return (AnalyticsDataServiceConfiguration) unmarshaller.unmarshal(confFile);
    } catch (JAXBException e) {
        throw new AnalyticsException(
                "Error in processing analytics data service configuration: " + e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceImpl.java

private AnalyticsDataServiceConfiguration loadAnalyticsDataServiceConfig() throws AnalyticsException {
    try {//from  w  ww  .ja va2  s  . com
        File confFile = new File(GenericUtils.getAnalyticsConfDirectory() + File.separator
                + AnalyticsDataSourceConstants.ANALYTICS_CONF_DIR + File.separator + ANALYTICS_DS_CONFIG_FILE);
        if (!confFile.exists()) {
            throw new AnalyticsException("Cannot initalize analytics data service, "
                    + "the analytics data service configuration file cannot be found at: "
                    + confFile.getPath());
        }
        JAXBContext ctx = JAXBContext.newInstance(AnalyticsDataServiceConfiguration.class);
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        return (AnalyticsDataServiceConfiguration) unmarshaller.unmarshal(confFile);
    } catch (JAXBException e) {
        throw new AnalyticsException(
                "Error in processing analytics data service configuration: " + e.getMessage(), e);
    }
}