Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-02-10 21:04:55 +0000
committerrescobar2010-02-10 21:04:55 +0000
commit30e4c3e9a0057e15f89f1a0db082107c68d65c1c (patch)
tree9429eeab1859eab2cd0c82bf9ebd95cbffe1a471 /org.eclipse.osee.framework.core.server
parent9fa96fe8b202f02dcc75cd3e666f996ca1ef04b8 (diff)
downloadorg.eclipse.osee-30e4c3e9a0057e15f89f1a0db082107c68d65c1c.tar.gz
org.eclipse.osee-30e4c3e9a0057e15f89f1a0db082107c68d65c1c.tar.xz
org.eclipse.osee-30e4c3e9a0057e15f89f1a0db082107c68d65c1c.zip
"Team Workflow" - NRW59 - "Differentiating between Network Release and Release Candidate version"
Diffstat (limited to 'org.eclipse.osee.framework.core.server')
-rw-r--r--org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildInfo.java89
-rw-r--r--org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeDataProvider.java27
-rw-r--r--org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeIdentifier.java166
-rw-r--r--org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/InternalOseeHttpServlet.java1
-rw-r--r--org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/SessionManager.java4
6 files changed, 287 insertions, 2 deletions
diff --git a/org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF b/org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF
index e3caa250828..7d0df3c0a08 100644
--- a/org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF
+++ b/org.eclipse.osee.framework.core.server/META-INF/MANIFEST.MF
@@ -13,6 +13,7 @@ Import-Package: javax.servlet,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.core.operation,
+ org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.database.core,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
@@ -21,6 +22,7 @@ Import-Package: javax.servlet,
org.osgi.framework,
org.osgi.service.http,
org.osgi.util.tracker
+Eclipse-ExtensibleAPI: true
Export-Package: org.eclipse.osee.framework.core.server
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/authentication.manager.xml,
diff --git a/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildInfo.java b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildInfo.java
new file mode 100644
index 00000000000..2976831d679
--- /dev/null
+++ b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildInfo.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.core.server.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class BuildInfo {
+ private final String typeName;
+ private final Set<String> versionPattern;
+
+ public BuildInfo(String typeName, String... patterns) {
+ this.typeName = typeName;
+ this.versionPattern = new HashSet<String>();
+
+ if (patterns != null && patterns.length > 0) {
+ for (String pattern : patterns) {
+ addPattern(pattern);
+ }
+ }
+ }
+
+ public void addPattern(String version) {
+ versionPattern.add(version);
+ }
+
+ public String getName() {
+ return typeName;
+ }
+
+ public String[] getVersions() {
+ return versionPattern.toArray(new String[versionPattern.size()]);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("Build:[%s] Patterns:%s", getName(), versionPattern);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (typeName == null ? 0 : typeName.hashCode());
+ result = prime * result + (versionPattern == null ? 0 : versionPattern.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ BuildInfo other = (BuildInfo) obj;
+ if (typeName == null) {
+ if (other.typeName != null) {
+ return false;
+ }
+ } else if (!typeName.equals(other.typeName)) {
+ return false;
+ }
+ if (versionPattern == null) {
+ if (other.versionPattern != null) {
+ return false;
+ }
+ } else if (!versionPattern.equals(other.versionPattern)) {
+ return false;
+ }
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeDataProvider.java b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeDataProvider.java
new file mode 100644
index 00000000000..8a893288106
--- /dev/null
+++ b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeDataProvider.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.core.server.internal;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.database.core.OseeInfo;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BuildTypeDataProvider {
+
+ private static final String BUILD_DATA_KEY = "osee.build.designation";
+
+ public String getData() throws OseeCoreException {
+ return OseeInfo.getValue(BUILD_DATA_KEY);
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeIdentifier.java b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeIdentifier.java
new file mode 100644
index 00000000000..882a1843177
--- /dev/null
+++ b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeIdentifier.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * 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.core.server.internal;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.regex.PatternSyntaxException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeWrappedException;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BuildTypeIdentifier {
+
+ private static final String DEFAULT_IDENTIFIER = "N/A";
+ private static final String START_TAG = "build";
+ private static final String ID_TAG = "type";
+ private static final String ENTRY_TAG = "matches";
+
+ private final BuildTypeDataProvider provider;
+
+ public BuildTypeIdentifier(BuildTypeDataProvider provider) {
+ this.provider = provider;
+ }
+
+ public String getBuildDesignation(String clientVersion) {
+ BuildInfo buildType = null;
+ try {
+ buildType = match(clientVersion, getBuildTypeEntries());
+ } catch (OseeCoreException ex) {
+ // Do Nothing -
+ }
+ return buildType != null ? buildType.getName() : DEFAULT_IDENTIFIER;
+ }
+
+ public synchronized Collection<BuildInfo> getBuildTypeEntries() throws OseeCoreException {
+ Collection<BuildInfo> dataEntries = new ArrayList<BuildInfo>();
+ String rawData = provider.getData();
+ BuildTypeParser parser = new BuildTypeParser();
+ parser.load(rawData, dataEntries);
+ return dataEntries;
+ }
+
+ private static BuildInfo match(String version, Collection<BuildInfo> dataEntries) {
+ BuildInfo toReturn = null;
+ if (Strings.isValid(version)) {
+ for (BuildInfo entry : dataEntries) {
+ for (String regEx : entry.getVersions()) {
+ if (Strings.isValid(regEx)) {
+ try {
+ if (isCompatibleVersion(regEx, version)) {
+ toReturn = entry;
+ }
+ } catch (PatternSyntaxException ex) {
+ // Do Nothing -
+ }
+ }
+ }
+ }
+ }
+ return toReturn;
+ }
+
+ private static boolean isCompatibleVersion(String serverVersion, String clientVersion) throws PatternSyntaxException {
+ boolean result = false;
+ if (serverVersion.equals(clientVersion)) {
+ result = true;
+ } else {
+ result = clientVersion.matches(serverVersion);
+ if (!result) {
+ result = serverVersion.matches(clientVersion);
+ }
+ }
+ return result;
+ }
+
+ private static final class BuildTypeParser {
+ private static final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
+ private BuildInfo currentType;
+ private String localName;
+ private String uri;
+ private boolean isVersionPattern;
+
+ public BuildTypeParser() {
+ reset();
+ }
+
+ public void reset() {
+ localName = null;
+ uri = null;
+ currentType = null;
+ isVersionPattern = false;
+ }
+
+ private void load(String rawData, Collection<BuildInfo> dataEntries) throws OseeCoreException {
+ if (Strings.isValid(rawData)) {
+ Reader reader = new StringReader(rawData);
+ try {
+ XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(reader);
+ while (streamReader.hasNext()) {
+ process(streamReader, dataEntries);
+ streamReader.next();
+ }
+ } catch (XMLStreamException ex) {
+ throw new OseeWrappedException(ex);
+ } finally {
+ Lib.close(reader);
+ }
+ }
+ }
+
+ private void process(XMLStreamReader reader, Collection<BuildInfo> dataEntries) {
+ int eventType = reader.getEventType();
+ switch (eventType) {
+ case XMLStreamConstants.START_ELEMENT:
+ localName = reader.getLocalName();
+ uri = reader.getNamespaceURI();
+ if (START_TAG.equals(localName)) {
+ String typeName = reader.getAttributeValue(uri, ID_TAG);
+ if (Strings.isValid(typeName)) {
+ currentType = new BuildInfo(typeName);
+ }
+ } else if (ENTRY_TAG.equals(localName) && currentType != null) {
+ isVersionPattern = true;
+ }
+ break;
+ case XMLStreamConstants.CDATA:
+ case XMLStreamConstants.CHARACTERS:
+ if (isVersionPattern) {
+ String data = reader.getText();
+ if (Strings.isValid(data)) {
+ currentType.addPattern(data);
+ }
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ localName = reader.getLocalName();
+ uri = reader.getNamespaceURI();
+ if (START_TAG.equals(localName) && currentType != null) {
+ dataEntries.add(currentType);
+ reset();
+ } else if (ENTRY_TAG.equals(localName) && currentType != null) {
+ isVersionPattern = false;
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/InternalOseeHttpServlet.java b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/InternalOseeHttpServlet.java
index 9a6726e29fd..ae7d5a1c5bb 100644
--- a/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/InternalOseeHttpServlet.java
+++ b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/InternalOseeHttpServlet.java
@@ -76,7 +76,6 @@ public abstract class InternalOseeHttpServlet extends HttpServlet {
this.request = request;
try {
checkAccessControl(request);
- String method = request.getMethod();
super.service(request, response);
} catch (OseeCoreException ex) {
response.setStatus(HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED);
diff --git a/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/SessionManager.java b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/SessionManager.java
index ebddf63dd08..a2c3430a37c 100644
--- a/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/SessionManager.java
+++ b/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/SessionManager.java
@@ -56,8 +56,10 @@ public class SessionManager implements ISessionManager {
private final Map<String, SessionData> sessionCache;
private final Timer updateTimer;
+ private final BuildTypeIdentifier typeIdentifier;
public SessionManager() {
+ this.typeIdentifier = new BuildTypeIdentifier(new BuildTypeDataProvider());
this.sessionCache = Collections.synchronizedMap(new HashMap<String, SessionData>());
this.updateTimer = new Timer("Persist Session Data Timer");
updateTimer.scheduleAtFixedRate(new UpdateDataStore(), DATASTORE_UPDATE, DATASTORE_UPDATE);
@@ -159,6 +161,7 @@ public class SessionManager implements ISessionManager {
sessionGrant.setDatabaseInfo(DatabaseInfoManager.getDefault());
sessionGrant.setSqlProperties(OseeSql.getSqlProperties(ConnectionHandler.getMetaData()));
sessionGrant.setDataStorePath(OseeServerProperties.getOseeApplicationServerData());
+ sessionGrant.setClientBuildDesination(typeIdentifier.getBuildDesignation(session.getVersion()));
}
return sessionGrant;
}
@@ -300,5 +303,4 @@ public class SessionManager implements ISessionManager {
}
}
}
-
}

Back to the top