Java Code Examples for org.jdom.Element#getChild()

The following examples show how to use org.jdom.Element#getChild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FrontEndTool.java    From ghidra with Apache License 2.0 7 votes vote down vote up
/**
 * Refresh the plugins in the Ghidra Project Window based on what is
 * contained in the given XML Element.
 * 
 * @param tc object that contains an entry for each plugin and its
 *            configuration state
 */
private void refresh(ToolTemplate tc) {
	listeners = WeakDataStructureFactory.createCopyOnWriteWeakSet();
	List<Plugin> list = getManagedPlugins();
	list.remove(plugin);
	Plugin[] plugins = new Plugin[list.size()];
	plugins = list.toArray(plugins);
	removePlugins(plugins);

	Element root = tc.saveToXml();
	Element elem = root.getChild("TOOL");

	restoreOptionsFromXml(elem);
	try {
		restorePluginsFromXml(elem);
	}
	catch (PluginException e) {
		Msg.showError(this, getToolFrame(), "Error Restoring Front-end Plugins", e.getMessage(),
			e);
	}
	winMgr.restoreFromXML(tc.getToolElement());

	setConfigChanged(false);
}
 
Example 2
Source File: ReplRunConfiguration.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Override
public void readExternal(@NotNull Element element) throws InvalidDataException {
    super.readExternal(element);
    Element node = element.getChild("sdk");
    if (node != null) {
        String sdkName = node.getAttributeValue("name");
        if (!sdkName.isEmpty()) {
            ProjectSdksModel model = new ProjectSdksModel();
            model.reset(getProject());
            for (Sdk sdk : model.getSdks()) {
                if (sdkName.equals(sdk.getName())) {
                    m_sdk = sdk;
                    break;
                }
            }
        }
        m_cygwinEnabled = Boolean.parseBoolean(node.getAttributeValue("cygwin"));
        m_cygwinPath = node.getAttributeValue("cygwinPath");
    }
}
 
Example 3
Source File: TraceEntry.java    From microrts with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructs the TraceEntry from a XML element and a UnitTypeTable
 *
 * @param e
 * @param utt
 */
public TraceEntry(Element e, UnitTypeTable utt) throws Exception {
    Element actions_e = e.getChild("actions");
    time = Integer.parseInt(e.getAttributeValue("time"));

    Element pgs_e = e.getChild(PhysicalGameState.class.getName());
    pgs = PhysicalGameState.fromXML(pgs_e, utt);

    for (Object o : actions_e.getChildren()) {
        Element action_e = (Element) o;
        long ID = Long.parseLong(action_e.getAttributeValue("unitID"));
        UnitAction a = new UnitAction(action_e.getChild("UnitAction"), utt);
        Unit u = pgs.getUnit(ID);
        if (u == null) {
            System.err.println("Undefined unit ID " + ID + " in action " + a + " at time " + time);
        }
        actions.add(new Pair<>(u, a));
    }
}
 
Example 4
Source File: WebLinkParser.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void 
parseContent(DefaultHandler the_handler,
             CartridgeLoader the_cartridge, 
             Element the_resource,
             boolean isProtected) throws ParseException {
  try {
    //ok, so we're looking at a web link here...
    Element link = getXML(the_cartridge, ((Element)the_resource.getChildren(FILE, the_handler.getNs().cc_ns()).get(0)).getAttributeValue(HREF));
    Namespace linkNs = the_handler.getNs().link_ns();
    Element urlElement = link.getChild(URL, linkNs);
    
    the_handler.startWebLink(link.getChildText(TITLE, linkNs),
                             urlElement.getAttributeValue(HREF),
                             urlElement.getAttributeValue(TARGET),
                             urlElement.getAttributeValue(WINDOW_FEATURES),
                             isProtected);
    the_handler.setWebLinkXml(link);                         
    the_handler.endWebLink();
  } catch (IOException e) {
    throw new ParseException(e);
  }
}
 
Example 5
Source File: DAOLunaticConfiguration.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
private IPartialOrder loadPartialOrder(Element partialOrderElement, String fileScenario) throws it.unibas.lunatic.exceptions.DAOException {
        if (partialOrderElement == null || partialOrderElement.getChildren().isEmpty()) {
            return new StandardPartialOrder();
        }
        Element typeElement = partialOrderElement.getChild("type");
        if (typeElement == null) {
            throw new it.unibas.lunatic.exceptions.DAOException("Unable to load scenario from file " + fileScenario + ". Missing tag <type>");
        }
        String partialOrderType = typeElement.getValue();
        if (PARTIAL_ORDER_STANDARD.equals(partialOrderType)) {
            return new StandardPartialOrder();
        }
        if (PARTIAL_ORDER_FREQUENCY.equals(partialOrderType)) {
            return new FrequencyPartialOrder();
        }
        if (PARTIAL_ORDER_GREEDY.equals(partialOrderType)) {
            return new GreedyPartialOrder();
        }
//        if (PARTIAL_ORDER_FREQUENCY_FO.equals(partialOrderType)) {
//            return new FrequencyPartialOrderFO();
//        }
        throw new it.unibas.lunatic.exceptions.DAOException("Unable to load scenario from file " + fileScenario + ". Unknown partial-order type " + partialOrderType);
    }
 
Example 6
Source File: ComponentInstallationReport.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected ComponentInstallationReport(Element element) {
	String componentCode = element.getAttributeValue(SystemInstallationReport.CODE_ATTRIBUTE);
	this.setComponentCode(componentCode);
	String dateString = element.getAttributeValue(SystemInstallationReport.DATE_ATTRIBUTE);
	Date date = DateConverter.parseDate(dateString, SystemInstallationReport.DATE_FORMAT);
	this.setDate(date);
	Element schemaElement = element.getChild(SystemInstallationReport.SCHEMA_ELEMENT);
	if (null != schemaElement) {
		this.setDataSourceReport(new DataSourceInstallationReport(schemaElement));
	}
	Element dataElement = element.getChild(SystemInstallationReport.DATA_ELEMENT);
	if (null != dataElement) {
		this.setDataReport(new DataInstallationReport(dataElement));
	}
	Element postProcessElement = element.getChild(SystemInstallationReport.COMPONENT_POST_PROCESS_ELEMENT);
	if (null != postProcessElement) {
		String postProcessStatusString = postProcessElement.getAttributeValue(SystemInstallationReport.STATUS_ATTRIBUTE);
		if (null != postProcessStatusString) {
			SystemInstallationReport.Status postProcessStatus =
					Enum.valueOf(SystemInstallationReport.Status.class, postProcessStatusString.toUpperCase());
			this.setPostProcessStatus(postProcessStatus);
		}
	}
}
 
Example 7
Source File: OWSCommands.java    From geoserver-shell with MIT License 5 votes vote down vote up
@CliCommand(value = "ows wms list", help = "List OWS WMS Settings.")
public String wmsList(
        @CliOption(key = "workspace", mandatory = false, help = "The workspace") String workspace
) throws Exception {
    String url = geoserver.getUrl() + "/rest/services/wms/" + (workspace != null ? "workspaces/" + URLUtil.encode(workspace) + "/" : "") + "settings.xml";
    String xml = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword());
    StringBuilder builder = new StringBuilder();
    if (xml != null) {
        Element element = JDOMBuilder.buildElement(xml);
        String TAB = "   ";
        builder.append(element.getChildText("name")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Enabled: ").append(element.getChildText("enabled")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Cite Compliant: ").append(element.getChildText("citeCompliant")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Schema Base URL: ").append(element.getChildText("schemaBaseURL")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Verbose: ").append(element.getChildText("verbose")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Interpolation: ").append(element.getChildText("interpolation")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Max Buffer: ").append(element.getChildText("maxBuffer")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Max Request Memory: ").append(element.getChildText("maxRequestMemory")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Max Rendering Time: ").append(element.getChildText("maxRenderingTime")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Max Rendering Errors: ").append(element.getChildText("maxRenderingErrors")).append(OsUtils.LINE_SEPARATOR);
        Element waterMarkElement = element.getChild("watermark");
        builder.append(TAB).append("Watermark:").append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append(TAB).append("Enabled: ").append(waterMarkElement.getChildText("enabled")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append(TAB).append("Position: ").append(waterMarkElement.getChildText("position")).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append(TAB).append("Transparency: ").append(waterMarkElement.getChildText("transparency")).append(OsUtils.LINE_SEPARATOR);
        Element vElement = element.getChild("versions");
        if (vElement != null) {
            List<Element> versionElements = vElement.getChildren("org.geotools.util.Version");
            builder.append(TAB).append("Versions:").append(OsUtils.LINE_SEPARATOR);
            for (Element versionElement : versionElements) {
                builder.append(TAB).append(TAB).append(versionElement.getChildText("version")).append(OsUtils.LINE_SEPARATOR);
            }
        }
    }

    return builder.toString();
}
 
Example 8
Source File: PrintHandler.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void setManifestMetadataXml(Element the_md) {
    if (log.isDebugEnabled())
 log.debug("manifest md xml: "+the_md);    
    // NOTE: need to handle languages
    if (the_md != null) {
    Element general = the_md.getChild(GENERAL, ns.getLom());
    if (general != null) {
 Element tnode = general.getChild(TITLE, ns.getLom());
 if (tnode != null) {
  	  title = tnode.getChildTextTrim(LANGSTRING, ns.getLom());
     if (title == null || title.equals(""))
   	  title = tnode.getChildTextTrim(STRING, ns.getLom());
 }
 Element tdescription=general.getChild(DESCRIPTION, ns.getLom());
 if (tdescription != null) {
     description = tdescription.getChildTextTrim(STRING, ns.getLom());
 }

    }
    }
    if (title == null || title.equals(""))
 title = "Cartridge";
    if ("".equals(description))
 description = null;
    ContentCollection baseCollection = makeBaseFolder(title);
    baseName = baseCollection.getId();
    baseUrl = baseCollection.getUrl();
    // kill the hostname part. We want to use relative URLs
    int relPart = baseUrl.indexOf("/access/");
    if (relPart >= 0)
 baseUrl = baseUrl.substring(relPart);
    //Start a folder to hold the entire sites content rather than create new top level pages
    boolean singlePage = ServerConfigurationService.getBoolean("lessonbuilder.cc.import.singlepage", false);
    if (singlePage == true)
  	  startCCFolder(null);

}
 
Example 9
Source File: InspectionProfileImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(@Nonnull Element element) throws InvalidDataException {
  super.readExternal(element);

  if (!ApplicationManager.getApplication().isUnitTestMode() || myBaseProfile == null) {
    // todo remove this strange side effect
    myBaseProfile = getDefaultProfile();
  }
  final String version = element.getAttributeValue(VERSION_TAG);
  if (version == null || !version.equals(VALID_VERSION)) {
    element = InspectionProfileConvertor.convertToNewFormat(element, this);
  }

  final Element highlightElement = element.getChild(USED_LEVELS);
  if (highlightElement != null) {
    // from old profiles
    ((SeverityProvider)getProfileManager()).getOwnSeverityRegistrar().readExternal(highlightElement);
  }

  StringInterner interner = new StringInterner();
  for (Element toolElement : element.getChildren(INSPECTION_TOOL_TAG)) {
    // make clone to avoid retaining memory via o.parent pointers
    toolElement = toolElement.clone();
    JDOMUtil.internStringsInElement(toolElement, interner);
    myUninstalledInspectionsSettings.put(toolElement.getAttributeValue(CLASS_TAG), toolElement);
  }
}
 
Example 10
Source File: SAT.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private byte[] calcDigest(SoapConverter sc){
	try {
		MessageDigest digest = MessageDigest.getInstance("SHA-1");
		Document doc = sc.getXML();
		Element eRoot = doc.getRootElement();
		Element body = eRoot.getChild("Body", SoapConverter.ns);
		addParameters(body, digest);
		return digest.digest();
	} catch (NoSuchAlgorithmException e) {
		ExHandler.handle(e);
	}
	return null;
}
 
Example 11
Source File: AbstractParser.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void
processResourceMetadata(DefaultHandler the_handler,
                        Element the_resource) throws ParseException {
    Element md = the_resource.getChild(METADATA, the_handler.getNs().getNs());
    if (md != null) {
the_handler.checkCurriculum(md);
md=the_resource.getChild(METADATA, the_handler.getNs().getNs()).getChild(MD_ROOT, the_handler.getNs().lom_ns());
if (md!=null) {    
    the_handler.setResourceMetadataXml(md);
}
    }
}
 
Example 12
Source File: Trace.java    From microrts with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs the Trace from a XML element, overriding the UnitTypeTable of
 * that element with one provided
 *
 * @param e
 * @param a_utt
 */
public Trace(Element e, UnitTypeTable a_utt) throws Exception {
    utt = a_utt;
    Element entries_e = e.getChild("entries");

    for (Object o : entries_e.getChildren()) {
        Element entry_e = (Element) o;
        entries.add(new TraceEntry(entry_e, utt));
    }
}
 
Example 13
Source File: ScormPackageHandler.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * A class to actually do the bulk of the work. It creates an xml file representing the organizations, similar to the imsmanifest, but also modelling the sco/asset
 * attributes needed by the runtime system - ie order of sequence, launch URL...
 * 
 * @throws NoItemFoundException
 */
public void buildSettings() throws NoItemFoundException {
    // get the root element of the manifest
    // NOTE: CLONE IT first- must work on a copy of the original JDOM doc.
    final Element manifestRoot = (Element) getDocument().getRootElement().clone();
    _sequencerModel.setManifestModifiedDate(super.getFile().lastModified());
    // now get the organizations node
    final Element orgs = manifestRoot.getChild(CP_Core.ORGANIZATIONS, manifestRoot.getNamespace());
    // get the identifier for the default organization
    final Element defaultOrgNode = getDefaultOrganization(orgs);
    if (defaultOrgNode != null) {
        // and store the default identifier
        final String defaultOrgIdentifier = defaultOrgNode.getAttributeValue(CP_Core.IDENTIFIER);
        // set the default organization
        _sequencerModel.setDefaultOrg(defaultOrgIdentifier);
        iterateThruManifest(manifestRoot);
    } else {
        _sequencerModel.setDefaultOrg("");
    }
    try {
        _sequencerModel.saveDocument(true);
    } catch (final IOException ex) {
        throw new OLATRuntimeException(this.getClass(), "Could not save package status.", ex);
    }
    // throw an exception if no items were found in the manifest
    if (!_hasItemsToPlay) {
        throw new NoItemFoundException(NoItemFoundException.NO_ITEM_FOUND_MSG);
    }
}
 
Example 14
Source File: UserRegConfigDOM.java    From entando-components with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void extractTokenValidityConfig(Element root, IUserRegConfig config) {
	Element tokenElem = root.getChild(TOKEN_VALIDITY);
	config.setTokenValidityMinutes(Long.parseLong(tokenElem.getAttributeValue(TOKEN_VALIDITY_MINUTES_ATTR)));
}
 
Example 15
Source File: GeoWebCacheCommands.java    From geoserver-shell with MIT License 4 votes vote down vote up
@CliCommand(value = "gwc layer get", help = "Get a GeoWebCache Layer.")
public String getLayer(
        @CliOption(key = "name", mandatory = true, help = "The layer name") String name
) throws Exception {
    String url = geoserver.getUrl() + "/gwc/rest/layers/" + URLUtil.encode(name) + ".xml";
    String xml = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword());
    StringBuilder builder = new StringBuilder();
    String TAB = "   ";
    Element element = JDOMBuilder.buildElement(xml);
    builder.append(element.getChildText("name")).append(OsUtils.LINE_SEPARATOR);
    builder.append(TAB).append("Enabled: ").append(element.getChildText("enabled")).append(OsUtils.LINE_SEPARATOR);
    builder.append(TAB).append("Gutter: ").append(element.getChildText("gutter")).append(OsUtils.LINE_SEPARATOR);
    builder.append(TAB).append("Auto Cache Styles: ").append(element.getChildText("autoCacheStyles")).append(OsUtils.LINE_SEPARATOR);
    Element mimeFormatsElement = element.getChild("mimeFormats");
    if (mimeFormatsElement != null) {
        List<Element> mimeFormatsElements = mimeFormatsElement.getChildren("string");
        if (mimeFormatsElements.size() > 0) {
            builder.append(TAB).append("Mime Formats:").append(OsUtils.LINE_SEPARATOR);
            for (Element mimeFormatElement : mimeFormatsElements) {
                builder.append(TAB).append(TAB).append(mimeFormatElement.getTextTrim()).append(OsUtils.LINE_SEPARATOR);
            }
        }
    }
    Element gridSubsetsElement = element.getChild("gridSubsets");
    if (gridSubsetsElement != null) {
        List<Element> gridSubsetElements = gridSubsetsElement.getChildren("gridSubset");
        if (gridSubsetElements.size() > 0) {
            builder.append(TAB).append("Grid Subsets:").append(OsUtils.LINE_SEPARATOR);
            for (Element gridSubsetElement : gridSubsetElements) {
                builder.append(TAB).append(TAB).append(gridSubsetElement.getChildText("gridSetName")).append(OsUtils.LINE_SEPARATOR);
            }
        }
    }
    Element metaWidthHeightElement = element.getChild("metaWidthHeight");
    if (metaWidthHeightElement != null) {
        List<Element> metaWidthHeightElements = metaWidthHeightElement.getChildren("int");
        builder.append(TAB).append("Meta Dimensions:").append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append(TAB).append("Width: ").append(metaWidthHeightElements.get(0).getText()).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append(TAB).append("Height: ").append(metaWidthHeightElements.get(1).getText()).append(OsUtils.LINE_SEPARATOR);
    }
    return builder.toString();
}
 
Example 16
Source File: FileTypeManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private FileType loadFileType(@Nonnull Element typeElement, boolean isDefault) {
  String fileTypeName = typeElement.getAttributeValue(ATTRIBUTE_NAME);
  String fileTypeDescr = typeElement.getAttributeValue(ATTRIBUTE_DESCRIPTION);
  String iconPath = typeElement.getAttributeValue("icon");

  String extensionsStr = StringUtil.nullize(typeElement.getAttributeValue("extensions"));
  if (isDefault && extensionsStr != null) {
    // todo support wildcards
    extensionsStr = filterAlreadyRegisteredExtensions(extensionsStr);
  }

  FileType type = isDefault ? getFileTypeByName(fileTypeName) : null;
  if (type != null) {
    return type;
  }

  Element element = typeElement.getChild(AbstractFileType.ELEMENT_HIGHLIGHTING);
  if (element == null) {
    type = new UserBinaryFileType();
  }
  else {
    SyntaxTable table = AbstractFileType.readSyntaxTable(element);
    type = new AbstractFileType(table);
    ((AbstractFileType)type).initSupport();
  }

  setFileTypeAttributes((UserFileType)type, fileTypeName, fileTypeDescr, iconPath);
  registerFileTypeWithoutNotification(type, parse(extensionsStr), isDefault);

  if (isDefault) {
    myDefaultTypes.add(type);
    if (type instanceof ExternalizableFileType) {
      ((ExternalizableFileType)type).markDefaultSettings();
    }
  }
  else {
    Element extensions = typeElement.getChild(AbstractFileType.ELEMENT_EXTENSION_MAP);
    if (extensions != null) {
      for (Pair<FileNameMatcher, String> association : AbstractFileType.readAssociations(extensions)) {
        associate(type, association.getFirst(), false);
      }

      for (RemovedMappingTracker.RemovedMapping removedAssociation : RemovedMappingTracker.readRemovedMappings(extensions)) {
        removeAssociation(type, removedAssociation.getFileNameMatcher(), false);
      }
    }
  }
  return type;
}
 
Example 17
Source File: DataSourceDumpReport.java    From entando-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public DataSourceDumpReport(String xmlText) {
	if (null == xmlText || xmlText.trim().length() == 0) {
		return;
	}
	SAXBuilder builder = new SAXBuilder();
	builder.setValidation(false);
	StringReader reader = new StringReader(xmlText);
	try {
		Document doc = builder.build(reader);
		Element rootElement = doc.getRootElement();
		Element dateElement = rootElement.getChild(DATE_ELEMENT);
		if (null != dateElement) {
			Date date = DateConverter.parseDate(dateElement.getText(), DATE_FORMAT);
			this.setDate(date);
		}
		Element subfolderElement = rootElement.getChild(SUBFOLDER_NAME_ELEMENT);
		if (null != subfolderElement) {
			this.setSubFolderName(subfolderElement.getText());
		}
		
		Element requiredTimeElement = rootElement.getChild(REQUIRED_TIME_ELEMENT);
		if (null != requiredTimeElement) {
			this.setRequiredTime(Long.valueOf(requiredTimeElement.getText()));
		}
		
		Element componentsElement = rootElement.getChild(COMPONENTS_HISTORY_ELEMENT);
		if (null != componentsElement) {
			List<Element> componentElements = componentsElement.getChildren();
			for (int i = 0; i < componentElements.size(); i++) {
				Element componentElement = componentElements.get(i);
				ComponentInstallationReport componentHistory = new ComponentInstallationReport(componentElement);
				this.addComponentHistory(componentHistory);
			}
		}
		List<Element> elements = rootElement.getChildren(DATASOURCE_ELEMENT);
		for (int i = 0; i < elements.size(); i++) {
			Element dataSourceElement = elements.get(i);
			String dataSourceName = dataSourceElement.getAttributeValue(NAME_ATTRIBUTE);
			List<Element> tableElements = dataSourceElement.getChildren();
			for (int j = 0; j < tableElements.size(); j++) {
				Element tableElement = tableElements.get(j);
				TableDumpReport tableDumpReport = new TableDumpReport(tableElement);
				this.addTableReport(dataSourceName, tableDumpReport);
			}
		}
	} catch (Throwable t) {
		_logger.error("Error parsing Report. xml:{} ", xmlText, t);
		throw new RuntimeException("Error detected while parsing the XML", t);
	}
}
 
Example 18
Source File: SlackNotificationMainConfig.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
void readConfigurationFromXmlElement(Element slackNotificationsElement) {
     if(slackNotificationsElement != null){
         content.setEnabled(true);
         if(slackNotificationsElement.getAttribute(ENABLED) != null)
         {
             setEnabled(Boolean.parseBoolean(slackNotificationsElement.getAttributeValue(ENABLED)));
         }
         if(slackNotificationsElement.getAttribute(DEFAULT_CHANNEL) != null)
         {
             setDefaultChannel(slackNotificationsElement.getAttributeValue(DEFAULT_CHANNEL));
         }
         if(slackNotificationsElement.getAttribute(TEAM_NAME) != null)
         {
             setTeamName(slackNotificationsElement.getAttributeValue(TEAM_NAME));
         }
         if(slackNotificationsElement.getAttribute(TOKEN) != null)
         {
             setToken(slackNotificationsElement.getAttributeValue(TOKEN));
         }
         if(slackNotificationsElement.getAttribute(ICON_URL) != null)
         {
             content.setIconUrl(slackNotificationsElement.getAttributeValue(ICON_URL));
         }
         if(slackNotificationsElement.getAttribute(BOT_NAME) != null)
         {
             content.setBotName(slackNotificationsElement.getAttributeValue(BOT_NAME));
         }
         if(slackNotificationsElement.getAttribute(SHOW_BUILD_AGENT) != null)
         {
             content.setShowBuildAgent(Boolean.parseBoolean(slackNotificationsElement.getAttributeValue(SHOW_BUILD_AGENT)));
         }
         if(slackNotificationsElement.getAttribute(SHOW_ELAPSED_BUILD_TIME) != null)
         {
             content.setShowElapsedBuildTime(Boolean.parseBoolean(slackNotificationsElement.getAttributeValue(SHOW_ELAPSED_BUILD_TIME)));
         }
         if(slackNotificationsElement.getAttribute(SHOW_COMMITS) != null)
         {
             content.setShowCommits(Boolean.parseBoolean(slackNotificationsElement.getAttributeValue(SHOW_COMMITS)));
         }
         if(slackNotificationsElement.getAttribute(SHOW_COMMITTERS) != null)
         {
             content.setShowCommitters(Boolean.parseBoolean(slackNotificationsElement.getAttributeValue(SHOW_COMMITTERS)));
         }
         if(slackNotificationsElement.getAttribute(SHOW_TRIGGERED_BY) != null)
         {
             content.setShowTriggeredBy(Boolean.parseBoolean(slackNotificationsElement.getAttributeValue(SHOW_TRIGGERED_BY)));
         }
         if(slackNotificationsElement.getAttribute(MAX_COMMITS_TO_DISPLAY) != null)
         {
             content.setMaxCommitsToDisplay(Integer.parseInt(slackNotificationsElement.getAttributeValue(MAX_COMMITS_TO_DISPLAY)));
         }
         if(slackNotificationsElement.getAttribute(SHOW_FAILURE_REASON) != null)
         {
             content.setShowFailureReason(Boolean.parseBoolean(slackNotificationsElement.getAttributeValue(SHOW_FAILURE_REASON)));
         }
if(slackNotificationsElement.getAttribute(FILTER_BRANCH_NAME) != null)
{
	setFilterBranchName(slackNotificationsElement.getAttributeValue(FILTER_BRANCH_NAME));
}

         Element proxyElement = slackNotificationsElement.getChild(PROXY);
         if(proxyElement != null)
         {
             if (proxyElement.getAttribute("proxyShortNames") != null){
                 setProxyShortNames(Boolean.parseBoolean(proxyElement.getAttributeValue("proxyShortNames")));
             }

             if (proxyElement.getAttribute("host") != null){
                 setProxyHost(proxyElement.getAttributeValue("host"));
             }

             if (proxyElement.getAttribute("port") != null){
                 setProxyPort(Integer.parseInt(proxyElement.getAttributeValue("port")));
             }

             if (proxyElement.getAttribute(USERNAME) != null){
                 setProxyUsername(proxyElement.getAttributeValue(USERNAME));
             }

             if (proxyElement.getAttribute(PASSWORD) != null){
                 setProxyPassword(proxyElement.getAttributeValue(PASSWORD));
             }
         }
         else {
             setProxyHost(null);
             setProxyPort(null);
             setProxyUsername(null);
             setProxyPassword(null);
         }
     }
 }
 
Example 19
Source File: DAOLunaticConfiguration.java    From Llunatic with GNU General Public License v3.0 4 votes vote down vote up
private CostManagerConfiguration loadCostManagerConfiguration(Element costManagerElement, String fileScenario) throws it.unibas.lunatic.exceptions.DAOException {
    if (costManagerElement == null || costManagerElement.getChildren().isEmpty()) {
        return null;
    }
    Element typeElement = costManagerElement.getChild("type");
    if (typeElement == null) {
        throw new it.unibas.lunatic.exceptions.DAOException("Unable to load scenario from file " + fileScenario + ". Missing tag <type>");
    }
    CostManagerConfiguration costManagerConfiguration = new CostManagerConfiguration();
    String costManagerType = typeElement.getValue();
    if (LunaticConstants.COST_MANAGER_STANDARD.equalsIgnoreCase(costManagerType)) {
        costManagerConfiguration.setType(LunaticConstants.COST_MANAGER_STANDARD);
    }
    if (LunaticConstants.COST_MANAGER_GREEDY.equalsIgnoreCase(costManagerType)) {
        costManagerConfiguration.setType(LunaticConstants.COST_MANAGER_GREEDY);
    }
    if (LunaticConstants.COST_MANAGER_SIMILARITY.equalsIgnoreCase(costManagerType)) {
        costManagerConfiguration.setType(LunaticConstants.COST_MANAGER_SIMILARITY);
        Element similarityStrategyElement = costManagerElement.getChild("similarityStrategy");
        if (similarityStrategyElement != null) {
            costManagerConfiguration.getDefaultSimilarityConfiguration().setStrategy(similarityStrategyElement.getValue().trim());
        }
        Element similarityThresholdElement = costManagerElement.getChild("similarityThreshold");
        if (similarityThresholdElement != null) {
            costManagerConfiguration.getDefaultSimilarityConfiguration().setThreshold(Double.parseDouble(similarityThresholdElement.getValue()));
        }
        loadExtraParams(costManagerConfiguration.getDefaultSimilarityConfiguration().getParams(), costManagerElement);
        Element requestMajority = costManagerElement.getChild("requestMajority");
        if (requestMajority != null) {
            costManagerConfiguration.setRequestMajorityInSimilarityCostManager(Boolean.parseBoolean(requestMajority.getValue()));
        }
    }
    if (costManagerConfiguration == null) {
        throw new it.unibas.lunatic.exceptions.DAOException("Unable to load scenario from file " + fileScenario + ". Unknown cost-manager type " + costManagerType);
    }
    Element doBackwardElement = costManagerElement.getChild("doBackward");
    if (doBackwardElement != null) {
        costManagerConfiguration.setDoBackward(Boolean.parseBoolean(doBackwardElement.getValue()));
    }
    Element doPermutationsElement = costManagerElement.getChild("doPermutations");
    if (doPermutationsElement != null) {
        costManagerConfiguration.setDoPermutations(Boolean.parseBoolean(doPermutationsElement.getValue()));
    }
    Element chaseTreeSizeThresholdElement = costManagerElement.getChild("chaseTreeSizeThreshold");
    if (chaseTreeSizeThresholdElement != null) {
        throw new IllegalArgumentException("Replace chase tree size with chaseBranchingThreshold and potentialSolutionsThreshold");
    }
    Element chaseBranchingThresholdElement = costManagerElement.getChild("chaseBranchingThreshold");
    if (chaseBranchingThresholdElement != null) {
        costManagerConfiguration.setChaseBranchingThreshold(Integer.parseInt(chaseBranchingThresholdElement.getValue()));
    }
    Element dependencyLimitElement = costManagerElement.getChild("dependencyLimit");
    if (dependencyLimitElement != null) {
        costManagerConfiguration.setDependencyLimit(Integer.parseInt(dependencyLimitElement.getValue()));
    }
    Element potentialSolutionsThresholdElement = costManagerElement.getChild("potentialSolutionsThreshold");
    if (potentialSolutionsThresholdElement != null) {
        costManagerConfiguration.setPotentialSolutionsThreshold(Integer.parseInt(potentialSolutionsThresholdElement.getValue()));
    }
    for (Object noBackwardEl : costManagerElement.getChildren("noBackwardOnDependency")) {
        Element noBackwardElement = (Element) noBackwardEl;
        costManagerConfiguration.addNoBackwardDependency(noBackwardElement.getValue().trim());
    }
    for (Object similarityAttributeEl : costManagerElement.getChildren("similarityForAttribute")) {
        Element similarityAttributeElement = (Element) similarityAttributeEl;
        String tableName = similarityAttributeElement.getAttribute("tableName").getValue().trim();
        String attributeName = similarityAttributeElement.getAttribute("attributeName").getValue().trim();
        AttributeRef attribute = new AttributeRef(tableName, attributeName);
        String similarityStrategy = similarityAttributeElement.getChild("similarityStrategy").getValue().trim();
        double similarityThreshold = Double.parseDouble(similarityAttributeElement.getChild("similarityThreshold").getValue().trim());
        SimilarityConfiguration similarityConfiguration = new SimilarityConfiguration(similarityStrategy, similarityThreshold);
        costManagerConfiguration.setSimilarityConfigurationForAttribute(attribute, similarityConfiguration);
        loadExtraParams(similarityConfiguration.getParams(), similarityAttributeElement);
    }
    return costManagerConfiguration;
}
 
Example 20
Source File: ConfigParameterUtils.java    From ankush with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Gets the tag content.
 * 
 * @param element
 *            the element
 * @param tagName
 *            the tag name
 * @return the tag content
 */
private static String getTagContent(Element element, String tagName) {
	String content = "";
	Element e = element.getChild(tagName);
	if (e != null) {
		content = e.getValue();
	}
	return content;
}