List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:org.wso2.carbon.identity.user.store.configuration.UserStoreConfigAdminService.java
/** * Check the connection heath for JDBC userstores * @param domainName/*ww w.j a v a 2 s . c o m*/ * @param driverName * @param connectionURL * @param username * @param connectionPassword * @param messageID * @return * @throws DataSourceException */ public boolean testRDBMSConnection(String domainName, String driverName, String connectionURL, String username, String connectionPassword, String messageID) throws IdentityUserStoreMgtException { RandomPasswordContainer randomPasswordContainer; if (messageID != null) { randomPasswordContainer = getRandomPasswordContainer(messageID); if (randomPasswordContainer != null) { RandomPassword randomPassword = getRandomPassword(randomPasswordContainer, JDBCRealmConstants.PASSWORD); if (randomPassword != null) { if (connectionPassword.equalsIgnoreCase(randomPassword.getRandomPhrase())) { connectionPassword = randomPassword.getPassword(); } } } } WSDataSourceMetaInfo wSDataSourceMetaInfo = new WSDataSourceMetaInfo(); RDBMSConfiguration rdbmsConfiguration = new RDBMSConfiguration(); rdbmsConfiguration.setUrl(connectionURL); rdbmsConfiguration.setUsername(username); rdbmsConfiguration.setPassword(connectionPassword); rdbmsConfiguration.setDriverClassName(driverName); WSDataSourceDefinition wSDataSourceDefinition = new WSDataSourceDefinition(); ByteArrayOutputStream out = new ByteArrayOutputStream(); JAXBContext context; try { context = JAXBContext.newInstance(RDBMSConfiguration.class); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(rdbmsConfiguration, out); } catch (JAXBException e) { String errorMessage = "Error while checking RDBMS connection health"; log.error(errorMessage, e); throw new IdentityUserStoreMgtException(errorMessage); } wSDataSourceDefinition.setDsXMLConfiguration(out.toString()); wSDataSourceDefinition.setType("RDBMS"); wSDataSourceMetaInfo.setName(domainName); wSDataSourceMetaInfo.setDefinition(wSDataSourceDefinition); try { return DataSourceManager.getInstance().getDataSourceRepository() .testDataSourceConnection(wSDataSourceMetaInfo.extractDataSourceMetaInfo()); } catch (DataSourceException e) { String errorMessage = e.getMessage(); // Does not print the error log since the log is already printed by DataSourceRepository // log.error(message, e); throw new IdentityUserStoreMgtException(errorMessage); } }
From source file:org.wso2.carbon.identity.workflow.mgt.template.AbstractTemplate.java
/** * AbstractTemplate Constructor with metadata xml string parameter * * @param metaDataXML metadata xml string that is validated against ParameterMetaData.xsd * @throws WorkflowRuntimeException//from w ww. j a va 2s . c om */ public AbstractTemplate(String metaDataXML) throws WorkflowRuntimeException { try { this.metaData = WorkflowManagementUtil.unmarshalXML(metaDataXML, MetaData.class); if (this.metaData == null || this.metaData.getTemplate() == null) { throw new WorkflowRuntimeException("Error occurred while Loading Template Meta Data"); } this.parametersMetaData = this.metaData.getTemplate().getParametersMetaData(); } catch (JAXBException e) { String errorMsg = "Error occured while converting template parameter data to object : " + e.getMessage(); log.error(errorMsg); throw new WorkflowRuntimeException(errorMsg, e); } }
From source file:org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow.java
/** * * * @param metaDataXML Parameter Metadata XML string * @throws WorkflowRuntimeException//from www. j av a 2 s. co m */ public AbstractWorkflow(Class<? extends TemplateInitializer> templateInitializerClass, Class<? extends WorkFlowExecutor> workFlowExecutorClass, String metaDataXML) throws WorkflowRuntimeException { try { this.templateInitializerClass = templateInitializerClass; this.workFlowExecutorClass = workFlowExecutorClass; this.metaData = WorkflowManagementUtil.unmarshalXML(metaDataXML, MetaData.class); if (this.metaData == null || this.metaData.getWorkflowImpl() == null) { throw new WorkflowRuntimeException("Error occurred while Loading WorkflowImpl Meta Data"); } this.parametersMetaData = this.metaData.getWorkflowImpl().getParametersMetaData(); } catch (JAXBException e) { String errorMsg = "Error occurred while converting workflow parameter data to object : " + e.getMessage(); log.error(errorMsg); throw new WorkflowRuntimeException(errorMsg, e); } }
From source file:org.wso2.carbon.mediation.connector.pmode.PModeRepository.java
/** * Constructor for PMode repository implementation. * * @param pmodeRepositoryPath Path to the directory containing PMode files *///from ww w. j a v a2 s . c o m private PModeRepository(String pmodeRepositoryPath) throws AxisFault { if (log.isDebugEnabled()) { log.debug("Initializing PMode repository for the location : " + pmodeRepositoryPath); } this.pModeMap = new HashMap<String, PMode>(); this.fileNameRefMap = new HashMap<String, String>(); this.possibleNameChangeMap = new HashMap<String, String>(); File pmodeFolder; try { this.pModeUnmarshaller = JAXBContext.newInstance(PMode.class).createUnmarshaller(); } catch (JAXBException e) { log.error("Unable to create JAXB unmarshaller for : " + PMode.class, e); throw new AxisFault("Unable to create JAXB unmarshaller for : " + PMode.class, e); } if (pmodeRepositoryPath != null) { pmodeFolder = new File(pmodeRepositoryPath); if (!pmodeFolder.exists() || !pmodeFolder.isDirectory()) { log.warn("Provided PMode directory is invalid, falling back to default PMode Directory : " + AS4Constants.AS4_PMODE_LOCATION); pmodeFolder = new File(AS4Constants.AS4_PMODE_LOCATION); } } else { if (log.isDebugEnabled()) { log.debug("PMode directory not provided, falling back to default PMode Directory : " + AS4Constants.AS4_PMODE_LOCATION); } pmodeFolder = new File(AS4Constants.AS4_PMODE_LOCATION); } traversePmodeDirectory(pmodeFolder); try { FileSystemManager fileSystemManager = VFS.getManager(); FileObject listenDirectory = fileSystemManager.resolveFile(pmodeFolder.getAbsolutePath()); this.basePathLength = listenDirectory.getName().getPathDecoded().length() + 1; DefaultFileMonitor fileMonitor = new DefaultFileMonitor(this); fileMonitor.addFile(listenDirectory); fileMonitor.start(); } catch (FileSystemException e) { log.warn("Error registering PMode watcher, hence needs to restart the server when PModes " + "change or added, " + e.getMessage(), e); } }
From source file:org.wso2.carbon.mediation.connector.pmode.PModeRepository.java
/** * Helper method to process PMode files/* w w w. j a v a2s. c o m*/ * * @param pmodeFile PMode file File object */ private void processPModeFile(File pmodeFile) { if (log.isDebugEnabled()) { log.debug("Processing PMode file : " + pmodeFile.getName()); } try { PMode pmode = (PMode) this.pModeUnmarshaller.unmarshal(pmodeFile); if (pmode.getAgreement() == null || pmode.getAgreement().getName() == null || pmode.getAgreement().getName().isEmpty()) { log.warn("Agreement not found in the PMode file, hence ignoring : " + pmodeFile.getName()); return; } validatePMode(pmode); addUpdateRemovePMode(Operation.ADD, pmodeFile.getAbsolutePath(), pmode); } catch (JAXBException e) { log.warn("Unable to unmarshall PMode file : " + pmodeFile.getName() + ", " + e.getMessage(), e); } catch (AxisFault axisFault) { log.warn("Error while validating PMode file : " + pmodeFile.getName() + ", " + axisFault.getMessage(), axisFault); } }
From source file:org.wso2.carbon.ml.core.impl.EmailNotificationSender.java
/** * Get the template of the given email type from ml-email-config.xml file * /* w w w . j a v a 2 s . c o m*/ * @param emailTemplateType Type of the email template * @return Template of the given email type * @throws MLEmailNotificationSenderException */ private static EmailTemplate getEmailTemplate(String emailTemplateType) throws MLEmailNotificationSenderException { String confXml = CarbonUtils.getCarbonConfigDirPath() + File.separator + MLConstants.EMAIL_CONF_DIRECTORY + File.separator + MLConstants.ML_EMAIL_TEMPLATES_FILE; JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(EmailTemplates.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); EmailTemplates emailConfigurations = (EmailTemplates) jaxbUnmarshaller.unmarshal(new File(confXml)); return emailConfigurations.getEmailTemplate(emailTemplateType); } catch (JAXBException e) { throw new MLEmailNotificationSenderException( "An error occurred while parsing email configurations from " + confXml + " : " + e.getMessage(), e); } }
From source file:org.wso2.carbon.ml.decomposition.spark.SparkDecompositionServiceUtil.java
/** * Parse XML file located at given file path. * * @param xmlFilePath Absolute path to an xml file * @return Returns unmarshalled xml/*from w w w .j a va 2 s .c om*/ * @throws DecompositionException */ private static Object parseXML(String xmlFilePath) throws SparkConfigException { try { File file = new File(xmlFilePath); JAXBContext jaxbContext = JAXBContext.newInstance(SparkSettings.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); return jaxbUnmarshaller.unmarshal(file); } catch (JAXBException e) { throw new SparkConfigException( "An error occurred while parsing: " + xmlFilePath + ": " + e.getMessage(), e); } }
From source file:org.wso2.carbon.ndatasource.capp.deployer.DataSourceCappDeployer.java
/** * Method to read data source file and create the object from it. * * @param file - xml file/*w w w .j av a 2 s .c o m*/ * @return - dataSourceMetaInfo object which is created using the xml file. * @throws - org.apache.axis2.deployment.DeploymentException. */ private DataSourceMetaInfo readDataSourceFile(File file) throws DeploymentException { if (log.isDebugEnabled()) { log.debug("Reading data source file from car file - " + file.getName()); } try { InputStream in = new FileInputStream(file); Document doc = DataSourceUtils.convertToDocument(in); /* only super tenant will lookup secure vault information for system data sources, * others are not allowed to */ DataSourceUtils.secureResolveDocument(doc, false); // create JAXB context and initializing Marshaller JAXBContext jaxbContext = JAXBContext.newInstance(DataSourceMetaInfo.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); // this will create Java object - data source from xml file DataSourceMetaInfo dataSourceMetaInfo = (DataSourceMetaInfo) jaxbUnmarshaller.unmarshal(doc); return dataSourceMetaInfo; } catch (JAXBException e) { throw new DeploymentException("DataSourceCappDeployer::readDataSourceFile --> " + "Error in reading data source file: " + e.getMessage(), e); } catch (FileNotFoundException e) { throw new DeploymentException("DataSourceCappDeployer::readDataSourceFile --> " + "Error data source file not found: " + e.getMessage(), e); } catch (DataSourceException e) { throw new DeploymentException("DataSourceCappDeployer::readDataSourceFile --> " + "Error in decrypting data source file: " + e.getMessage(), e); } }
From source file:org.wso2.carbon.ndatasource.ui.NDataSourceHelper.java
public static DSXMLConfiguration unMarshal(String datasourceType, String configuration) throws NDataSourceAdminDataSourceException { if (datasourceType.equals(NDataSourceClientConstants.RDBMS_DTAASOURCE_TYPE)) { JAXBContext ctx = null;/* w ww. ja va2s. c om*/ RDBMSDSXMLConfiguration rdbmsConfiguration = null; try { ctx = JAXBContext.newInstance(RDBMSDSXMLConfiguration.class); rdbmsConfiguration = (RDBMSDSXMLConfiguration) ctx.createUnmarshaller() .unmarshal((Element) (stringToElement(configuration))); } catch (JAXBException e) { throw new NDataSourceAdminDataSourceException( "Error creating rdbms data source configuration info unmarshaller: " + e.getMessage(), e); } return rdbmsConfiguration; } else { throw new IllegalArgumentException("Provided Dta Source type not supported"); } }
From source file:org.wso2.carbon.ntask.core.service.impl.TaskServiceImpl.java
private TaskServiceXMLConfiguration loadTaskServiceXMLConfig() throws TaskException { String path = CarbonUtils.getCarbonConfigDirPath() + File.separator + "etc" + File.separator + "tasks-config.xml"; File file = new File(path); if (!file.exists()) { return null; }//from ww w .j a v a 2 s. c o m Document doc = TaskUtils.convertToDocument(file); TaskUtils.secureResolveDocument(doc); JAXBContext ctx; try { ctx = JAXBContext.newInstance(TaskServiceXMLConfiguration.class); TaskServiceXMLConfiguration taskConfig = (TaskServiceXMLConfiguration) ctx.createUnmarshaller() .unmarshal(doc); return taskConfig; } catch (JAXBException e) { throw new TaskException(e.getMessage(), Code.CONFIG_ERROR, e); } }