static String getJiraHomeValue(InputStream propertiesInputStream) throws ParseException, IOException { Properties applicationProperties = new Properties(); applicationProperties.load(propertiesInputStream); String jiraHome = applicationProperties.getProperty("jira.home"); if (jiraHome == null) { // We didn't find the jira.home property :( throw new ParseException("Unable to find the jira.home property."); } return jiraHome; }
private static void loadApplicationProperties(final Settings settings) throws IOException { final File jiraApplicationProperties = new File(getJiraApplicationProperties()); logInfo("Loading application properties from " + jiraApplicationProperties.getCanonicalPath()); InputStream propertiesInputStream = new FileInputStream(jiraApplicationProperties); try { String jiraHome = getJiraHomeValue(propertiesInputStream); // IF we are on Windoze, then display backslashes instead of forward slashes if (File.separatorChar == '\\') { jiraHome = jiraHome.replace("/", "\\"); } settings.setJiraHome(jiraHome); } catch (ParseException ex) { throw new IOException("Error parsing " + jiraApplicationProperties + ". " + ex.getMessage()); } finally { propertiesInputStream.close(); } }
private static void loadServerXmlSettings(final Settings settings) throws IOException { final Document doc = parseDocument(getServerXmlFile()); try { loadWebServerSettings(doc, settings); } catch (ParseException ex) { throw new IOException("Unable to parse the config file '" + getServerXmlFile() + "'. " + ex.getMessage()); } }
private void handleApplicationUser(final Map<String,String> attributes) throws ParseException { final String id = attributes.get(ID); if (StringUtils.isEmpty(id)) { throw new ParseException("Missing 'id' field for ApplicationUser entry."); } final String userKey = attributes.get(USER_KEY); if (StringUtils.isEmpty(userKey)) { throw new ParseException("Missing userKey from ApplicationUser id = " + id); } final String lowerUserName = attributes.get(LOWER_USER_NAME); if (StringUtils.isEmpty(lowerUserName)) { throw new ParseException("Missing lowerUserName from ApplicationUser id = " + id); } appUserIdToUserKeyMap.put(id, userKey); userNameToUserKeyMap.put(lowerUserName, userKey); }
private static void loadCurrentSettings() { try { settings = SettingsLoader.loadCurrentSettings(); } catch (IOException e) { showErrorDialogAndExit("IO Exception occurred while trying to load settings.\n" + e.getMessage()); } catch (SAXException e) { showErrorDialogAndExit("SAX Exception occurred while trying to load settings.\n" + e.getMessage()); } catch (ParserConfigurationException e) { showErrorDialogAndExit("Parser Configuration Exception occurred while trying to load settings.\n" + e.getMessage()); } catch (ParseException e) { showErrorDialogAndExit("Parse Exception occurred while trying to load settings.\n" + e.getMessage()); } }
protected String removeProtocolPrefix(final String jdbcUrl) throws ParseException { String protocolPrefix = getProtocolPrefix(); if (!jdbcUrl.startsWith(protocolPrefix)) { throw new ParseException("Unable to parse the JDBC URL '" + jdbcUrl + "'. It should start with protocol prefix '" + protocolPrefix + "'."); } // Strip off the protocol prefix return jdbcUrl.substring(protocolPrefix.length()); }
public void setSettings(Settings settings) { this.settings = settings; selectedDatabaseType = settings.initDatabaseType(false); try { getSelectedDatabaseConfig().setSettings(settings); } catch (ParseException e) { console.printErrorMessage("Unable to fully parse the current JDBC settings. Some settings may be blank."); console.printErrorMessage("Parse Exception: " + e.getMessage()); } }
public void handleEntity(final String entityName, final Map<String, String> attributes) throws ParseException { // Check if the incoming entity is one of the ones we are interested in. if (entityTypeName.equals(entityName)) { final String id = (String) attributes.get("id"); final String name = (String) attributes.get("name"); if (StringUtils.isBlank(id)) { throw new ParseException("Encountered an entity of type '" + entityTypeName + "' with a missing ID."); } if (StringUtils.isBlank(name)) { throw new ParseException("The name of " + entityTypeName + " '" + id + "' is missing."); } mapperEntityRegister.registerOldValue(id, name); } }
public String getUrl() throws ValidationException { try { return databaseType.getJdbcUrlParser().getUrl(cfHostname.getValue(), cfPort.getValue(), cfInstance.getValue()); } catch (ParseException e) { throw new ValidationException(e.getMessage()); } }
private <T> T verifyRequiredAttribute(final Map<String, String> attributes, final String key, Function<String, T> transform) throws ParseException { String id = attributes.get(EntityProperty.ID); id = id == null ? "" : " '" + id + "'"; if (!attributes.containsKey(key)) { throw new ParseException("The " + key + " of " + EntityProperty.ENTITY_NAME + id + " is missing "); } try { return transform.get(attributes.get(key)); } catch (NumberFormatException e) { throw new ParseException("The " + key + " of " + EntityProperty.ENTITY_NAME + id + " has invalid value " + attributes.get(key)); } catch (IllegalArgumentException e) { throw new ParseException("The " + key + " of " + EntityProperty.ENTITY_NAME + id + " has invalid value " + attributes.get(key)); } } }
@Override public String getUrl(String jiraHome) throws ValidationException { try { return databaseType.getJdbcUrlParser().getUrl(getHostname(), getPort(), getInstance()); } catch (ParseException e) { throw new ValidationException(e.getMessage()); } }
public void handleEntity(final String entityName, final Map<String, String> attributes) throws ParseException { // Check if the incoming entity is one of the ones we are interested in. if (ISSUETYPE_ENTITY_NAME.equals(entityName)) { final String id = (String) attributes.get("id"); final String name = (String) attributes.get("name"); final String style = (String) attributes.get("style"); if (StringUtils.isBlank(id)) { throw new ParseException("Encountered an entity of type '" + ISSUETYPE_ENTITY_NAME + "' with a missing ID."); } if (StringUtils.isBlank(name)) { throw new ParseException("The name of " + ISSUETYPE_ENTITY_NAME + " '" + id + "' is missing."); } // Keep track if our issue type is a subtask or not issueTypeMapper.registerOldValue(id, name, JIRA_SUBTASK.equals(style)); } }
private static void startGui() { ConfiguratorFrame configuratorFrame = new ConfiguratorFrame(); // Appear in the middle of the screen configuratorFrame.setLocationRelativeTo(null); // "Configurator" is the nickname, but the official name from the Documentation Team is "JIRA Configuration Tool" configuratorFrame.setTitle("JIRA Configuration Tool"); try { configuratorFrame.setSettings(settings); } catch (ParseException e) { showWarningDialog("Unable to fully parse the current JDBC settings. Some settings may be blank.\n" + e.getMessage()); } configuratorFrame.setVisible(true); }
public ExternalCustomField parseCustomField(final Map attributes) throws ParseException { if (attributes == null) { throw new IllegalArgumentException("The 'attributes' parameter cannot be null."); } // <CustomField id="10001" customfieldtypekey="com.atlassian.jira.plugin.system.customfieldtypes:textarea" // customfieldsearcherkey="com.atlassian.jira.plugin.system.customfieldtypes:textsearcher" name="text cf"/> final String id = (String) attributes.get("id"); final String name = (String) attributes.get("name"); final String customfieldtypekey = (String) attributes.get("customfieldtypekey"); // Validate the data if (StringUtils.isEmpty(id)) { throw new ParseException("No 'id' field for CustomField."); } if (StringUtils.isEmpty(name)) { throw new ParseException("No 'name' field for CustomField " + id + "."); } if (StringUtils.isEmpty(customfieldtypekey)) { throw new ParseException("No 'customfieldtypekey' field for CustomField " + id + "."); } return new ExternalCustomField(id, name, customfieldtypekey); }
public BackupOverviewBuilderImpl.FieldConfigSchemeIssueType parseFieldConfigSchemeIssueType(final Map attributes) throws ParseException { if (attributes == null) { throw new IllegalArgumentException("The 'attributes' parameter cannot be null."); } // <FieldConfigSchemeIssueType id="10012" issuetype="1" fieldconfigscheme="10011" fieldconfiguration="10011"/> final String id = (String) attributes.get("id"); if (StringUtils.isEmpty(id)) { throw new ParseException("No 'id' field for FieldConfigSchemeIssueType."); } final String fieldconfigscheme = (String) attributes.get("fieldconfigscheme"); if (StringUtils.isEmpty(fieldconfigscheme)) { throw new ParseException("No 'fieldconfigscheme' field for FieldConfigSchemeIssueType."); } // Issue type can be null and this represents a configuration for all issue types final String issuetype = (String) attributes.get("issuetype"); return new BackupOverviewBuilderImpl.FieldConfigSchemeIssueType(fieldconfigscheme, issuetype); } }
private static Node getOnlyChildNode(final Node parentNode, final String tagName) throws ParseException { List<Node> childNodes = getChildNodes(parentNode, tagName); if (childNodes.size() == 1) { return childNodes.get(0); } else if (childNodes.size() == 0) { return null; } else { throw new ParseException("Expected to find one child <" + tagName + "> in <" + parentNode.getNodeName() + "> but found " + childNodes.size()); } }
throw new ParseException("No 'id' field for ProjectRoleActor."); throw new ParseException("No 'projectroleid' field for ProjectRoleActor " + id + "."); throw new ParseException("No 'roletypeparameter' field for ProjectRoleActor " + id + "."); throw new ParseException("No 'roletype' field for ProjectRoleActor " + id + ".");
throw new ParseException("No 'sourceNodeId' field for NodeAssocation."); throw new ParseException("No 'sourceNodeEntity' field for NodeAssocation."); throw new ParseException("No 'sinkNodeId' field for NodeAssocation."); throw new ParseException("No 'sinkNodeEntity' field for NodeAssocation."); throw new ParseException("No 'associationType' field for NodeAssocation.");
public ExternalAttachment parse(final Map<String, String> attributes) throws ParseException { notNull("attributes", attributes); //<FileAttachment id="10000" issue="10000" mimetype="application/octet-stream" filename="clover.license" created="2008-01-08 12:17:39.544" filesize="7535" author="admin"/> final String id = attributes.get(ID); final String issueId = attributes.get(ISSUE); final String fileName = attributes.get(FILENAME); final String created = attributes.get(CREATED); final String author = attributes.get(AUTHOR); //Validate the values if (StringUtils.isEmpty(id)) { throw new ParseException("A file attachment must have an id specified."); } if (StringUtils.isEmpty(issueId)) { throw new ParseException("A file attachment with id '" + id + "' must have an issue id specified."); } // JRA-15914 Some backups have an empty file name. if (fileName == null) { throw new ParseException("A file attachment with id '" + id + "' must have a file name specified."); } if (StringUtils.isEmpty(created)) { throw new ParseException("A file attachment with id '" + id + "' must have a create date specified."); } final Date createdDate = java.sql.Timestamp.valueOf(created); return new ExternalAttachment(id, issueId, fileName, createdDate, author); }
public ExternalChangeItem parse(final Map attributes) throws ParseException { Null.not("attributes", attributes); //<ChangeItem id="10014" group="10006" fieldtype="jira" field="security" oldvalue="10000" oldstring="level1" newvalue="10001" newstring="level2"/> final String id = (String) attributes.get(ID); final String changeGroupId = (String) attributes.get(GROUP); final String fieldType = (String) attributes.get(FIELD_TYPE); final String field = (String) attributes.get(FIELD); final String oldvalue = (String) attributes.get(OLD_VALUE); final String oldstring = (String) attributes.get(OLD_STRING); final String newvalue = (String) attributes.get(NEW_VALUE); final String newstring = (String) attributes.get(NEW_STRING); if (StringUtils.isEmpty(id)) { throw new ParseException("A change item must have an id specified."); } if (StringUtils.isEmpty(changeGroupId)) { throw new ParseException("Change item '" + id + "' is missing the change group id."); } if (StringUtils.isEmpty(field)) { throw new ParseException("Change item '" + id + "' is missing the 'field' attribute."); } return new ExternalChangeItem(id, changeGroupId, fieldType, field, oldvalue, oldstring, newvalue, newstring); }