List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:org.wso2.carbon.analytics.dataservice.impl.AnalyticsDataServiceImpl.java
private AnalyticsDataServiceConfiguration loadAnalyticsDataServiceConfig() throws AnalyticsException { File confFile = AnalyticsCommonUtils.loadConfigFile(ANALYTICS_CONF_DIR, ANALYTICS_CONFIG_FILE); try {/*from www .jav a 2 s . c o m*/ if (confFile == null || !confFile.exists()) { throw new AnalyticsException( "Cannot find analytics data service configuration file: " + ANALYTICS_CONFIG_FILE); } 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.datasource.rdbms.RDBMSUtils.java
public static RDBMSQueryConfiguration loadQueryConfiguration() throws AnalyticsException { try {/*from w w w .ja va 2 s .c om*/ File confFile = new File(GenericUtils.getAnalyticsConfDirectory() + File.separator + AnalyticsDataSourceConstants.ANALYTICS_CONF_DIR + File.separator + RDBMS_QUERY_CONFIG_FILE); if (!confFile.exists()) { throw new AnalyticsException("Cannot initalize RDBMS analytics data source, " + "the query configuration file cannot be found at: " + confFile.getPath()); } JAXBContext ctx = JAXBContext.newInstance(RDBMSQueryConfiguration.class); Unmarshaller unmarshaller = ctx.createUnmarshaller(); RDBMSQueryConfiguration conf = (RDBMSQueryConfiguration) unmarshaller.unmarshal(confFile); validateRDBMSQueryConfiguration(conf); return conf; } catch (JAXBException e) { throw new AnalyticsException("Error in processing RDBMS query configuration: " + e.getMessage(), e); } }
From source file:org.wso2.carbon.analytics.spark.core.internal.SparkAnalyticsExecutor.java
private UDFConfiguration loadUDFConfiguration() throws AnalyticsException { try {/*from www. ja v a 2s .c om*/ File confFile = new File(GenericUtils.getAnalyticsConfDirectory() + File.separator + "analytics" + File.separator + AnalyticsConstants.SPARK_CONF_DIR + File.separator + AnalyticsConstants.SPARK_UDF_CONF_FILE); if (!confFile.exists()) { throw new AnalyticsUDFException("Cannot load UDFs, " + "the UDF configuration file cannot be found at: " + confFile.getPath()); } JAXBContext ctx = JAXBContext.newInstance(UDFConfiguration.class); Unmarshaller unmarshaller = ctx.createUnmarshaller(); return (UDFConfiguration) unmarshaller.unmarshal(confFile); } catch (JAXBException e) { throw new AnalyticsUDFException("Error in processing UDF configuration: " + e.getMessage(), e); } }
From source file:org.wso2.carbon.analytics.tools.backup.AnalyticsDataBackupTool.java
private static AnalyticsDataServiceConfiguration loadAnalyticsDataServiceConfig() throws AnalyticsException { try {// w w w . j a va 2 s .c o m 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()); } System.out.println("conf: " + confFile.getAbsolutePath()); 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.appfactory.ext.datasource.ApplicationAwareDataSourceRepository.java
public ApplicationAwareDataSourceRepository(int tenantId) throws DataSourceException { super(tenantId); /* Map to hold map of datasources of application*/ this.dataSources = new HashMap<String, Map<String, CarbonDataSource>>(); try {//from ww w .j a va2s .c om JAXBContext ctx = JAXBContext.newInstance(DataSourceMetaInfo.class); this.dsmMarshaller = ctx.createMarshaller(); this.dsmUnMarshaller = ctx.createUnmarshaller(); } catch (JAXBException e) { throw new DataSourceException( "Error creating data source meta info marshaller/unmarshaller: " + e.getMessage(), e); } }
From source file:org.wso2.carbon.coordination.core.sync.impl.ZKGroup.java
private byte[] processDataNodeReply(byte[] data) throws CoordinationException { ByteArrayInputStream byteIn = new ByteArrayInputStream(data); PeerResponseMessage responseMsg;/* www.j a v a 2 s . c o m*/ try { responseMsg = (PeerResponseMessage) getPeerResponseUnmarshaller().unmarshal(byteIn); } catch (JAXBException e) { throw new CoordinationException("Error in unmarshalling peer response message: " + e.getMessage(), ExceptionCode.GENERIC_ERROR, e); } if (!responseMsg.isSuccess()) { throw new CoordinationException("Error occured in target peer processing: " + responseMsg.getMessage(), ExceptionCode.GENERIC_ERROR); } ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); for (String msgId : responseMsg.getMessageIds()) { try { byteOut.write(this.retrieveResultData(msgId)); } catch (IOException e) { throw new CoordinationException("Error creating result buffer: " + e.getMessage(), ExceptionCode.GENERIC_ERROR, e); } } return byteOut.toByteArray(); }
From source file:org.wso2.carbon.datasource.core.DataSourceRepository.java
public DataSourceRepository(int tenantId) throws DataSourceException { this.tenantId = tenantId; this.dataSources = new HashMap<String, CarbonDataSource>(); try {/*www.j av a 2 s . co m*/ JAXBContext ctx = JAXBContext.newInstance(DataSourceMetaInfo.class); this.dsmMarshaller = ctx.createMarshaller(); this.dsmUnmarshaller = ctx.createUnmarshaller(); } catch (JAXBException e) { throw new DataSourceException( "Error creating data source meta info marshaller/unmarshaller: " + e.getMessage(), e); } }
From source file:org.wso2.carbon.device.mgt.core.config.tenant.TenantConfigurationManagementServiceImpl.java
@Override public TenantConfiguration getConfiguration(String resourcePath) throws ConfigurationManagementException { Resource resource;//from ww w . jav a2 s . c om try { resource = ConfigurationManagerUtil.getRegistryResource(resourcePath); if (resource != null) { JAXBContext context = JAXBContext.newInstance(TenantConfiguration.class); Unmarshaller unmarshaller = context.createUnmarshaller(); return (TenantConfiguration) unmarshaller .unmarshal(new StringReader(new String((byte[]) resource.getContent(), Charset.forName(ConfigurationManagerConstants.CharSets.CHARSET_UTF8)))); } return new TenantConfiguration(); } catch (JAXBException e) { throw new ConfigurationManagementException( "Error occurred while parsing the Tenant configuration : " + e.getMessage(), e); } catch (RegistryException e) { throw new ConfigurationManagementException( "Error occurred while retrieving the Registry resource of Tenant Configuration : " + e.getMessage(), e); } }
From source file:org.wso2.carbon.device.mgt.extensions.device.type.template.DeviceTypeManager.java
private PlatformConfiguration getDefaultConfiguration() throws DeviceManagementException { if (log.isDebugEnabled()) { log.debug("Loading default " + deviceType + " platform configuration from " + deviceType + "-default-platform-configuration.xml"); }/* w ww . ja v a2 s. com*/ try { String platformConfigurationPath = PATH_MOBILE_PLUGIN_CONF_DIR + File.separator + deviceType + "-default-platform-configuration.xml"; File platformConfig = new File(platformConfigurationPath); if (platformConfig.exists()) { Document doc = DeviceTypeUtils.convertToDocument(platformConfig); JAXBContext context = JAXBContext.newInstance(PlatformConfiguration.class); Unmarshaller unmarshaller = context.createUnmarshaller(); return (PlatformConfiguration) unmarshaller.unmarshal(doc); } else { log.warn(deviceType + "-default-platform-configuration.xml is not available, hence default " + deviceType + "platform configuration cannot be loaded."); } return null; } catch (JAXBException e) { throw new DeviceManagementException("Error occurred while parsing the " + deviceType + " default platform configuration : " + e.getMessage(), e); } catch (DeviceTypeMgtPluginException e) { throw new DeviceManagementException("Error occurred while parsing the " + deviceType + " default platform configuration : " + e.getMessage(), e); } }
From source file:org.wso2.carbon.event.simulator.admin.internal.util.EventSimulatorDataSourceInfo.java
/** * Populate xml values to Jaxb mapping classes *///from w w w. java2s .co m private static void populateJaxbMappings() throws AxisFault { JAXBContext jaxbContext; dbTypeMappings = new HashMap<String, Map<String, String>>(); try { jaxbContext = JAXBContext.newInstance(Mappings.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); String path = CarbonUtils.getCarbonConfigDirPath() + File.separator + EventSimulatorDataSourceConstants.GENERIC_RDBMS_FILE_SPECIFIC_PATH + EventSimulatorDataSourceConstants.GENERIC_RDBMS_FILE_NAME; File configFile = new File(path); if (!configFile.exists()) { throw new AxisFault("The " + EventSimulatorDataSourceConstants.GENERIC_RDBMS_FILE_NAME + " can not found in " + path); } Mappings mappings = (Mappings) unmarshaller.unmarshal(configFile); Map<String, Mapping> dbMap = new HashMap<String, Mapping>(); List<Mapping> mappingList = mappings.getMapping(); for (Mapping mapping : mappingList) { dbMap.put(mapping.getDb(), mapping); } //Constructs a map to contain all db wise elements and there values for (Mapping mapping : mappingList) { if (mapping.getDb() != null) { Mapping defaultMapping = dbMap.get(null); Mapping specificMapping = dbMap.get(mapping.getDb()); List<Element> defaultElementList = defaultMapping.getElements().getElementList(); Map<String, String> elementMappings = new HashMap<String, String>(); for (Element element : defaultElementList) { //Check if the mapping is present in the specific mapping Element elementDetails = null; if (specificMapping.getElements().getElementList() != null) { elementDetails = specificMapping.getElements().getType(element.getKey()); } //If a specific mapping is not found then use the default mapping if (elementDetails == null) { elementDetails = defaultMapping.getElements().getType(element.getKey()); } elementMappings.put(elementDetails.getKey(), elementDetails.getValue()); } dbTypeMappings.put(mapping.getDb(), elementMappings); } } } catch (JAXBException e) { throw new AxisFault(e.getMessage(), e); } }