Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorafinkbein2009-01-14 23:30:57 +0000
committerafinkbein2009-01-14 23:30:57 +0000
commitb6d994e61e19a7b22cfd36fd0a8cc2887e6d9e9e (patch)
tree45fe1fc3fc8343644b817bf80aced75cf3664e23
parent663c97c25d9e264616642cbff8878b456eb0836c (diff)
downloadorg.eclipse.osee-b6d994e61e19a7b22cfd36fd0a8cc2887e6d9e9e.tar.gz
org.eclipse.osee-b6d994e61e19a7b22cfd36fd0a8cc2887e6d9e9e.tar.xz
org.eclipse.osee-b6d994e61e19a7b22cfd36fd0a8cc2887e6d9e9e.zip
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/.classpath7
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/.project28
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/META-INF/MANIFEST.MF21
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/build.properties4
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/Activator.java38
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/ClientInstallInfo.java132
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/ClientInstallInfoServlet.java140
-rw-r--r--org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/InstallLinkPageGenerator.java148
10 files changed, 529 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.client.info.servlet/.classpath b/org.eclipse.osee.framework.client.info.servlet/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.osee.framework.client.info.servlet/.project b/org.eclipse.osee.framework.client.info.servlet/.project
new file mode 100644
index 00000000000..77267dc62a4
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.client.info.servlet</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.osee.framework.client.info.servlet/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.osee.framework.client.info.servlet/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..7ac6bb66ec1
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Thu Oct 09 10:04:50 MST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.osee.framework.client.info.servlet/.settings/org.eclipse.pde.core.prefs b/org.eclipse.osee.framework.client.info.servlet/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 00000000000..e4085f3bf06
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+#Thu Oct 09 10:04:50 MST 2008
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/org.eclipse.osee.framework.client.info.servlet/META-INF/MANIFEST.MF b/org.eclipse.osee.framework.client.info.servlet/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..f6e57de8312
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Client Info Servlet Plug-in
+Bundle-SymbolicName: org.eclipse.osee.framework.client.info.servlet;singleton:=true
+Bundle-Version: 0.4.0.qualifier
+Bundle-Activator: org.eclipse.osee.framework.client.info.servlet.Activator
+Bundle-Vendor: Eclipse.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: javax.servlet;version="2.4.0",
+ javax.servlet.http;version="2.4.0",
+ org.eclipse.osee.framework.db.connection,
+ org.eclipse.osee.framework.db.connection.core,
+ org.eclipse.osee.framework.db.connection.exception,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.jdk.core.util.io.xml,
+ org.eclipse.osee.framework.logging,
+ org.eclipse.osee.framework.core.server,
+ org.osgi.framework;version="1.3.0",
+ org.osgi.service.http;version="1.2.0",
+ org.osgi.util.tracker;version="1.3.3"
+Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.osee.framework.client.info.servlet/build.properties b/org.eclipse.osee.framework.client.info.servlet/build.properties
new file mode 100644
index 00000000000..41eb6ade2b4
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/Activator.java b/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/Activator.java
new file mode 100644
index 00000000000..8e9848f7904
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/Activator.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.client.info.servlet;
+
+import org.eclipse.osee.framework.core.server.OseeHttpServiceTracker;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private OseeHttpServiceTracker httpTracker = null;
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ httpTracker = new OseeHttpServiceTracker(context, "osee/install/info", ClientInstallInfoServlet.class);
+ httpTracker.open();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ httpTracker.close();
+ httpTracker = null;
+ }
+}
diff --git a/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/ClientInstallInfo.java b/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/ClientInstallInfo.java
new file mode 100644
index 00000000000..3dc815691e8
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/ClientInstallInfo.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.client.info.servlet;
+
+import java.io.StringReader;
+import org.eclipse.osee.framework.db.connection.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.AbstractSaxHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * @author Roberto E. Escobar
+ */
+class ClientInstallInfo {
+ private final static String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ private final static String EMPTY_STRING = "";
+
+ private final String name;
+ private String os;
+ private boolean isActive;
+ private String execPath;
+ private String comment;
+
+ private ClientInstallInfo(String name) {
+ this.name = name;
+ this.os = null;
+ this.execPath = EMPTY_STRING;
+ this.isActive = false;
+ this.comment = EMPTY_STRING;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getOs() {
+ return os;
+ }
+
+ public String getExecPath() {
+ return execPath;
+ }
+
+ public boolean isActive() {
+ return this.isActive;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public String toString() {
+ return String.format("name:[%s] os:[%s] isActive:[%s] comment:[%s] location:[%s]", name, os, isActive, comment,
+ execPath);
+ }
+
+ public static ClientInstallInfo createFromXml(String name, String data) throws OseeCoreException {
+ ClientInstallInfo info = new ClientInstallInfo(name);
+ try {
+ if (!data.startsWith(XML_HEADER)) {
+ data = XML_HEADER + data;
+ }
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setContentHandler(new Parser(info));
+ reader.parse(new InputSource(new StringReader(data)));
+ } catch (Exception ex) {
+ throw new OseeCoreException(String.format("Error parsing data for client install: [%s]", name), ex);
+ }
+ return info;
+ }
+
+ private final static class Parser extends AbstractSaxHandler {
+ private ClientInstallInfo info;
+
+ private Parser(ClientInstallInfo info) {
+ this.info = info;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.jdk.core.util.io.xml.AbstractSaxHandler#startElementFound(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ @Override
+ public void startElementFound(String uri, String localName, String name, Attributes attributes) throws SAXException {
+ try {
+ if (localName.equalsIgnoreCase("install")) {
+ info.os = attributes.getValue("os");
+ if (info.os != null) {
+ info.os = info.os.toLowerCase();
+ } else {
+ info.os = EMPTY_STRING;
+ }
+ info.isActive = Boolean.valueOf(attributes.getValue("isActive"));
+ }
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.jdk.core.util.io.xml.AbstractSaxHandler#endElementFound(java.lang.String, java.lang.String, java.lang.String)
+ */
+ @Override
+ public void endElementFound(String uri, String localName, String name) throws SAXException {
+ try {
+ if (localName.equalsIgnoreCase("location")) {
+ info.execPath = getContents();
+ if (info.execPath == null) {
+ info.execPath = EMPTY_STRING;
+ }
+ } else if (localName.equalsIgnoreCase("comment")) {
+ info.comment = getContents();
+ if (info.comment == null) {
+ info.comment = EMPTY_STRING;
+ }
+ }
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+ }
+}
diff --git a/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/ClientInstallInfoServlet.java b/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/ClientInstallInfoServlet.java
new file mode 100644
index 00000000000..55ae541f218
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/ClientInstallInfoServlet.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.client.info.servlet;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.eclipse.osee.framework.core.server.OseeHttpServlet;
+import org.eclipse.osee.framework.db.connection.ConnectionHandlerStatement;
+import org.eclipse.osee.framework.db.connection.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * Sends a page with links to OSEE client install locations.
+ * <p>
+ * Client Install information are entries in the OSEE Info Table:
+ * <ul>
+ * <li><b>osee_key:</b> uniquely identifies this install record <br/><b>NOTE:</b> must with prefixed with
+ * "<b><i>osee.install.</i></b>"</li>
+ * <li><b>osee_value:</b> contains client install information
+ *
+ * <pre>
+ * Data for this field is formatted as follows:
+ * &lt;client&gt;
+ * &lt;install os=&quot;Windows&quot; isActive=&quot;true&quot; /&gt;
+ * &lt;comment&gt; This is a shared installation &lt;/comment&gt;
+ * &lt;location&gt;\\server\\OSEE\\Shared\\osee.exe&lt;/location&gt;
+ * &lt;client&gt;
+ * </pre>
+ *
+ * </li>
+ * </ul>
+ * <code>
+ * </p>
+ *
+ * @author Roberto E. Escobar
+ */
+public class ClientInstallInfoServlet extends OseeHttpServlet {
+
+ private static final long serialVersionUID = -4089363221030046759L;
+
+ private static final String QUERY = "Select OSEE_KEY, OSEE_VALUE FROM osee_info where OSEE_KEY LIKE ?";
+
+ private enum CommandType {
+ exec_path;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.core.server.OseeHttpServlet#checkAccessControl(javax.servlet.http.HttpServletRequest)
+ */
+ @Override
+ protected void checkAccessControl(HttpServletRequest request) throws OseeCoreException {
+ // Allow access to all
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ try {
+ String cmd = request.getParameter("cmd");
+ String key = request.getParameter("key");
+ boolean isCloseAllowed = Boolean.valueOf(request.getParameter("close"));
+ boolean isPromptAllowed = Boolean.valueOf(request.getParameter("prompt"));
+ if (Strings.isValid(cmd)) {
+ CommandType cmdType = CommandType.valueOf(cmd);
+ switch (cmdType) {
+ case exec_path:
+ if (!Strings.isValid(key)) {
+ key = "osee.install.%";
+ }
+ if (key.startsWith("osee.install.")) {
+ List<ClientInstallInfo> infos = getInfoEntry(key);
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.setContentType("text/html");
+ if (infos.size() == 0) {
+ response.getWriter().write("<html><body>No installations found</body></html>");
+ } else {
+ String html = InstallLinkPageGenerator.generate(infos, isCloseAllowed, isPromptAllowed);
+ response.getWriter().print(html);
+ }
+ } else {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ response.setContentType("text/plain");
+ response.getWriter().write("key parameter was invalid. must start with: osee.install.");
+ }
+ break;
+ default:
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ break;
+ }
+ } else {
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ response.setContentType("text/plain");
+ response.getWriter().write(
+ String.format("cmd parameter was invalid. use any of the following: %s",
+ Arrays.deepToString(CommandType.values())));
+ }
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, String.format("Failed to process client install info request [%s]",
+ request.toString()), ex);
+ response.setContentType("text/plain");
+ response.getWriter().write(Lib.exceptionToString(ex));
+ }
+ response.getWriter().flush();
+ response.getWriter().close();
+ }
+
+ private List<ClientInstallInfo> getInfoEntry(String key) throws OseeCoreException {
+ List<ClientInstallInfo> infos = new ArrayList<ClientInstallInfo>();
+ ConnectionHandlerStatement chStmt = new ConnectionHandlerStatement();
+ try {
+ chStmt.runPreparedQuery(QUERY, key);
+ while (chStmt.next()) {
+ String name = chStmt.getString("osee_key");
+ String data = chStmt.getString("osee_value");
+ infos.add(ClientInstallInfo.createFromXml(name, data));
+ }
+ } finally {
+ chStmt.close();
+ }
+ return infos;
+ }
+}
diff --git a/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/InstallLinkPageGenerator.java b/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/InstallLinkPageGenerator.java
new file mode 100644
index 00000000000..2439048b2ce
--- /dev/null
+++ b/org.eclipse.osee.framework.client.info.servlet/src/org/eclipse/osee/framework/client/info/servlet/InstallLinkPageGenerator.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.client.info.servlet;
+
+import java.util.List;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class InstallLinkPageGenerator {
+
+ private static final String HTML_HEADER =
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html14/loose.dtd\">\n";
+
+ private static final String CSS_SHEET =
+ "<style type=\"text/css\"> table.oseeTable { border-width: 1px 1px 1px 1px; border-spacing: 2px; border-style: solid solid solid solid; border-color: blue blue blue blue; border-collapse: separate; background-color: rgb(255, 250, 250); } " + " table.oseeTable th { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } " + " table.oseeTable td { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } </style>\n";
+
+ private static final String MULTI_LINK_TEMPLATE =
+ HTML_HEADER + "<html>\n<head>\n" + CSS_SHEET + "%s</head>\n<body onload=\"initialize()\">\n%s</body>\n</html>";
+ private static final String LAUNCH_PAGE_TEMPLATE =
+ HTML_HEADER + "<html>\n<head>\n" + CSS_SHEET + "%s</head>\n<body onload=\"initialize()\">\n<div id='xmsg'/>\n</body>\n</html>";
+
+ private static final String LAUNCH_ERROR_MESSAGE =
+ "Please use Internet Explorer. Your browser does not support this operation.";
+
+ private static final String LINK_ERROR_MESSAGE = "Links below will not work unless you use Internet Explorer.";
+
+ private static final String JS_CHECK =
+ "if (document.implementation && document.implementation.createDocument) {\nalert('%s');\n return;}\n";
+
+ private InstallLinkPageGenerator() {
+ }
+
+ private static String normalizePath(String path) {
+ StringBuilder pathBuilder = new StringBuilder();
+ boolean wasLastPathSeparator = false;
+ for (int charIndex = 0; charIndex < path.length(); charIndex++) {
+ char charVal = path.charAt(charIndex);
+ if (charVal == '\\' && !wasLastPathSeparator) {
+ if (charIndex + 1 < path.length()) {
+ if (path.charAt(charIndex + 1) != '\\') {
+ pathBuilder.append('\\');
+ }
+ } else {
+ pathBuilder.append('\\');
+ }
+ wasLastPathSeparator = true;
+ } else {
+ wasLastPathSeparator = false;
+ }
+ pathBuilder.append(charVal);
+ }
+ return pathBuilder.toString();
+ }
+
+ private static String getOpenScript(ClientInstallInfo info, boolean isCloseAllowed, boolean isPromptAllowed) {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<script type=\"text/javascript\">\n");
+ builder.append("function initialize()\n{\n");
+ builder.append(String.format(JS_CHECK, LAUNCH_ERROR_MESSAGE));
+ String path = info.getExecPath();
+ if (info.getOs().contains("win") && info.isActive()) {
+ String execName = null;
+ String execPath = "";
+ int index = path.lastIndexOf("\\");
+ if (index > -1) {
+ execName = path.substring(index + 1, path.length());
+ execPath = normalizePath(path.substring(0, index));
+ } else {
+ execName = path;
+ execPath = "";
+ }
+ builder.append("var v = new ActiveXObject(\"Shell.Application\");\n");
+ builder.append(String.format("v.ShellExecute(\"%s\",\"\",\"%s\", \"open\", 10);\n", execName, execPath));
+ if (!isPromptAllowed) {
+ builder.append("window.opener=\"self\";\n");
+ }
+ if (isCloseAllowed) {
+ builder.append("window.close();\n");
+ }
+ builder.append("}\n");
+ } else {
+ // INVALID LINK PAGE
+ builder.append(String.format(
+ "var ex=\"No valid link found. Contact your OSEE administrator. Key was: [%s]\";", info.getName()));
+ builder.append("document.getElementById('xmsg').innerHTML=ex;");
+ builder.append("}\n");
+ }
+ builder.append("</script>\n");
+ return builder.toString();
+ }
+
+ private static String getCheckScript() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<script type=\"text/javascript\">\n");
+ builder.append("function initialize()\n{\n");
+ builder.append(String.format(JS_CHECK, LINK_ERROR_MESSAGE));
+ builder.append("}\n</script>\n");
+ return builder.toString();
+ }
+
+ private static String getLinkTable(List<ClientInstallInfo> infos) {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<h3>OSEE Client Installs</h3>");
+ builder.append("<p>Click on the <i>Active</i> install names to launch OSEE.</p>");
+ builder.append("<table class=\"oseeTable\" width=\"95%\">");
+ builder.append("<tr style=\"background:gray\" ><th>Name</th> <th>Comment</th><th>Status</th>");
+ for (ClientInstallInfo info : infos) {
+ builder.append("<tr>");
+ if (info.isActive()) {
+ String path = info.getExecPath();
+ builder.append("<td>");
+ builder.append(String.format("<a href=\"%s\"> %s</a>",
+ path.startsWith("file://") ? path : "file://" + path,
+ info.getName().replaceAll("osee.install", "").toUpperCase().replaceAll("\\.", " ")));
+ builder.append("</td>");
+ builder.append(String.format("<td>%s</td>", info.getComment()));
+ builder.append("<td>Active</td>");
+ } else {
+ builder.append(String.format("<td>%s</td>",
+ info.getName().replaceAll("osee.install", "").toUpperCase().replaceAll("\\.", " ")));
+ builder.append(String.format("<td>%s</td>", info.getComment()));
+ builder.append("<td>In Active</td>");
+ }
+ builder.append("</tr>");
+ }
+ builder.append("</table>");
+ return builder.toString();
+ }
+
+ public static String generate(List<ClientInstallInfo> infos, boolean isCloseAllowed, boolean isPromptAllowed) {
+ String toReturn = null;
+ if (infos.size() == 1) {
+ toReturn = String.format(LAUNCH_PAGE_TEMPLATE, getOpenScript(infos.get(0), isCloseAllowed, isPromptAllowed));
+ } else {
+ toReturn = String.format(MULTI_LINK_TEMPLATE, getCheckScript(), getLinkTable(infos));
+ }
+ return toReturn;
+ }
+}

Back to the top