Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-04-28 05:03:25 +0000
committerRoberto E. Escobar2012-04-28 05:03:25 +0000
commit65f6159a5fdc57fb788c992d8be81636a9ad0351 (patch)
tree15d9a64d7c32fec05a3d2cb8b171a1636d475f91 /plugins/org.eclipse.osee.framework.access
parentbf9c5e0efcf32fcbeca4f871f4f12203c53e3d31 (diff)
downloadorg.eclipse.osee-65f6159a5fdc57fb788c992d8be81636a9ad0351.tar.gz
org.eclipse.osee-65f6159a5fdc57fb788c992d8be81636a9ad0351.tar.xz
org.eclipse.osee-65f6159a5fdc57fb788c992d8be81636a9ad0351.zip
feature[ats_VGR8B]: Redesign InternalOseeEventManager to fix initialization
Redesign OseeEventManager Make OseeEventManagerService Fix access control service initialization Re-enable skynet core tests
Diffstat (limited to 'plugins/org.eclipse.osee.framework.access')
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml3
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/object.access.provider.xml1
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/static.access.control.helper.xml5
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlManager.java17
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java40
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java38
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java37
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java77
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java84
9 files changed, 169 insertions, 133 deletions
diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml
index 8ac54f9891a..fc7b8e278f8 100644
--- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml
@@ -7,4 +7,5 @@
<reference bind="setDbService" cardinality="1..1" interface="org.eclipse.osee.framework.database.IOseeDatabaseService" name="IOseeDatabaseService" policy="static"/>
<reference bind="setCachingService" cardinality="1..1" interface="org.eclipse.osee.framework.core.services.IOseeCachingService" name="IOseeCachingService" policy="static"/>
<reference bind="setIdentityService" cardinality="1..1" interface="org.eclipse.osee.framework.core.services.IdentityService" name="IdentityService" policy="static"/>
-</scr:component> \ No newline at end of file
+ <reference bind="setEventService" cardinality="1..1" interface="org.eclipse.osee.framework.skynet.core.event.OseeEventService" name="OseeEventService" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/object.access.provider.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/object.access.provider.xml
index f1bd825d7ed..930f58a61de 100644
--- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/object.access.provider.xml
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/object.access.provider.xml
@@ -4,5 +4,4 @@
<service>
<provide interface="org.eclipse.osee.framework.access.IAccessProvider"/>
</service>
- <reference bind="setAccessControlService" cardinality="1..1" interface="org.eclipse.osee.framework.core.services.IAccessControlService" name="IAccessControlService" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/static.access.control.helper.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/static.access.control.helper.xml
deleted file mode 100644
index 6190fd28d33..00000000000
--- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/static.access.control.helper.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osee.framework.access.internal.AccessControlHelper">
- <implementation class="org.eclipse.osee.framework.access.internal.AccessControlHelper"/>
- <reference bind="setAccessControlService" cardinality="1..1" interface="org.eclipse.osee.framework.core.services.IAccessControlService" name="IAccessControlService" policy="static"/>
-</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlManager.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlManager.java
index 677f156faeb..3a2efdb8e74 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlManager.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlManager.java
@@ -13,8 +13,8 @@ package org.eclipse.osee.framework.access;
import java.util.Collection;
import java.util.logging.Level;
-import org.eclipse.osee.framework.access.internal.AccessControlService;
import org.eclipse.osee.framework.access.internal.AccessControlHelper;
+import org.eclipse.osee.framework.access.internal.AccessControlService;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeAuthenticationRequiredException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -34,7 +34,12 @@ public final class AccessControlManager {
}
public static AccessControlService getService() {
- AccessControlService accessService = AccessControlHelper.getAccessControlService();
+ AccessControlService accessService = null;
+ try {
+ accessService = AccessControlHelper.getAccessControlService();
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, "Acquiring Access Control Service", ex);
+ }
if (accessService == null) {
OseeLog.log(AccessControlHelper.class, Level.SEVERE, "Access Service was null");
}
@@ -70,7 +75,13 @@ public final class AccessControlManager {
}
public static boolean isOseeAdmin() throws OseeCoreException {
- return getService().isOseeAdmin();
+ AccessControlService service = null;
+ try {
+ service = AccessControlHelper.getAccessControlService();
+ } catch (Exception ex) {
+ // Do nothing;
+ }
+ return service != null ? service.isOseeAdmin() : false;
}
public static Collection<AccessControlData> getAccessControlList(Object object) {
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java
index 11f2d4cd21f..eadc6b11863 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java
@@ -10,26 +10,46 @@
*******************************************************************************/
package org.eclipse.osee.framework.access.internal;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.services.IAccessControlService;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
public final class AccessControlHelper {
public static final String PLUGIN_ID = "org.eclipse.osee.framework.access";
- private static AccessControlService accessControlService;
+ private AccessControlHelper() {
+ // Utility class
+ }
- public void setAccessControlService(IAccessControlService accessControlService) {
- if (accessControlService instanceof AccessControlServiceProxy) {
- AccessControlHelper.accessControlService =
- ((AccessControlServiceProxy) accessControlService).getProxiedObject();
- } else {
- AccessControlHelper.accessControlService = null;
- }
+ private static BundleContext getBundleContext() throws OseeCoreException {
+ Bundle bundle = FrameworkUtil.getBundle(AccessControlHelper.class);
+ Conditions.checkNotNull(bundle, "bundle");
+ return bundle.getBundleContext();
+ }
+
+ private static <T> T getService(Class<T> clazz) throws OseeCoreException {
+ BundleContext context = getBundleContext();
+ Conditions.checkNotNull(context, "bundleContext");
+ ServiceReference<T> reference = context.getServiceReference(clazz);
+ Conditions.checkNotNull(reference, "serviceReference");
+ T service = context.getService(reference);
+ Conditions.checkNotNull(service, "service");
+ return service;
}
@Deprecated
- public static AccessControlService getAccessControlService() {
- return accessControlService;
+ public static AccessControlService getAccessControlService() throws OseeCoreException {
+ IAccessControlService service = getService(IAccessControlService.class);
+ AccessControlService toReturn = null;
+ if (service instanceof AccessControlServiceProxy) {
+ toReturn = ((AccessControlServiceProxy) service).getProxiedObject();
+ }
+ return toReturn;
}
}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
index 1a04b349271..0a1eef7517b 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java
@@ -61,11 +61,12 @@ import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
+import org.eclipse.osee.framework.skynet.core.event.OseeEventService;
import org.eclipse.osee.framework.skynet.core.event.filter.ArtifactEventFilter;
import org.eclipse.osee.framework.skynet.core.event.filter.ArtifactTypeEventFilter;
import org.eclipse.osee.framework.skynet.core.event.filter.BranchGuidEventFilter;
import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter;
+import org.eclipse.osee.framework.skynet.core.event.listener.EventQosType;
import org.eclipse.osee.framework.skynet.core.event.listener.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event.model.AccessControlEvent;
import org.eclipse.osee.framework.skynet.core.event.model.AccessControlEventType;
@@ -121,14 +122,22 @@ public class AccessControlService implements IAccessControlService {
private final IOseeCachingService cachingService;
private final IOseeDatabaseService databaseService;
private final IdentityService identityService;
- private AccessControlUpdateListener eventListener;
+ private final OseeEventService eventService;
- public AccessControlService(IOseeDatabaseService databaseService, IOseeCachingService cachingService, IdentityService identityService) {
+ private IArtifactEventListener listener1;
+ private IArtifactEventListener listener2;
+
+ public AccessControlService(IOseeDatabaseService databaseService, IOseeCachingService cachingService, IdentityService identityService, OseeEventService eventService) {
super();
this.databaseService = databaseService;
this.cachingService = cachingService;
this.identityService = identityService;
- OseeEventManager.addListener(new AccessControlUpdateListener());
+ this.eventService = eventService;
+ }
+
+ public void start() {
+ listener1 = new AccessControlUpdateListener();
+ eventService.addListener(EventQosType.NORMAL, listener1);
if (!DbUtil.isDbInit()) {
try {
@@ -139,6 +148,17 @@ public class AccessControlService implements IAccessControlService {
}
}
+ public void stop() {
+ if (listener1 != null) {
+ eventService.removeListener(EventQosType.NORMAL, listener1);
+ listener1 = null;
+ }
+ if (listener2 != null) {
+ eventService.removeListener(EventQosType.NORMAL, listener2);
+ listener2 = null;
+ }
+ }
+
private ArtifactTypeCache getArtifactTypeCache() {
return cachingService.getArtifactTypeCache();
}
@@ -308,9 +328,9 @@ public class AccessControlService implements IAccessControlService {
}
}
- if (eventListener == null) {
- eventListener = new AccessControlUpdateListener((Artifact) userArtifact.getFullArtifact());
- OseeEventManager.addListener(eventListener);
+ if (listener2 == null) {
+ listener2 = new AccessControlUpdateListener((Artifact) userArtifact.getFullArtifact());
+ eventService.addListener(EventQosType.NORMAL, listener2);
}
if (!accessDataCache.containsKey(key)) {
@@ -616,7 +636,7 @@ public class AccessControlService implements IAccessControlService {
}
}
try {
- OseeEventManager.kickAccessControlArtifactsEvent(this, event);
+ eventService.send(this, event);
} catch (Exception ex) {
OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
@@ -645,7 +665,7 @@ public class AccessControlService implements IAccessControlService {
}
}
try {
- OseeEventManager.kickAccessControlArtifactsEvent(this, event);
+ eventService.send(this, event);
} catch (Exception ex) {
OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java
index f4604f4c700..62723c241d3 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java
@@ -23,16 +23,19 @@ import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
+import org.eclipse.osee.framework.skynet.core.event.OseeEventService;
+import org.eclipse.osee.framework.skynet.core.event.listener.EventQosType;
public final class AccessControlServiceProxy implements IAccessControlService {
private IOseeDatabaseService dbService;
private IOseeCachingService cachingService;
private IdentityService identityService;
+ private OseeEventService eventService;
private AccessControlService accessService;
private AccessEventListener accessEventListener;
+ private Thread thread;
public void setDbService(IOseeDatabaseService dbService) {
this.dbService = dbService;
@@ -46,6 +49,10 @@ public final class AccessControlServiceProxy implements IAccessControlService {
this.identityService = identityService;
}
+ public void setEventService(OseeEventService eventService) {
+ this.eventService = eventService;
+ }
+
public AccessControlService getProxiedObject() {
return accessService;
}
@@ -59,23 +66,41 @@ public final class AccessControlServiceProxy implements IAccessControlService {
}
public void start() {
- accessService = new AccessControlService(dbService, cachingService, identityService);
+ accessService = new AccessControlService(dbService, cachingService, identityService, eventService);
accessEventListener = new AccessEventListener(accessService, new AccessControlCacheHandler());
- OseeEventManager.addPriorityListener(accessEventListener);
+ eventService.addListener(EventQosType.PRIORITY, accessEventListener);
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ accessService.start();
+ }
+ };
+
+ thread = new Thread(runnable);
+ thread.start();
}
public void stop() {
+ if (thread != null) {
+ thread.interrupt();
+ thread = null;
+ }
+
if (accessEventListener != null) {
- OseeEventManager.removeListener(accessEventListener);
+ eventService.removeListener(EventQosType.PRIORITY, accessEventListener);
accessEventListener = null;
}
- accessService = null;
+
+ if (accessService != null) {
+ accessService.stop();
+ accessService = null;
+ }
}
private void checkInitialized() throws OseeCoreException {
Conditions.checkNotNull(accessService, "accessService", "Access Service not properly initialized");
- Conditions.checkNotNull(accessEventListener, "accessEventListener", "Access Service not properly initialized");
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java
deleted file mode 100644
index 91b75704d22..00000000000
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProvider.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.access.internal;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.access.IAccessProvider;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.PermissionEnum;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.IBasicArtifact;
-import org.eclipse.osee.framework.core.model.access.AccessData;
-import org.eclipse.osee.framework.core.model.access.AccessDetail;
-import org.eclipse.osee.framework.core.model.access.Scope;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
-
-public class ObjectAccessProvider implements IAccessProvider {
-
- private final AccessControlService accessService;
-
- public ObjectAccessProvider(AccessControlService accessService) {
- this.accessService = accessService;
- }
-
- @Override
- public void computeAccess(IBasicArtifact<?> userArtifact, Collection<?> objToCheck, AccessData accessData) throws OseeCoreException {
- for (Object object : objToCheck) {
- if (object instanceof Artifact) {
- setArtifactAccessData(userArtifact, (Artifact) object, accessData);
- } else if (object instanceof Branch) {
- setBranchAccessData(userArtifact, (Branch) object, accessData);
- } else if (object instanceof RelationLink) {
- RelationLink relation = (RelationLink) object;
- Artifact artifactA = relation.getArtifactA();
- Artifact artifactB = relation.getArtifactB();
- setArtifactAccessData(userArtifact, artifactA, accessData);
- setArtifactAccessData(userArtifact, artifactB, accessData);
- }
- }
- }
-
- private void setArtifactAccessData(IBasicArtifact<?> userArtifact, Artifact artifact, AccessData accessData) throws OseeCoreException {
- setBranchAccessData(userArtifact, artifact.getBranch(), accessData);
- String reason = "Legacy Artifact Permission";
- PermissionEnum userPermission = accessService.getArtifactPermission(userArtifact, artifact);
-
- if (userPermission == null) {
- reason = "User Permission was null in setArtifactAccessData - artifact is read only";
- userPermission = PermissionEnum.READ;
- } else if (artifact.isHistorical()) {
- userPermission = PermissionEnum.READ;
- reason = "User Permission set to Read - artifact is historical - artifact is read only";
- } else if (!artifact.getFullBranch().isEditable()) {
- userPermission = PermissionEnum.READ;
- reason = "User Permission set to Read - artifact's branch is not editable - artifact is read only";
- }
- //artifact.isDeleted()
- accessData.add(artifact,
- new AccessDetail<IBasicArtifact<Artifact>>(artifact, userPermission, Scope.createLegacyScope(), reason));
- }
-
- private void setBranchAccessData(IBasicArtifact<?> userArtifact, IOseeBranch branch, AccessData accessData) throws OseeCoreException {
- String reason = "Legacy Branch Permission";
- PermissionEnum userPermission = accessService.getBranchPermission(userArtifact, branch);
- accessData.add(branch, new AccessDetail<IOseeBranch>(branch, userPermission, Scope.createLegacyScope(), reason));
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java
index 76f11701450..4f7c6a8eee8 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java
@@ -13,47 +13,89 @@ package org.eclipse.osee.framework.access.internal;
import java.util.Collection;
import java.util.logging.Level;
import org.eclipse.osee.framework.access.IAccessProvider;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.IBasicArtifact;
import org.eclipse.osee.framework.core.model.access.AccessData;
+import org.eclipse.osee.framework.core.model.access.AccessDetail;
+import org.eclipse.osee.framework.core.model.access.Scope;
import org.eclipse.osee.framework.core.services.IAccessControlService;
-import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
public final class ObjectAccessProviderProxy implements IAccessProvider {
- private IAccessProvider accessProvider;
- private IAccessControlService accessControlService;
+ private BundleContext bundleContext;
- public void setAccessControlService(IAccessControlService accessControlService) {
- this.accessControlService = accessControlService;
+ public void start(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
}
- public void start() {
- if (accessControlService instanceof AccessControlServiceProxy) {
- AccessControlServiceProxy proxy = (AccessControlServiceProxy) accessControlService;
- accessProvider = new ObjectAccessProvider(proxy.getProxiedObject());
+ public void stop() {
+ bundleContext = null;
+ }
+
+ private AccessControlService getAccessService() {
+ AccessControlService toReturn = null;
+
+ ServiceReference<IAccessControlService> reference =
+ bundleContext.getServiceReference(IAccessControlService.class);
+ IAccessControlService service = bundleContext.getService(reference);
+ if (service instanceof AccessControlServiceProxy) {
+ AccessControlServiceProxy proxy = (AccessControlServiceProxy) service;
+ toReturn = proxy.getProxiedObject();
} else {
OseeLog.log(AccessControlHelper.class, Level.SEVERE, "Error initializing ObjectAccessProvider");
}
+ return toReturn;
}
- public void stop() {
- accessProvider = null;
+ @Override
+ public void computeAccess(IBasicArtifact<?> userArtifact, Collection<?> objToCheck, AccessData accessData) throws OseeCoreException {
+ for (Object object : objToCheck) {
+ if (object instanceof Artifact) {
+ setArtifactAccessData(userArtifact, (Artifact) object, accessData);
+ } else if (object instanceof Branch) {
+ setBranchAccessData(userArtifact, (Branch) object, accessData);
+ } else if (object instanceof RelationLink) {
+ RelationLink relation = (RelationLink) object;
+ Artifact artifactA = relation.getArtifactA();
+ Artifact artifactB = relation.getArtifactB();
+ setArtifactAccessData(userArtifact, artifactA, accessData);
+ setArtifactAccessData(userArtifact, artifactB, accessData);
+ }
+ }
}
- public IAccessProvider getAccessProvider() {
- return accessProvider;
- }
+ private void setArtifactAccessData(IBasicArtifact<?> userArtifact, Artifact artifact, AccessData accessData) throws OseeCoreException {
+ setBranchAccessData(userArtifact, artifact.getBranch(), accessData);
+ String reason = "Legacy Artifact Permission";
+ PermissionEnum userPermission = getAccessService().getArtifactPermission(userArtifact, artifact);
- private void checkInitialized() throws OseeCoreException {
- Conditions.checkNotNull(getAccessProvider(), "object access provider",
- "Object Access Provider not properly initialized");
+ if (userPermission == null) {
+ reason = "User Permission was null in setArtifactAccessData - artifact is read only";
+ userPermission = PermissionEnum.READ;
+ } else if (artifact.isHistorical()) {
+ userPermission = PermissionEnum.READ;
+ reason = "User Permission set to Read - artifact is historical - artifact is read only";
+ } else if (!artifact.getFullBranch().isEditable()) {
+ userPermission = PermissionEnum.READ;
+ reason = "User Permission set to Read - artifact's branch is not editable - artifact is read only";
+ }
+ //artifact.isDeleted()
+ accessData.add(artifact,
+ new AccessDetail<IBasicArtifact<Artifact>>(artifact, userPermission, Scope.createLegacyScope(), reason));
}
- @Override
- public void computeAccess(IBasicArtifact<?> userArtifact, Collection<?> objToCheck, AccessData accessData) throws OseeCoreException {
- checkInitialized();
- getAccessProvider().computeAccess(userArtifact, objToCheck, accessData);
+ private void setBranchAccessData(IBasicArtifact<?> userArtifact, IOseeBranch branch, AccessData accessData) throws OseeCoreException {
+ String reason = "Legacy Branch Permission";
+ PermissionEnum userPermission = getAccessService().getBranchPermission(userArtifact, branch);
+ accessData.add(branch, new AccessDetail<IOseeBranch>(branch, userPermission, Scope.createLegacyScope(), reason));
}
+
} \ No newline at end of file

Back to the top