Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 90359 Details for
Bug 202626
TPTP needs to provide upgrade functionality
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
CreateUpgrade class
202626.txt (text/plain), 5.43 KB, created by
Joel Cayne
on 2008-02-21 10:39:55 EST
(
hide
)
Description:
CreateUpgrade class
Filename:
MIME Type:
Creator:
Joel Cayne
Created:
2008-02-21 10:39:55 EST
Size:
5.43 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.agentcontroller >Index: src-config/org/eclipse/tptp/platform/agentcontroller/config/ConfigUpgrade.java >=================================================================== >RCS file: src-config/org/eclipse/tptp/platform/agentcontroller/config/ConfigUpgrade.java >diff -N src-config/org/eclipse/tptp/platform/agentcontroller/config/ConfigUpgrade.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-config/org/eclipse/tptp/platform/agentcontroller/config/ConfigUpgrade.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,150 @@ >+package org.eclipse.tptp.platform.agentcontroller.config; >+/********************************************************************** >+ Copyright (c) 2008 IBM Corporation and others. >+ All rights reserved. This program and the accompanying materials >+ are made available under the terms of the Eclipse Public License v1.0 >+ which accompanies this distribution, and is available at >+ http://www.eclipse.org/legal/epl-v10.html >+ $Id: $ >+ >+ Contributors: >+ IBM Rational - initial implementation >+ **********************************************************************/ >+ >+import java.io.File; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.util.Hashtable; >+import java.util.Properties; >+import javax.xml.parsers.DocumentBuilderFactory; >+import javax.xml.parsers.ParserConfigurationException; >+ >+import org.eclipse.tptp.platform.agentcontroller.config.Allow; >+import org.eclipse.tptp.platform.agentcontroller.config.ConfigFile; >+import org.eclipse.tptp.platform.agentcontroller.config.Logger; >+import org.eclipse.tptp.platform.agentcontroller.config.SecurityEnabled; >+import org.eclipse.tptp.platform.agentcontroller.config.UserDefinition; >+import org.w3c.dom.Document; >+import org.w3c.dom.Node; >+import org.w3c.dom.NodeList; >+import org.xml.sax.SAXException; >+ >+/* >+ * Sample usage: >+ * ConfigUpgrade upgrade = new ConfigUpgrade("<AC HOME>\\config\\serviceconfig.xml"); >+ * upgrade.parseDocument(); >+ */ >+public class ConfigUpgrade { >+ >+ protected ConfigFile configFile; >+ protected Document doc; >+ protected static String JAVA_PATH = new String("JAVA_PATH"); //$NON-NLS-1$ >+ protected Properties hash; >+ >+ /** >+ * Provides for upgrading an existing Agent Controller installation. >+ * @param filename The path to the serviceconfig.xml to retrieve an existing configuration from. >+ */ >+ public ConfigUpgrade(String filename) { >+ try { >+ doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(filename)); >+ configFile = new ConfigFile(filename); >+ hash = new Properties(); >+ } catch (SAXException e) { >+ Logger.err(e.getMessage()); >+ } catch (IOException e) { >+ Logger.err(e.getMessage()); >+ } catch (ParserConfigurationException e) { >+ Logger.err(e.getMessage()); >+ } >+ } >+ >+ /** >+ * Parses the serviceconfig.xml and obtains the user provided values. >+ */ >+ public void parseDocument() { >+ hash.put(JAVA_PATH, configFile.getValue(JAVA_PATH)); >+ if (doc.hasChildNodes()) { >+ traverseNode(doc.getChildNodes()); >+ } >+ } >+ >+ /** >+ * Traverses a set of nodes to determine their values. >+ * @param nl A list of nodes in the serviceconfig.xml. >+ */ >+ protected void traverseNode(NodeList nl) { >+ for (int i = 0; i < nl.getLength(); i++) { >+ Node n = nl.item(i); >+ /* Handled nodes contain the desired information, so there is no need to check its child nodes */ >+ if(!handleNode(n)) { >+ traverseNode(n.getChildNodes()); >+ } >+ } >+ } >+ >+ /** >+ * Determines which nodes are of value from the serviceconfig.xml for storing. >+ * @param n The node to check. >+ * @return true if the node was handled, false otherwise. >+ */ >+ protected boolean handleNode(Node n) { >+ /* The security enabled tag */ >+ if (n.getNodeName().equals(SecurityEnabled.TAG)) { >+ hash.put(SecurityEnabled.TAG, n.getTextContent()); >+ return true; >+ } >+ /* The users allowed to access the Agent Controller tag */ >+ else if (n.getNodeName().equals(UserDefinition.TAG)) { >+ hash.put(UserDefinition.TAG, n.getTextContent()); >+ return true; >+ } >+ /* The hosts tag containing hosts indicating machines allowed network access */ >+ else if (n.getNodeName().equals(Allow.TAG)) { >+ String host = (String) hash.get(Allow.TAG); >+ /* No hosts exist in the hash table */ >+ if (host == null) { >+ hash.put(Allow.TAG, n.getAttributes().getNamedItem("host").getTextContent()); //$NON-NLS-1$ >+ } >+ /* Add to the existing list of hosts */ >+ else { >+ host = host + "," + n.getAttributes().getNamedItem("host").getTextContent(); //$NON-NLS-1$ >+ hash.put(Allow.TAG, host); >+ } >+ return true; >+ } >+ else { >+ /* The tag was not handled */ >+ return false; >+ } >+ } >+ >+ /** >+ * >+ * @return An instance of the serviceconfig.xml Document. >+ */ >+ public Document getDoc() { >+ return doc; >+ } >+ >+ /** >+ * Provides a hash table containing the user entered values. >+ * @return A hash with the user entered values. >+ */ >+ public Hashtable getHash() { >+ return hash; >+ } >+ >+ /** >+ * Outputs the user entered values to a property file. >+ * @param filename The name of the property file to store the user entered values to. >+ */ >+ public void getPropertyFile(File filename) { >+ try { >+ hash.store(new FileOutputStream(filename), "Agent Controller Configuration"); >+ } catch (IOException e) { >+ Logger.err(e.getMessage()); >+ } >+ >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 202626
:
90359
|
90748
|
91249
|
91372