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 91249 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 - 3
202626.txt (text/plain), 5.65 KB, created by
Joel Cayne
on 2008-02-29 16:14:36 EST
(
hide
)
Description:
CreateUpgrade class - 3
Filename:
MIME Type:
Creator:
Joel Cayne
Created:
2008-02-29 16:14:36 EST
Size:
5.65 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,147 @@ >+/********************************************************************** >+ 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 >+ **********************************************************************/ >+package org.eclipse.tptp.platform.agentcontroller.config; >+ >+import java.io.File; >+import java.io.FileOutputStream; >+import java.io.IOException; >+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.ConfigUtility; >+import org.eclipse.tptp.platform.agentcontroller.config.Constants; >+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: <br> >+ * ConfigUpgrade upgrade = ConfigUpgrade.getInstance("<AC HOME>\\config\\serviceconfig.xml"); <br> >+ * upgrade.parseDocument(); >+ * >+ * @author Joel Cayne >+ * @version February 29, 2008 >+ * @since February 29, 2008 >+ * >+ */ >+public class ConfigUpgrade { >+ >+ protected ConfigFile configFile; >+ protected Document doc; >+ protected Properties properties; >+ >+ private static ConfigUpgrade instance = null; >+ >+ /** >+ * The method called to acquire a reference of the singleton ConfigUpgrade. >+ * @param filename The path to the serviceconfig.xml to retrieve an existing configuration from. >+ * @return An instance of ConfigUpgrade. >+ */ >+ public static ConfigUpgrade getInstance(String filename) { >+ if(instance == null) { >+ instance = new ConfigUpgrade(filename); >+ } >+ return instance; >+ } >+ >+ /** >+ * Provides for upgrading an existing Agent Controller installation. >+ * @param filename The path to the serviceconfig.xml to retrieve an existing configuration from. >+ */ >+ private ConfigUpgrade(String filename) { >+ try { >+ doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(filename)); >+ configFile = new ConfigFile(filename); >+ properties = 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. >+ * @return The properties hash with the user entered values. >+ */ >+ public Properties parseDocument() { >+ properties.put(Constants.JAVA_PATH, configFile.getValue(Constants.JAVA_PATH)); >+ addElement(SecurityEnabled.TAG); >+ addElement(UserDefinition.TAG); >+ addElement(Allow.TAG, ConfigUtility.getString("Config.Allow.Host.Tag")); >+ return properties; >+ } >+ >+ /** >+ * Searches for the tag in the serviceconfig.xml and adds it to the properties hash. >+ * @param tag The tag to search for. >+ */ >+ protected void addElement(String tag) { >+ addElement(tag, null); >+ } >+ >+ /** >+ * Searches for the tag containing the id attribute in serviceconfig.xml and adds it to the properties hash. >+ * @param tag The tag to search for. >+ * @param id The id attribute to search for in the tag. >+ */ >+ protected void addElement(String tag, String id) { >+ NodeList nl = doc.getElementsByTagName(tag); >+ if(nl != null) { >+ /* Traverse the nodes with the tag name adding them to the properties hash */ >+ for(int i = 0; i < nl.getLength(); i++) { >+ Node n = nl.item(i); >+ String text = null; >+ /* Obtain the attribute value and add it to the properties hash */ >+ if(id != null) { >+ n = n.getAttributes().getNamedItem(id); >+ if(n != null) { >+ text = n.getTextContent(); >+ /* The tag exists in the properties hash */ >+ if (properties.containsKey(tag)) { >+ text = (String) properties.get(tag) + "," + text; >+ } >+ } >+ } else { >+ /* Obtain a unique tag value and add it to the properties hash */ >+ text = n.getTextContent(); >+ } >+ if(text != null) { >+ properties.put(tag, text); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Outputs the user entered values to a property file and provides a properties hash table containing the user entered values. >+ * @param filename The name of the property file to store the user entered values to. >+ */ >+ public void getPropertyFile(File filename) { >+ try { >+ if(filename != null) { >+ properties.store(new FileOutputStream(filename), null); >+ } >+ } 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