diff options
author | Roberto E. Escobar | 2015-01-15 22:49:09 +0000 |
---|---|---|
committer | Angel Avila | 2015-01-15 22:49:09 +0000 |
commit | 02908e6aa0efdfe5c5d7288a7e817a2be8bd4e8d (patch) | |
tree | 9dacb266c8813658add6ca4276e52940a71da80a /plugins/org.eclipse.osee.framework.core.server | |
parent | 0b3a6efb33f4caee629df6cd255fb549bf538e8f (diff) | |
download | org.eclipse.osee-02908e6aa0efdfe5c5d7288a7e817a2be8bd4e8d.tar.gz org.eclipse.osee-02908e6aa0efdfe5c5d7288a7e817a2be8bd4e8d.tar.xz org.eclipse.osee-02908e6aa0efdfe5c5d7288a7e817a2be8bd4e8d.zip |
feature[ats_ATS152956]: Remove osee.build.designation from app server
Change-Id: I83d7d8f6e7165cd47844855af7ededd44492e055
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.server')
4 files changed, 2 insertions, 280 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildInfo.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildInfo.java deleted file mode 100644 index f338a9a5345..00000000000 --- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildInfo.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * 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/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeIdentifier.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeIdentifier.java deleted file mode 100644 index dde73089dde..00000000000 --- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/BuildTypeIdentifier.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * 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.OseeExceptions; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -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 { - - public static interface BuildTypeDataProvider { - - String getData(); - } - - 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) { - OseeExceptions.wrapAndThrow(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/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/SessionFactory.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/SessionFactory.java index 29dd3354d5c..798c196c592 100644 --- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/SessionFactory.java +++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/SessionFactory.java @@ -18,7 +18,6 @@ import org.eclipse.osee.framework.core.data.IUserToken; import org.eclipse.osee.framework.core.data.OseeSessionGrant; import org.eclipse.osee.framework.core.model.cache.IOseeTypeFactory; import org.eclipse.osee.framework.core.server.OseeServerProperties; -import org.eclipse.osee.framework.core.server.internal.BuildTypeIdentifier; import org.eclipse.osee.framework.core.server.internal.util.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; @@ -33,12 +32,10 @@ import org.eclipse.osee.logger.Log; * @author Roberto E. Escobar */ public final class SessionFactory implements IOseeTypeFactory { - private final BuildTypeIdentifier typeIdentifier; private final Log logger; private final JdbcService jdbcService; - public SessionFactory(Log logger, JdbcService jdbcService, BuildTypeIdentifier typeIdentifier) { - this.typeIdentifier = typeIdentifier; + public SessionFactory(Log logger, JdbcService jdbcService) { this.logger = logger; this.jdbcService = jdbcService; } @@ -69,7 +66,6 @@ public final class SessionFactory implements IOseeTypeFactory { sessionGrant.setSqlProperties(properties); sessionGrant.setDataStorePath(OseeServerProperties.getOseeApplicationServerData(logger)); - sessionGrant.setClientBuildDesination(typeIdentifier.getBuildDesignation(session.getClientVersion())); return sessionGrant; } diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/SessionManagerService.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/SessionManagerService.java index a980bb29e34..a7b2320af40 100644 --- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/SessionManagerService.java +++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/SessionManagerService.java @@ -20,9 +20,6 @@ import org.eclipse.osee.framework.core.exception.OseeExceptions; import org.eclipse.osee.framework.core.server.IAuthenticationManager; import org.eclipse.osee.framework.core.server.ISession; import org.eclipse.osee.framework.core.server.ISessionManager; -import org.eclipse.osee.framework.core.server.internal.BuildTypeIdentifier; -import org.eclipse.osee.framework.core.server.internal.BuildTypeIdentifier.BuildTypeDataProvider; -import org.eclipse.osee.framework.core.server.internal.util.OseeInfo; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.jdbc.JdbcClient; import org.eclipse.osee.jdbc.JdbcService; @@ -33,8 +30,6 @@ import org.eclipse.osee.logger.Log; */ public final class SessionManagerService implements ISessionManager { - private static final String BUILD_DATA_KEY = "osee.build.designation"; - private Log logger; private JdbcService jdbcService; private IAuthenticationManager authenticationManager; @@ -60,16 +55,7 @@ public final class SessionManagerService implements ISessionManager { public void start() throws OseeCoreException { final JdbcClient jdbcClient = jdbcService.getClient(); - BuildTypeIdentifier identifier = new BuildTypeIdentifier(new BuildTypeDataProvider() { - - @Override - public String getData() { - return OseeInfo.getValue(jdbcClient, BUILD_DATA_KEY); - } - - }); - - SessionFactory sessionFactory = new SessionFactory(logger, jdbcService, identifier); + SessionFactory sessionFactory = new SessionFactory(logger, jdbcService); ISessionQuery sessionQuery = new DatabaseSessionQuery(jdbcClient); DatabaseSessionAccessor accessor = new DatabaseSessionAccessor(sessionFactory, sessionQuery, jdbcClient); |