Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-04-16 19:28:47 +0000
committerRoberto E. Escobar2012-04-16 19:28:47 +0000
commit34b436679032e7814189569902fb4290367ba0fd (patch)
tree89cbab9d9b7d526c40004d8e62cc7fa3f8375894 /plugins/org.eclipse.osee.framework.access
parentd295ca6c10186e8ae9ccb7a4a819cffb2f38945b (diff)
downloadorg.eclipse.osee-34b436679032e7814189569902fb4290367ba0fd.tar.gz
org.eclipse.osee-34b436679032e7814189569902fb4290367ba0fd.tar.xz
org.eclipse.osee-34b436679032e7814189569902fb4290367ba0fd.zip
feature[ats_VDYBJ]: Convert framework access to DS
Diffstat (limited to 'plugins/org.eclipse.osee.framework.access')
-rw-r--r--plugins/org.eclipse.osee.framework.access/.project5
-rw-r--r--plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml10
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/access.provider.admin.xml6
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml10
-rw-r--r--plugins/org.eclipse.osee.framework.access/OSGI-INF/object.access.provider.xml8
-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/build.properties6
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlManager.java6
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessManagerHandler.java4
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java35
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlService.java40
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java92
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceRegHandler.java68
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessEventListener.java8
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderAdmin.java79
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderVisitor.java2
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/Activator.java52
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java59
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderRegistrationHandler.java58
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java78
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderRegistrationHandler.java92
22 files changed, 419 insertions, 306 deletions
diff --git a/plugins/org.eclipse.osee.framework.access/.project b/plugins/org.eclipse.osee.framework.access/.project
index a3609e44515..6ce0380f735 100644
--- a/plugins/org.eclipse.osee.framework.access/.project
+++ b/plugins/org.eclipse.osee.framework.access/.project
@@ -20,6 +20,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
index 4cdd680cf67..d82084b13b7 100644
--- a/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF
@@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
Bundle-Name: Osee Access
Bundle-SymbolicName: org.eclipse.osee.framework.access;singleton:=true
Bundle-Version: 0.9.9.qualifier
-Bundle-Activator: org.eclipse.osee.framework.access.internal.Activator
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.google.common.collect,
@@ -33,3 +32,4 @@ Export-Package: org.eclipse.osee.framework.access,
org.eclipse.osee.framework.access.internal.data
Require-Bundle: org.eclipse.osee.framework.skynet.core,
org.eclipse.osee.framework.core.model
+Service-Component: OSGI-INF/*.xml
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
new file mode 100644
index 00000000000..d14d548d0e1
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" immediate="true" name="org.eclipse.osee.framework.access.internal.AccessControlServiceProxy">
+ <implementation class="org.eclipse.osee.framework.access.internal.AccessControlServiceProxy"/>
+ <service>
+ <provide interface="org.eclipse.osee.framework.core.services.IAccessControlService"/>
+ </service>
+ <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
diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.provider.admin.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.provider.admin.xml
new file mode 100644
index 00000000000..65e1f75f07d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.provider.admin.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" activate="start" deactivate="stop" name="org.eclipse.osee.framework.access.internal.AccessProviderAdmin">
+ <implementation class="org.eclipse.osee.framework.access.internal.AccessProviderAdmin"/>
+ <reference bind="setLifecycleService" cardinality="1..1" interface="org.eclipse.osee.framework.lifecycle.ILifecycleService" name="ILifecycleService" policy="static"/>
+ <reference bind="addAccessProvider" cardinality="1..n" interface="org.eclipse.osee.framework.access.IAccessProvider" name="IAccessProvider" policy="dynamic" unbind="removeAccessProvider"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml
new file mode 100644
index 00000000000..d66b84826f4
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.framework.access.internal.cm.CmAccessProviderProxy">
+ <implementation class="org.eclipse.osee.framework.access.internal.cm.CmAccessProviderProxy"/>
+ <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"/>
+ <reference bind="addCmAccessControl" cardinality="1..n" interface="org.eclipse.osee.framework.core.services.CmAccessControl"
+ name="CmAccessControl" policy="dynamic" unbind="removeCmAccessControl"/>
+</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
new file mode 100644
index 00000000000..f1bd825d7ed
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/object.access.provider.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.framework.access.internal.ObjectAccessProviderProxy">
+ <implementation class="org.eclipse.osee.framework.access.internal.ObjectAccessProviderProxy"/>
+ <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
new file mode 100644
index 00000000000..6190fd28d33
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/OSGI-INF/static.access.control.helper.xml
@@ -0,0 +1,5 @@
+<?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/build.properties b/plugins/org.eclipse.osee.framework.access/build.properties
index 34d2e4d2dad..d8b631f26ae 100644
--- a/plugins/org.eclipse.osee.framework.access/build.properties
+++ b/plugins/org.eclipse.osee.framework.access/build.properties
@@ -1,4 +1,6 @@
-source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ OSGI-INF/,\
+ OSGI-INF/static.access.control.helper.xml .xml
+source.. = src/
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 b7b60d1fa62..677f156faeb 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
@@ -14,7 +14,7 @@ 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.Activator;
+import org.eclipse.osee.framework.access.internal.AccessControlHelper;
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,9 +34,9 @@ public final class AccessControlManager {
}
public static AccessControlService getService() {
- AccessControlService accessService = Activator.getAccessControlService();
+ AccessControlService accessService = AccessControlHelper.getAccessControlService();
if (accessService == null) {
- OseeLog.log(Activator.class, Level.SEVERE, "Access Service was null");
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, "Access Service was null");
}
return accessService;
}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessManagerHandler.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessManagerHandler.java
index 0e752edbcc2..00f460bf203 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessManagerHandler.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessManagerHandler.java
@@ -14,7 +14,7 @@ import java.util.Collection;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.osee.framework.access.internal.Activator;
+import org.eclipse.osee.framework.access.internal.AccessControlHelper;
import org.eclipse.osee.framework.core.model.IBasicArtifact;
import org.eclipse.osee.framework.lifecycle.IAccessCheckProvider;
import org.eclipse.osee.framework.lifecycle.LifecycleHandler;
@@ -42,7 +42,7 @@ public class AccessManagerHandler implements LifecycleHandler {
for (IBasicArtifact<?> artifactToChk : artsToCheck) {
if (!accessCheckProvider.canEdit(userArtifact, artifactToChk)) {
- statusToReturn = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error");
+ statusToReturn = new Status(IStatus.ERROR, AccessControlHelper.PLUGIN_ID, "Error");
break;
}
}
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
new file mode 100644
index 00000000000..11f2d4cd21f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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 org.eclipse.osee.framework.core.services.IAccessControlService;
+
+public final class AccessControlHelper {
+
+ public static final String PLUGIN_ID = "org.eclipse.osee.framework.access";
+
+ private static AccessControlService accessControlService;
+
+ public void setAccessControlService(IAccessControlService accessControlService) {
+ if (accessControlService instanceof AccessControlServiceProxy) {
+ AccessControlHelper.accessControlService =
+ ((AccessControlServiceProxy) accessControlService).getProxiedObject();
+ } else {
+ AccessControlHelper.accessControlService = null;
+ }
+ }
+
+ @Deprecated
+ public static AccessControlService getAccessControlService() {
+ return accessControlService;
+ }
+
+}
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 f65f64250c4..4bbffaf02f1 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
@@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.osee.framework.access.AccessControlData;
import org.eclipse.osee.framework.access.AccessObject;
import org.eclipse.osee.framework.access.internal.data.ArtifactAccessObject;
@@ -37,19 +36,18 @@ import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeAuthenticationRequiredException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeStateException;
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.AccessDataQuery;
import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.core.services.IAccessControlService;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
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.database.core.IOseeStatement;
import org.eclipse.osee.framework.jdk.core.type.DoubleKeyHashMap;
@@ -74,7 +72,9 @@ import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent;
import org.eclipse.osee.framework.skynet.core.event.model.Sender;
import org.eclipse.osee.framework.skynet.core.utility.DbUtil;
import org.osgi.framework.Bundle;
-import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
import com.google.common.collect.MapMaker;
/**
@@ -141,10 +141,6 @@ public class AccessControlService implements IAccessControlService {
return cachingService.getArtifactTypeCache();
}
- private RelationTypeCache getRelationTypeCache() {
- return cachingService.getRelationTypeCache();
- }
-
private BranchCache getBranchCache() {
return cachingService.getBranchCache();
}
@@ -318,16 +314,14 @@ public class AccessControlService implements IAccessControlService {
}
private ILifecycleService getLifecycleService() throws OseeCoreException {
- Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
- ServiceTracker tracker = new ServiceTracker(bundle.getBundleContext(), ILifecycleService.class.getName(), null);
- tracker.open(true);
- Object serviceObject = tracker.getService();
- tracker.close();
- if (serviceObject instanceof ILifecycleService) {
- return (ILifecycleService) serviceObject;
- } else {
- throw new OseeStateException("Lifecycle service is unavailable");
- }
+ Bundle bundle = FrameworkUtil.getBundle(getClass());
+ Conditions.checkNotNull(bundle, "bundle");
+ BundleContext bundleContext = bundle.getBundleContext();
+ Conditions.checkNotNull(bundleContext, "bundleContext");
+ ServiceReference<ILifecycleService> reference = bundleContext.getServiceReference(ILifecycleService.class);
+ ILifecycleService service = bundleContext.getService(reference);
+ Conditions.checkNotNull(service, "ILifecycleService");
+ return service;
}
public PermissionEnum getBranchPermission(IBasicArtifact<?> subject, IOseeBranch branch) throws OseeCoreException {
@@ -475,7 +469,7 @@ public class AccessControlService implements IAccessControlService {
}
cacheAccessControlData(data);
} catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
}
}
@@ -507,7 +501,7 @@ public class AccessControlService implements IAccessControlService {
datas = generateAccessControlList(accessObject);
} catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
return datas;
}
@@ -611,7 +605,7 @@ public class AccessControlService implements IAccessControlService {
try {
OseeEventManager.kickAccessControlArtifactsEvent(this, event);
} catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
}
@@ -640,7 +634,7 @@ public class AccessControlService implements IAccessControlService {
try {
OseeEventManager.kickAccessControlArtifactsEvent(this, event);
} catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
}
@@ -719,7 +713,7 @@ public class AccessControlService implements IAccessControlService {
try {
reloadCache();
} catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, 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
new file mode 100644
index 00000000000..c50e4b7f5dc
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceProxy.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.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.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.access.AccessDataQuery;
+import org.eclipse.osee.framework.core.services.IAccessControlService;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+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.skynet.core.event.OseeEventManager;
+
+public final class AccessControlServiceProxy implements IAccessControlService {
+
+ private IOseeDatabaseService dbService;
+ private IOseeCachingService cachingService;
+ private IdentityService identityService;
+
+ private AccessControlService accessService;
+ private AccessEventListener accessEventListener;
+
+ public void setDbService(IOseeDatabaseService dbService) {
+ this.dbService = dbService;
+ }
+
+ public void setCachingService(IOseeCachingService cachingService) {
+ this.cachingService = cachingService;
+ }
+
+ public void setIdentityService(IdentityService identityService) {
+ this.identityService = identityService;
+ }
+
+ public AccessControlService getProxiedObject() {
+ return accessService;
+ }
+
+ public void clearCache() {
+ getProxiedObject().clearCache();
+ }
+
+ public void start() {
+ accessService = new AccessControlService(dbService, cachingService, identityService);
+
+ accessEventListener = new AccessEventListener(accessService, new AccessControlCacheHandler());
+ OseeEventManager.addPriorityListener(accessEventListener);
+ }
+
+ public void stop() {
+ if (accessEventListener != null) {
+ OseeEventManager.removeListener(accessEventListener);
+ accessEventListener = null;
+ }
+ 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
+ public boolean hasPermission(Object object, PermissionEnum permission) throws OseeCoreException {
+ checkInitialized();
+ return getProxiedObject().hasPermission(object, permission);
+ }
+
+ @Override
+ public void removePermissions(IOseeBranch branch) throws OseeCoreException {
+ checkInitialized();
+ getProxiedObject().removePermissions(branch);
+ }
+
+ @Override
+ public AccessDataQuery getAccessData(IBasicArtifact<?> userArtifact, Collection<?> itemsToCheck) throws OseeCoreException {
+ checkInitialized();
+ return getProxiedObject().getAccessData(userArtifact, itemsToCheck);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceRegHandler.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceRegHandler.java
deleted file mode 100644
index 5a14d08b20e..00000000000
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlServiceRegHandler.java
+++ /dev/null
@@ -1,68 +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.Map;
-import org.eclipse.osee.framework.core.services.IAccessControlService;
-import org.eclipse.osee.framework.core.services.IOseeCachingService;
-import org.eclipse.osee.framework.core.services.IdentityService;
-import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public final class AccessControlServiceRegHandler extends AbstractTrackingHandler {
-
- private static final Class<?>[] DEPENDENCIES = new Class[] {
- IOseeDatabaseService.class,
- IOseeCachingService.class,
- IdentityService.class,};
-
- private AccessControlService accessService;
- private ServiceRegistration serviceRegistration;;
- private AccessEventListener accessEventListener;
-
- public AccessControlService getService() {
- return accessService;
- }
-
- @Override
- public Class<?>[] getDependencies() {
- return DEPENDENCIES;
- }
-
- @Override
- public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
- IOseeDatabaseService databaseService = getService(IOseeDatabaseService.class, services);
- IOseeCachingService cachingService = getService(IOseeCachingService.class, services);
- IdentityService identityService = getService(IdentityService.class, services);
-
- // IAccessCacheAccessor accessor = new DatabaseAccessCacheAccessor(databaseService, cachingService);
- // ObjectBasedAccessCache cache = new ObjectBasedAccessCache(accessor);
-
- accessService = new AccessControlService(databaseService, cachingService, identityService);
- serviceRegistration = context.registerService(IAccessControlService.class.getName(), accessService, null);
-
- accessEventListener = new AccessEventListener(accessService, new AccessControlCacheHandler());
- OseeEventManager.addPriorityListener(accessEventListener);
- }
-
- @Override
- public void onDeActivate() {
- if (accessEventListener != null) {
- OseeEventManager.removeListener(accessEventListener);
- }
- if (serviceRegistration != null) {
- serviceRegistration.unregister();
- }
- }
-} \ No newline at end of file
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 0d6ab11f977..8f9fc478fff 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
@@ -51,7 +51,7 @@ public final class AccessEventListener implements IBranchEventListener, IAccessC
try {
accessControlCacheHandler.reloadCache(service);
} catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
}
if (guidArt.is(EventModType.Purged)) {
@@ -62,7 +62,7 @@ public final class AccessEventListener implements IBranchEventListener, IAccessC
accessControlCacheHandler.updateAccessList(service, artifactAccessObject);
}
} catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
}
@@ -81,7 +81,7 @@ public final class AccessEventListener implements IBranchEventListener, IAccessC
accessControlCacheHandler.updateAccessListForBranchObject(service, branchEvent.getBranchGuid());
}
} catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
}
@@ -93,7 +93,7 @@ public final class AccessEventListener implements IBranchEventListener, IAccessC
accessControlCacheHandler.reloadCache(service);
}
} catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderAdmin.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderAdmin.java
new file mode 100644
index 00000000000..948c9c6c1ec
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderAdmin.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.access.IAccessProvider;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.lifecycle.ILifecycleService;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+public class AccessProviderAdmin {
+
+ private final List<IAccessProvider> pendingProviders = new CopyOnWriteArrayList<IAccessProvider>();
+
+ private ILifecycleService lifecycleService;
+
+ public void setLifecycleService(ILifecycleService service) {
+ this.lifecycleService = service;
+ }
+
+ public void addAccessProvider(IAccessProvider accessProvider) {
+ if (isReady()) {
+ register(accessProvider);
+ } else {
+ pendingProviders.add(accessProvider);
+ }
+ }
+
+ public void removeAccessProvider(IAccessProvider accessProvider) {
+ if (isReady()) {
+ deregister(accessProvider);
+ } else {
+ pendingProviders.remove(accessProvider);
+ }
+ }
+
+ public void start() {
+ for (IAccessProvider provider : pendingProviders) {
+ register(provider);
+ }
+ }
+
+ public void stop() {
+ for (IAccessProvider provider : pendingProviders) {
+ deregister(provider);
+ }
+ }
+
+ private boolean isReady() {
+ return lifecycleService != null;
+ }
+
+ private void register(IAccessProvider accessProvider) {
+ try {
+ lifecycleService.addHandler(AccessProviderVisitor.TYPE, accessProvider);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
+ }
+ }
+
+ private void deregister(IAccessProvider accessProvider) {
+ try {
+ lifecycleService.removeHandler(AccessProviderVisitor.TYPE, accessProvider);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderVisitor.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderVisitor.java
index 37b79ffe5b5..e513c96e743 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderVisitor.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderVisitor.java
@@ -49,7 +49,7 @@ public class AccessProviderVisitor extends AbstractLifecycleVisitor<IAccessProvi
try {
accessProvider.computeAccess(userArtifact, artsToCheck, mainAccessData);
} catch (OseeCoreException ex) {
- status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error during access control computation", ex);
+ status = new Status(IStatus.ERROR, AccessControlHelper.PLUGIN_ID, "Error during access control computation", ex);
}
return status;
}
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/Activator.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/Activator.java
deleted file mode 100644
index 8b9b8c793d3..00000000000
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/Activator.java
+++ /dev/null
@@ -1,52 +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.ArrayList;
-import java.util.Collection;
-import org.eclipse.osee.framework.access.internal.cm.CmAccessProviderRegistrationHandler;
-import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class Activator implements BundleActivator {
-
- public static final String PLUGIN_ID = "org.eclipse.osee.framework.access";
-
- private static AccessControlServiceRegHandler handler;
-
- private final Collection<ServiceDependencyTracker> trackers = new ArrayList<ServiceDependencyTracker>();
-
- @Override
- public void start(BundleContext context) throws Exception {
- handler = new AccessControlServiceRegHandler();
- trackers.add(new ServiceDependencyTracker(context, handler));
- trackers.add(new ServiceDependencyTracker(context, new ObjectAccessProviderRegistrationHandler()));
- trackers.add(new ServiceDependencyTracker(context, new CmAccessProviderRegistrationHandler()));
- for (ServiceDependencyTracker tracker : trackers) {
- tracker.open();
- }
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- for (ServiceDependencyTracker tracker : trackers) {
- Lib.close(tracker);
- }
- }
-
- @Deprecated
- public static AccessControlService getAccessControlService() {
- return handler.getService();
- }
-
-}
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
new file mode 100644
index 00000000000..76f11701450
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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 java.util.logging.Level;
+import org.eclipse.osee.framework.access.IAccessProvider;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.access.AccessData;
+import org.eclipse.osee.framework.core.services.IAccessControlService;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+public final class ObjectAccessProviderProxy implements IAccessProvider {
+
+ private IAccessProvider accessProvider;
+ private IAccessControlService accessControlService;
+
+ public void setAccessControlService(IAccessControlService accessControlService) {
+ this.accessControlService = accessControlService;
+ }
+
+ public void start() {
+ if (accessControlService instanceof AccessControlServiceProxy) {
+ AccessControlServiceProxy proxy = (AccessControlServiceProxy) accessControlService;
+ accessProvider = new ObjectAccessProvider(proxy.getProxiedObject());
+ } else {
+ OseeLog.log(AccessControlHelper.class, Level.SEVERE, "Error initializing ObjectAccessProvider");
+ }
+ }
+
+ public void stop() {
+ accessProvider = null;
+ }
+
+ public IAccessProvider getAccessProvider() {
+ return accessProvider;
+ }
+
+ private void checkInitialized() throws OseeCoreException {
+ Conditions.checkNotNull(getAccessProvider(), "object access provider",
+ "Object Access Provider not properly initialized");
+ }
+
+ @Override
+ public void computeAccess(IBasicArtifact<?> userArtifact, Collection<?> objToCheck, AccessData accessData) throws OseeCoreException {
+ checkInitialized();
+ getAccessProvider().computeAccess(userArtifact, objToCheck, accessData);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderRegistrationHandler.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderRegistrationHandler.java
deleted file mode 100644
index 7fc87c0ed6d..00000000000
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderRegistrationHandler.java
+++ /dev/null
@@ -1,58 +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.Map;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.access.IAccessProvider;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.services.IAccessControlService;
-import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
-import org.eclipse.osee.framework.lifecycle.ILifecycleService;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.osgi.framework.BundleContext;
-
-public final class ObjectAccessProviderRegistrationHandler extends AbstractTrackingHandler {
-
- private static final Class<?>[] DEPENDENCIES = new Class[] {IAccessControlService.class, ILifecycleService.class};
-
- private IAccessProvider accessProvider;
- private ILifecycleService service;
-
- @Override
- public Class<?>[] getDependencies() {
- return DEPENDENCIES;
- }
-
- @Override
- public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
- service = (ILifecycleService) services.get(ILifecycleService.class);
- IAccessControlService accessService = (IAccessControlService) services.get(IAccessControlService.class);
- try {
- // TODO remove specific access control service cast
- accessProvider = new ObjectAccessProvider((AccessControlService) accessService);
- service.addHandler(AccessProviderVisitor.TYPE, accessProvider);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
-
- @Override
- public void onDeActivate() {
- if (accessProvider != null) {
- try {
- service.removeHandler(AccessProviderVisitor.TYPE, accessProvider);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java
new file mode 100644
index 00000000000..c2d68cdd46e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.cm;
+
+import java.util.Collection;
+import java.util.concurrent.CopyOnWriteArraySet;
+import org.eclipse.osee.framework.access.IAccessProvider;
+import org.eclipse.osee.framework.access.internal.AccessControlServiceProxy;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IBasicArtifact;
+import org.eclipse.osee.framework.core.model.access.AccessData;
+import org.eclipse.osee.framework.core.services.CmAccessControl;
+import org.eclipse.osee.framework.core.services.CmAccessControlProvider;
+import org.eclipse.osee.framework.core.services.IAccessControlService;
+import org.eclipse.osee.framework.core.util.Conditions;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class CmAccessProviderProxy implements IAccessProvider {
+
+ private final Collection<CmAccessControl> cmServices = new CopyOnWriteArraySet<CmAccessControl>();
+ private IAccessProvider accessProvider;
+ private IAccessControlService accessControlService;
+
+ public void setAccessControlService(IAccessControlService accessControlService) {
+ this.accessControlService = accessControlService;
+ }
+
+ public void addCmAccessControl(CmAccessControl cmAccessControl) {
+ cmServices.add(cmAccessControl);
+ refreshCache();
+ }
+
+ public void removeCmAccessControl(CmAccessControl cmAccessControl) {
+ cmServices.remove(cmAccessControl);
+ refreshCache();
+ }
+
+ public void start() {
+ CmAccessControlProvider cmProvider = new CmAccessControlProviderImpl(cmServices);
+ accessProvider = new CmAccessProvider(cmProvider);
+ }
+
+ public void stop() {
+ accessProvider = null;
+ cmServices.clear();
+ }
+
+ public void refreshCache() {
+ if (accessControlService instanceof AccessControlServiceProxy) {
+ ((AccessControlServiceProxy) accessControlService).clearCache();
+ }
+ }
+
+ public IAccessProvider getAccessProvider() {
+ return accessProvider;
+ }
+
+ private void checkInitialized() throws OseeCoreException {
+ Conditions.checkNotNull(getAccessProvider(), "object access provider",
+ "Object Access Provider not properly initialized");
+ }
+
+ @Override
+ public void computeAccess(IBasicArtifact<?> userArtifact, Collection<?> objToCheck, AccessData accessData) throws OseeCoreException {
+ checkInitialized();
+ getAccessProvider().computeAccess(userArtifact, objToCheck, accessData);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderRegistrationHandler.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderRegistrationHandler.java
deleted file mode 100644
index 7caca9ca9c2..00000000000
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderRegistrationHandler.java
+++ /dev/null
@@ -1,92 +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.cm;
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.access.IAccessProvider;
-import org.eclipse.osee.framework.access.internal.AccessProviderVisitor;
-import org.eclipse.osee.framework.access.internal.Activator;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.services.CmAccessControl;
-import org.eclipse.osee.framework.core.services.CmAccessControlProvider;
-import org.eclipse.osee.framework.core.services.IAccessControlService;
-import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
-import org.eclipse.osee.framework.core.util.ServiceBindType;
-import org.eclipse.osee.framework.lifecycle.ILifecycleService;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.osgi.framework.BundleContext;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class CmAccessProviderRegistrationHandler extends AbstractTrackingHandler {
-
- private final Map<Class<?>, ServiceBindType> dependencyMap = new LinkedHashMap<Class<?>, ServiceBindType>();
- private final Collection<CmAccessControl> cmServices = new CopyOnWriteArraySet<CmAccessControl>();
- private IAccessProvider accessProvider;
- private ILifecycleService service;
-
- public CmAccessProviderRegistrationHandler() {
- dependencyMap.put(ILifecycleService.class, ServiceBindType.SINGLETON);
- dependencyMap.put(IAccessControlService.class, ServiceBindType.SINGLETON);
- dependencyMap.put(CmAccessControl.class, ServiceBindType.MANY);
- }
-
- @Override
- public Class<?>[] getDependencies() {
- return null;
- }
-
- @Override
- public Map<Class<?>, ServiceBindType> getConfiguredDependencies() {
- return dependencyMap;
- }
-
- @Override
- public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
- service = getService(ILifecycleService.class, services);
- CmAccessControl cm = getService(CmAccessControl.class, services);
- cmServices.add(cm);
- try {
- CmAccessControlProvider cmProvider = new CmAccessControlProviderImpl(cmServices);
- accessProvider = new CmAccessProvider(cmProvider);
- service.addHandler(AccessProviderVisitor.TYPE, accessProvider);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
-
- @Override
- public void onServiceAdded(BundleContext context, Class<?> clazz, Object service) {
- cmServices.add((CmAccessControl) service);
- }
-
- @Override
- public void onServiceRemoved(BundleContext context, Class<?> clazz, Object service) {
- cmServices.remove(service);
- }
-
- @Override
- public void onDeActivate() {
- cmServices.clear();
- if (accessProvider != null) {
- try {
- service.removeHandler(AccessProviderVisitor.TYPE, accessProvider);
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- }
-} \ No newline at end of file

Back to the top