Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2011-03-04 19:21:20 +0000
committerRyan D. Brooks2011-03-04 19:21:20 +0000
commitaff856fa61e80518f9d7533c1ca193fb1b8312ef (patch)
treedb3789cd517a8d49286bf63989e81c6be7f5c084
parentcb93b5b7f6a456baef8b5756b4c3875a5bbe482b (diff)
downloadorg.eclipse.osee-aff856fa61e80518f9d7533c1ca193fb1b8312ef.tar.gz
org.eclipse.osee-aff856fa61e80518f9d7533c1ca193fb1b8312ef.tar.xz
org.eclipse.osee-aff856fa61e80518f9d7533c1ca193fb1b8312ef.zip
bug[ats_7RGMG]: Fix issue with purge operation
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessEventListener.java4
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/BranchPurgeTest.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/event/BranchEventTest.java74
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java2
5 files changed, 38 insertions, 50 deletions
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessEventListener.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessEventListener.java
index 38c1a9e4501..26a8ae1fa15 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessEventListener.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessEventListener.java
@@ -81,7 +81,7 @@ public final class AccessEventListener implements IBranchEventListener, IAccessC
@Override
public void handleBranchEvent(Sender sender, final BranchEvent branchEvent) {
try {
- if (branchEvent.getEventType() == BranchEventType.Deleted || sender.isLocal() && branchEvent.getEventType() == BranchEventType.Purged) {
+ if (branchEvent.getEventType() == BranchEventType.Deleted || (!sender.isLocal() && branchEvent.getEventType() == BranchEventType.Purged)) {
BranchAccessObject branchAccessObject =
BranchAccessObject.getBranchAccessObject(branchEvent.getBranchGuid());
updateAccessList(sender, branchAccessObject);
@@ -94,7 +94,7 @@ public final class AccessEventListener implements IBranchEventListener, IAccessC
private void updateAccessList(Sender sender, AccessObject accessObject) throws OseeCoreException {
List<AccessControlData> acl = service.generateAccessControlList(accessObject);
for (AccessControlData accessControlData : acl) {
- service.removeAccessControlDataIf(sender.isLocal(), accessControlData);
+ service.removeAccessControlDataIf(false, accessControlData);
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/BranchPurgeTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/BranchPurgeTest.java
index 406762c467f..6c521121017 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/BranchPurgeTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/cases/BranchPurgeTest.java
@@ -86,7 +86,7 @@ public class BranchPurgeTest {
TestUtil.checkThatIncreased(preCreateCount, postCreateBranchCount);
// Purge branch
- BranchManager.purgeBranch(branch);
+ BranchManager.purgeBranchPending(branch);
TestUtil.sleep(4000);
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/event/BranchEventTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/event/BranchEventTest.java
index b3a9f126c78..42775a0d617 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/event/BranchEventTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/test/event/BranchEventTest.java
@@ -12,9 +12,10 @@ package org.eclipse.osee.framework.skynet.core.test.event;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
-import java.util.logging.Level;
-import org.junit.Assert;
+import java.util.Set;
+import junit.framework.Assert;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
@@ -27,7 +28,6 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -41,7 +41,6 @@ import org.eclipse.osee.framework.skynet.core.event.listener.IBranchEventListene
import org.eclipse.osee.framework.skynet.core.event.model.BranchEvent;
import org.eclipse.osee.framework.skynet.core.event.model.BranchEventType;
import org.eclipse.osee.framework.skynet.core.event.model.Sender;
-import org.eclipse.osee.framework.skynet.core.internal.Activator;
import org.eclipse.osee.support.test.util.TestUtil;
/**
@@ -53,6 +52,7 @@ public class BranchEventTest {
private Sender resultSender = null;
public static List<String> ignoreLogging = Arrays.asList("");
private static String BRANCH_NAME_PREFIX = "BranchEventManagerTest";
+ private static Set<Branch> branches = new HashSet<Branch>();
@org.junit.Test
public void testRegistration() throws Exception {
@@ -106,10 +106,6 @@ public class BranchEventTest {
BranchManager.updateBranchArchivedState(null, committedBranch.getId(), committedBranch.getGuid(),
BranchArchivedState.UNARCHIVED);
- // if (isRemoteTest()) {
- // Thread.sleep(2000);
- // }
-
Assert.assertNotNull(resultBranchEvent);
Assert.assertEquals(BranchEventType.ArchiveStateUpdated, resultBranchEvent.getEventType());
if (isRemoteTest()) {
@@ -127,6 +123,7 @@ public class BranchEventTest {
clearEventCollections();
Branch workingBranch =
BranchManager.createWorkingBranch(topLevel, BRANCH_NAME_PREFIX + " - to commit", UserManager.getUser());
+ branches.add(workingBranch);
Assert.assertNotNull(workingBranch);
@@ -158,12 +155,14 @@ public class BranchEventTest {
clearEventCollections();
Branch workingBranch =
BranchManager.createWorkingBranch(topLevel, BRANCH_NAME_PREFIX + " - to purge", UserManager.getUser());
+ branches.add(workingBranch);
Assert.assertNotNull(workingBranch);
final String guid = workingBranch.getGuid();
Assert.assertNotNull(workingBranch);
- BranchManager.purgeBranch(workingBranch);
+
+ BranchManager.purgeBranchPending(workingBranch);
// if (isRemoteTest()) {
// Thread.sleep(2000);
@@ -197,10 +196,6 @@ public class BranchEventTest {
Operations.executeWork(new DeleteBranchOperation(workingBranch));
- // if (isRemoteTest()) {
- // Thread.sleep(2000);
- // }
-
Assert.assertNotNull(resultBranchEvent);
Assert.assertEquals(BranchEventType.Deleted, resultBranchEvent.getEventType());
if (isRemoteTest()) {
@@ -220,10 +215,6 @@ public class BranchEventTest {
Assert.assertEquals(BranchState.CREATED, workingBranch.getBranchState());
BranchManager.updateBranchState(null, workingBranch.getId(), workingBranch.getGuid(), BranchState.MODIFIED);
- // if (isRemoteTest()) {
- // Thread.sleep(2000);
- // }
-
Assert.assertNotNull(resultBranchEvent);
Assert.assertEquals(BranchEventType.StateUpdated, resultBranchEvent.getEventType());
if (isRemoteTest()) {
@@ -243,10 +234,6 @@ public class BranchEventTest {
Assert.assertEquals(BranchType.WORKING, workingBranch.getBranchType());
BranchManager.updateBranchType(null, workingBranch.getId(), workingBranch.getGuid(), BranchType.BASELINE);
- // if (isRemoteTest()) {
- // Thread.sleep(2000);
- // }
-
Assert.assertNotNull(resultBranchEvent);
Assert.assertEquals(BranchEventType.TypeUpdated, resultBranchEvent.getEventType());
if (isRemoteTest()) {
@@ -267,10 +254,6 @@ public class BranchEventTest {
workingBranch.setName(newName);
BranchManager.persist(workingBranch);
- // if (isRemoteTest()) {
- // Thread.sleep(2000);
- // }
-
Assert.assertNotNull(resultBranchEvent);
Assert.assertEquals(BranchEventType.Renamed, resultBranchEvent.getEventType());
if (isRemoteTest()) {
@@ -288,7 +271,7 @@ public class BranchEventTest {
clearEventCollections();
Branch workingBranch =
BranchManager.createWorkingBranch(topLevel, BRANCH_NAME_PREFIX + " - working", UserManager.getUser());
-
+ branches.add(workingBranch);
Assert.assertNotNull(workingBranch);
Thread.sleep(4000);
@@ -309,10 +292,10 @@ public class BranchEventTest {
final String branchName = String.format("%s - top level branch", BRANCH_NAME_PREFIX);
IOseeBranch branchToken = TokenFactory.createBranch(guid, branchName);
Branch branch = BranchManager.createTopLevelBranch(branchToken);
-
+ branches.add(branch);
Assert.assertNotNull(branch);
- Thread.sleep(1000);
+ Thread.sleep(2000);
Assert.assertNotNull(resultBranchEvent);
Assert.assertEquals(BranchEventType.Added, resultBranchEvent.getEventType());
@@ -344,26 +327,25 @@ public class BranchEventTest {
}
@org.junit.BeforeClass
+ public static void cleanUpBefore() {
+ branches.clear();
+ }
+
@org.junit.AfterClass
- public static void cleanUp() throws OseeCoreException {
-
- for (Branch branch : BranchManager.getBranches(BranchArchivedState.ALL, BranchType.MERGE, BranchType.WORKING)) {
- if (branch.getName().startsWith(BRANCH_NAME_PREFIX)) {
- try {
- BranchManager.purgeBranch(branch);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
+ public static void cleanUpAfter() throws OseeCoreException {
+ for (Branch branch : branches) {
+ purgeBranch(branch);
}
- for (Branch branch : BranchManager.getBranches(BranchArchivedState.ALL, BranchType.BASELINE, BranchType.MERGE,
- BranchType.WORKING)) {
- if (branch.getName().startsWith(BRANCH_NAME_PREFIX)) {
- try {
- BranchManager.purgeBranch(branch);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
+ }
+
+ private static void purgeBranch(Branch branch) throws OseeCoreException {
+ if (!branch.getChildBranches().isEmpty()) {
+ for (Branch childBranch : branch.getChildren()) {
+ purgeBranch(childBranch);
+ }
+ } else {
+ if (branch.getStorageState() != StorageState.PURGED) {
+ BranchManager.purgeBranchPending(branch);
}
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java
index 5c4b7582f91..4514858971d 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java
@@ -224,10 +224,14 @@ public class BranchManager {
return Operations.executeAsJob(operation, true);
}
- public static void purgeBranch(final Branch branch) throws OseeCoreException {
+ public static void purgeBranchPending(Branch branch) throws OseeCoreException {
Operations.executeWorkAndCheckStatus(new PurgeBranchHttpRequestOperation(branch));
}
+ public static void purgeBranch(final Branch branch) {
+ purgeBranch(Arrays.asList(branch));
+ }
+
/**
* Purges branches from the system. (sets branch state to purged. operation is undo-able)
*/
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java
index 20d5ee0fad0..8090ecf5e70 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/PurgeBranchHttpRequestOperation.java
@@ -54,6 +54,8 @@ public final class PurgeBranchHttpRequestOperation extends AbstractOperation {
if (response.wasSuccessful()) {
branch.setStorageState(StorageState.PURGED);
+ branch.setArchived(true);
+ Activator.getInstance().getAccessControlService().removePermissions(branch);
BranchManager.decache(branch);
OseeEventManager.kickBranchEvent(getClass(), new BranchEvent(BranchEventType.Purged, branch.getGuid()),
branch.getId());

Back to the top