Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2014-04-23 23:08:22 +0000
committerDonald Dunne2014-04-24 16:21:13 +0000
commit280af9a80be6932dbde90582c515199890d0e6e2 (patch)
tree06069309f6ac397e92bd52a22352e803cafa13ef /plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core
parent12e0e49add1caeaa7ec6f6f7614a78ee60e929d1 (diff)
downloadorg.eclipse.osee-280af9a80be6932dbde90582c515199890d0e6e2.tar.gz
org.eclipse.osee-280af9a80be6932dbde90582c515199890d0e6e2.tar.xz
org.eclipse.osee-280af9a80be6932dbde90582c515199890d0e6e2.zip
feature[ats_ATS19845]: Handle compatibility for app server branch messaging
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core')
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java84
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java44
2 files changed, 100 insertions, 28 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
index 278a06cfd82..9269a982dd9 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchRow.java
@@ -19,6 +19,7 @@ import org.eclipse.osee.framework.core.enums.StorageState;
import org.eclipse.osee.framework.core.message.internal.DatabaseService;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
public final class BranchRow {
private final long branchUuid;
@@ -74,32 +75,87 @@ public final class BranchRow {
}
public String[] toArray() {
- return new String[] {
- getBranchArchived().name(),
- String.valueOf(getBranchId()),
- getBranchName(),
- getBranchState().name(),
- getBranchType().name(),
- getStorageState().name(),
- Boolean.toString(isInheritAccessControl())};
+ if (isOseeUsingGuidsForAppServerMessaging()) {
+ return new String[] {
+ getBranchArchived().name(),
+ getBranchGuidLegacy(getBranchId()),
+ String.valueOf(getBranchId()),
+ getBranchName(),
+ getBranchState().name(),
+ getBranchType().name(),
+ getStorageState().name(),
+ Boolean.toString(isInheritAccessControl())};
+ } else {
+ return new String[] {
+ getBranchArchived().name(),
+ String.valueOf(getBranchId()),
+ getBranchName(),
+ getBranchState().name(),
+ getBranchType().name(),
+ getStorageState().name(),
+ Boolean.toString(isInheritAccessControl())};
+ }
}
public static BranchRow fromArray(String[] data) {
BranchArchivedState archived = BranchArchivedState.valueOf(data[0]);
long branchUuid = 0;
+ boolean inheritAccessControl = false;
+ String branchName = null;
+ BranchState branchState = null;
+ BranchType branchType = null;
+ StorageState storageState = null;
if (GUID.isValid(data[1])) {
- branchUuid = getBranchIdLegacy(data[1]);
+ // skip guid
+ branchUuid = Long.valueOf(data[2]);
+ branchName = data[3];
+ branchState = BranchState.valueOf(data[4]);
+ branchType = BranchType.valueOf(data[5]);
+ storageState = StorageState.valueOf(data[6]);
} else {
branchUuid = Long.valueOf(data[1]);
+ branchName = data[2];
+ branchState = BranchState.valueOf(data[3]);
+ branchType = BranchType.valueOf(data[4]);
+ storageState = StorageState.valueOf(data[5]);
+ inheritAccessControl = Boolean.parseBoolean(data[6]);
}
- String branchName = data[2];
- BranchState branchState = BranchState.valueOf(data[3]);
- BranchType branchType = BranchType.valueOf(data[4]);
- StorageState storageState = StorageState.valueOf(data[5]);
- boolean inheritAccessControl = Boolean.parseBoolean(data[6]);
return new BranchRow(branchUuid, branchName, branchType, branchState, archived, storageState,
inheritAccessControl);
}
+
+ // Temporary cache till all code uses branch uuid. Remove after 0.17.0
+ private static final String SELECT_OSEE_INFO =
+ "select osee_value from osee_info where osee_key = 'osee.using.guids.for.app.server.messaging'";
+ private static Boolean oseeUsingGuidsForAppServerMessaging = null;
+
+ public static boolean isOseeUsingGuidsForAppServerMessaging() {
+ if (oseeUsingGuidsForAppServerMessaging == null) {
+ oseeUsingGuidsForAppServerMessaging =
+ DatabaseService.getDatabaseService().runPreparedQueryFetchObject("", SELECT_OSEE_INFO).equals("true");
+ }
+ return oseeUsingGuidsForAppServerMessaging;
+ }
+
+ private static final String SELECT_BRANCH_GUID_BY_ID = "select branch_guid from osee_branch where branch_id = ?";
+ // Temporary cache till all code uses branch uuid. Remove after 0.17.0
+ private static final Map<Long, String> longToGuidCache = new HashMap<Long, String>(50);
+
+ /**
+ * Temporary method till all code uses branch uuid. Remove after 0.17.0
+ */
+ public static String getBranchGuidLegacy(long branchUuid) {
+ String guid = longToGuidCache.get(branchUuid);
+ if (!Strings.isValid(guid)) {
+ guid =
+ DatabaseService.getDatabaseService().runPreparedQueryFetchObject("", SELECT_BRANCH_GUID_BY_ID, branchUuid);
+ Conditions.checkExpressionFailOnTrue(!Strings.isValid(guid), "Error getting branch_guid for branch: [%d]",
+ branchUuid);
+ longToGuidCache.put(branchUuid, guid);
+ }
+ return guid;
+ }
+
// Temporary cache till all code uses branch uuid. Remove after 0.17.0
private static final String SELECT_BRANCH_ID_BY_GUID = "select branch_id from osee_branch where branch_guid = ?";
// Temporary cache till all code uses branch uuid. Remove after 0.17.0
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java
index 708485f32bb..b6f7f9bf1ab 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java
@@ -141,14 +141,26 @@ public final class TranslationUtil {
private static void storeToTripletList(List<Triplet<Long, Long, Long>> data, PropertyStore innerStore) {
for (String strKey : innerStore.arrayKeySet()) {
String[] value = innerStore.getArray(strKey);
- data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), Long.valueOf(value[1]), Long.valueOf(value[2])));
+ if (BranchRow.isOseeUsingGuidsForAppServerMessaging()) {
+ data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), BranchRow.getBranchIdLegacy(value[1]),
+ Long.valueOf(value[2])));
+ } else {
+ data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), Long.valueOf(value[1]),
+ Long.valueOf(value[2])));
+ }
}
}
private static void storeToStringTripletList(List<Triplet<Long, Long, Long>> data, PropertyStore innerStore) {
for (String strKey : innerStore.arrayKeySet()) {
String[] value = innerStore.getArray(strKey);
- data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), Long.valueOf(value[1]), Long.valueOf(value[2])));
+ if (BranchRow.isOseeUsingGuidsForAppServerMessaging()) {
+ data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), BranchRow.getBranchIdLegacy(value[1]),
+ Long.valueOf(value[2])));
+ } else {
+ data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), Long.valueOf(value[1]),
+ Long.valueOf(value[2])));
+ }
}
}
@@ -156,27 +168,31 @@ public final class TranslationUtil {
PropertyStore innerStore = new PropertyStore();
int index = 0;
for (Triplet<Long, Long, Long> entry : list) {
- innerStore.put(
- String.valueOf(index),
- new String[] {
- String.valueOf(entry.getFirst()),
- String.valueOf(entry.getSecond()),
- String.valueOf(entry.getThird())});
+ innerStore.put(String.valueOf(index), new String[] {
+ String.valueOf(entry.getFirst()),
+ getStringBranchGuid(entry.getSecond()),
+ String.valueOf(entry.getThird())});
index++;
}
return innerStore;
}
+ private static String getStringBranchGuid(Long second) {
+ String result = String.valueOf(second);
+ if (BranchRow.isOseeUsingGuidsForAppServerMessaging()) {
+ result = BranchRow.getBranchGuidLegacy(second);
+ }
+ return result;
+ }
+
private static PropertyStore tripletLongListToStore(List<Triplet<Long, Long, Long>> list) {
PropertyStore innerStore = new PropertyStore();
int index = 0;
for (Triplet<Long, Long, Long> entry : list) {
- innerStore.put(
- String.valueOf(index),
- new String[] {
- String.valueOf(entry.getFirst()),
- String.valueOf(entry.getSecond()),
- String.valueOf(entry.getThird())});
+ innerStore.put(String.valueOf(index), new String[] {
+ String.valueOf(entry.getFirst()),
+ getStringBranchGuid(entry.getSecond()),
+ String.valueOf(entry.getThird())});
index++;
}
return innerStore;

Back to the top