List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:com.dcsquare.fileauthplugin.utility.Commands.java
/** * This method sets the path to the configuration file. * * @param path to configuration file/*from w w w .ja v a 2 s. c om*/ * @return message if loading of file was successful or not */ @CliCommand(value = "configure", help = "reads File Authentication Plugin Configuration File") public String configure(@CliOption(key = { "file" }, mandatory = true, help = "The absolute path to the fileAuthentication.properties file") final String path) { try { fileAuthConfiguration = new FileAuthConfiguration(path); } catch (ConfigurationException e) { return "Error reading configuration, try again"; } catch (FileNotFoundException e) { return e.getMessage(); } catch (IOException e) { return "Error did not find credential file and creation was not possible"; } final File file = new File(new File(path).getParent(), fileAuthConfiguration.getCredentialFileName()); try { credentialProperties = new CredentialProperties(file.getAbsolutePath()); } catch (ConfigurationException e) { return "Error reading credentials, try again"; } return "Configuration successfully read!"; }
From source file:com.bibisco.manager.ConfigManager.java
private XMLConfiguration getXMLConfiguration() { XMLConfiguration lXMLConfiguration = null; lXMLConfiguration = new XMLConfiguration(); lXMLConfiguration.setEncoding(ENCODING); try {// www .ja va 2s . c om lXMLConfiguration.setBasePath(CONFIG_DIR); lXMLConfiguration.load(CONFIG_FILENAME); lXMLConfiguration.setExpressionEngine(new XPathExpressionEngine()); } catch (ConfigurationException e) { mLog.error(e, "Error while reading configuration from file ", CONFIG_FILENAME); throw new BibiscoException(e, "bibiscoException.configManager.errorWhileReadingConfiguration", CONFIG_FILENAME, e.getMessage()); } return lXMLConfiguration; }
From source file:com.tulskiy.musique.system.configuration.Configuration.java
@Override public void save(Writer writer) { logger.fine("Saving configuration"); try {//w w w. j a va 2 s .com OutputFormat format = new OutputFormat(createDocument()); format.setLineWidth(65); format.setIndenting(true); format.setIndent(2); XMLSerializer serializer = new XMLSerializer(writer, format); serializer.serialize(getDocument()); writer.close(); } catch (ConfigurationException ce) { logger.severe("Failed to save configuration: " + ce.getMessage()); } catch (IOException ioe) { logger.severe("Failed to save configuration: " + ioe.getMessage()); } }
From source file:com.nridge.connector.common.con_com.transform.TCPCCollapse.java
/** * Applies a transformation against the source document to produce * the returned destination document.//from ww w . j av a 2s.c o m * * @param aSrcDoc Source document instance. * @return New destination document instance. * * @throws NSException Indicates a data validation error condition. */ @Override public Document process(Document aSrcDoc) throws NSException { Document dstDoc; Logger appLogger = mAppMgr.getLogger(this, "process"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); if (aSrcDoc == null) throw new NSException("Source document is null."); if (mCfgProperties == null) { String compositeFileName = getCfgString("collapse_file"); if (StringUtils.isNotEmpty(compositeFileName)) { String compositePathFileName = String.format("%s%c%s", mAppMgr.getString(mAppMgr.APP_PROPERTY_CFG_PATH), File.separatorChar, compositeFileName); File parentChildFile = new File(compositePathFileName); if (parentChildFile.exists()) { try { mCfgProperties = new PropertiesConfiguration(); mCfgProperties.setFileName(compositePathFileName); mCfgProperties.setIOFactory(new WhitespaceIOFactory()); mCfgProperties.load(); } catch (ConfigurationException e) { mCfgProperties = null; String msgStr = String.format("%s: %s", compositePathFileName, e.getMessage()); throw new NSException(msgStr); } } } } // Clone our source document. dstDoc = new Document(aSrcDoc); // Execute the transformation. if (mCfgProperties != null) transform(dstDoc); appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return dstDoc; }
From source file:com.termmed.reconciliation.ChangeConsolidator.java
/** * Gets the params.// w w w. j a va 2 s . c o m * * @return the params * @throws ConfigurationException the configuration exception */ private void getParams() throws ConfigurationException { try { xmlConfig = new XMLConfiguration(config); } catch (ConfigurationException e) { log.info("ChangeConsolidator - Error happened getting params file." + e.getMessage()); throw e; } relationship = xmlConfig.getString(I_Constants.RELATIONSHIP_FILE); String snapshotFinal = xmlConfig.getString(I_Constants.CONSOLIDATED_SNAPSHOT_FILE); snapshotFinalFile = new File(snapshotFinal); String deltaFinal = xmlConfig.getString(I_Constants.CONSOLIDATED_DELTA_FILE); deltaFinalFile = new File(deltaFinal); additionalCharType = xmlConfig.getString(I_Constants.ADDITIONAL_RELS_SNAPSHOT_FILE); List<String> prevRelFiles = xmlConfig.getList(I_Constants.PREVIOUS_INFERRED_RELATIONSHIP_FILES); if (prevRelFiles != null && prevRelFiles.size() > 0) { previousInferredRelationshipsFile = new String[prevRelFiles.size()]; prevRelFiles.toArray(previousInferredRelationshipsFile); } releaseDate = xmlConfig.getString(I_Constants.RELEASEDATE); log.info("Consolidator - Parameters:"); log.info("Input file : " + relationship); log.info("Previous Relationship files : "); if (previousInferredRelationshipsFile != null) { for (String relFile : previousInferredRelationshipsFile) { log.info(relFile); } } log.info("Snapshot final file : " + snapshotFinal); log.info("Delta final file : " + deltaFinal); log.info("Release date : " + releaseDate); }
From source file:com.nridge.connector.common.con_com.transform.TFieldCollapse.java
/** * Applies a transformation against the source document to produce * the returned destination document. If the document has a field * containing content, then this method may update it as part of its * processing logic.//w ww.j a v a 2s .c om * * @param aSrcDoc Source document instance. * * @return New destination DataBag instance. * * @throws NSException Indicates a data validation error condition. */ public Document process(Document aSrcDoc) throws NSException { Document dstDoc; Logger appLogger = mAppMgr.getLogger(this, "process"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); if (aSrcDoc == null) throw new NSException("Source document is null."); if (mCfgProperties == null) { String fieldMappingFileName = getCfgString("field_collapse_file"); if (StringUtils.isNotEmpty(fieldMappingFileName)) { String fieldMappingPathFileName = String.format("%s%c%s", mAppMgr.getString(mAppMgr.APP_PROPERTY_CFG_PATH), File.separatorChar, fieldMappingFileName); File mappingFile = new File(fieldMappingPathFileName); if (mappingFile.exists()) { try { mCfgProperties = new PropertiesConfiguration(fieldMappingPathFileName); } catch (ConfigurationException e) { mCfgProperties = null; String msgStr = String.format("%s: %s", fieldMappingPathFileName, e.getMessage()); throw new NSException(msgStr); } } } } mBag = (DataBag) mAppMgr.getProperty(Connector.PROPERTY_SCHEMA_NAME); dstDoc = new Document(aSrcDoc); if (mCfgProperties != null) transform(dstDoc); appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return dstDoc; }
From source file:de.sub.goobi.metadaten.RenderableMetadataGroup.java
/** * Copy constructor, creates a RenderableMetadataGroup initialised with the * data from an existing metadata group, but still able to add any metadata * group that still can be added to the currently selected level of the * document structure hierarchy. Initialises the type to the type of the * copy master and sets the values of the fields to the values of the copy * master, but doesnt bind them to the copy master, so changing the values * late wont arm the master object this copy is derived from. * /* www.j ava 2 s . com*/ * @param master * a metadata group that a copy shall be created of * @param addableTypes * all metadata group types that still can be added to the * logical document hierarchy node currently under edit */ public RenderableMetadataGroup(RenderableMetadataGroup master, Collection<MetadataGroupType> addableTypes) { super(master.labels, null); possibleTypes = new LinkedHashMap<>(Util.hashCapacityFor(addableTypes)); for (MetadataGroupType possibleType : addableTypes) { possibleTypes.put(possibleType.getName(), possibleType); } type = master.type; this.projectName = master.projectName; this.metadataGroup = null; this.container = null; try { createMembers(master.toMetadataGroup(), false); } catch (ConfigurationException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:net.pms.newgui.LanguageSelection.java
public void show() { if (PMS.isHeadless()) { // Can only get here during startup in headless mode, there's no way to trigger it from the GUI LOGGER.info(//from ww w . j a v a 2 s . c o m "No language is configured and the language selection dialog is unavailable in headless mode"); LOGGER.info("Defaulting to OS locale {}", Locale.getDefault().getDisplayName()); PMS.setLocale(Locale.getDefault()); } else { pane = new JOptionPane(buildComponent(), JOptionPane.PLAIN_MESSAGE, JOptionPane.NO_OPTION, null, new JButton[] { applyButton, selectButton }, selectButton); pane.setComponentOrientation(ComponentOrientation.getOrientation(locale)); dialog = pane.createDialog(parentComponent, PMS.NAME); dialog.setModalityType(ModalityType.APPLICATION_MODAL); dialog.setIconImage(LooksFrame.readImageIcon("icon-32.png").getImage()); setStrings(); dialog.pack(); dialog.setLocationRelativeTo(parentComponent); dialog.setVisible(true); dialog.dispose(); if (pane.getValue() == null) { aborted = true; } else if (!((String) pane.getValue()).equals(PMS.getConfiguration().getLanguageRawString())) { if (rebootOnChange) { int response = JOptionPane.showConfirmDialog(parentComponent, String.format(buildString("Dialog.Restart", true), PMS.NAME, PMS.NAME), buildString("Dialog.Confirm"), JOptionPane.YES_NO_CANCEL_OPTION); if (response != JOptionPane.CANCEL_OPTION) { PMS.getConfiguration().setLanguage((String) pane.getValue()); if (response == JOptionPane.YES_OPTION) { try { PMS.getConfiguration().save(); } catch (ConfigurationException e) { LOGGER.error("Error while saving configuration: {}", e.getMessage()); LOGGER.trace("", e); } ProcessUtil.reboot(); } } } else { PMS.getConfiguration().setLanguage((String) pane.getValue()); } } } }
From source file:com.evolveum.midpoint.pwdfilter.opendj.PasswordPusher.java
private void readConfig() throws InitializationException { String configFile = "/opt/midpoint/opendj-pwdpusher.xml"; if (System.getProperty("config") != null) { configFile = System.getProperty("config"); }//w w w .jav a2s. c o m File f = new File(configFile); if (!f.exists() || !f.canRead()) { throw new IllegalArgumentException("Config file " + configFile + " does not exist or is not readable"); } try { XMLConfiguration config = new XMLConfiguration(f); String notifierDN = "cn=" + config.getString("passwordpusher.statusNotifierName") + ",cn=Account Status Notification Handlers"; String ldapURL = config.getString("passwordpusher.ldapServerURL"); boolean ldapSSL = config.getBoolean("passwordpusher.ldapServerSSL"); String ldapUsername = config.getString("passwordpusher.ldapServerUsername"); String ldapPassword = config.getString("passwordpusher.ldapServerPassword"); Hashtable<Object, Object> env = new Hashtable<Object, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, ldapURL + "/cn=config"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, ldapUsername); env.put(Context.SECURITY_CREDENTIALS, ldapPassword); if (ldapSSL) { env.put(Context.SECURITY_PROTOCOL, "ssl"); } try { DirContext context = new InitialDirContext(env); Attributes attr = context.getAttributes(notifierDN); this.endPoint = attr.get("ds-cfg-referrals-url").get(0).toString(); this.username = attr.get("ds-cfg-midpoint-username").get(0).toString(); this.password = attr.get("ds-cfg-midpoint-password").get(0).toString(); this.pwdChangeDirectory = attr.get("ds-cfg-midpoint-passwordcachedir").get(0).toString(); } catch (NamingException ne) { throw new InitializationException( ERR_MIDPOINT_PWDSYNC_READING_CONFIG_FROM_LDAP.get(ne.getMessage()), ne); } } catch (ConfigurationException ce) { throw new InitializationException(ERR_MIDPOINT_PWDSYNC_PARSING_XML_CONFIG.get(ce.getMessage()), ce); } }
From source file:com.nridge.connector.common.con_com.transform.TParentChild.java
/** * Applies a transformation against the source document to produce * the returned destination document.//from w w w .j a v a2 s. c o m * * @param aSrcDoc Source document instance. * @return New destination document instance. * @throws com.nridge.core.base.std.NSException Indicates a data validation error condition. */ @Override public Document process(Document aSrcDoc) throws NSException { DataBag relBag; Document dstDoc; DataField dfParentId; Logger appLogger = mAppMgr.getLogger(this, "process"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); if (aSrcDoc == null) throw new NSException("Source document is null."); if (mCfgProperties == null) { String parentChildFileName = getCfgString("parent_child_file"); if (StringUtils.isNotEmpty(parentChildFileName)) { String parentChildPathFileName = String.format("%s%c%s", mAppMgr.getString(mAppMgr.APP_PROPERTY_CFG_PATH), File.separatorChar, parentChildFileName); File parentChildFile = new File(parentChildPathFileName); if (parentChildFile.exists()) { try { mCfgProperties = new PropertiesConfiguration(); mCfgProperties.setFileName(parentChildPathFileName); mCfgProperties.setIOFactory(new WhitespaceIOFactory()); mCfgProperties.load(); } catch (ConfigurationException e) { mCfgProperties = null; String msgStr = String.format("%s: %s", parentChildPathFileName, e.getMessage()); throw new NSException(msgStr); } } } } // Clone our source document. dstDoc = new Document(aSrcDoc); // Execute the transformation. if (mCfgProperties != null) transform(dstDoc); // Assign our parent ids now. DataBag dstBag = dstDoc.getBag(); DataField dfIsParent = dstBag.getFieldByName("nsd_is_parent"); String nsdId = dstBag.getValueAsString("nsd_id"); if (StringUtils.isNotEmpty(nsdId)) { ArrayList<Relationship> relationshipList = dstDoc.getRelationships(); for (Relationship relationship : relationshipList) { relBag = relationship.getBag(); dfParentId = relBag.getFieldByName("nsd_parent_id"); if (dfParentId == null) { dfParentId = new DataTextField("nsd_parent_id", "NSD Parent Id"); dfParentId.setMultiValueFlag(true); relBag.add(dfParentId); } dfParentId.addValueUnique(nsdId); if (dfIsParent != null) { if (dfIsParent.isValueFalse()) dfIsParent.setValue(true); } } } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return dstDoc; }