diff --git a/features/org.eclipse.osee.core.server.external.feature/feature.xml b/features/org.eclipse.osee.core.server.external.feature/feature.xml index 0eb95c6d0c..683b9d4a63 100644 --- a/features/org.eclipse.osee.core.server.external.feature/feature.xml +++ b/features/org.eclipse.osee.core.server.external.feature/feature.xml @@ -1076,20 +1076,6 @@ version="0.0.0" unpack="false"/> - - - - - - - - - - - - - - - - - @@ -58,7 +57,6 @@ - @@ -70,7 +68,6 @@ - @@ -140,18 +137,4 @@ version="0.0.0" unpack="false"/> - - - - diff --git a/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF index 1875dc5b13..4a5c885fc2 100644 --- a/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF @@ -66,11 +66,14 @@ Import-Package: com.fasterxml.jackson.annotation, org.eclipse.nebula.widgets.xviewer.core.model, org.eclipse.osee.activity.api, org.eclipse.osee.framework.core, + org.eclipse.osee.framework.core.access, + org.eclipse.osee.framework.core.access.context, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.enums.token, org.eclipse.osee.framework.core.event, org.eclipse.osee.framework.core.model, + org.eclipse.osee.framework.core.model.access, org.eclipse.osee.framework.core.model.change, org.eclipse.osee.framework.core.util, org.eclipse.osee.framework.core.util.result, diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/AtsApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/AtsApi.java index 5cb4cdfd1b..f1cd52214c 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/AtsApi.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/AtsApi.java @@ -15,6 +15,7 @@ package org.eclipse.osee.ats.api; import java.util.Collection; import java.util.List; +import org.eclipse.osee.ats.api.access.IAtsAccessService; import org.eclipse.osee.ats.api.agile.IAgileService; import org.eclipse.osee.ats.api.agile.IAgileSprintHtmlOperation; import org.eclipse.osee.ats.api.ai.IAtsActionableItemService; @@ -56,6 +57,7 @@ import org.eclipse.osee.ats.api.workflow.log.IAtsLogFactory; import org.eclipse.osee.ats.api.workflow.state.IAtsStateFactory; import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory; import org.eclipse.osee.framework.core.OseeApi; +import org.eclipse.osee.framework.core.access.IAccessControlService; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; @@ -200,6 +202,11 @@ public interface AtsApi extends OseeApi, IAtsEarnedValueServiceProvider, IAtsWor IAtsServerEndpointProvider getServerEndpoints(); + IAtsAccessService getAtsAccessService(); + + @Override + IAccessControlService getAccessControlService(); + default void reloadServerAndClientCaches() { getServerEndpoints().getConfigEndpoint().getWithPend(); getConfigService().getConfigurationsWithPend(); diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/access/AtsAccessContextTokens.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/access/AtsAccessContextTokens.java index 9ea5544367..598b2b9962 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/access/AtsAccessContextTokens.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/access/AtsAccessContextTokens.java @@ -20,8 +20,8 @@ import org.eclipse.osee.framework.core.data.AccessContextToken; */ public final class AtsAccessContextTokens { - public static final AccessContextToken DENY_CONTEXT = - AccessContextToken.valueOf(4870045005030602805L, "ats.branchobject.deny"); + public static final AccessContextToken ATS_BRANCH_READ = + AccessContextToken.valueOf(4870045005030602805L, "ats.branch.read"); private AtsAccessContextTokens() { // Branch Object Contexts; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/tx/IAtsConfigTxActionableItem.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/tx/IAtsConfigTxActionableItem.java index 8ed5867c63..94151a1d4c 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/tx/IAtsConfigTxActionableItem.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/tx/IAtsConfigTxActionableItem.java @@ -16,6 +16,7 @@ package org.eclipse.osee.ats.api.config.tx; import org.eclipse.osee.ats.api.ai.IAtsActionableItem; import org.eclipse.osee.ats.api.config.Csci; import org.eclipse.osee.ats.api.config.WorkType; +import org.eclipse.osee.framework.core.data.AccessContextToken; import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.core.data.AccessContextToken; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/tx/IAtsConfigTxTeamDef.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/tx/IAtsConfigTxTeamDef.java index 7c0430c899..228dd6fe43 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/tx/IAtsConfigTxTeamDef.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/tx/IAtsConfigTxTeamDef.java @@ -20,6 +20,7 @@ import org.eclipse.osee.ats.api.query.NextRelease; import org.eclipse.osee.ats.api.query.ReleasedOption; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; import org.eclipse.osee.ats.api.version.IAtsVersion; +import org.eclipse.osee.framework.core.data.AccessContextToken; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.core.data.AccessContextToken; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsUserGroups.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsUserGroups.java index 477883d8ed..b69ccc26f3 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsUserGroups.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsUserGroups.java @@ -22,8 +22,8 @@ import org.eclipse.osee.framework.core.data.UserGroupArtifactToken; public class AtsUserGroups { public static IUserGroupArtifactToken AtsAddAttrColumns = - UserGroupArtifactToken.valueOf(10847751L, "AtsAddAttrColumns"); - public static IUserGroupArtifactToken AtsAdmin = UserGroupArtifactToken.valueOf(136750L, "AtsAdmin"); - public static IUserGroupArtifactToken AtsTempAdmin = UserGroupArtifactToken.valueOf(5367074L, "AtsTempAdmin"); + UserGroupArtifactToken.valueOf(10847751L, "Ats Add Attr Columns"); + public static IUserGroupArtifactToken AtsAdmin = UserGroupArtifactToken.valueOf(136750L, "Ats Admin"); + public static IUserGroupArtifactToken AtsTempAdmin = UserGroupArtifactToken.valueOf(5367074L, "AtsTemp Admin"); } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/demo/DemoArtifactToken.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/demo/DemoArtifactToken.java index e590012b0a..8b7e88dd22 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/demo/DemoArtifactToken.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/demo/DemoArtifactToken.java @@ -43,6 +43,17 @@ public final class DemoArtifactToken { public static final ArtifactToken SystemReqArtifact = ArtifactToken.valueOf(45454545, "System Req Artifact", DemoBranches.SAW_Bld_1, CoreArtifactTypes.SystemRequirementMsWord); public static final ArtifactToken EventsSwReq = ArtifactToken.valueOf(200090, "Events", DemoBranches.SAW_Bld_1, CoreArtifactTypes.SoftwareRequirementMsWord); + ////////////////////////////////// + // Software Requirements + ////////////////////////////////// + public static final ArtifactToken CollaborativeRobotEvents = ArtifactToken.valueOf(200092, "Collaborative robot events", DemoBranches.SAW_Bld_2); + public static final ArtifactToken VirtualFixes = ArtifactToken.valueOf(200095, "VirtualFixes", DemoBranches.SAW_PL_Access_Baseline_Test); + + ////////////////////////////////// + // System Requirements + ////////////////////////////////// + public static final ArtifactToken PerformanceRequirements = ArtifactToken.valueOf(200112, "Performance Requirements", DemoBranches.SAW_Bld_2); + ////////////////////////////////// // Impl Details Configuration ////////////////////////////////// @@ -154,6 +165,10 @@ public final class DemoArtifactToken { public static final ArtifactToken SAW_NoBranch_Req_TeamWf = ArtifactToken.valueOf(5564873, DemoWorkflowTitles.SAW_NO_BRANCH_REQT_CHANGES_FOR_DIAGRAM_VIEW, COMMON, AtsDemoOseeTypes.DemoReqTeamWorkflow); public static final ArtifactToken SAW_NoBranch_Test_TeamWf = ArtifactToken.valueOf(11548766, DemoWorkflowTitles.SAW_NO_BRANCH_REQT_CHANGES_FOR_DIAGRAM_VIEW, COMMON, AtsDemoOseeTypes.DemoTestTeamWorkflow); + public static final ArtifactToken SAW_Access_Control_Req_TeamWf = ArtifactToken.valueOf(32482, "SAW Access Ctrl Test - Req", AtsDemoOseeTypes.DemoReqTeamWorkflow); + public static final ArtifactToken SAW_Access_Control_Code_TeamWf = ArtifactToken.valueOf(32483, "SAW Access Ctrl Test - Code", AtsDemoOseeTypes.DemoCodeTeamWorkflow); + public static final ArtifactToken SAW_Access_Control_Test_TeamWf = ArtifactToken.valueOf(32484, "SAW Access Ctrl Test - Test", AtsDemoOseeTypes.DemoTestTeamWorkflow); + ////////////////////////////////// // RD Agile Configuration ////////////////////////////////// diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/IRelationResolver.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/IRelationResolver.java index d8f64f4ff0..0756cd4007 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/IRelationResolver.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/IRelationResolver.java @@ -17,6 +17,7 @@ import java.util.Collection; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.osee.ats.api.IAtsObject; import org.eclipse.osee.ats.api.IAtsWorkItem; +import org.eclipse.osee.framework.core.access.context.IParentProvider; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; @@ -27,7 +28,7 @@ import org.eclipse.osee.framework.core.enums.DeletionFlag; /** * @author Donald G. Dunne */ -public interface IRelationResolver { +public interface IRelationResolver extends IParentProvider { Collection getRelated(ArtifactId artifact, RelationTypeSide relationType); @@ -68,8 +69,6 @@ public interface IRelationResolver { Collection getChildren(ArtifactId artifact); - ArtifactToken getParent(ArtifactId artifact); - int getRelatedCount(ArtifactToken artifact, RelationTypeSide relationTypeSide); Collection getRelatedIds(ArtifactId artifact, RelationTypeSide relationTypeSide); diff --git a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF index 9c7b174179..88b8532604 100644 --- a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF @@ -39,6 +39,7 @@ Import-Package: com.fasterxml.jackson.annotation, org.osgi.service.event Bundle-Vendor: Eclipse Open System Engineering Environment Export-Package: org.eclipse.osee.ats.core.access, + org.eclipse.osee.ats.core.access.demo, org.eclipse.osee.ats.core.agile, org.eclipse.osee.ats.core.agile.operations, org.eclipse.osee.ats.core.ai, diff --git a/plugins/org.eclipse.osee.ats.core/OSGI-INF/artifact.check.provider.task.autogen.xml b/plugins/org.eclipse.osee.ats.core/OSGI-INF/artifact.check.provider.task.autogen.xml deleted file mode 100644 index b299df7545..0000000000 --- a/plugins/org.eclipse.osee.ats.core/OSGI-INF/artifact.check.provider.task.autogen.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/plugins/org.eclipse.osee.ats.core/OSGI-INF/artifact.check.provider.xml b/plugins/org.eclipse.osee.ats.core/OSGI-INF/artifact.check.provider.xml deleted file mode 100644 index 726d59dea4..0000000000 --- a/plugins/org.eclipse.osee.ats.core/OSGI-INF/artifact.check.provider.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/tx/AtsConfigTxTeamDef.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/tx/AtsConfigTxTeamDef.java index 60b66ba11b..0e8a922487 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/tx/AtsConfigTxTeamDef.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/tx/AtsConfigTxTeamDef.java @@ -35,6 +35,7 @@ import org.eclipse.osee.ats.api.query.ReleasedOption; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; import org.eclipse.osee.ats.api.util.IAtsChangeSet; import org.eclipse.osee.ats.api.version.IAtsVersion; +import org.eclipse.osee.framework.core.data.AccessContextToken; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.AccessContextToken; import org.eclipse.osee.framework.core.data.BranchToken; diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java index 67af55270a..5fb1a5a78d 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java @@ -32,6 +32,7 @@ import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow; import org.eclipse.osee.ats.core.util.AtsRelationChange.RelationOperation; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; +import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.AttributeTypeGeneric; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.RelationTypeSide; @@ -180,6 +181,11 @@ public abstract class AbstractAtsChangeSet implements IAtsChangeSet { @Override public ArtifactToken createArtifact(ArtifactToken token) { + ArtifactTypeToken typeToken = token.getArtifactType(); + if (typeToken.isInvalid()) { + throw new OseeArgumentException("Artifact Type Token %s is invalid for artifact creation", + typeToken.toStringWithId()); + } return createArtifact(token.getArtifactType(), token.getName(), token.getId()); } diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsApiImpl.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsApiImpl.java index bfb1b6b0bd..b8435ba257 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsApiImpl.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsApiImpl.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.logging.Level; import org.eclipse.osee.ats.api.AtsApi; import org.eclipse.osee.ats.api.IAtsObject; +import org.eclipse.osee.ats.api.access.IAtsAccessService; import org.eclipse.osee.ats.api.agile.IAgileSprintHtmlOperation; import org.eclipse.osee.ats.api.ai.IAtsActionableItemService; import org.eclipse.osee.ats.api.column.IAtsColumnService; @@ -59,6 +60,7 @@ import org.eclipse.osee.ats.api.workflow.ITeamWorkflowProvidersLazy; import org.eclipse.osee.ats.api.workflow.log.IAtsLogFactory; import org.eclipse.osee.ats.api.workflow.state.IAtsStateFactory; import org.eclipse.osee.ats.api.workflow.state.IAtsWorkStateFactory; +import org.eclipse.osee.ats.core.access.AtsAccessService; import org.eclipse.osee.ats.core.config.TeamDefinitionServiceImpl; import org.eclipse.osee.ats.core.internal.column.ev.AtsColumnService; import org.eclipse.osee.ats.core.internal.log.AtsLogFactory; @@ -131,6 +133,7 @@ public abstract class AtsApiImpl extends OseeApiBase implements AtsApi { protected IAtsTaskSetDefinitionProviderService taskSetDefinitionProviderService; protected IAtsNotificationService notificationService; protected List attributeFactoryProviders = new LinkedList<>(); + protected IAtsAccessService atsAccessService; Collection agileSprintHtmlReportOperations = new LinkedList<>(); @@ -588,4 +591,12 @@ public abstract class AtsApiImpl extends OseeApiBase implements AtsApi { return notificationService; } + @Override + public IAtsAccessService getAtsAccessService() { + if (atsAccessService == null) { + atsAccessService = new AtsAccessService(this); + } + return atsAccessService; + } + } diff --git a/plugins/org.eclipse.osee.ats.ide.demo/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.ide.demo/META-INF/MANIFEST.MF index 9bfbad256c..abaefc8b42 100644 --- a/plugins/org.eclipse.osee.ats.ide.demo/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.ide.demo/META-INF/MANIFEST.MF @@ -13,6 +13,8 @@ Require-Bundle: org.eclipse.ui, Import-Package: javax.ws.rs.core, org.eclipse.core.filesystem, org.eclipse.osee.ats.api, + org.eclipse.osee.ats.core.access, + org.eclipse.osee.ats.core.access.demo, org.eclipse.osee.ats.core.config, org.eclipse.osee.ats.core.model, org.eclipse.osee.ats.core.model.impl, @@ -43,13 +45,16 @@ Import-Package: javax.ws.rs.core, org.eclipse.osee.client.demo, org.eclipse.osee.define.ide.traceability, org.eclipse.osee.define.ide.traceability.data, - org.eclipse.osee.framework.access, + org.eclipse.osee.framework.core, + org.eclipse.osee.framework.core.access, + org.eclipse.osee.framework.core.access.context, org.eclipse.osee.framework.core.client, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.enums.token, org.eclipse.osee.framework.core.exception, org.eclipse.osee.framework.core.model, + org.eclipse.osee.framework.core.model.access, org.eclipse.osee.framework.core.model.type, org.eclipse.osee.framework.core.operation, org.eclipse.osee.framework.core.util, diff --git a/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/artifact/DemoTeamWorkflows.java b/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/artifact/DemoTeamWorkflows.java index da49ec6343..43015ff8ac 100644 --- a/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/artifact/DemoTeamWorkflows.java +++ b/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/artifact/DemoTeamWorkflows.java @@ -45,8 +45,8 @@ public class DemoTeamWorkflows implements ITeamWorkflowProvider { @Override public String getBranchName(IAtsTeamWorkflow teamWf, String defaultBranchName) { try { - if (teamWf.getTeamDefinition().getName().contains("SAW Test")) { - return "SAW Test - " + defaultBranchName; + if (teamWf.getTeamDefinition().getName().contains("SAW Code")) { + return "SAW Code - " + defaultBranchName; } } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); diff --git a/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/populate/Pdd10SetupAndImportReqs.java b/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/populate/Pdd10SetupAndImportReqs.java index 1d3935e452..edf741ed24 100644 --- a/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/populate/Pdd10SetupAndImportReqs.java +++ b/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/populate/Pdd10SetupAndImportReqs.java @@ -21,12 +21,13 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.logging.Level; +import org.eclipse.osee.ats.api.data.AtsArtifactToken; import org.eclipse.osee.ats.api.demo.DemoArtifactToken; import org.eclipse.osee.ats.ide.demo.config.DemoDbUtil; import org.eclipse.osee.ats.ide.demo.internal.Activator; import org.eclipse.osee.ats.ide.demo.internal.AtsApiService; +import org.eclipse.osee.ats.ide.demo.internal.OseeApiService; import org.eclipse.osee.ats.ide.util.AtsUtilClient; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.BranchId; @@ -37,6 +38,8 @@ import org.eclipse.osee.framework.core.enums.CoreArtifactTokens; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; +import org.eclipse.osee.framework.core.enums.CoreUserGroups; +import org.eclipse.osee.framework.core.enums.DemoBranches; import org.eclipse.osee.framework.core.enums.DemoUsers; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.operation.IOperation; @@ -99,12 +102,35 @@ public class Pdd10SetupAndImportReqs implements IPopulateDemoDatabase { demoDbTraceabilityTx(demoDbTraceability, SAW_Bld_1); demoDbTraceability.execute(); + // Note: SAW_Bld_1 is created during orcs dbinit in CreateDemoBranches + BranchManager.setAssociatedArtifactId(SAW_Bld_1, AtsArtifactToken.AtsCmBranch); + createNewBaselineBranch(SAW_Bld_1, SAW_Bld_2); + BranchManager.setAssociatedArtifactId(SAW_Bld_2, AtsArtifactToken.AtsCmBranch); createNewBaselineBranch(SAW_Bld_2, SAW_Bld_3); + BranchManager.setAssociatedArtifactId(SAW_Bld_3, AtsArtifactToken.AtsCmBranch); + + // Note: CIS_Bld_1 is created during orcs dbinit in CreateDemoBranches + BranchManager.setAssociatedArtifactId(DemoBranches.CIS_Bld_1, AtsArtifactToken.AtsCmBranch); + + // Note: PL branches are created in CreateDemoBranches + BranchManager.setAssociatedArtifactId(DemoBranches.SAW_PL, AtsArtifactToken.AtsCmBranch); + setBaselineAccessControl(DemoBranches.SAW_PL); + + BranchManager.setAssociatedArtifactId(DemoBranches.SAW_PL_Hardening_Branch, AtsArtifactToken.AtsCmBranch); + setBaselineAccessControl(DemoBranches.SAW_PL_Hardening_Branch); configureRequirementsForImplDetails(); } + private void setBaselineAccessControl(BranchToken branch) { + OseeApiService.get().getAccessControlService().removePermissions(branch); + ArtifactToken kayJones = UserManager.getUserByArtId(DemoUsers.Kay_Jones); + OseeApiService.get().getAccessControlService().setPermission(kayJones, branch, PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(CoreUserGroups.Everyone, branch, + PermissionEnum.READ); + } + private void configureRequirementsForImplDetails() { SkynetTransaction transaction = @@ -196,8 +222,8 @@ public class Pdd10SetupAndImportReqs implements IPopulateDemoDatabase { try { childBranch = BranchManager.createBaselineBranch(srcBranch, destBranch); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), childBranch, - PermissionEnum.FULLACCESS); + AtsApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), + childBranch, PermissionEnum.FULLACCESS); // need to update the branch type; ConnectionHandler.runPreparedUpdate(UPDATE_BRANCH_TYPE, BranchType.BASELINE, childBranch); diff --git a/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/populate/Pdd95CreateDemoEVConfigAndWorkPackages.java b/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/populate/Pdd95CreateDemoEVConfigAndWorkPackages.java index 99403ebb12..d0f8b52b27 100644 --- a/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/populate/Pdd95CreateDemoEVConfigAndWorkPackages.java +++ b/plugins/org.eclipse.osee.ats.ide.demo/src/org/eclipse/osee/ats/ide/demo/populate/Pdd95CreateDemoEVConfigAndWorkPackages.java @@ -182,7 +182,7 @@ public class Pdd95CreateDemoEVConfigAndWorkPackages { // create country createCountry(countryEp, country); - // create and relate programs + // create and relate programs; these calls ensure that the static tokens are loaded and thus related to proper parents DemoInsertion.getInsertions(); DemoInsertionActivity.getActivities(); for (DemoProgram program : country.getPrograms()) { diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.ide.integration.tests/META-INF/MANIFEST.MF index 52f3464345..9913462a03 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/META-INF/MANIFEST.MF @@ -29,6 +29,7 @@ Import-Package: com.fasterxml.jackson.core, org.eclipse.nebula.widgets.xviewer.util, org.eclipse.osee.account.rest.model, org.eclipse.osee.ats.core.access, + org.eclipse.osee.ats.core.access.demo, org.eclipse.osee.ats.core.column, org.eclipse.osee.ats.core.config, org.eclipse.osee.ats.core.query, @@ -47,7 +48,6 @@ Import-Package: com.fasterxml.jackson.core, org.eclipse.osee.ats.core.workflow.transition, org.eclipse.osee.ats.core.workflow.util, org.eclipse.osee.ats.ide, - org.eclipse.osee.ats.ide.access, org.eclipse.osee.ats.ide.actions, org.eclipse.osee.ats.ide.actions.wizard, org.eclipse.osee.ats.ide.branch, @@ -91,8 +91,8 @@ Import-Package: com.fasterxml.jackson.core, org.eclipse.osee.ats.ide.world.search, org.eclipse.osee.client.test.framework, org.eclipse.osee.define.api, - org.eclipse.osee.framework.access, org.eclipse.osee.framework.core, + org.eclipse.osee.framework.core.access, org.eclipse.osee.framework.core.client, org.eclipse.osee.framework.core.client.server, org.eclipse.osee.framework.core.data, diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/OSGI-INF/ats.api.ide.ref.xml b/plugins/org.eclipse.osee.ats.ide.integration.tests/OSGI-INF/ats.api.ide.ref.xml deleted file mode 100644 index d55db6c17a..0000000000 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/OSGI-INF/ats.api.ide.ref.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/AtsIdeIntegrationTestSuite.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/AtsIdeIntegrationTestSuite.java index 22d61eb048..239c96015f 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/AtsIdeIntegrationTestSuite.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/AtsIdeIntegrationTestSuite.java @@ -16,6 +16,7 @@ package org.eclipse.osee.ats.ide.integration; import org.eclipse.osee.ats.ide.integration.tests.AtsTest_AllAts_Suite; import org.eclipse.osee.ats.ide.integration.tests.DemoDbPopulateSuite; import org.eclipse.osee.ats.ide.integration.tests.DirtyArtifactCacheTest; +import org.eclipse.osee.ats.ide.integration.tests.framework.access.FrameworkAccess_Suite; import org.eclipse.osee.ats.ide.integration.tests.framework.skynet.core.artifact.SkyentCoreArtifact_Suite; import org.eclipse.osee.ats.ide.integration.tests.framework.ui.skynet.FrameworkUiSkynetTest_Suite; import org.eclipse.osee.ats.ide.integration.tests.framework.ui.skynet.dialog.FrameworkUiSkynetTest_Dialog_Suite; @@ -36,6 +37,7 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ DbInitTest.class, DemoDbPopulateSuite.class, + FrameworkAccess_Suite.class, SkyentCoreArtifact_Suite.class, AtsTest_AllAts_Suite.class, FrameworkUiSkynetTest_Suite.class, diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/access/AtsBranchAccessManagerTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/access/AtsBranchAccessManagerTest.java index 410e18014d..26e64990b6 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/access/AtsBranchAccessManagerTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/access/AtsBranchAccessManagerTest.java @@ -14,24 +14,26 @@ package org.eclipse.osee.ats.ide.integration.tests.ats.access; import static org.eclipse.osee.framework.core.enums.DemoBranches.SAW_Bld_1; -import java.util.Arrays; import java.util.Collection; -import org.eclipse.osee.ats.api.data.AtsRelationTypes; -import org.eclipse.osee.ats.api.demo.DemoActionableItems; +import org.eclipse.osee.ats.api.access.AtsAccessContextTokens; +import org.eclipse.osee.ats.api.access.IAtsAccessService; +import org.eclipse.osee.ats.api.ai.IAtsActionableItem; +import org.eclipse.osee.ats.api.demo.DemoArtifactToken; import org.eclipse.osee.ats.api.demo.DemoWorkType; -import org.eclipse.osee.ats.ide.access.AtsBranchAccessManager; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.ats.api.util.IAtsChangeSet; +import org.eclipse.osee.ats.api.version.IAtsVersion; +import org.eclipse.osee.ats.core.access.AtsAccessService; +import org.eclipse.osee.ats.core.access.demo.DemoAtsAccessContextTokens; +import org.eclipse.osee.ats.ide.demo.DemoUtil; import org.eclipse.osee.ats.ide.integration.tests.AtsApiService; import org.eclipse.osee.ats.ide.integration.tests.util.DemoTestUtil; import org.eclipse.osee.ats.ide.workflow.teamwf.TeamWorkFlowArtifact; -import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.AccessContextToken; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; -import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; /** @@ -41,7 +43,7 @@ public class AtsBranchAccessManagerTest { @Test public void testIsApplicable() { - AtsBranchAccessManager mgr = new AtsBranchAccessManager(); + AtsAccessService mgr = new AtsAccessService(AtsApiService.get()); Assert.assertFalse(mgr.isApplicable(AtsApiService.get().getAtsBranch())); Assert.assertFalse(mgr.isApplicable(SAW_Bld_1)); @@ -55,94 +57,63 @@ public class AtsBranchAccessManagerTest { Assert.assertTrue(mgr.isApplicable(branch)); } - @Before - @After - public void cleanup() { - TeamWorkFlowArtifact teamArt = - (TeamWorkFlowArtifact) DemoTestUtil.getUncommittedActionWorkflow(DemoWorkType.Requirements); - SkynetTransaction transaction = TransactionManager.createTransaction(AtsApiService.get().getAtsBranch(), - "testGetContextIdArtifact cleanup"); - Artifact teamDefArt = AtsApiService.get().getQueryServiceIde().getArtifact(teamArt.getTeamDefinition()); - teamDefArt.deleteAttributes(CoreAttributeTypes.AccessContextId); - teamDefArt.persist(transaction); - for (Artifact art : teamDefArt.getRelatedArtifacts(AtsRelationTypes.TeamActionableItem_ActionableItem)) { - art.deleteAttributes(CoreAttributeTypes.AccessContextId); - art.persist(transaction); - } - teamArt.deleteAttributes(CoreAttributeTypes.AccessContextId); - teamArt.persist(transaction); - transaction.execute(); - } - - /** - * Test method for - * {@link org.eclipse.osee.ats.ide.access.AtsBranchAccessManager#getContextId(org.eclipse.osee.framework.skynet.core.artifact.Artifact)} - * {@link org.eclipse.osee.ats.ide.access.AtsBranchAccessManager#getEventFilters()}. - * {@link org.eclipse.osee.ats.ide.access.AtsBranchAccessManager#handleArtifactEvent(org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent, org.eclipse.osee.framework.skynet.core.event.model.Sender)} - */ @Test - public void testGetContextIdBranch() throws Exception { - AtsBranchAccessManager mgr = new AtsBranchAccessManager(); - TeamWorkFlowArtifact teamArt = - (TeamWorkFlowArtifact) DemoTestUtil.getUncommittedActionWorkflow(DemoWorkType.Requirements); - - // confirm that no context id returned - Assert.assertEquals(0, mgr.getContextId(teamArt.getWorkingBranch(), false).size()); - - String teamDefContextId1 = "1234"; - String teamDefContextId2 = "2345"; - Artifact teamDefArt = AtsApiService.get().getQueryServiceIde().getArtifact(teamArt.getTeamDefinition()); - teamDefArt.setAttributeValues(CoreAttributeTypes.AccessContextId, - Arrays.asList(teamDefContextId1, teamDefContextId2)); - teamDefArt.persist(getClass().getSimpleName()); - - Assert.assertEquals(2, mgr.getContextId(teamArt.getWorkingBranch(), false).size()); - - String aiContextId = "6789"; - Artifact aiArt = AtsApiService.get().getQueryServiceIde().getArtifact( - AtsApiService.get().getActionableItemService().getActionableItems( - Arrays.asList(DemoActionableItems.SAW_Requirements.getName())).iterator().next()); - aiArt.setAttributeValues(CoreAttributeTypes.AccessContextId, Arrays.asList(aiContextId)); - aiArt.persist(getClass().getSimpleName()); + public void testGetContextIds() throws Exception { + IAtsAccessService accessService = AtsApiService.get().getAtsAccessService(); + TeamWorkFlowArtifact teamArt = DemoUtil.getButtonWDoesntWorkOnSituationPageWf(); + IAtsTeamDefinition teamDef = teamArt.getTeamDefinition(); + IAtsActionableItem ai = teamArt.getActionableItems().iterator().next(); + + // confirm that deny context id is returned cause no branch + Collection contextIds = accessService.getContextIds(teamArt.getWorkingBranch(), false); + Assert.assertEquals(1, contextIds.size()); + Assert.assertTrue(contextIds.contains(AtsAccessContextTokens.ATS_BRANCH_READ)); + + // create branch + IAtsChangeSet changes = AtsApiService.get().createChangeSet(getClass().getSimpleName() + " - set target ver"); + IAtsVersion ver = AtsApiService.get().getVersionService().getVersionById(DemoArtifactToken.CIS_Bld_1); + AtsApiService.get().getVersionService().setTargetedVersion(teamArt, ver, changes); + changes.execute(); + AtsApiService.get().getBranchServiceIde().createWorkingBranch_Create(teamArt, true); + + // confirm 0 contexts + contextIds = accessService.getContextIds(teamArt.getWorkingBranch(), false); + Assert.assertEquals(0, contextIds.size()); + + // set 2 on team def + AtsApiService.get().getAtsAccessService().setContextIds(teamDef, DemoAtsAccessContextTokens.DEMO_CODE_CONTEXT, + DemoAtsAccessContextTokens.DEMO_TEST_CONTEXT); + + // 2 returned + contextIds = accessService.getContextIds(teamArt.getWorkingBranch(), false); + Assert.assertEquals(2, contextIds.size()); + Assert.assertTrue(contextIds.contains(DemoAtsAccessContextTokens.DEMO_CODE_CONTEXT)); + Assert.assertTrue(contextIds.contains(DemoAtsAccessContextTokens.DEMO_TEST_CONTEXT)); + + // set 1 on ai + AtsApiService.get().getAtsAccessService().setContextIds(ai, DemoAtsAccessContextTokens.DEMO_SYSTEMS_CONTEXT); + + // only 1 cause AI overrides Team Def + contextIds = accessService.getContextIds(teamArt.getWorkingBranch(), false); + Assert.assertEquals(1, contextIds.size()); + Assert.assertTrue(contextIds.contains(DemoAtsAccessContextTokens.DEMO_SYSTEMS_CONTEXT)); - Assert.assertEquals(1, mgr.getContextId(teamArt.getWorkingBranch(), false).size()); + // set 1 on workflow + AtsApiService.get().getAtsAccessService().setContextIds(teamArt, + DemoAtsAccessContextTokens.DEMO_REQUIREMENT_CONTEXT); - String teamContextId1 = "1234"; - String teamContextId2 = "2345"; - String teamContextId3 = "3456"; - teamArt.setAttributeValues(CoreAttributeTypes.AccessContextId, - Arrays.asList(teamContextId1, teamContextId2, teamContextId3)); - teamArt.persist(getClass().getSimpleName()); + // only 1 cause workflow overrides AI and Team Def + contextIds = accessService.getContextIds(teamArt.getWorkingBranch(), false); + Assert.assertEquals(1, contextIds.size()); + Assert.assertTrue(contextIds.contains(DemoAtsAccessContextTokens.DEMO_REQUIREMENT_CONTEXT)); - AtsApiService.get().clearCaches(); + // cleanup + changes = AtsApiService.get().createChangeSet(getClass().getSimpleName() + " - cleanup"); + changes.deleteAttributes((ArtifactId) teamArt, CoreAttributeTypes.AccessContextId); + changes.deleteAttributes(teamDef, CoreAttributeTypes.AccessContextId); + changes.deleteAttributes(ai, CoreAttributeTypes.AccessContextId); + changes.execute(); - Assert.assertEquals(3, mgr.getContextId(teamArt.getWorkingBranch(), false).size()); } - /** - * Test method for { - * - * @param useCache TODO@link org.eclipse.osee.ats.ide.access.AtsBranchAccessManager#convertAccessAttributeToGuid - */ - @Test - public void testConvertAccessAttributeToGuid() throws Exception { - AtsBranchAccessManager mgr = new AtsBranchAccessManager(); - TeamWorkFlowArtifact teamArt = - (TeamWorkFlowArtifact) DemoTestUtil.getUncommittedActionWorkflow(DemoWorkType.Requirements); - - // confirm that no context id returned - Assert.assertEquals(0, mgr.getContextId(teamArt.getWorkingBranch()).size()); - - String teamDefContextId1 = "16546, this is the name"; - Artifact teamDefArt = AtsApiService.get().getQueryServiceIde().getArtifact(teamArt.getTeamDefinition()); - teamDefArt.setAttributeValues(CoreAttributeTypes.AccessContextId, Arrays.asList(teamDefContextId1)); - teamDefArt.persist(getClass().getSimpleName()); - - mgr.clearCache(); - - Collection contextIds = mgr.getContextId(teamArt.getWorkingBranch()); - Assert.assertEquals(1, contextIds.size()); - AccessContextToken contextId = contextIds.iterator().next(); - Assert.assertEquals(Long.valueOf(16546), contextId.getId()); - } } diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/access/UserGroupImplTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/access/UserGroupImplTest.java index 3d530e383e..e46a689d96 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/access/UserGroupImplTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/access/UserGroupImplTest.java @@ -27,7 +27,7 @@ public class UserGroupImplTest { @Test public void test() { - // Joe Smith is no admin by default, but is temp admin + // Joe Smith is not admin by default, but is temp admin Assert.assertFalse(UserGroupService.get(AtsUserGroups.AtsAdmin).isCurrentUserMember()); Assert.assertTrue(UserGroupService.get(AtsUserGroups.AtsTempAdmin).isCurrentUserMember()); } diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/config/ActionableItemResourceTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/config/ActionableItemResourceTest.java index 1f1b041ec4..4dec693a37 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/config/ActionableItemResourceTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/config/ActionableItemResourceTest.java @@ -33,12 +33,12 @@ public class ActionableItemResourceTest extends AbstractRestTest { @Test public void testAtsAisRestCall() { - testActionableItemUrl("/ats/ai", 68, false); + testActionableItemUrl("/ats/ai", 70, false); } @Test public void testAtsAisDetailsRestCall() { - testActionableItemUrl("/ats/ai/details", 68, true); + testActionableItemUrl("/ats/ai/details", 70, true); } @Test diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/config/TeamResourceTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/config/TeamResourceTest.java index f1b20480f7..53fe7c96fa 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/config/TeamResourceTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/config/TeamResourceTest.java @@ -33,13 +33,13 @@ public class TeamResourceTest extends AbstractRestTest { @Test public void testAtsTeamsRestCall() { - JsonNode team = testTeamUrl("/ats/team", 25, false); + JsonNode team = testTeamUrl("/ats/team", 27, false); Assert.assertFalse(team.has("version")); } @Test public void testAtsTeamsDetailsRestCall() { - JsonNode team = testTeamUrl("/ats/team/details", 25, true); + JsonNode team = testTeamUrl("/ats/team/details", 27, true); Assert.assertEquals(3, team.get("version").size()); } diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/resource/AtsActionEndpointImplTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/resource/AtsActionEndpointImplTest.java index ee827d37aa..b738594cae 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/resource/AtsActionEndpointImplTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/resource/AtsActionEndpointImplTest.java @@ -93,7 +93,7 @@ public class AtsActionEndpointImplTest extends AbstractRestTest { "Title", "SAW"// ); - getFirstAndCount(target, 3); + getFirstAndCount(target, 4); } @Test @@ -113,7 +113,7 @@ public class AtsActionEndpointImplTest extends AbstractRestTest { "Team", codeWfId, // "StateType", StateType.Working.name()// ); - getAndCountWorkItems(target, 4); + getAndCountWorkItems(target, 5); } @Test @@ -122,7 +122,7 @@ public class AtsActionEndpointImplTest extends AbstractRestTest { "Team", codeWfId, // "Assignee", "4444", // "Assignee", "3333"); - getAndCountWorkItems(target, 4); + getAndCountWorkItems(target, 5); } @Test @@ -131,13 +131,13 @@ public class AtsActionEndpointImplTest extends AbstractRestTest { "Team", codeWfId, // "Originator", "3333" // ); - getAndCountWorkItems(target, 4); + getAndCountWorkItems(target, 5); } @Test public void testQueryTeam() { WebTarget target = createWebTarget("Team", codeWfId); - getFirstAndCount(target, 4); + getFirstAndCount(target, 5); } @Test @@ -148,7 +148,7 @@ public class AtsActionEndpointImplTest extends AbstractRestTest { "Priority", "3", // "StateType", StateType.Working.name() // ); - getFirstAndCount(target, 2); + getFirstAndCount(target, 3); } public TeamWorkFlowArtifact getCodeWorkflow() { diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/resource/AtsProductLineEndpointTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/resource/AtsProductLineEndpointTest.java index c5ec9ae52d..edc3a93b5d 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/resource/AtsProductLineEndpointTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/resource/AtsProductLineEndpointTest.java @@ -34,7 +34,7 @@ public class AtsProductLineEndpointTest extends AbstractRestTest { String path = "ats/ple/branches/"; WebTarget target = jaxRsApi.newTargetQuery(path + "/baseline"); - testActionRestCall(target, 1); + testActionRestCall(target, 2); } private JsonNode testActionRestCall(WebTarget target, int size) { @@ -43,4 +43,4 @@ public class AtsProductLineEndpointTest extends AbstractRestTest { Assert.assertEquals(size, arrayNode.size()); return arrayNode.get(0); } -} \ No newline at end of file +} diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/util/AtsProgramServiceTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/util/AtsProgramServiceTest.java index 735070718c..7570f2896d 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/util/AtsProgramServiceTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/util/AtsProgramServiceTest.java @@ -138,7 +138,7 @@ public class AtsProgramServiceTest { public void testGetTeamDefinition() { assertEquals("SAW SW", programService.getTeamDefinition(sawProgram).getName()); - assertEquals(6, programService.getTeamDefs(sawProgram).size()); + assertEquals(8, programService.getTeamDefs(sawProgram).size()); assertEquals(1, programService.getTeamDefs(sawProgram, WorkType.Code).size()); @@ -147,7 +147,7 @@ public class AtsProgramServiceTest { @Test public void testGetAIs() { - assertEquals(6, programService.getAis(sawProgram).size()); + assertEquals(8, programService.getAis(sawProgram).size()); assertEquals(1, programService.getAis(sawProgram, WorkType.Code).size()); @@ -157,7 +157,7 @@ public class AtsProgramServiceTest { @Test public void testGetWorkType() { Collection workflows = programService.getWorkflows(sawProgram, WorkType.Code); - assertEquals(4, workflows.size()); + assertEquals(5, workflows.size()); IAtsTeamWorkflow codeTeamWf = workflows.iterator().next(); assertEquals(WorkType.Code, programService.getWorkType(codeTeamWf)); diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/util/CreateActionUsingAllActionableItemsTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/util/CreateActionUsingAllActionableItemsTest.java index 4088f9a80e..92f9eecfcd 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/util/CreateActionUsingAllActionableItemsTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/util/CreateActionUsingAllActionableItemsTest.java @@ -50,7 +50,7 @@ public class CreateActionUsingAllActionableItemsTest { SevereLoggingMonitor monitor = TestUtil.severeLoggingStart(); ActionResult action = CreateActionUsingAllActionableItems.createActionWithAllAis(); if (TestUtil.isDemoDb()) { - Assert.assertEquals("Should be 21 workflows created", 21, action.getTeams().size()); + Assert.assertEquals("Should be 23 workflows created", 23, action.getTeams().size()); } else { Assert.assertEquals("Should be 34 workflows created", 34, action.getTeams().size()); } diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/workflow/transition/TransitionManagerTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/workflow/transition/TransitionManagerTest.java index d485434b92..4eca2998dd 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/workflow/transition/TransitionManagerTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/workflow/transition/TransitionManagerTest.java @@ -97,11 +97,10 @@ public class TransitionManagerTest { @org.junit.Test public void testHandleTransitionValidation__NoAwas() { AtsTestUtil.cleanupAndReset("TransitionManagerTest-A"); - TransitionHelper helper = - new TransitionHelper(getClass().getSimpleName(), EMPTY_AWAS, AtsTestUtil.getImplementStateDef().getName(), - Arrays.asList(AtsApiService.get().getUserService().getCurrentUser()), null, - AtsApiService.get().createChangeSet(getClass().getSimpleName()), AtsApiService.get(), - TransitionOption.None); + TransitionHelper helper = new TransitionHelper(getClass().getSimpleName(), EMPTY_AWAS, + AtsTestUtil.getImplementStateDef().getName(), + Arrays.asList(AtsApiService.get().getUserService().getCurrentUser()), null, + AtsApiService.get().createChangeSet(getClass().getSimpleName()), AtsApiService.get(), TransitionOption.None); TransitionManager transMgr = new TransitionManager(helper); TransitionResults results = new TransitionResults(); transMgr.handleTransitionValidation(results); @@ -112,8 +111,7 @@ public class TransitionManagerTest { public void testHandleTransitionValidation__ToStateNotNull() { TransitionHelper helper = new TransitionHelper(getClass().getSimpleName(), Arrays.asList(AtsTestUtil.getTeamWf()), null, Arrays.asList(AtsApiService.get().getUserService().getCurrentUser()), null, - AtsApiService.get().createChangeSet(getClass().getSimpleName()), AtsApiService.get(), - TransitionOption.None); + AtsApiService.get().createChangeSet(getClass().getSimpleName()), AtsApiService.get(), TransitionOption.None); TransitionManager transMgr = new TransitionManager(helper); TransitionResults results = new TransitionResults(); transMgr.handleTransitionValidation(results); @@ -124,8 +122,7 @@ public class TransitionManagerTest { public void testHandleTransitionValidation__InvalidToState() { TransitionHelper helper = new TransitionHelper(getClass().getSimpleName(), Arrays.asList(AtsTestUtil.getTeamWf()), "InvalidStateName", Arrays.asList(AtsApiService.get().getUserService().getCurrentUser()), null, - AtsApiService.get().createChangeSet(getClass().getSimpleName()), AtsApiService.get(), - TransitionOption.None); + AtsApiService.get().createChangeSet(getClass().getSimpleName()), AtsApiService.get(), TransitionOption.None); TransitionManager transMgr = new TransitionManager(helper); TransitionResults results = new TransitionResults(); transMgr.handleTransitionValidation(results); @@ -143,8 +140,7 @@ public class TransitionManagerTest { TransitionHelper helper = new TransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt), AtsTestUtil.getImplementStateDef().getName(), Arrays.asList(AtsApiService.get().getUserService().getCurrentUser()), null, - AtsApiService.get().createChangeSet(getClass().getSimpleName()), AtsApiService.get(), - TransitionOption.None); + AtsApiService.get().createChangeSet(getClass().getSimpleName()), AtsApiService.get(), TransitionOption.None); helper.setExecuteChanges(true); TransitionManager transMgr = new TransitionManager(helper); TransitionResults results = new TransitionResults(); @@ -156,8 +152,7 @@ public class TransitionManagerTest { // Un-Assign Joe Smith results.clear(); Assert.assertFalse(helper.isOverrideAssigneeCheck()); - teamArt.getStateMgr().setAssignee( - AtsApiService.get().getUserService().getUserByToken(DemoUsers.Alex_Kay)); + teamArt.getStateMgr().setAssignee(AtsApiService.get().getUserService().getUserByToken(DemoUsers.Alex_Kay)); transMgr.handleTransitionValidation(results); Assert.assertTrue(results.contains(AtsTestUtil.getTeamWf(), TransitionResult.MUST_BE_ASSIGNED)); @@ -165,8 +160,7 @@ public class TransitionManagerTest { results.clear(); helper.addTransitionOption(TransitionOption.OverrideAssigneeCheck); Assert.assertTrue(helper.isOverrideAssigneeCheck()); - teamArt.getStateMgr().setAssignee( - AtsApiService.get().getUserService().getUserByToken(DemoUsers.Alex_Kay)); + teamArt.getStateMgr().setAssignee(AtsApiService.get().getUserService().getUserByToken(DemoUsers.Alex_Kay)); transMgr.handleTransitionValidation(results); Assert.assertTrue(results.isEmpty()); @@ -174,14 +168,12 @@ public class TransitionManagerTest { results.clear(); helper.removeTransitionOption(TransitionOption.OverrideAssigneeCheck); Assert.assertFalse(helper.isOverrideAssigneeCheck()); - teamArt.getStateMgr().setAssignee( - AtsApiService.get().getUserService().getUserByToken(SystemUser.UnAssigned)); + teamArt.getStateMgr().setAssignee(AtsApiService.get().getUserService().getUserByToken(SystemUser.UnAssigned)); transMgr.handleTransitionValidation(results); Assert.assertTrue(getResultsAndDebug(results, teamArt, helper), results.isEmpty()); // cleanup test - teamArt.getStateMgr().setAssignee( - AtsApiService.get().getUserService().getUserByToken(SystemUser.UnAssigned)); + teamArt.getStateMgr().setAssignee(AtsApiService.get().getUserService().getUserByToken(SystemUser.UnAssigned)); } private String getResultsAndDebug(TransitionResults results, TeamWorkFlowArtifact teamArt, TransitionHelper helper) { @@ -365,6 +357,7 @@ public class TransitionManagerTest { TransitionResults results = new TransitionResults(); when(teamWf.isTeamWorkflow()).thenReturn(true); + when(teamWf.getId()).thenReturn(4353454L); // validate that if rule exists and is working, then transition with tasks is ok when(teamWf.getStateDefinition()).thenReturn(toStateDef); @@ -512,8 +505,8 @@ public class TransitionManagerTest { // validate that can transition cause review completed changes = AtsApiService.get().createChangeSet(getClass().getSimpleName()); - Result result = AtsApiService.get().getReviewService().transitionDecisionTo(decArt, - DecisionReviewState.Completed, AtsApiService.get().getUserService().getCurrentUser(), false, changes); + Result result = AtsApiService.get().getReviewService().transitionDecisionTo(decArt, DecisionReviewState.Completed, + AtsApiService.get().getUserService().getCurrentUser(), false, changes); Assert.assertTrue(result.getText(), result.isTrue()); changes.execute(); results.clear(); @@ -674,9 +667,9 @@ public class TransitionManagerTest { // transition workflow to cancelled - peer review not cancelled changes.clear(); - TransitionHelper transHelper = new TransitionHelper("Transition Team Workflow Review", Arrays.asList(teamArt), - "Cancelled", new ArrayList(), "", changes, AtsApiService.get(), - TransitionOption.OverrideAssigneeCheck); + TransitionHelper transHelper = + new TransitionHelper("Transition Team Workflow Review", Arrays.asList(teamArt), "Cancelled", + new ArrayList(), "", changes, AtsApiService.get(), TransitionOption.OverrideAssigneeCheck); transHelper.setTransitionUser(AtsApiService.get().getUserService().getCurrentUser()); TransitionManager mgr = new TransitionManager(transHelper); results = mgr.handleAll(); @@ -687,8 +680,7 @@ public class TransitionManagerTest { results.clear(); changes.clear(); transHelper = new TransitionHelper("Transition Team Workflow Review", Arrays.asList(peerReview), "Cancelled", - new ArrayList(), "", changes, AtsApiService.get(), - TransitionOption.OverrideAssigneeCheck); + new ArrayList(), "", changes, AtsApiService.get(), TransitionOption.OverrideAssigneeCheck); transHelper.setTransitionUser(AtsApiService.get().getUserService().getCurrentUser()); mgr = new TransitionManager(transHelper); results = mgr.handleAll(); diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/AtsConfigQueryImplTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/AtsConfigQueryImplTest.java index 1007a83cda..f2e88de4aa 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/AtsConfigQueryImplTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/AtsConfigQueryImplTest.java @@ -58,10 +58,10 @@ public class AtsConfigQueryImplTest { public void test() { IAtsConfigQuery query = queryService.createQuery(AtsArtifactTypes.TeamDefinition); ResultSet teamDefs = query.getConfigObjectResultSet(); - assertEquals(25, teamDefs.size()); + assertEquals(27, teamDefs.size()); Collection resultArtifacts = query.getArtifacts(); - assertEquals(25, resultArtifacts.size()); + assertEquals(27, resultArtifacts.size()); query.andAttr(CoreAttributeTypes.Name, DemoArtifactToken.SAW_Code.getName()); IAtsTeamDefinition teamDef = @@ -73,7 +73,7 @@ public class AtsConfigQueryImplTest { query = queryService.createQuery(AtsArtifactTypes.ActionableItem); ResultSet ais = query.getConfigObjectResultSet(); - assertEquals(68, ais.size()); + assertEquals(70, ais.size()); } @Test @@ -105,7 +105,7 @@ public class AtsConfigQueryImplTest { IAtsConfigQuery query = queryService.createQuery(AtsArtifactTypes.TeamDefinition).andProgram(DemoArtifactToken.SAW_Program.getId()); ResultSet teamDefs = query.getConfigObjectResultSet(); - assertEquals(6, teamDefs.size()); + assertEquals(8, teamDefs.size()); } diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/AtsQueryImplTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/AtsQueryImplTest.java index b41602821b..7f912bd98d 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/AtsQueryImplTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/AtsQueryImplTest.java @@ -60,7 +60,7 @@ public class AtsQueryImplTest { // test by type IAtsQuery query = queryService.createQuery(WorkItemType.TeamWorkflow); - assertEquals(28, query.getResults().size()); + assertEquals(31, query.getResults().size()); query = queryService.createQuery(WorkItemType.Task); assertEquals(50, query.getResults().size()); @@ -68,18 +68,18 @@ public class AtsQueryImplTest { // assignee query = queryService.createQuery(WorkItemType.TeamWorkflow); query.andAssignee(atsApi.getUserService().getUserByUserId("3333")); - assertEquals(8, query.getResults().size()); + assertEquals(10, query.getResults().size()); // team query = queryService.createQuery(WorkItemType.TeamWorkflow); query.andTeam(Arrays.asList(30013695L)); - assertEquals(4, query.getResults().size()); + assertEquals(5, query.getResults().size()); // ai query = queryService.createQuery(WorkItemType.TeamWorkflow); ArtifactId ai = atsApi.getQueryService().getArtifactByName(AtsArtifactTypes.ActionableItem, "SAW Requirements"); query.andActionableItem(Arrays.asList(ai.getId())); - assertEquals(5, query.getResults().size()); + assertEquals(6, query.getResults().size()); // by ids (hijack two workflows from previous search) List ids = new LinkedList<>(); @@ -100,11 +100,11 @@ public class AtsQueryImplTest { // by state type query = queryService.createQuery(WorkItemType.WorkItem); query.andStateType(StateType.Working); - assertEquals(92, query.getResults().size()); + assertEquals(95, query.getResults().size()); query = queryService.createQuery(WorkItemType.TeamWorkflow); query.andStateType(StateType.Working); - assertEquals(24, query.getResults().size()); + assertEquals(27, query.getResults().size()); query = queryService.createQuery(WorkItemType.TeamWorkflow); query.andStateType(StateType.Completed); @@ -112,23 +112,23 @@ public class AtsQueryImplTest { query = queryService.createQuery(WorkItemType.TeamWorkflow); query.andStateType(StateType.Completed, StateType.Working); - assertEquals(28, query.getResults().size()); + assertEquals(31, query.getResults().size()); // by version query = queryService.createQuery(WorkItemType.TeamWorkflow); ArtifactId version = atsApi.getQueryService().getArtifactByName(AtsArtifactTypes.Version, "SAW_Bld_2"); query.andVersion(version.getId()); - assertEquals(17, query.getResults().size()); + assertEquals(20, query.getResults().size()); // by assignee query = queryService.createQuery(WorkItemType.TeamWorkflow); query.andAssignee(joeSmith); - assertEquals(8, query.getResults().size()); + assertEquals(10, query.getResults().size()); // by originator query = queryService.createQuery(WorkItemType.TeamWorkflow); query.andOriginator(joeSmith); - assertEquals(28, query.getResults().size()); + assertEquals(31, query.getResults().size()); // by favorite query = queryService.createQuery(WorkItemType.TeamWorkflow); @@ -152,8 +152,8 @@ public class AtsQueryImplTest { IAtsInsertion insertion = programService.getInsertion(activity); // COMM IAtsProgram program = programService.getProgram(insertion); // SAW Program - IAtsTeamWorkflow codeWf = AtsApiService.get().getWorkItemService().getTeamWf( - DemoTestUtil.getCommittedActionWorkflow(DemoWorkType.Code)); + IAtsTeamWorkflow codeWf = + AtsApiService.get().getWorkItemService().getTeamWf(DemoTestUtil.getCommittedActionWorkflow(DemoWorkType.Code)); IAtsTask codeTask = (IAtsTask) AtsApiService.get().getQueryService().createQuery(WorkItemType.Task).andAttr( CoreAttributeTypes.Name, "Create test plan").getItems().iterator().next(); diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/MyWorldSearchItemTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/MyWorldSearchItemTest.java index 9ba6ff0de2..bc64ea7fa0 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/MyWorldSearchItemTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/MyWorldSearchItemTest.java @@ -38,15 +38,15 @@ public class MyWorldSearchItemTest { AtsUser currentUser = AtsApiService.get().getUserService().getCurrentUser(); MyWorldSearchItem search = new MyWorldSearchItem("Search", currentUser); Collection results = search.performSearchGetResults(); - DemoTestUtil.assertTypes(results, 12, IAtsWorkItem.class); - DemoTestUtil.assertTypes(results, 8, IAtsTeamWorkflow.class); + DemoTestUtil.assertTypes(results, 14, IAtsWorkItem.class); + DemoTestUtil.assertTypes(results, 10, IAtsTeamWorkflow.class); DemoTestUtil.assertTypes(results, 2, IAtsDecisionReview.class); DemoTestUtil.assertTypes(results, 2, IAtsPeerToPeerReview.class); search = new MyWorldSearchItem("Search", AtsApiService.get().getUserService().getUserByUserId(DemoUsers.Kay_Jones.getUserId())); results = search.performSearchGetResults(); - DemoTestUtil.assertTypes(results, 13, IAtsWorkItem.class); + DemoTestUtil.assertTypes(results, 14, IAtsWorkItem.class); DemoTestUtil.assertTypes(results, 1, IAtsPeerToPeerReview.class); } diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/NextVersionSearchItemTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/NextVersionSearchItemTest.java index b6e49d4255..3b5fd8ba0a 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/NextVersionSearchItemTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/NextVersionSearchItemTest.java @@ -33,11 +33,11 @@ public class NextVersionSearchItemTest { @Test public void testByTeam() { - IAtsTeamDefinition teamDef = AtsApiService.get().getTeamDefinitionService().getTeamDefinitions( - Arrays.asList("SAW SW")).iterator().next(); + IAtsTeamDefinition teamDef = + AtsApiService.get().getTeamDefinitionService().getTeamDefinitions(Arrays.asList("SAW SW")).iterator().next(); NextVersionSearchItem search = new NextVersionSearchItem(teamDef, LoadView.WorldEditor); Collection results = search.performSearchGetResults(); - DemoTestUtil.assertTypes(results, 17, IAtsTeamWorkflow.class); + DemoTestUtil.assertTypes(results, 20, IAtsTeamWorkflow.class); } } diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/VersionTargetedForTeamSearchItemTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/VersionTargetedForTeamSearchItemTest.java index 680899bdb4..ee55467f8c 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/VersionTargetedForTeamSearchItemTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/VersionTargetedForTeamSearchItemTest.java @@ -37,7 +37,7 @@ public class VersionTargetedForTeamSearchItemTest { VersionTargetedForTeamSearchItem search = new VersionTargetedForTeamSearchItem(null, version, false, LoadView.WorldEditor); Collection results = search.performSearchGetResults(); - DemoTestUtil.assertTypes(results, 17, IAtsTeamWorkflow.class); + DemoTestUtil.assertTypes(results, 20, IAtsTeamWorkflow.class); } } diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/WorldSearchItemTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/WorldSearchItemTest.java index 7409eeef00..824d9f5959 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/WorldSearchItemTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/ats/world/search/WorldSearchItemTest.java @@ -66,7 +66,7 @@ public class WorldSearchItemTest { data.setTeamDefIds(Arrays.asList(DemoArtifactToken.SAW_Code.getId())); WorldSearchItem search = new WorldSearchItem(data); Collection results = search.performSearch(SearchType.Search); - Assert.assertEquals(4, results.size()); + Assert.assertEquals(5, results.size()); } @Test diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/framework/ui/skynet/FrameworkUiSkynetTest_Suite.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/framework/ui/skynet/FrameworkUiSkynetTest_Suite.java index 20eaf228b8..4295d8585b 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/framework/ui/skynet/FrameworkUiSkynetTest_Suite.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/framework/ui/skynet/FrameworkUiSkynetTest_Suite.java @@ -23,8 +23,8 @@ import org.junit.runners.Suite; */ @RunWith(Suite.class) @Suite.SuiteClasses({ // - OpenBlamsTest.class, // LinkUtilTest.class, // + OpenBlamsTest.class, // WordTemplateProcessorTest.class // }) public class FrameworkUiSkynetTest_Suite { diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/util/DbInitTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/util/DbInitTest.java index 66aac55362..b96379bd9d 100644 --- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/util/DbInitTest.java +++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/util/DbInitTest.java @@ -81,7 +81,7 @@ public class DbInitTest { UserManager.setSetting(UserManager.DOUBLE_CLICK_SETTING_KEY_EDIT, "false"); UserManager.getUser().saveSettings(); - UserGroupService.get(CoreUserGroups.DefaultArtifactEditor).addMember(UserManager.getUser()); + UserGroupService.get(CoreUserGroups.DefaultArtifactEditor).addMember(UserManager.getUser(), true); } diff --git a/plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF index e52095a4c0..a5f56ffeb2 100644 --- a/plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF @@ -23,7 +23,6 @@ Require-Bundle: org.eclipse.gef, org.junit, org.apache.commons.httpclient Export-Package: org.eclipse.osee.ats.ide, - org.eclipse.osee.ats.ide.access, org.eclipse.osee.ats.ide.actions, org.eclipse.osee.ats.ide.actions.wizard, org.eclipse.osee.ats.ide.branch, @@ -136,16 +135,12 @@ Import-Package: com.fasterxml.jackson.annotation, org.eclipse.osee.ats.ide.search, org.eclipse.osee.define.ide.traceability, org.eclipse.osee.define.ide.traceability.report, - org.eclipse.osee.framework.access, org.eclipse.osee.framework.core, org.eclipse.osee.framework.core.access, + org.eclipse.osee.framework.core.access.event, org.eclipse.osee.framework.core.client, org.eclipse.osee.framework.core.client.server, org.eclipse.osee.framework.core.data, - org.eclipse.osee.framework.core.dsl.integration, - org.eclipse.osee.framework.core.dsl.integration.util, - org.eclipse.osee.framework.core.dsl.oseeDsl, - org.eclipse.osee.framework.core.dsl.ui.integration.operations, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.enums.token, org.eclipse.osee.framework.core.event, diff --git a/plugins/org.eclipse.osee.ats.ide/OSGI-INF/ats.cm.access.xml b/plugins/org.eclipse.osee.ats.ide/OSGI-INF/ats.cm.access.xml deleted file mode 100644 index 25c93e9bb1..0000000000 --- a/plugins/org.eclipse.osee.ats.ide/OSGI-INF/ats.cm.access.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/AtsBranchAccessManager.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/AtsBranchAccessManager.java deleted file mode 100644 index 9461ecc8cd..0000000000 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/AtsBranchAccessManager.java +++ /dev/null @@ -1,281 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.ats.ide.access; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.logging.Level; -import org.eclipse.osee.ats.api.access.AtsAccessContextTokens; -import org.eclipse.osee.ats.api.ai.IAtsActionableItem; -import org.eclipse.osee.ats.api.data.AtsArtifactTypes; -import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow; -import org.eclipse.osee.ats.ide.internal.Activator; -import org.eclipse.osee.ats.ide.internal.AtsApiService; -import org.eclipse.osee.ats.ide.util.AtsUtilClient; -import org.eclipse.osee.ats.ide.workflow.teamwf.TeamWorkFlowArtifact; -import org.eclipse.osee.framework.access.AccessControlManager; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.integration.RoleContextProvider; -import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.util.GUID; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.logging.OseeLog; -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.ArtifactCache; -import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; -import org.eclipse.osee.framework.skynet.core.event.filter.ArtifactTypeEventFilter; -import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter; -import org.eclipse.osee.framework.skynet.core.event.listener.IArtifactEventListener; -import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; -import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidArtifact; -import org.eclipse.osee.framework.skynet.core.event.model.Sender; -import org.osgi.service.event.Event; -import org.osgi.service.event.EventHandler; - -/** - * This class will return access context ids related to editing artifacts stored on a team workflow's working branch. - *
- *
- * Access control can be called frequently, thus a cache is used. Events will clear cache as necessary.
- *
- * Access is determined from "Access Context Id" value stored on Team Workflow, if not there, then Actionable Items, if - * not there, then Team Defs. - * - * @author Donald G. Dunne - */ -public class AtsBranchAccessManager implements IArtifactEventListener, EventHandler { - - // Cache to store branch id to context id list so don't have to re-compute - private static final Map> branchIdToContextIdCache = new HashMap<>(50); - - private final RoleContextProvider roleContextProvider; - private volatile long cacheUpdated = 0; - - public AtsBranchAccessManager() { - // Available for osgi instantiation - this(null); - } - - public AtsBranchAccessManager(RoleContextProvider roleContextProvider) { - this.roleContextProvider = roleContextProvider; - } - - /** - * True if not common branch and branch's associated artifact is a Team Workflow artifact - */ - public boolean isApplicable(BranchId objectBranch) { - boolean result = false; - try { - if (AtsApiService.get().getAtsBranch().notEqual(objectBranch)) { - Artifact associatedArtifact = BranchManager.getAssociatedArtifact(objectBranch); - if (associatedArtifact.isValid()) { - result = associatedArtifact.isOfType(AtsArtifactTypes.AtsArtifact); - } - } - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.INFO, "Error determining access applicibility", ex); - } - return result; - } - - public Collection getContextId(BranchId branch) { - return getContextId(branch, true); - } - - public Collection getContextId(BranchId branch, boolean useCache) { - if (useCache && branchIdToContextIdCache.containsKey(branch)) { - return branchIdToContextIdCache.get(branch); - } - Collection contextIds = new ArrayList<>(); - - if (branch.isInvalid()) { - contextIds.add(AtsAccessContextTokens.DENY_CONTEXT); - - return contextIds; - } - - branchIdToContextIdCache.put(branch, contextIds); - try { - // don't access control common branch artifacts...yet - if (AtsApiService.get().getAtsBranch().notEqual(branch)) { - // do this check first since role will supersede others - if (roleContextProvider != null) { - contextIds.addAll(roleContextProvider.getContextId(UserManager.getUser())); - } - - if (contextIds.isEmpty()) { - // Else, get from associated artifact - Artifact assocArtifact = BranchManager.getAssociatedArtifact(branch); - if (assocArtifact.isOfType(AtsArtifactTypes.TeamWorkflow)) { - contextIds.addAll(internalGetFromWorkflow((TeamWorkFlowArtifact) assocArtifact)); - } else { - contextIds.add(AtsAccessContextTokens.DENY_CONTEXT); - } - } - } - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, "Exception obtaining Branch Access Context Id; Deny returned", ex); - contextIds.add(AtsAccessContextTokens.DENY_CONTEXT); - } - return contextIds; - } - - /** - * Provided for testing purposes only. - */ - public Collection internalGetFromWorkflow(IAtsTeamWorkflow teamWf) { - Set contextIds = new HashSet<>(); - try { - contextIds.addAll(getFromArtifact(AtsApiService.get().getQueryServiceIde().getArtifact(teamWf))); - if (contextIds.isEmpty()) { - for (IAtsActionableItem aia : AtsApiService.get().getActionableItemService().getActionableItems( - teamWf)) { - Artifact artifact = AtsApiService.get().getQueryServiceIde().getArtifact(aia); - if (artifact != null) { - contextIds.addAll(getFromArtifact(artifact)); - } - if (!contextIds.isEmpty()) { - return contextIds; - } - } - if (contextIds.isEmpty()) { - Artifact artifact = - AtsApiService.get().getQueryServiceIde().getArtifact(teamWf.getTeamDefinition()); - if (artifact != null) { - contextIds.addAll(getFromArtifact(artifact)); - } - } - } - } catch (Exception ex) { - OseeLog.log(Activator.class, Level.SEVERE, "Exception obtaining Branch Access Context Id; Deny returned", ex); - return Arrays.asList(AtsAccessContextTokens.DENY_CONTEXT); - } - return contextIds; - } - - /** - * Recursively check artifact and all default hierarchy parents - */ - private Collection getFromArtifact(Artifact artifact) { - Set contextIds = new HashSet<>(); - try { - for (String id : artifact.getAttributesToStringList(CoreAttributeTypes.AccessContextId)) { - // Do not use getOrCreateId here cause name represents where context ids came from - // Cache above will take care of this not being created on each access request call. - contextIds.add(AccessContextToken.valueOf(convertAccessAttributeToContextId(id, artifact), - "From [" + artifact.getArtifactTypeName() + "]" + artifact.toStringWithId() + " as [" + id + "]")); - } - if (contextIds.isEmpty() && artifact.getParent() != null) { - contextIds.addAll(getFromArtifact(artifact.getParent())); - } - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - return contextIds; - } - - /** - * ATS "Access Context Id" attribute value can be stored as "id" or "id,name" for easy reading. This method strips - * ,name out so only id is returned. - */ - private Long convertAccessAttributeToContextId(String value, Artifact art) { - String idStr = value.split(",")[0]; - if (Strings.isNumeric(idStr)) { - return Long.valueOf(idStr); - } else if (GUID.isValid(idStr)) { - return roleContextProvider.getContextGuidToIdMap().get(idStr); - } - throw new OseeArgumentException("Invalid access value [%s] on artifact %s", value, art.toStringWithId()); - } - - /** - * Need to process artifact events for Common branch Team Workflows, Actionable Items and Team Definitions in case - * Access Context Id attribute is edited. - */ - @Override - public List getEventFilters() { - return getAtsObjectEventFilters(); - } - - private static final List atsObjectEventFilter = new ArrayList<>(2); - private static final ArtifactTypeEventFilter atsArtifactTypesFilter = new ArtifactTypeEventFilter( - AtsArtifactTypes.TeamWorkflow, AtsArtifactTypes.TeamDefinition, AtsArtifactTypes.ActionableItem); - - private synchronized static List getAtsObjectEventFilters() { - try { - if (atsObjectEventFilter.isEmpty()) { - atsObjectEventFilter.add(AtsUtilClient.getAtsBranchFilter()); - atsObjectEventFilter.add(atsArtifactTypesFilter); - } - } catch (Exception ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - return atsObjectEventFilter; - } - - /** - * Since multiple events of same artifact type can come through, only clear cache every one second - */ - public synchronized void clearCache() { - long now = new Date().getTime(); - if (now - cacheUpdated > 1000) { - branchIdToContextIdCache.clear(); - } - } - - @Override - public void handleArtifactEvent(ArtifactEvent artifactEvent, Sender sender) { - for (EventBasicGuidArtifact guidArt : artifactEvent.getArtifacts()) { - if (guidArt.getArtifactType().matches(AtsArtifactTypes.ActionableItem, AtsArtifactTypes.TeamDefinition)) { - clearCache(); - return; - } - try { - if (guidArt.getArtifactType().inheritsFrom(AtsArtifactTypes.TeamWorkflow)) { - TeamWorkFlowArtifact teamArt = (TeamWorkFlowArtifact) ArtifactCache.getActive(guidArt); - if (teamArt != null && teamArt.getWorkingBranch().isValid()) { - branchIdToContextIdCache.remove(teamArt.getWorkingBranch()); - } - } - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - } - } - - @Override - public void handleEvent(Event event) { - try { - clearCache(); - } catch (Exception ex) { - OseeLog.log(AccessControlManager.class, Level.SEVERE, ex); - } - } - - public static void clearCaches() { - branchIdToContextIdCache.clear(); - } - -} diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsAccessOseeDslProvider.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsAccessOseeDslProvider.java deleted file mode 100644 index e34d5b0f1c..0000000000 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsAccessOseeDslProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.ats.ide.access.internal; - -import org.eclipse.osee.ats.api.data.AtsArtifactToken; -import org.eclipse.osee.framework.core.dsl.ui.integration.operations.AbstractOseeDslProvider; -import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; - -/** - * @author Roberto E. Escobar - */ -public class AtsAccessOseeDslProvider extends AbstractOseeDslProvider { - - public AtsAccessOseeDslProvider(String locationUri) { - super(locationUri); - } - - private Artifact getStorageArtifact() { - try { - return ArtifactQuery.getArtifactFromToken(AtsArtifactToken.AtsCmAccessControl); - } catch (OseeCoreException ex) { - return null; - } - } - - @Override - protected String getModelFromStorage() { - Artifact storageArtifact = getStorageArtifact(); - if (storageArtifact != null) { - return storageArtifact.getSoleAttributeValue(CoreAttributeTypes.GeneralStringData); - } else { - return Strings.EMPTY_STRING; - } - } - - @Override - protected void saveModelToStorage(String model) { - Artifact artifact = getStorageArtifact(); - if (artifact != null) { - artifact.setSoleAttributeFromString(CoreAttributeTypes.GeneralStringData, model); - artifact.persist(getClass().getSimpleName()); - } - } - -} diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsCmAccessControl.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsCmAccessControl.java deleted file mode 100644 index b03d7c097e..0000000000 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsCmAccessControl.java +++ /dev/null @@ -1,70 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.ats.ide.access.internal; - -import java.util.Collection; -import java.util.Collections; -import org.eclipse.osee.ats.ide.access.AtsBranchAccessManager; -import org.eclipse.osee.ats.ide.internal.AtsApiService; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.services.CmAccessControl; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; - -/** - * ATS currently only provides access control for artifacts on a Team Workflow's working branch. - * - * @author Roberto E. Escobar - * @author Donald G. Dunne - */ -public class AtsCmAccessControl implements CmAccessControl { - - private final AtsBranchAccessManager atsBranchAccessManager; - - public AtsCmAccessControl(AtsBranchAccessManager atsBranchObjectManager) { - this.atsBranchAccessManager = atsBranchObjectManager; - } - - @Override - public boolean isApplicable(ArtifactToken user, Object object) { - boolean result = false; - if (object != null) { - if (object instanceof Artifact && !AtsApiService.get().getQueryServiceIde().getArtifact( - object).isOnBranch(AtsApiService.get().getAtsBranch())) { - result = atsBranchAccessManager.isApplicable( - AtsApiService.get().getQueryServiceIde().getArtifact(object).getBranch()); - } - if (object instanceof BranchId) { - result = atsBranchAccessManager.isApplicable((BranchId) object); - } - } - return result; - } - - @Override - public Collection getContextId(ArtifactToken user, Object object) { - if (object != null) { - if (object instanceof Artifact && !AtsApiService.get().getQueryServiceIde().getArtifact( - object).isOnBranch(AtsApiService.get().getAtsBranch())) { - return atsBranchAccessManager.getContextId( - AtsApiService.get().getQueryServiceIde().getArtifact(object).getBranch()); - } - if (object instanceof BranchId) { - return atsBranchAccessManager.getContextId((BranchId) object); - } - } - return Collections.emptyList(); - } -} diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsCmAccessControlProxy.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsCmAccessControlProxy.java deleted file mode 100644 index e8e1150a1b..0000000000 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsCmAccessControlProxy.java +++ /dev/null @@ -1,117 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.ats.ide.access.internal; - -import java.util.Collection; -import org.eclipse.osee.ats.ide.access.AtsBranchAccessManager; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter; -import org.eclipse.osee.framework.core.dsl.integration.OseeDslAccessModel; -import org.eclipse.osee.framework.core.dsl.integration.OseeDslProvider; -import org.eclipse.osee.framework.core.dsl.integration.RoleContextProvider; -import org.eclipse.osee.framework.core.dsl.ui.integration.operations.OseeDslRoleContextProvider; -import org.eclipse.osee.framework.core.model.access.AccessModel; -import org.eclipse.osee.framework.core.model.access.HasAccessModel; -import org.eclipse.osee.framework.core.services.CmAccessControl; -import org.eclipse.osee.framework.skynet.core.event.OseeEventService; -import org.eclipse.osee.framework.skynet.core.event.listener.EventQosType; -import org.eclipse.osee.framework.skynet.core.event.listener.IEventListener; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -/** - * @author Roberto E. Escobar - */ -public class AtsCmAccessControlProxy implements CmAccessControl, HasAccessModel { - - private IEventListener listener; - private AtsBranchAccessManager atsBranchObjectManager; - private ServiceReference reference; - private CmAccessControl cmService; - private AccessModel accessModel; - private OseeEventService eventService; - private BundleContext bundleContext; - - private volatile boolean isInitialized = false; - - public void setAccessModelInterpreter(ServiceReference reference) { - this.reference = reference; - } - - public void setEventService(OseeEventService eventService) { - this.eventService = eventService; - } - - public void start(BundleContext bundleContext) { - this.bundleContext = bundleContext; - } - - public void stop() { - if (listener != null) { - eventService.removeListener(EventQosType.NORMAL, listener); - listener = null; - } - - if (atsBranchObjectManager != null) { - atsBranchObjectManager = null; - } - cmService = null; - accessModel = null; - bundleContext = null; - isInitialized = false; - } - - private boolean isReady() { - return reference != null && eventService != null && bundleContext != null; - } - - private synchronized void ensureInitialized() { - if (isReady() && !isInitialized) { - AccessModelInterpreter interpreter = bundleContext.getService(reference); - OseeDslProvider dslProvider = new AtsAccessOseeDslProvider("ats:/xtext/cm.access.osee"); - accessModel = new OseeDslAccessModel(interpreter, dslProvider); - RoleContextProvider roleAccessProvider = new OseeDslRoleContextProvider(dslProvider); - - atsBranchObjectManager = new AtsBranchAccessManager(roleAccessProvider); - cmService = new AtsCmAccessControl(atsBranchObjectManager); - - listener = new AtsDslProviderUpdateListener(dslProvider); - eventService.addListener(EventQosType.NORMAL, listener); - isInitialized = true; - } - } - - private CmAccessControl getProxiedService() { - ensureInitialized(); - return cmService; - } - - @Override - public boolean isApplicable(ArtifactToken user, Object object) { - return getProxiedService().isApplicable(user, object); - } - - @Override - public Collection getContextId(ArtifactToken user, Object object) { - return getProxiedService().getContextId(user, object); - } - - @Override - public AccessModel getAccessModel() { - ensureInitialized(); - return accessModel; - } - -} diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsDslProviderUpdateListener.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsDslProviderUpdateListener.java deleted file mode 100644 index d20c7d8762..0000000000 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/access/internal/AtsDslProviderUpdateListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.ats.ide.access.internal; - -import java.util.Arrays; -import java.util.List; -import java.util.logging.Level; -import org.eclipse.osee.ats.ide.internal.Activator; -import org.eclipse.osee.ats.ide.internal.AtsApiService; -import org.eclipse.osee.framework.core.dsl.integration.OseeDslProvider; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.event.filter.ArtifactTypeEventFilter; -import org.eclipse.osee.framework.skynet.core.event.filter.BranchIdEventFilter; -import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter; -import org.eclipse.osee.framework.skynet.core.event.listener.IArtifactEventListener; -import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; -import org.eclipse.osee.framework.skynet.core.event.model.Sender; - -/** - * @author Roberto E. Escobar - */ -public final class AtsDslProviderUpdateListener implements IArtifactEventListener { - - //@formatter:off - private final List eventFilters = - Arrays.asList( - new ArtifactTypeEventFilter(CoreArtifactTypes.AccessControlModel), - new BranchIdEventFilter(AtsApiService.get().getAtsBranch()) - ); - //@formatter:on - - private final OseeDslProvider dslProvider; - - public AtsDslProviderUpdateListener(OseeDslProvider dslProvider) { - this.dslProvider = dslProvider; - } - - @Override - public List getEventFilters() { - return eventFilters; - } - - @Override - public void handleArtifactEvent(ArtifactEvent artifactEvent, Sender sender) { - try { - dslProvider.loadDsl(); - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/actions/AccessControlAction.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/actions/AccessControlAction.java index 56adb1f038..b5fe83828f 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/actions/AccessControlAction.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/actions/AccessControlAction.java @@ -37,7 +37,7 @@ public class AccessControlAction extends Action { public PolicyDialog getDialog() { if (dialog == null) { - dialog = new PolicyDialog(Displays.getActiveShell(), sma); + dialog = PolicyDialog.createPolicyDialog(Displays.getActiveShell(), sma); } return dialog; } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/branch/BranchRegressionTest.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/branch/BranchRegressionTest.java index 11baba2208..12da179d53 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/branch/BranchRegressionTest.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/branch/BranchRegressionTest.java @@ -41,7 +41,6 @@ import org.eclipse.osee.ats.ide.internal.AtsApiService; import org.eclipse.osee.ats.ide.util.AtsUtilClient; import org.eclipse.osee.ats.ide.util.widgets.XWorkingBranchEnablement; import org.eclipse.osee.ats.ide.workflow.teamwf.TeamWorkFlowArtifact; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.AttributeId; @@ -294,7 +293,8 @@ public abstract class BranchRegressionTest { ArtifactQuery.getArtifactFromAttribute(CoreAttributeTypes.Name, SOFTWARE_REQUIREMENTS, getProgramBranch()); Assert.assertNotNull("Can't get softReqArt", softReqArt); - AccessControlManager.setPermission(UserManager.getUser(), getProgramBranch(), PermissionEnum.FULLACCESS); + AtsApiService.get().getAccessControlService().setPermission(UserManager.getUser(), getProgramBranch(), + PermissionEnum.FULLACCESS); createSoftwareArtifact(CoreArtifactTypes.SoftwareRequirementMsWord, softReqArt, PRE_BRANCH_ARTIFACT_NAME, getPreBranchCscis(), getProgramBranch()); @@ -773,12 +773,18 @@ public abstract class BranchRegressionTest { } protected Artifact createSoftwareArtifact(ArtifactTypeToken artifactType, Artifact parent, String title, String[] partitions, BranchToken branch) { - SkynetTransaction tx = TransactionManager.createTransaction(branch, "Create " + title); - Artifact newArt = ArtifactTypeManager.addArtifact(artifactType, branch, title); - Artifact parentArt = setParent(parent, partitions, newArt, tx); - tx.addArtifact(newArt); - tx.addArtifact(parent); - tx.execute(); + Artifact parentArt = null; + try { + SkynetTransaction.setOverrideAccess(true); + SkynetTransaction tx = TransactionManager.createTransaction(branch, "Create " + title); + Artifact newArt = ArtifactTypeManager.addArtifact(artifactType, branch, title); + parentArt = setParent(parent, partitions, newArt, tx); + tx.addArtifact(newArt); + tx.addArtifact(parent); + tx.execute(); + } finally { + SkynetTransaction.setOverrideAccess(false); + } return parentArt; } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/WorkflowEditor.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/WorkflowEditor.java index cfdac92e29..69c0e8ceb7 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/WorkflowEditor.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/WorkflowEditor.java @@ -48,6 +48,7 @@ import org.eclipse.osee.ats.ide.editor.tab.workflow.WfeWorkFlowTab; import org.eclipse.osee.ats.ide.editor.tab.workflow.util.WfeOutlinePage; import org.eclipse.osee.ats.ide.internal.Activator; import org.eclipse.osee.ats.ide.internal.AtsApiService; +import org.eclipse.osee.ats.ide.internal.OseeApiService; import org.eclipse.osee.ats.ide.navigate.RecentlyVisitedNavigateItems; import org.eclipse.osee.ats.ide.workflow.AbstractWorkflowArtifact; import org.eclipse.osee.ats.ide.workflow.goal.GoalArtifact; @@ -57,7 +58,6 @@ import org.eclipse.osee.ats.ide.workflow.task.TaskArtifact; import org.eclipse.osee.ats.ide.workflow.task.TaskComposite; import org.eclipse.osee.ats.ide.workflow.teamwf.TeamWorkFlowArtifact; import org.eclipse.osee.ats.ide.world.IAtsMetricsProvider; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; @@ -585,7 +585,8 @@ public class WorkflowEditor extends AbstractArtifactEditor implements IDirtyRepo } public boolean isAccessControlWrite() { - return AccessControlManager.hasPermission(workItem, PermissionEnum.WRITE); + return OseeApiService.get().getAccessControlService().hasArtifactPermission(workItem, PermissionEnum.WRITE, + null).isSuccess(); } @Override diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/header/WfeDragAndDrop.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/header/WfeDragAndDrop.java index 90ffa9cd5c..484d9044f6 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/header/WfeDragAndDrop.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/header/WfeDragAndDrop.java @@ -16,21 +16,24 @@ package org.eclipse.osee.ats.ide.editor.tab.workflow.header; import java.io.File; import java.util.LinkedList; import java.util.List; -import java.util.logging.Level; +import org.eclipse.osee.ats.ide.internal.AtsApiService; import org.eclipse.osee.ats.ide.workflow.AbstractWorkflowArtifact; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; +import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.plugin.core.util.Jobs; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactData; +import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer; import org.eclipse.osee.framework.ui.skynet.internal.Activator; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DropTargetEvent; import org.eclipse.swt.dnd.FileTransfer; @@ -72,18 +75,38 @@ public class WfeDragAndDrop extends SkynetDragAndDrop { ArtifactData toBeDropped = ArtifactTransfer.getInstance().nativeToJava(event.currentDataType); if (dropTarget != null) { try { - AccessPolicy policy = ServiceUtil.getAccessPolicy(); Artifact[] artifactsBeingDropped = toBeDropped.getArtifacts(); List artsOnSameBranchAsDestination = new LinkedList<>(); BranchId destinationBranch = dropTarget.getBranch(); + boolean onSameBranch = true; for (Artifact art : artifactsBeingDropped) { if (art.isOnBranch(destinationBranch)) { artsOnSameBranchAsDestination.add(art); + } else { + onSameBranch = false; + break; } } - valid = policy.canRelationBeModified(dropTarget, artsOnSameBranchAsDestination, - CoreRelationTypes.SupportingInfo_SupportingInfo, Level.FINE).matched(); + if (!onSameBranch) { + AWorkbench.popup("Related Artifact(s) must be on the same branch.\n\nAborting Drop."); + return false; + } + if (artsOnSameBranchAsDestination.isEmpty()) { + AWorkbench.popup("No Artifact(s) to relate.\n\nAborting Drop."); + return false; + } + XResultData rd = AtsApiService.get().getAccessControlService().hasRelationTypePermission(dropTarget, + CoreRelationTypes.SupportingInfo_SupportingInfo, artsOnSameBranchAsDestination, PermissionEnum.WRITE, + AccessControlArtifactUtil.getXResultAccessHeader("Relating Artifacts to Workflow", + artsOnSameBranchAsDestination)); + if (rd.isErrors()) { + XResultDataDialog.open(rd, "Relate Artifact(s) to Workflow", + "Invalid Access for Relation.\n\nAborting Drop."); + valid = false; + } else { + valid = true; + } } catch (OseeCoreException ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/header/WfeRelationsHyperlinkComposite.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/header/WfeRelationsHyperlinkComposite.java index 56823c98ce..9532cd97ae 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/header/WfeRelationsHyperlinkComposite.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/header/WfeRelationsHyperlinkComposite.java @@ -58,11 +58,9 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Collections; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.relation.RelationLink; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.swt.ALayout; import org.eclipse.osee.framework.ui.swt.Displays; @@ -322,7 +320,6 @@ public class WfeRelationsHyperlinkComposite extends Composite { delArt = thisArt; } - AccessPolicy policy = ServiceUtil.getAccessPolicy(); Collection related = Arrays.asList(thatArt); if (thatArt instanceof IAtsObject) { if (MessageDialog.openConfirm(Displays.getActiveShell(), "Delete Related", @@ -333,7 +330,8 @@ public class WfeRelationsHyperlinkComposite extends Composite { } return; } - XResultData results = policy.isDeleteable(related, new XResultData()); + XResultData results = + AtsApiService.get().getAccessControlService().isDeleteable(related, new XResultData()); if (results.isErrors()) { AWorkbench.popup(results.toString()); return; diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/section/WfeDetailsSection.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/section/WfeDetailsSection.java index 38044223d9..f78c505c7d 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/section/WfeDetailsSection.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/editor/tab/workflow/section/WfeDetailsSection.java @@ -17,20 +17,17 @@ import java.util.Collection; import java.util.Map; import java.util.logging.Level; import org.eclipse.osee.ats.api.IAtsWorkItem; +import org.eclipse.osee.ats.api.access.IAtsAccessService; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.workflow.IAtsAction; -import org.eclipse.osee.ats.ide.access.AtsBranchAccessManager; import org.eclipse.osee.ats.ide.editor.WorkflowEditor; import org.eclipse.osee.ats.ide.internal.Activator; import org.eclipse.osee.ats.ide.internal.AtsApiService; import org.eclipse.osee.ats.ide.workflow.teamwf.TeamWorkFlowArtifact; -import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.services.CmAccessControl; +import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.User; -import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.utility.Artifacts; import org.eclipse.osee.framework.ui.swt.ALayout; @@ -71,6 +68,7 @@ public class WfeDetailsSection extends SectionPart { Section section = getSection(); section.setText("Details"); section.setLayout(new GridLayout()); + section.setExpanded(false); section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); // Only load when users selects section @@ -151,36 +149,30 @@ public class WfeDetailsSection extends SectionPart { private String getAccessContextId(TeamWorkFlowArtifact workflow) { String message; - CmAccessControl accessControl = workflow.getAccessControl(); - if (accessControl == null) { - message = "AtsCmAccessControlService not found."; - } else { - BranchId workingBranch = null; + IAtsAccessService accessService = AtsApiService.get().getAtsAccessService(); + BranchId workingBranch = null; + try { + workingBranch = workflow.getWorkingBranch(); + } catch (Exception ex) { + OseeLog.log(Activator.class, Level.SEVERE, ex); + } + Collection ids = null; + if (workingBranch == null) { try { - workingBranch = workflow.getWorkingBranch(); + // get what would be if branch created + ids = accessService.getFromWorkflow(workflow); + message = ids.toString(); } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); + message = String.format("Error getting context id [%s]", ex.getMessage()); } - Collection ids = null; - if (workingBranch == null) { - try { - // get what would be if branch created - AtsBranchAccessManager accessMgr = new AtsBranchAccessManager(); - ids = accessMgr.internalGetFromWorkflow(workflow); - message = ids.toString(); - } catch (Exception ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - message = String.format("Error getting context id [%s]", ex.getMessage()); - } - } else { - try { - User user = UserManager.getUserByArtId(AtsApiService.get().getUserService().getCurrentUser()); - ids = accessControl.getContextId(user, workingBranch); - message = ids.toString(); - } catch (Exception ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - message = String.format("Error getting context id [%s]", ex.getMessage()); - } + } else { + try { + ids = accessService.getContextIds(workingBranch); + message = ids.toString(); + } catch (Exception ex) { + OseeLog.log(Activator.class, Level.SEVERE, ex); + message = String.format("Error getting context id [%s]", ex.getMessage()); } } return message; diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/internal/Activator.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/internal/Activator.java index 2965390194..7738321fa7 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/internal/Activator.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/internal/Activator.java @@ -15,11 +15,10 @@ package org.eclipse.osee.ats.ide.internal; import org.eclipse.osee.ats.api.util.AtsTopicEvent; import org.eclipse.osee.ats.api.util.AtsUtil; -import org.eclipse.osee.ats.ide.access.AtsBranchAccessManager; +import org.eclipse.osee.ats.core.access.AtsBranchAccessManager; import org.eclipse.osee.ats.ide.workflow.AtsWorkItemRemoteTopicEventHandler; +import org.eclipse.osee.framework.core.access.event.AccessTopicEvent; import org.eclipse.osee.framework.plugin.core.OseeActivator; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.osgi.framework.BundleContext; import org.osgi.service.event.EventConstants; import org.osgi.service.event.EventHandler; @@ -38,19 +37,6 @@ public class Activator extends OseeActivator { context.registerService(EventHandler.class.getName(), new AtsBranchAccessManager(), AtsUtil.hashTable(EventConstants.EVENT_TOPIC, AccessTopicEvent.ACCESS_BRANCH_MODIFIED.getTopic())); - // Start loading access control - Thread loadAccessControl = new Thread(new Runnable() { - - @Override - public void run() { - try { - ServiceUtil.getAccessPolicy().ensurePopulated(); - } catch (Exception ex) { - // do nothing - } - } - }, "Load Access Control"); - loadAccessControl.start(); } } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/NavigateViewItems.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/NavigateViewItems.java index 7125e5b11d..8854df971a 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/NavigateViewItems.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/NavigateViewItems.java @@ -155,6 +155,7 @@ public final class NavigateViewItems implements XNavigateViewItems, IXNavigateCo new ClearAtsConfigCache(utilItems); new XNavigateItemBlam(utilItems, new MoveTeamWorkflowsBlam(), AtsImage.TEAM_WORKFLOW); new AtsConfigResultsEditorNavigateItem(utilItems); + new ToggleAccessControlDebug(utilItems); } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ToggleAtsAdmin.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ToggleAtsAdmin.java index 584444fd55..f9ad11882a 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ToggleAtsAdmin.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/navigate/ToggleAtsAdmin.java @@ -61,7 +61,7 @@ public class ToggleAtsAdmin extends XNavigateItemAction { if (!isAdmin) { IUserGroup atsAdminGroup = UserGroupService.get(AtsUserGroups.AtsAdmin); if (!atsAdminGroup.isCurrentUserMember()) { - atsAdminGroup.addMember(UserManager.getUser()); + atsAdminGroup.addMember(UserManager.getUser(), true); Conditions.assertTrue(atsAdminGroup.getArtifact() instanceof Artifact, "Must be artifact."); ((Artifact) atsAdminGroup.getArtifact()).persist("Toggle Admin"); } @@ -69,21 +69,21 @@ public class ToggleAtsAdmin extends XNavigateItemAction { IUserGroup oseeAdminGroup = org.eclipse.osee.framework.skynet.core.access.UserGroupService.getOseeAdmin(); if (!oseeAdminGroup.isCurrentUserMember()) { - oseeAdminGroup.addMember(UserManager.getUser()); + oseeAdminGroup.addMember(UserManager.getUser(), true); Conditions.assertTrue(oseeAdminGroup.getArtifact() instanceof Artifact, "Must be artifact."); ((Artifact) oseeAdminGroup.getArtifact()).persist("Toggle Admin"); } } else { IUserGroup atsAdminGroup = UserGroupService.get(AtsUserGroups.AtsAdmin); if (atsAdminGroup.isCurrentUserMember()) { - atsAdminGroup.removeMember(UserManager.getUser()); + atsAdminGroup.removeMember(UserManager.getUser(), true); Conditions.assertTrue(atsAdminGroup.getArtifact() instanceof Artifact, "Must be artifact."); ((Artifact) atsAdminGroup.getArtifact()).persist("Toggle Admin"); } IUserGroup oseeAdminGroup = UserGroupService.get(CoreUserGroups.OseeAdmin); if (oseeAdminGroup.isCurrentUserMember()) { - oseeAdminGroup.removeMember(UserManager.getUser()); + oseeAdminGroup.removeMember(UserManager.getUser(), true); Conditions.assertTrue(oseeAdminGroup.getArtifact() instanceof Artifact, "Must be artifact."); ((Artifact) oseeAdminGroup.getArtifact()).persist("Toggle Admin"); } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/operation/ExportChangeReportOperation.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/operation/ExportChangeReportOperation.java index 434c71b4a7..b59fd42e5f 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/operation/ExportChangeReportOperation.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/operation/ExportChangeReportOperation.java @@ -111,7 +111,7 @@ public final class ExportChangeReportOperation extends AbstractOperation { Collection artifactDeltas = ChangeManager.getCompareArtifacts(changes); - // only allow SoftwareRequirements for HLR + // only allow SoftwareRequirementsFolder for HLR Iterator it = artifactDeltas.iterator(); while (it.hasNext()) { ArtifactDelta next = it.next(); diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/query/AtsQueryServiceIde.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/query/AtsQueryServiceIde.java index 0215b76661..6517058743 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/query/AtsQueryServiceIde.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/query/AtsQueryServiceIde.java @@ -185,6 +185,9 @@ public class AtsQueryServiceIde { Artifact result = null; if (obj instanceof Artifact) { result = (Artifact) obj; + if (obj instanceof IAtsObject) { + result.setArtifactType(((IAtsObject) obj).getArtifactType()); + } } else if (obj instanceof IAtsObject) { result = getArtifact(((IAtsObject) obj).getStoreObject(), atsApi.getAtsBranch()); } else if (obj instanceof ArtifactId) { diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/Import/ExcelAtsActionArtifactExtractor.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/Import/ExcelAtsActionArtifactExtractor.java index 509e35381a..dbea453a6e 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/Import/ExcelAtsActionArtifactExtractor.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/Import/ExcelAtsActionArtifactExtractor.java @@ -485,7 +485,7 @@ public class ExcelAtsActionArtifactExtractor { Assignees("ActionableItems"), Originator("Originator"), Priority("Priority"), - ChangeType("ChangeType"), + ChangeType("AllowDeny"), Version("Version"), EstimatedHours("EstimatedHours"), Goal("Goal"), diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/OpenInAtsLoopbackCmd.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/OpenInAtsLoopbackCmd.java index 438657126e..119a9c9173 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/OpenInAtsLoopbackCmd.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/OpenInAtsLoopbackCmd.java @@ -18,7 +18,7 @@ import java.util.Map; import java.util.logging.Level; import org.eclipse.osee.ats.ide.AtsOpenOption; import org.eclipse.osee.ats.ide.internal.Activator; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.ats.ide.internal.AtsApiService; import org.eclipse.osee.framework.core.client.server.HttpResponse; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.jdk.core.type.MutableBoolean; @@ -44,7 +44,8 @@ public class OpenInAtsLoopbackCmd extends BaseArtifactLoopbackCmd { try { boolean hasPermissionToRead = false; try { - hasPermissionToRead = AccessControlManager.hasPermission(artifact, PermissionEnum.READ); + hasPermissionToRead = AtsApiService.get().getAccessControlService().hasArtifactPermission(artifact, + PermissionEnum.READ, null).isSuccess(); } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsApiIdeImpl.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsApiIdeImpl.java index eba17935f3..e8a6edab2d 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsApiIdeImpl.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsApiIdeImpl.java @@ -36,12 +36,12 @@ import org.eclipse.osee.ats.api.workflow.IAtsWorkItemService; import org.eclipse.osee.ats.core.agile.AgileService; import org.eclipse.osee.ats.core.ai.ActionableItemServiceImpl; import org.eclipse.osee.ats.core.util.AtsApiImpl; -import org.eclipse.osee.ats.ide.access.AtsBranchAccessManager; import org.eclipse.osee.ats.ide.branch.AtsBranchServiceIde; import org.eclipse.osee.ats.ide.branch.internal.AtsBranchServiceIdeImpl; import org.eclipse.osee.ats.ide.branch.internal.AtsBranchServiceImpl; import org.eclipse.osee.ats.ide.ev.internal.AtsEarnedValueImpl; import org.eclipse.osee.ats.ide.health.AtsHealthServiceImpl; +import org.eclipse.osee.ats.ide.internal.OseeApiService; import org.eclipse.osee.ats.ide.notify.AtsNotificationServiceImpl; import org.eclipse.osee.ats.ide.query.AtsQueryServiceIde; import org.eclipse.osee.ats.ide.search.internal.query.AtsQueryServiceImpl; @@ -58,6 +58,7 @@ import org.eclipse.osee.ats.ide.workflow.sprint.SprintArtifact; import org.eclipse.osee.ats.ide.workflow.task.IAtsTaskServiceIde; import org.eclipse.osee.ats.ide.workflow.task.internal.AtsTaskService; import org.eclipse.osee.ats.ide.workflow.task.related.AtsTaskRelatedService; +import org.eclipse.osee.framework.core.access.IAccessControlService; import org.eclipse.osee.framework.core.client.OseeClientProperties; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.IUserGroupService; @@ -131,6 +132,24 @@ public class AtsApiIdeImpl extends AtsApiImpl implements AtsApiIde { agileService = new AgileService(logger, this); notificationService = new AtsNotificationServiceImpl(); + startAccessControlLoading(); + + } + + private void startAccessControlLoading() { + // Start loading access control + Thread loadAccessControl = new Thread(new Runnable() { + + @Override + public void run() { + try { + OseeApiService.get().getAccessControlService().ensurePopulated(); + } catch (Exception ex) { + // do nothing + } + } + }, "Load Access Control"); + loadAccessControl.start(); } public void setAttributeResolverService(IAttributeResolver attributeResolverService) { @@ -152,7 +171,8 @@ public class AtsApiIdeImpl extends AtsApiImpl implements AtsApiIde { sprintItemsCache.invalidate(); } - AtsBranchAccessManager.clearCaches(); + getAccessControlService().clearCaches(); + getAtsAccessService().clearCaches(); } @Override @@ -288,4 +308,8 @@ public class AtsApiIdeImpl extends AtsApiImpl implements AtsApiIde { return branchServiceIde; } + @Override + public IAccessControlService getAccessControlService() { + return OseeApiService.get().getAccessControlService(); + } } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/widgets/XWorkingBranchButtonLock.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/widgets/XWorkingBranchButtonLock.java index 2a8ecfbd7c..524f86daba 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/widgets/XWorkingBranchButtonLock.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/widgets/XWorkingBranchButtonLock.java @@ -19,8 +19,10 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osee.ats.api.util.AtsUtil; import org.eclipse.osee.ats.ide.internal.Activator; import org.eclipse.osee.ats.ide.internal.AtsApiService; -import org.eclipse.osee.framework.access.AccessControlData; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.ats.ide.internal.OseeApiService; +import org.eclipse.osee.framework.core.access.AccessControlData; +import org.eclipse.osee.framework.core.access.event.AccessTopicEvent; +import org.eclipse.osee.framework.core.access.event.AccessTopicEventPayload; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IUserGroup; import org.eclipse.osee.framework.core.enums.CoreUserGroups; @@ -31,8 +33,6 @@ import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.access.UserGroupService; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEventPayload; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.swt.ImageManager; @@ -85,7 +85,7 @@ public class XWorkingBranchButtonLock extends XWorkingBranchButtonAbstract imple if (branch.isInvalid()) { noBranch = true; } else { - someAccessControlSet = !AccessControlManager.getAccessControlList(branch).isEmpty(); + someAccessControlSet = !OseeApiService.get().getAccessControlService().getAccessControlList(branch).isEmpty(); } button.setImage(ImageManager.getImage( noBranch || someAccessControlSet ? FrameworkImage.LOCK_LOCKED : FrameworkImage.LOCK_UNLOCKED)); @@ -93,7 +93,6 @@ public class XWorkingBranchButtonLock extends XWorkingBranchButtonAbstract imple button.getParent().redraw(); } - @SuppressWarnings("unlikely-arg-type") private void toggleWorkingBranchLock(Button button) { try { BranchId branch = getTeamArt().getWorkingBranch(); @@ -102,7 +101,8 @@ public class XWorkingBranchButtonLock extends XWorkingBranchButtonAbstract imple return; } boolean isLocked = false, manuallyLocked = false; - Collection datas = AccessControlManager.getAccessControlList(branch); + Collection datas = + AtsApiService.get().getAccessControlService().getAccessControlList(branch); if (datas.size() > 1) { manuallyLocked = true; } else if (datas.isEmpty()) { @@ -125,11 +125,12 @@ public class XWorkingBranchButtonLock extends XWorkingBranchButtonAbstract imple isLocked ? "Locked" : "NOT Locked", isLocked ? "UnLock" : "Lock"); if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Toggle Branch Lock", message)) { if (isLocked) { - AccessControlManager.removeAccessControlDataIf(true, datas.iterator().next()); + AtsApiService.get().getAccessControlService().removeAccessControlDataIf(true, datas.iterator().next()); } else { IUserGroup everyoneGroup = UserGroupService.get(CoreUserGroups.Everyone); Conditions.assertTrue(everyoneGroup.getArtifact() instanceof Artifact, "Must be Artifact"); - AccessControlManager.setPermission((Artifact) everyoneGroup.getArtifact(), branch, PermissionEnum.READ); + AtsApiService.get().getAccessControlService().setPermission(everyoneGroup.getArtifact(), branch, + PermissionEnum.READ); } AWorkbench.popup(String.format("Branch set to [%s]", !isLocked ? "Locked" : "NOT Locked")); } diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/workflow/AbstractWorkflowArtifact.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/workflow/AbstractWorkflowArtifact.java index 826345798b..bb07feb17a 100644 --- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/workflow/AbstractWorkflowArtifact.java +++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/workflow/AbstractWorkflowArtifact.java @@ -43,15 +43,11 @@ import org.eclipse.osee.ats.ide.internal.Activator; import org.eclipse.osee.ats.ide.internal.AtsApiService; import org.eclipse.osee.ats.ide.workflow.review.AbstractReviewArtifact; import org.eclipse.osee.ats.ide.workflow.teamwf.TeamWorkFlowArtifact; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.services.CmAccessControl; -import org.eclipse.osee.framework.core.services.HasCmAccessControl; import org.eclipse.osee.framework.core.util.IGroupExplorerProvider; -import org.eclipse.osee.framework.core.util.OsgiUtil; import org.eclipse.osee.framework.core.util.Result; import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; @@ -68,7 +64,7 @@ import org.eclipse.osee.framework.skynet.core.relation.RelationManager; /** * @author Donald G. Dunne */ -public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact implements IAtsWorkItem, HasCmAccessControl, IGroupExplorerProvider { +public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact implements IAtsWorkItem, IGroupExplorerProvider { private Collection transitionAssignees; protected AbstractWorkflowArtifact parentAwa; @@ -265,7 +261,7 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple } public boolean isAccessControlWrite() { - return AccessControlManager.hasPermission(this, PermissionEnum.WRITE); + return AtsApiService.get().getAccessControlService().hasArtifactPermission(this, PermissionEnum.WRITE, null).isSuccess(); } /** @@ -419,11 +415,6 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple return AtsApiService.get().getStateFactory().getStateManager(this); } - @Override - public CmAccessControl getAccessControl() { - return OsgiUtil.getService(getClass(), CmAccessControl.class); - } - public List getToStatesWithCompleteCancelReturnStates() { List allPages = new ArrayList<>(); IAtsStateDefinition currState = getStateDefinition(); diff --git a/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF index a7282b210b..e1b9367f2d 100644 --- a/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Import-Package: com.fasterxml.jackson.core, org.eclipse.core.runtime, org.eclipse.define.api.importing, org.eclipse.nebula.widgets.xviewer.core.model, + org.eclipse.osee.ats.core.access.demo, org.eclipse.osee.ats.core.agile, org.eclipse.osee.ats.core.agile.operations, org.eclipse.osee.ats.core.ai, @@ -42,6 +43,7 @@ Import-Package: com.fasterxml.jackson.core, org.eclipse.osee.define.rest.importing.resolvers, org.eclipse.osee.framework.core, org.eclipse.osee.framework.core.access, + org.eclipse.osee.framework.core.access.context, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.enums.token, diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApiServerImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApiServerImpl.java index 195e8916d5..74c3f156a5 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApiServerImpl.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApiServerImpl.java @@ -47,6 +47,7 @@ import org.eclipse.osee.ats.rest.internal.util.AtsRelationResolverServiceImpl; import org.eclipse.osee.ats.rest.internal.util.AtsStoreServiceImpl; import org.eclipse.osee.ats.rest.internal.workitem.AtsActionEndpointImpl; import org.eclipse.osee.ats.rest.internal.workitem.AtsTaskService; +import org.eclipse.osee.framework.core.access.IAccessControlService; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; @@ -288,4 +289,9 @@ public class AtsApiServerImpl extends AtsApiImpl implements AtsApiServer { return orcsApi.getUserGroupService(); } + @Override + public IAccessControlService getAccessControlService() { + return orcsApi.getAccessControlService(); + } + } diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigurationsService.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigurationsService.java index a7cae9b953..694377ff43 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigurationsService.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigurationsService.java @@ -45,6 +45,7 @@ import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.enums.SystemUser; +import org.eclipse.osee.framework.jdk.core.result.XConsoleLogger; import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.ResultSet; import org.eclipse.osee.framework.jdk.core.util.ElapsedTime; @@ -159,7 +160,7 @@ public class AtsConfigurationsService extends AbstractAtsConfigurationService { } idToArtifact.put(art.getId(), art); } catch (Exception ex) { - System.err.println("Exception " + ex.getLocalizedMessage()); + XConsoleLogger.err("Exception " + ex.getLocalizedMessage()); } } time2.end(); diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/demo/AtsDbConfigDemoOp.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/demo/AtsDbConfigDemoOp.java index 6f109ec7ff..924f034698 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/demo/AtsDbConfigDemoOp.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/demo/AtsDbConfigDemoOp.java @@ -14,34 +14,16 @@ package org.eclipse.osee.ats.rest.internal.demo; import org.eclipse.osee.ats.api.AtsApi; -import org.eclipse.osee.ats.api.config.Csci; -import org.eclipse.osee.ats.api.config.WorkType; -import org.eclipse.osee.ats.api.config.tx.IAtsConfigTx; -import org.eclipse.osee.ats.api.config.tx.IAtsConfigTxActionableItem; -import org.eclipse.osee.ats.api.config.tx.IAtsConfigTxTeamDef; import org.eclipse.osee.ats.api.data.AtsArtifactToken; -import org.eclipse.osee.ats.api.data.AtsArtifactTypes; -import org.eclipse.osee.ats.api.data.AtsAttributeTypes; import org.eclipse.osee.ats.api.data.AtsRelationTypes; import org.eclipse.osee.ats.api.data.AtsUserGroups; -import org.eclipse.osee.ats.api.demo.AtsDemoOseeTypes; -import org.eclipse.osee.ats.api.demo.DemoAis; import org.eclipse.osee.ats.api.demo.DemoArtifactToken; -import org.eclipse.osee.ats.api.demo.DemoWorkDefinitions; -import org.eclipse.osee.ats.api.query.NextRelease; -import org.eclipse.osee.ats.api.query.ReleasedOption; -import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; -import org.eclipse.osee.ats.api.user.AtsCoreUsers; import org.eclipse.osee.ats.api.util.AtsUtil; import org.eclipse.osee.ats.api.util.IAtsChangeSet; import org.eclipse.osee.ats.api.version.IAtsVersion; -import org.eclipse.osee.ats.api.workdef.AtsWorkDefinitionTokens; import org.eclipse.osee.ats.core.config.OrganizePrograms; -import org.eclipse.osee.ats.core.task.TaskSetDefinitionTokensDemo; import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; -import org.eclipse.osee.framework.core.enums.DemoBranches; import org.eclipse.osee.framework.core.enums.DemoUsers; import org.eclipse.osee.framework.jdk.core.result.XResultData; @@ -53,7 +35,6 @@ import org.eclipse.osee.framework.jdk.core.result.XResultData; public class AtsDbConfigDemoOp { private final AtsApi atsApi; - private IAtsConfigTx cfgTx; public AtsDbConfigDemoOp(AtsApi atsApi) { this.atsApi = atsApi; @@ -61,7 +42,7 @@ public class AtsDbConfigDemoOp { public XResultData run() { - configTxDemoAisAndTeams(); + (new AtsDbConfigAIsAndTeamsDemoOp(atsApi)).run(); configureForParallelCommit(); IAtsChangeSet changes = atsApi.createChangeSet("Set ATS Admin"); @@ -88,454 +69,6 @@ public class AtsDbConfigDemoOp { changes.execute(); } - private void configTxDemoAisAndTeams() { - - cfgTx = atsApi.getConfigService().createConfigTx("Create Demo Config", AtsCoreUsers.SYSTEM_USER); - IAtsConfigTxTeamDef topTeamDef = - cfgTx.createTeamDef((IAtsTeamDefinition) null, AtsArtifactToken.TopTeamDefinition).andWorkDef( - AtsWorkDefinitionTokens.WorkDef_Team_Default); - IAtsConfigTxActionableItem topAi = - cfgTx.createActionableItem(AtsArtifactToken.TopActionableItem).andActionable(false); - - createSawPlTeamConfig(cfgTx, topTeamDef, topAi); - createSawTeamConfig(cfgTx, topTeamDef, topAi); - createCisTeamConfig(cfgTx, topTeamDef, topAi); - createFacilitiesTeamConfig(cfgTx, topTeamDef, topAi); - createProcessTeamConfig(cfgTx, topTeamDef, topAi); - createToolsTeamConfig(cfgTx, topTeamDef, topAi); - createSystemSafetyTeamConfig(cfgTx, topTeamDef, topAi); - - cfgTx.execute(); - - } - - private void createFacilitiesTeamConfig(IAtsConfigTx cfgTx, IAtsConfigTxTeamDef topTeam, IAtsConfigTxActionableItem topActionableItem) { - - // Facilities Team - IAtsConfigTxTeamDef facilitiesTeamDef = - topTeam.createChildTeamDef(topTeam.getTeamDef(), DemoArtifactToken.Facilities_Team) // - .andLeads(DemoUsers.John_Stevens) // - .andMembers(DemoUsers.John_Stevens, DemoUsers.Steven_Michael, DemoUsers.Michael_John, - DemoUsers.Jason_Stevens) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Simple); - - // IT Team - facilitiesTeamDef.createChildTeamDef(facilitiesTeamDef.getTeamDef(), DemoArtifactToken.Facilities_IT_Team) // - .andLeads(DemoUsers.Kay_Wheeler) // - .andMembers(DemoUsers.Kay_Wheeler, DemoUsers.Jason_Stevens, DemoUsers.Michael_John, DemoUsers.Jason_Stevens) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Simple); - - // Facilities Actionable Items - IAtsConfigTxActionableItem facilitiesAi = - topActionableItem.createChildActionableItem(DemoArtifactToken.Facilities_Ai) // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.Facilities_Team); - - facilitiesAi.createChildActionableItem("Backups") // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.Facilities_IT_Team); - - facilitiesAi.createChildActionableItem("Break Room") // - .andActionable(true); - - facilitiesAi.createChildActionableItem("Computers") // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.Facilities_IT_Team); - - facilitiesAi.createChildActionableItem("Network") // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.Facilities_IT_Team); - - facilitiesAi.createChildActionableItem("Vending Machines") // - .andActionable(true); - - } - - private void createToolsTeamConfig(IAtsConfigTx cfgTx, IAtsConfigTxTeamDef topTeam, IAtsConfigTxActionableItem topActionableItem) { - - // Tools Team - IAtsConfigTxTeamDef toolsTeamDef = topTeam.createChildTeamDef(topTeam.getTeamDef(), DemoArtifactToken.Tools_Team) // - .andLeads(DemoUsers.Jeffery_Kay) // - .andMembers(DemoUsers.Jeffery_Kay, DemoUsers.Roland_Stevens) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Default); - - // Web Team - toolsTeamDef.createChildTeamDef(toolsTeamDef.getTeamDef(), DemoArtifactToken.Website_Team) // - .andLeads(DemoUsers.Karmen_John) // - .andMembers(DemoUsers.Karmen_John, DemoUsers.Jeffery_Kay, DemoUsers.Roland_Stevens) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Simple); - - // Tools Actionable Items - IAtsConfigTxActionableItem toolsAi = topActionableItem.createChildActionableItem(DemoArtifactToken.Tools_Ai) // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.Tools_Team); - - toolsAi.createChildActionableItem(DemoArtifactToken.Reader_AI) // - .andActionable(true); - - toolsAi.createChildActionableItem("Results Reporter") // - .andActionable(true); - - toolsAi.createChildActionableItem(DemoArtifactToken.Timesheet_AI) // - .andActionable(true); - - toolsAi.createChildActionableItem("Website") // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.Website_Team); - - } - - private void createSystemSafetyTeamConfig(IAtsConfigTx cfgTx, IAtsConfigTxTeamDef topTeamDef, IAtsConfigTxActionableItem topAi) { - - // System Safety Team - topTeamDef.createChildTeamDef(topTeamDef.getTeamDef(), DemoArtifactToken.System_Safety_Team) // - .andLeads(DemoUsers.Joe_Smith) // - .andMembers(DemoUsers.Jeffery_Kay) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Default); - - // System Safety Actionable Items - topAi.createChildActionableItem(DemoArtifactToken.System_Safety_Ai) // - .andTeamDef(DemoArtifactToken.System_Safety_Team) // - .andActionable(true); - - } - - private void createProcessTeamConfig(IAtsConfigTx cfgTx, IAtsConfigTxTeamDef topTeamDef, IAtsConfigTxActionableItem topActionableItem) { - - // Process Team - topTeamDef.createChildTeamDef(topTeamDef.getTeamDef(), DemoArtifactToken.Process_Team) // - .andLeads(DemoUsers.Alex_Kay) // - .andMembers(DemoUsers.Keith_Johnson, DemoUsers.Michael_Alex, DemoUsers.Janice_Michael, DemoUsers.Alex_Kay) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Default); - - // Process Actionable Items - IAtsConfigTxActionableItem processesAi = topActionableItem.createChildActionableItem("Processes") // - .andActionable(false) // - .andTeamDef(DemoArtifactToken.Process_Team); - - processesAi.createChildActionableItem("Coding Standards") // - .andActionable(true); - - processesAi.createChildActionableItem("Config Mgmt") // - .andActionable(true); - - processesAi.createChildActionableItem("New Employee Manual") // - .andActionable(true); - - processesAi.createChildActionableItem("Reviews") // - .andActionable(true); - } - - private void createSawPlTeamConfig(IAtsConfigTx cfgTx, IAtsConfigTxTeamDef topTeam, IAtsConfigTxActionableItem topActionableItem) { - - // SAW PL - IAtsConfigTxTeamDef sawPlTeamDef = topTeam.createChildTeamDef(topTeam.getTeamDef(), DemoArtifactToken.SAW_PL_TeamDef) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andLeads(DemoUsers.Kay_Jason) // - .andMembers(DemoUsers.Kay_Jason, DemoUsers.Michael_John, DemoUsers.Steven_Kohn) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Default) // - .andVersion(DemoArtifactToken.SAW_Product_Line, ReleasedOption.UnReleased, DemoBranches.SAW_PL, - NextRelease.Next) // - .andVersion(DemoArtifactToken.SAW_Hardening_Branch, ReleasedOption.UnReleased, - DemoBranches.SAW_PL_Hardening_Branch, NextRelease.Next) // - .andRelatedPeerWorkflowDefinition(AtsWorkDefinitionTokens.WorkDef_Review_PeerToPeer_Demo); - - // SAW PL Team Defs - sawPlTeamDef.createChildTeamDef(sawPlTeamDef.getTeamDef(), DemoArtifactToken.SAW_PL_Code_TeamDef) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.Code) // - .andLeads(DemoUsers.Joe_Smith) // - .andMembers(DemoUsers.Joe_Smith) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Code) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoCodeTeamWorkflow); - - sawPlTeamDef.createChildTeamDef(sawPlTeamDef.getTeamDef(), DemoArtifactToken.SAW_PL_HW_TeamDef) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.Hardware) // - .andLeads(DemoUsers.Jason_Michael) // - .andMembers(DemoUsers.Jason_Michael) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Default) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoReqTeamWorkflow); - - sawPlTeamDef.createChildTeamDef(sawPlTeamDef.getTeamDef(), DemoArtifactToken.SAW_PL_Requirements_TeamDef) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.Requirements) // - .andLeads(DemoUsers.Joe_Smith) // - .andMembers(DemoUsers.Joe_Smith) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Req) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoReqTeamWorkflow); - - sawPlTeamDef.createChildTeamDef(sawPlTeamDef.getTeamDef(), DemoArtifactToken.SAW_PL_SW_Design_TeamDef) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.SW_Design) // - .andLeads(DemoUsers.Kay_Jones) // - .andMembers(DemoUsers.Kay_Jones) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_SwDesign); - - sawPlTeamDef.createChildTeamDef(sawPlTeamDef.getTeamDef(), DemoArtifactToken.SAW_PL_Test_TeamDef) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.Test) // - .andLeads(DemoUsers.Kay_Jones) // - .andMembers(DemoUsers.Kay_Jones) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Test) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoTestTeamWorkflow); - - sawPlTeamDef.createChildTeamDef(sawPlTeamDef.getTeamDef(), DemoArtifactToken.SAW_PL_ARB_TeamDef) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.ARB) // - .andLeads(DemoUsers.Joe_Smith) // - .andMembers(DemoUsers.Joe_Smith) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_ProductLine) // - .andTeamWorkflowArtifactType(AtsArtifactTypes.TeamWorkflow); - - // SAW SW Actionable Items - IAtsConfigTxActionableItem sawPlSwAi = - topActionableItem.createChildActionableItem(DemoArtifactToken.SAW_PL_CSCI_AI) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andActionable(false); - - sawPlSwAi.createChildActionableItem(DemoArtifactToken.SAW_PL_Code_AI) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.Code) // - .andTeamDef(DemoArtifactToken.SAW_PL_Code_TeamDef) // - .andActionable(true) // - .andChildAis("COMM", "MSM", "NAV", "Test Page"); - - sawPlSwAi.createChildActionableItem(DemoArtifactToken.SAW_PL_Requirements_AI) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.Requirements) // - .andTeamDef(DemoArtifactToken.SAW_PL_Requirements_TeamDef) // - .andActionable(true) // - .andChildAis("COMM", "MSM", "NAV") // - .and(CoreAttributeTypes.StaticId, DemoAis.TEST_AI); - - sawPlSwAi.createChildActionableItem(DemoArtifactToken.SAW_PL_Test_AI) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.Test) // - .andTeamDef(DemoArtifactToken.SAW_PL_Test_TeamDef) // - .andActionable(true) // - .andChildAis("ADT", "COMM", "MSM", "NAV", "RulLists"); - - sawPlSwAi.createChildActionableItem(DemoArtifactToken.SAW_PL_SW_Design_AI) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.SW_Design) // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.SAW_PL_SW_Design_TeamDef); - - sawPlSwAi.createChildActionableItem(DemoArtifactToken.SAW_PL_HW_AI) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.Hardware) // - .andTeamDef(DemoArtifactToken.SAW_PL_HW_TeamDef) // - .andActionable(true) // - .andChildAis("Adapter", "Case", "Manual", "Screen"); - - sawPlSwAi.createChildActionableItem(DemoArtifactToken.SAW_PL_ARB_AI) // - .andProgram(DemoArtifactToken.SAW_PL_Program) // - .andWorkType(WorkType.ARB) // - .andTeamDef(DemoArtifactToken.SAW_PL_ARB_TeamDef) // - .andActionable(true); - - // SAW PL Program - cfgTx.createProgram(DemoArtifactToken.SAW_PL_Program) // - .andTeamDef(DemoArtifactToken.SAW_PL_TeamDef) // - .and(AtsAttributeTypes.Description, "Program object for SAW PL Program") // - .and(AtsAttributeTypes.Namespace, "org.demo.saw.pl"); - - } - - private void createSawTeamConfig(IAtsConfigTx cfgTx, IAtsConfigTxTeamDef topTeam, IAtsConfigTxActionableItem topActionableItem) { - - // SAW SW - IAtsConfigTxTeamDef sawSwTeamDef = topTeam.createChildTeamDef(topTeam.getTeamDef(), DemoArtifactToken.SAW_SW) // - .andProgram(DemoArtifactToken.SAW_Program) // - .and(CoreAttributeTypes.StaticId, "saw.teamDefHoldingVersions") // - .andLeads(DemoUsers.Kay_Jason) // - .andMembers(DemoUsers.Steven_Kohn, DemoUsers.Michael_John, DemoUsers.Kay_Jason) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Default) // - .andVersion(DemoArtifactToken.SAW_Bld_1, ReleasedOption.Released, DemoBranches.SAW_Bld_1, NextRelease.None) // - .andVersion(DemoArtifactToken.SAW_Bld_2, ReleasedOption.UnReleased, DemoBranches.SAW_Bld_2, NextRelease.Next) // - .andVersion(DemoArtifactToken.SAW_Bld_3, ReleasedOption.UnReleased, DemoBranches.SAW_Bld_3, NextRelease.None) // - .andRelatedPeerWorkflowDefinition(AtsWorkDefinitionTokens.WorkDef_Review_PeerToPeer_Demo); - - /** - * Artifact types used can be declared through Team Definition or Workflow Definition. This will get its artifact - * type through the Workflow Definition. - */ - // SAW SW Team Defs - sawSwTeamDef.createChildTeamDef(sawSwTeamDef.getTeamDef(), DemoArtifactToken.SAW_Code) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.Code) // - .andCsci(Csci.DP, Csci.SP, Csci.WP) // - .and(CoreAttributeTypes.StaticId, "saw.code") // - .andLeads(DemoUsers.Joe_Smith) // - .andMembers(DemoUsers.Joe_Smith) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Code); - - /** - * Artifact types used can be declared through Team Definition or Workflow Definition. This is an example of the - * config through Team Definition. - */ - sawSwTeamDef.createChildTeamDef(sawSwTeamDef.getTeamDef(), DemoArtifactToken.SAW_HW) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.Hardware) // - .andLeads(DemoUsers.Jason_Michael) // - .andMembers(DemoUsers.Jason_Michael) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Default) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoReqTeamWorkflow); - - sawSwTeamDef.createChildTeamDef(sawSwTeamDef.getTeamDef(), DemoArtifactToken.SAW_Test) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.Test) // - .andCsci(Csci.DP, Csci.SP, Csci.WP) // - .and(CoreAttributeTypes.StaticId, "saw.test") // - .andLeads(DemoUsers.Kay_Jones) // - .andMembers(DemoUsers.Kay_Jones) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Test) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoTestTeamWorkflow); - - sawSwTeamDef.createChildTeamDef(sawSwTeamDef.getTeamDef(), DemoArtifactToken.SAW_SW_Design) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.SW_Design) // - .and(CoreAttributeTypes.StaticId, "saw.sw.design") // - .andLeads(DemoUsers.Kay_Jones) // - .andMembers(DemoUsers.Kay_Jones) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_SwDesign) // - .andRelatedPeerWorkflowDefinition(DemoWorkDefinitions.WorkDef_Review_Demo_Peer_SwDesign) // - .andRelatedTaskWorkflowDefinition(DemoWorkDefinitions.WorkDef_Task_Demo_SwDesign, - AtsWorkDefinitionTokens.WorkDef_Task_Default) // - .andTaskSet(TaskSetDefinitionTokensDemo.SawSwDesignTestingChecklist, - TaskSetDefinitionTokensDemo.SawSwDesignProcessChecklist); - - sawSwTeamDef.createChildTeamDef(sawSwTeamDef.getTeamDef(), DemoArtifactToken.SAW_Requirements) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.Requirements) // - .andCsci(Csci.DP, Csci.SP, Csci.WP) // - .and(CoreAttributeTypes.StaticId, "saw.reqirements") // - .andLeads(DemoUsers.Joe_Smith) // - .andMembers(DemoUsers.Joe_Smith) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Req) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoReqTeamWorkflow); - - // SAW SW Actionable Items - IAtsConfigTxActionableItem sawSwAi = topActionableItem.createChildActionableItem(DemoArtifactToken.SAW_CSCI_AI) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andCsci(Csci.DP, Csci.SP, Csci.WP) // - .andActionable(false); - - sawSwAi.createChildActionableItem(DemoArtifactToken.SAW_Code_AI) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.Code) // - .andCsci(Csci.DP, Csci.SP, Csci.WP) // - .andTeamDef(DemoArtifactToken.SAW_Code) // - .andActionable(true) // - .andChildAis("COMM", "MSM", "NAV", "Test Page"); - - sawSwAi.createChildActionableItem(DemoArtifactToken.SAW_HW_AI) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.Hardware) // - .andTeamDef(DemoArtifactToken.SAW_HW) // - .andChildAis(DemoArtifactToken.Adapter_AI) // - .andActionable(true) // - .andChildAis("Case", "Manual", "Screen"); - - sawSwAi.createChildActionableItem(DemoArtifactToken.SAW_Requirements_AI) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.Requirements) // - .andCsci(Csci.DP, Csci.SP, Csci.WP) // - .andTeamDef(DemoArtifactToken.SAW_Requirements) // - .andActionable(true) // - .andChildAis("COMM", "MSM", "NAV"); - - sawSwAi.createChildActionableItem(DemoArtifactToken.SAW_Test_AI) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.Test) // - .andCsci(Csci.DP, Csci.SP, Csci.WP) // - .andTeamDef(DemoArtifactToken.SAW_Test) // - .andActionable(true) // - .andChildAis("ADT", "COMM", "MSM", "NAV", "RunLists"); - - sawSwAi.createChildActionableItem(DemoArtifactToken.SAW_SW_Design_AI) // - .andProgram(DemoArtifactToken.SAW_Program) // - .andWorkType(WorkType.SW_Design) // - .andTeamDef(DemoArtifactToken.SAW_SW_Design) // - .andActionable(true); - - // SAW Program - cfgTx.createProgram(DemoArtifactToken.SAW_Program) // - .andTeamDef(DemoArtifactToken.SAW_SW) // - .andCsci(Csci.DP, Csci.SP, Csci.WP) // - .and(AtsAttributeTypes.Description, "Program object for SAW Program") // - .and(AtsAttributeTypes.Namespace, "org.demo.saw"); - - } - - private void createCisTeamConfig(IAtsConfigTx cfgTx, IAtsConfigTxTeamDef topTeam, IAtsConfigTxActionableItem topActionableItem) { - - // CIS SW - IAtsConfigTxTeamDef cisSwTeamDef = topTeam.createChildTeamDef(topTeam.getTeamDef(), DemoArtifactToken.CIS_SW) // - .and(CoreAttributeTypes.StaticId, "cis.teamDefHoldingVersions") // - .andLeads(DemoUsers.Kay_Jason) // - .andMembers(DemoUsers.Steven_Kohn, DemoUsers.Michael_John, DemoUsers.Kay_Jason) // - .andWorkDef(AtsWorkDefinitionTokens.WorkDef_Team_Default) // - .andVersion("CIS Bld 1", ReleasedOption.Released, DemoBranches.CIS_Bld_1, NextRelease.None) // - .andVersion("CIS Bld 2", ReleasedOption.UnReleased, null, NextRelease.Next) // - .andVersion("CIS Bld 3", ReleasedOption.UnReleased, null, NextRelease.None); - - // CIS SW Team Defs - cisSwTeamDef.createChildTeamDef(cisSwTeamDef.getTeamDef(), DemoArtifactToken.CIS_Code) // - .and(CoreAttributeTypes.StaticId, "cis.code") // - .andLeads(DemoUsers.Jason_Michael) // - .andMembers(DemoUsers.Jason_Michael) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Code); - - cisSwTeamDef.createChildTeamDef(cisSwTeamDef.getTeamDef(), DemoArtifactToken.CIS_Test) // - .and(CoreAttributeTypes.StaticId, "cis.test") // - .andLeads(DemoUsers.Kay_Jones) // - .andMembers(DemoUsers.Kay_Jones) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Test) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoTestTeamWorkflow); - - cisSwTeamDef.createChildTeamDef("CIS SW Design") // - .and(CoreAttributeTypes.StaticId, "cis.sw.design") // - .andLeads(DemoUsers.Kay_Jones) // - .andMembers(DemoUsers.Kay_Jones) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_SwDesign); - - cisSwTeamDef.createChildTeamDef("CIS Requirements") // - .and(CoreAttributeTypes.StaticId, "cis.reqirements") // - .andLeads(DemoUsers.Joe_Smith) // - .andMembers(DemoUsers.Joe_Smith) // - .andWorkDef(DemoWorkDefinitions.WorkDef_Team_Demo_Req) // - .andTeamWorkflowArtifactType(AtsDemoOseeTypes.DemoReqTeamWorkflow); - - // CIS SW Actionable Items - IAtsConfigTxActionableItem cisSwAi = topActionableItem.createChildActionableItem(DemoArtifactToken.CIS_CSCI) // - .andActionable(false); - - cisSwAi.createChildActionableItem("CIS Code") // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.CIS_Code); - - cisSwAi.createChildActionableItem("CIS Requirements") // - .andActionable(true) // - .andTeamDef("CIS Requirements"); - - cisSwAi.createChildActionableItem(DemoArtifactToken.CIS_Test_AI) // - .andActionable(true) // - .andTeamDef(DemoArtifactToken.CIS_Test); - - cisSwAi.createChildActionableItem("CIS SW Design") // - .andActionable(true) // - .andTeamDef("CIS SW Design"); - - // CIS Program - cfgTx.createProgram(DemoArtifactToken.CIS_Program) // - .andTeamDef(DemoArtifactToken.CIS_SW) // - .and(AtsAttributeTypes.Description, "Program object for CIS Program") // - .and(AtsAttributeTypes.Namespace, "org.demo.cis"); - - } - /** * Configure SAW_Bld_1 and SAW_Bld_2 for parallel commit, including recursive setup where SAW_Bld_1 needs to be * committed to SAW_Bld_1 and SAW_Bld_2 and SAW_Bld_2 needs to be committed to SAW_Bld_2 and SAW_Bld_1 @@ -553,4 +86,5 @@ public class AtsDbConfigDemoOp { changes.execute(); } + } diff --git a/plugins/org.eclipse.osee.client.demo/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.client.demo/META-INF/MANIFEST.MF index a85fc0fea1..acfe5e3a7a 100644 --- a/plugins/org.eclipse.osee.client.demo/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.client.demo/META-INF/MANIFEST.MF @@ -12,8 +12,8 @@ Import-Package: javax.ws.rs.core, org.eclipse.jdt.annotation, org.eclipse.osee.define.ide.traceability, org.eclipse.osee.define.ide.traceability.data, - org.eclipse.osee.framework.access, org.eclipse.osee.framework.core, + org.eclipse.osee.framework.core.access, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.data.computed, org.eclipse.osee.framework.core.enums, diff --git a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java index 1a33bd5d27..37ab2ad0fb 100644 --- a/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java +++ b/plugins/org.eclipse.osee.client.demo/src/org/eclipse/osee/client/demo/internal/AddRequirementData.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.BranchId; @@ -67,11 +66,15 @@ public class AddRequirementData implements IDbInitializationTask { try { BranchId branch = SAW_Bld_1; - //@formatter:off - importRequirements(branch, CoreArtifactTypes.SoftwareRequirementMsWord, CoreArtifactTokens.SoftwareRequirementsFolder, OseeInf.getResourceAsFile("requirements/SAW-SoftwareRequirements.xml", getClass())); - importRequirements(branch, CoreArtifactTypes.SystemRequirementMsWord, CoreArtifactTokens.SystemRequirementsFolder, OseeInf.getResourceAsFile("requirements/SAW-SystemRequirements.xml", getClass())); - importRequirements(branch, CoreArtifactTypes.SubsystemRequirementMsWord, CoreArtifactTokens.SubSystemRequirementsFolder, OseeInf.getResourceAsFile("requirements/SAW-SubsystemRequirements.xml", getClass())); - //@formatter:on + importRequirements(branch, CoreArtifactTypes.SoftwareRequirementMsWord, + CoreArtifactTokens.SoftwareRequirementsFolder, + OseeInf.getResourceAsFile("requirements/SAW-SoftwareRequirements.xml", getClass())); + importRequirements(branch, CoreArtifactTypes.SystemRequirementMsWord, + CoreArtifactTokens.SystemRequirementsFolder, + OseeInf.getResourceAsFile("requirements/SAW-SystemRequirements.xml", getClass())); + importRequirements(branch, CoreArtifactTypes.SubsystemRequirementMsWord, + CoreArtifactTokens.SubSystemRequirementsFolder, + OseeInf.getResourceAsFile("requirements/SAW-SubsystemRequirements.xml", getClass())); SkynetTransaction demoDbTraceability = TransactionManager.createTransaction(branch, "Populate Demo DB - Create Traceability"); @@ -80,8 +83,8 @@ public class AddRequirementData implements IDbInitializationTask { // Create SAW_Bld_2 Child Main Working Branch off SAW_Bld_1 BranchId childBranch = BranchManager.createBaselineBranch(SAW_Bld_1, SAW_Bld_2); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), SAW_Bld_2, - PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), + SAW_Bld_2, PermissionEnum.FULLACCESS); // need to update the branch type; ConnectionHandler.runPreparedUpdate(UPDATE_BRANCH_TYPE, BranchType.BASELINE, childBranch); diff --git a/plugins/org.eclipse.osee.client.integration.tests/.project b/plugins/org.eclipse.osee.client.integration.tests/.project index 28184747a1..dc10962dea 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/.project +++ b/plugins/org.eclipse.osee.client.integration.tests/.project @@ -20,6 +20,11 @@ + + org.eclipse.pde.ds.core.builder + + + org.eclipse.pde.PluginNature diff --git a/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF index 07873b6f65..fc7acb1e78 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.client.integration.tests/META-INF/MANIFEST.MF @@ -6,6 +6,7 @@ Bundle-ActivationPolicy: lazy Bundle-Version: 1.0.0.qualifier Bundle-Vendor: Eclipse Open System Engineering Environment Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Service-Component: OSGI-INF/*.xml Import-Package: javax.ws.rs.client, javax.ws.rs.core, org.eclipse.core.runtime, @@ -14,7 +15,6 @@ Import-Package: javax.ws.rs.client, org.eclipse.osee.client.demo, org.eclipse.osee.client.test.framework, org.eclipse.osee.define.api, - org.eclipse.osee.framework.access, org.eclipse.osee.framework.core, org.eclipse.osee.framework.core.access, org.eclipse.osee.framework.core.applicability, @@ -22,9 +22,6 @@ Import-Package: javax.ws.rs.client, org.eclipse.osee.framework.core.client.server, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.data.computed, - org.eclipse.osee.framework.core.dsl, - org.eclipse.osee.framework.core.dsl.integration, - org.eclipse.osee.framework.core.dsl.oseeDsl, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.enums.token, org.eclipse.osee.framework.core.exception, @@ -64,6 +61,4 @@ Require-Bundle: org.junit, org.eclipse.osee.framework.skynet.core, org.eclipse.osee.framework.ui.skynet, org.eclipse.osee.define.ide, - org.eclipse.osee.framework.core.dsl.ui.integration, - org.eclipse.osee.framework.core.dsl.integration, javax.mail.glassfish;bundle-version="1.4.1" diff --git a/plugins/org.eclipse.osee.client.integration.tests/OSGI-INF/osee.api.service.ref.xml b/plugins/org.eclipse.osee.client.integration.tests/OSGI-INF/osee.api.service.ref.xml index 10cc8fa2a4..4b8d770146 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/OSGI-INF/osee.api.service.ref.xml +++ b/plugins/org.eclipse.osee.client.integration.tests/OSGI-INF/osee.api.service.ref.xml @@ -1,5 +1,5 @@ - + diff --git a/plugins/org.eclipse.osee.client.integration.tests/build.properties b/plugins/org.eclipse.osee.client.integration.tests/build.properties index 17908691f5..f58f8375b8 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/build.properties +++ b/plugins/org.eclipse.osee.client.integration.tests/build.properties @@ -3,4 +3,5 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ logback-test.xml,\ - support/ + support/,\ + OSGI-INF/ diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/OseeClientIntegrationTestSuite.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/OseeClientIntegrationTestSuite.java index 916214e54c..fb2967e215 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/OseeClientIntegrationTestSuite.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/OseeClientIntegrationTestSuite.java @@ -16,7 +16,6 @@ package org.eclipse.osee.client.integration.tests; import org.eclipse.osee.client.integration.tests.integration.DirtyArtifactCacheTest; import org.eclipse.osee.client.integration.tests.integration.LongRunningTestSuite; import org.eclipse.osee.client.integration.tests.integration.define.XDefineIntegrationTestSuite; -import org.eclipse.osee.client.integration.tests.integration.dsl.ui.integration.XDslUiIntegrationTestSuite; import org.eclipse.osee.client.integration.tests.integration.endpoint.EndpointIntegrationTestSuite; import org.eclipse.osee.client.integration.tests.integration.orcs.rest.OrcsRestTestSuite; import org.eclipse.osee.client.integration.tests.integration.skynet.core.XSkynetCoreIntegrationTestSuite; @@ -32,7 +31,6 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ OrcsRestTestSuite.class, EndpointIntegrationTestSuite.class, - XDslUiIntegrationTestSuite.class, XDefineIntegrationTestSuite.class, XSkynetCoreIntegrationTestSuite.class, XUiSkynetCoreIntegrationTestSuite.class, diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/OseeApiService.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/OseeApiService.java deleted file mode 100644 index 291f98eb05..0000000000 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/OseeApiService.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021 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.client.integration.tests.integration; - -import org.eclipse.osee.framework.core.OseeApi; - -/** - * @author Donald G. Dunne - */ -public class OseeApiService { - - public static OseeApi oseeApi; - - public OseeApiService() { - // for jax-rs - } - - public OseeApi getOseeApi() { - return oseeApi; - } - - public void setOseeApi(OseeApi oseeApi) { - OseeApiService.oseeApi = oseeApi; - } - - public static OseeApi get() { - return oseeApi; - } - -} diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/MockDslProvider.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/MockDslProvider.java deleted file mode 100644 index 7846b084e6..0000000000 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/MockDslProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.client.integration.tests.integration.dsl.ui.integration; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.eclipse.osee.framework.core.dsl.integration.OseeDslProvider; -import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; - -/** - * @author Roberto E. Escobar - */ -public class MockDslProvider implements OseeDslProvider { - - private final OseeDsl dslToReturn; - - private boolean wasLoadDslCalled; - private boolean wasGetDslCalled; - private OseeDsl dslToStore; - - public MockDslProvider(OseeDsl dslToReturn) { - this.dslToReturn = dslToReturn; - } - - @Override - public void loadDsl() { - wasLoadDslCalled = true; - } - - @Override - public OseeDsl getDsl() { - wasGetDslCalled = true; - return dslToReturn; - } - - @Override - public void storeDsl(OseeDsl dsl) { - dslToStore = dsl; - } - - public OseeDsl getDslToStore() { - return dslToStore; - } - - public boolean wasLoadDslCalled() { - return wasLoadDslCalled; - } - - public boolean wasGetDslCalled() { - return wasGetDslCalled; - } - - @Override - public Map getContextGuidToIdMap() { - return new ConcurrentHashMap<>(); - } - -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/OseeDslRoleContextProviderTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/OseeDslRoleContextProviderTest.java deleted file mode 100644 index a51f2ebab5..0000000000 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/OseeDslRoleContextProviderTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.client.integration.tests.integration.dsl.ui.integration; - -import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO; -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Artifact; -import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule; -import org.eclipse.osee.client.test.framework.OseeLogMonitorRule; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.OseeDslResourceUtil; -import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; -import org.eclipse.osee.framework.core.dsl.ui.integration.operations.OseeDslRoleContextProvider; -import org.eclipse.osee.framework.core.enums.CoreArtifactTokens; -import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.core.enums.SystemUser; -import org.eclipse.osee.framework.jdk.core.util.Lib; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; -import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; - -/** - * Test Case for {@link OseeDslRoleContextProvider} - * - * @author John R. Misinco - */ -public class OseeDslRoleContextProviderTest { - - @Rule - public OseeClientIntegrationRule integration = new OseeClientIntegrationRule(OSEE_CLIENT_DEMO); - - @Rule - public OseeLogMonitorRule monitorRule = new OseeLogMonitorRule(); - - @Test - public void testGetContextId() throws Exception { - Long contextId = Lib.generateArtifactIdAsInt(); - Artifact user = ArtifactQuery.getArtifactFromToken(SystemUser.Anonymous); - String testSheet = getTestSheet1(contextId, user.getId()); - OseeDsl model = OseeDslResourceUtil.loadModel("osee:/text.osee", testSheet).getModel(); - MockDslProvider dslProvider = new MockDslProvider(model); - OseeDslRoleContextProvider contextProvider = new OseeDslRoleContextProvider(dslProvider); - Collection contextIds = contextProvider.getContextId(user); - - Assert.assertEquals(1, contextIds.size()); - Assert.assertEquals(contextId, contextIds.iterator().next().getId()); - } - - @Test - public void testGetContextIdExtended() throws Exception { - Long contextId1 = Lib.generateArtifactIdAsInt(); - Long contextId2 = Lib.generateArtifactIdAsInt(); - Artifact user = ArtifactQuery.getArtifactFromToken(SystemUser.Anonymous); - Artifact role2User = ArtifactTypeManager.addArtifact(Artifact, COMMON, "Role 2 user"); - - String testSheet = getTestSheet2(contextId1, user.getId(), contextId2, role2User); - OseeDsl model = OseeDslResourceUtil.loadModel("osee:/text.osee", testSheet).getModel(); - MockDslProvider dslProvider = new MockDslProvider(model); - OseeDslRoleContextProvider contextProvider = new OseeDslRoleContextProvider(dslProvider); - Collection contextIds = contextProvider.getContextId(user); - - Assert.assertEquals(1, contextIds.size()); - Assert.assertEquals(contextId1, contextIds.iterator().next().getId()); - - role2User.persist("Test User"); - contextIds = contextProvider.getContextId(role2User); - - Assert.assertEquals(2, contextIds.size()); - Iterator iterator = contextIds.iterator(); - List contextList = new LinkedList<>(); - contextList.add(contextId1); - contextList.add(contextId2); - Assert.assertTrue(contextList.remove(iterator.next().getId())); - Assert.assertTrue(contextList.remove(iterator.next().getId())); - - role2User.deleteAndPersist(getClass().getSimpleName()); - } - - @Test - public void testDbInitCreationOfAccessModel() throws Exception { - Artifact model = ArtifactQuery.getArtifactFromToken(CoreArtifactTokens.FrameworkAccessModel); - String xtext = model.getSoleAttributeValue(CoreAttributeTypes.GeneralStringData); - Assert.assertTrue(xtext.contains("anonymous.context")); - } - - private String getTestSheet1(Long contextId, Long role1Id) { - StringBuilder sb = new StringBuilder(); - sb.append("role \"role1\" {\n"); - sb.append(" id "); - sb.append(role1Id); - sb.append(";\n"); - sb.append(" accessContext \"role1.context\";\n"); - sb.append("}\n\n"); - - sb.append("accessContext \"role1.context\" {\n"); - sb.append(" id "); - sb.append(contextId); - sb.append(";\n"); - sb.append(" DENY edit relationType ALL BOTH;\n"); - sb.append("}\n"); - return sb.toString(); - } - - private String getTestSheet2(Long context1, Long role1Id, Long context2, Artifact role2) { - StringBuilder sb = new StringBuilder(getTestSheet1(context1, role1Id)); - sb.append("\nrole \"role2\" extends \"role1\" {\n"); - sb.append(" id "); - sb.append(role2.getIdString()); - sb.append(";\n"); - sb.append(" accessContext \"role2.context\";\n"); - sb.append("}\n\n"); - - sb.append("accessContext \"role2.context\" {\n"); - sb.append(" id "); - sb.append(context2); - sb.append(";\n"); - sb.append(" DENY edit relationType ALL BOTH;\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/XDslUiIntegrationTestSuite.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/XDslUiIntegrationTestSuite.java deleted file mode 100644 index 4ddbed430d..0000000000 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/dsl/ui/integration/XDslUiIntegrationTestSuite.java +++ /dev/null @@ -1,26 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.client.integration.tests.integration.dsl.ui.integration; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({OseeDslRoleContextProviderTest.class}) -/** - * @author Ryan D. Brooks - */ -public class XDslUiIntegrationTestSuite { - // Test Suite -} diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/AccessControlTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/AccessControlTest.java index f1c17bbfe2..cbbf311718 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/AccessControlTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/AccessControlTest.java @@ -14,13 +14,13 @@ package org.eclipse.osee.client.integration.tests.integration.skynet.core; import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO; +import org.eclipse.osee.client.integration.tests.internal.OseeApiService; import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule; import org.eclipse.osee.client.test.framework.OseeLogMonitorRule; import org.eclipse.osee.client.test.framework.TestInfo; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; 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; @@ -51,38 +51,39 @@ public class AccessControlTest { private static BranchToken branch; - @Test(expected = OseeStateException.class) + @Test(expected = OseeCoreException.class) public void testNoWriteOnReadAccessOnBranch() { - AccessControlManager.setPermission(UserManager.getUser(), branch, PermissionEnum.READ); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(), branch, PermissionEnum.READ); artifact1 = new Artifact(branch, "New Name"); artifact1.persist(testInfo.getTestName()); } - @Test(expected = OseeStateException.class) + @Test(expected = OseeCoreException.class) public void testNoWriteOnNoneAccessOnBranch() { - AccessControlManager.setPermission(UserManager.getUser(), branch, PermissionEnum.NONE); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(), branch, PermissionEnum.NONE); artifact2 = new Artifact(branch, "New Name"); artifact2.persist(testInfo.getTestName()); } @Test public void testWriteAccessOnBranch() { - AccessControlManager.setPermission(UserManager.getUser(), branch, PermissionEnum.WRITE); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(), branch, PermissionEnum.WRITE); artifact3 = new Artifact(branch, "New Name"); artifact3.persist(testInfo.getTestName()); } @Test public void testWriteOnFullAccessOnBranch() { - AccessControlManager.setPermission(UserManager.getUser(), branch, PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(), branch, + PermissionEnum.FULLACCESS); artifact4 = new Artifact(branch, "New Name"); artifact4.persist(testInfo.getTestName()); } - @Test(expected = OseeStateException.class) + @Test(expected = OseeCoreException.class) public void testNoWriteOnDenyAccessOnBranch() { BranchToken branch = BranchManager.createTopLevelBranch(testInfo.getTestName() + " branch"); - AccessControlManager.setPermission(UserManager.getUser(), branch, PermissionEnum.DENY); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(), branch, PermissionEnum.DENY); artifact5 = new Artifact(branch, "New Name"); artifact5.persist(testInfo.getTestName()); } @@ -118,4 +119,4 @@ public class AccessControlTest { BranchManager.purgeBranch(branch); } } -} \ No newline at end of file +} diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java index 8465df1ed9..5376259ec6 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java @@ -23,11 +23,11 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.osee.client.integration.tests.internal.OseeApiService; import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule; import org.eclipse.osee.client.test.framework.OseeHousekeepingRule; import org.eclipse.osee.client.test.framework.OseeLogMonitorRule; import org.eclipse.osee.client.test.framework.TestInfo; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.AttributeId; import org.eclipse.osee.framework.core.data.BranchId; @@ -38,6 +38,7 @@ import org.eclipse.osee.framework.core.enums.CoreArtifactTokens; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.CoreBranches; +import org.eclipse.osee.framework.core.enums.CoreUserGroups; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.enums.DemoUsers; import org.eclipse.osee.framework.core.enums.PermissionEnum; @@ -192,7 +193,8 @@ public class ArtifactQueryTest { public void testGetOrCreate() throws Exception { String guid = GUID.create(); BranchToken branch = BranchManager.createTopLevelBranch(testInfo.getTestName() + " branch"); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, + PermissionEnum.FULLACCESS); Artifact artifact1 = ArtifactQuery.getOrCreate(guid, CoreArtifactTypes.GeneralData, branch); Assert.assertNotNull(artifact1); @@ -206,7 +208,8 @@ public class ArtifactQueryTest { public void testLargeAttributeIndexing() throws Exception { String guid = GUID.create(); BranchToken branch = BranchManager.createTopLevelBranch(testInfo.getTestName() + " branch"); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, + PermissionEnum.FULLACCESS); Artifact artifact1 = ArtifactQuery.getOrCreate(guid, CoreArtifactTypes.GeneralData, branch); artifact1.setSoleAttributeFromString(CoreAttributeTypes.Name, longStr()); @@ -231,7 +234,8 @@ public class ArtifactQueryTest { @Test public void testQueryById() { BranchToken branch = BranchManager.createTopLevelBranch(testInfo.getTestName() + " branch"); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, + PermissionEnum.FULLACCESS); List newIdsInOrder = new LinkedList<>(); createArtifactFortestQueryById(newIdsInOrder, branch); @@ -280,7 +284,8 @@ public class ArtifactQueryTest { @Test public void testMultipleValues() { QueryBuilderArtifact builder = ArtifactQuery.createQueryBuilder(CoreBranches.COMMON); - builder.and(CoreAttributeTypes.Name, Arrays.asList("Everyone", "OseeAdmin")); + builder.and(CoreAttributeTypes.Name, + Arrays.asList(CoreUserGroups.Everyone.getName(), CoreUserGroups.OseeAdmin.getName())); int count = builder.getCount(); Assert.assertEquals(2, count); } @@ -288,9 +293,11 @@ public class ArtifactQueryTest { @Test public void testMultipleValuesIgnoreCase() { QueryBuilderArtifact builder = ArtifactQuery.createQueryBuilder(CoreBranches.COMMON); - builder.and(CoreAttributeTypes.Name, Arrays.asList("everyone", "oseeadmin"), QueryOption.CASE__IGNORE); - int count = builder.getCount(); - Assert.assertEquals(2, count); + builder.and(CoreAttributeTypes.Name, Arrays.asList(CoreUserGroups.Everyone.getName().toLowerCase(), + CoreUserGroups.OseeAdmin.getName().toLowerCase()), QueryOption.CASE__IGNORE); + List arts = builder.getResults().getList(); + int count = arts.size(); + Assert.assertEquals(3, count); } @Test diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/DoorsArtifactExtractorTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/DoorsArtifactExtractorTest.java index 347df61c6c..ef45795096 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/DoorsArtifactExtractorTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/DoorsArtifactExtractorTest.java @@ -40,7 +40,6 @@ import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; import org.eclipse.osee.framework.skynet.core.importing.RoughArtifact; -import org.eclipse.osee.framework.skynet.core.importing.RoughArtifactKind; import org.eclipse.osee.framework.skynet.core.importing.RoughAttributeSet; import org.eclipse.osee.framework.skynet.core.importing.operations.RoughArtifactCollector; import org.eclipse.osee.framework.skynet.core.importing.parsers.DoorsArtifactExtractor; diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/OseeApiService.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/OseeApiService.java deleted file mode 100644 index 356e139fcd..0000000000 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/OseeApiService.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021 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.client.integration.tests.integration.skynet.core; - -import org.eclipse.osee.framework.core.OseeApi; - -/** - * @author Donald G. Dunne - */ -public class OseeApiService { - - public static OseeApi oseeApi; - - public OseeApiService() { - // for jax-rs - } - - public OseeApi getOseeApi() { - return oseeApi; - } - - public void setOseeApi(OseeApi oseeApi) { - OseeApiService.oseeApi = oseeApi; - } - - public static OseeApi get() { - return oseeApi; - } - -} diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/HtmlRendererTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/HtmlRendererTest.java index 149fc888e4..2f3bc5eddb 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/HtmlRendererTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/HtmlRendererTest.java @@ -19,10 +19,10 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.eclipse.osee.client.integration.tests.internal.OseeApiService; import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule; import org.eclipse.osee.client.test.framework.OseeLogMonitorRule; import org.eclipse.osee.client.test.framework.TestInfo; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; @@ -87,7 +87,7 @@ public class HtmlRendererTest { String branchName = method.getQualifiedTestName(); rootBranch = BranchManager.createTopLevelBranch(branchName); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), rootBranch, + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), rootBranch, PermissionEnum.FULLACCESS); Artifact programRoot = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(rootBranch); @@ -150,4 +150,4 @@ public class HtmlRendererTest { return value; } -} \ No newline at end of file +} diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/RelationIntegrityCheckTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/RelationIntegrityCheckTest.java index 5de9cca438..786215c81b 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/RelationIntegrityCheckTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/RelationIntegrityCheckTest.java @@ -16,9 +16,9 @@ package org.eclipse.osee.client.integration.tests.integration.ui.skynet; import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO; import java.util.LinkedList; import java.util.List; +import org.eclipse.osee.client.integration.tests.internal.OseeApiService; import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule; import org.eclipse.osee.client.test.framework.OseeLogMonitorRule; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.GammaId; @@ -71,8 +71,8 @@ public class RelationIntegrityCheckTest { @Before public void setUp() throws Exception { parentBranch = BranchManager.createTopLevelBranch("1"); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), parentBranch, - PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), + parentBranch, PermissionEnum.FULLACCESS); Artifact art_A = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, parentBranch, "A"); art_A.persist(getClass().getSimpleName()); diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ViewWordChangeAndDiffTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ViewWordChangeAndDiffTest.java index 0c639bc123..6efbea2eb5 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ViewWordChangeAndDiffTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ViewWordChangeAndDiffTest.java @@ -27,9 +27,9 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import org.eclipse.core.resources.IFolder; +import org.eclipse.osee.client.integration.tests.internal.OseeApiService; import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule; import org.eclipse.osee.client.test.framework.OseeLogMonitorRule; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; @@ -163,7 +163,8 @@ public final class ViewWordChangeAndDiffTest { } private static void checkPermissions(List artifacts) { - boolean isReadable = AccessControlManager.hasPermission(artifacts, PermissionEnum.READ); + boolean isReadable = + OseeApiService.get().getAccessControlService().hasArtifactPermission(artifacts, PermissionEnum.READ, null).isSuccess(); assertTrue("Valid object permissions", isReadable); } diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java index ed10c5c856..8491b20176 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java @@ -39,10 +39,10 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.osee.client.integration.tests.internal.OseeApiService; import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule; import org.eclipse.osee.client.test.framework.OseeLogMonitorRule; import org.eclipse.osee.client.test.framework.TestInfo; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; @@ -171,7 +171,7 @@ public class WordTemplateRendererTest { String branchName = method.getQualifiedTestName(); rootBranch = BranchManager.createTopLevelBranch(branchName); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), rootBranch, + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), rootBranch, PermissionEnum.FULLACCESS); Artifact programRoot = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(rootBranch); @@ -211,7 +211,8 @@ public class WordTemplateRendererTest { @Test public void testBlankWordTemplateContent() { BranchToken rootBr = BranchManager.createTopLevelBranch("Root Branch"); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), rootBr, PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), rootBr, + PermissionEnum.FULLACCESS); SkynetTransaction tx = TransactionManager.createTransaction(rootBr, String.format("%s", method.getQualifiedTestName())); diff --git a/plugins/org.eclipse.osee.client.parent/pom.xml b/plugins/org.eclipse.osee.client.parent/pom.xml index 9fe9969515..58c2b52bf2 100644 --- a/plugins/org.eclipse.osee.client.parent/pom.xml +++ b/plugins/org.eclipse.osee.client.parent/pom.xml @@ -32,14 +32,9 @@ ../../plugins/org.eclipse.osee.framework.lifecycle ../../plugins/org.eclipse.osee.framework.lifecycle.test - ../../plugins/org.eclipse.osee.framework.access - ../../plugins/org.eclipse.osee.framework.access.provider - ../../plugins/org.eclipse.osee.framework.branch.gantt ../../plugins/org.eclipse.osee.framework.core.client - - ../../plugins/org.eclipse.osee.framework.database.init ../../plugins/org.eclipse.osee.framework.messaging.event.res @@ -58,10 +53,6 @@ ../../plugins/org.eclipse.osee.framework.ui.skynet ../../plugins/org.eclipse.osee.framework.ui.skynet.test - ../../plugins/org.eclipse.osee.framework.core.dsl.ui - ../../plugins/org.eclipse.osee.framework.core.dsl.ui.integration - ../../plugins/org.eclipse.osee.framework.core.dsl.ui.integration.test - ../../plugins/org.eclipse.osee.framework.ui.branch.graph ../../plugins/org.eclipse.osee.framework.ui.data.model.editor ../../plugins/org.eclipse.osee.framework.ui.product @@ -106,14 +97,9 @@ ../../plugins/org.eclipse.osee.framework.lifecycle ../../plugins/org.eclipse.osee.framework.lifecycle.test - ../../plugins/org.eclipse.osee.framework.access - ../../plugins/org.eclipse.osee.framework.access.provider - ../../plugins/org.eclipse.osee.framework.branch.gantt ../../plugins/org.eclipse.osee.framework.core.client - - ../../plugins/org.eclipse.osee.framework.database.init ../../plugins/org.eclipse.osee.framework.messaging.event.res @@ -132,10 +118,6 @@ ../../plugins/org.eclipse.osee.framework.ui.skynet ../../plugins/org.eclipse.osee.framework.ui.skynet.test - ../../plugins/org.eclipse.osee.framework.core.dsl.ui - ../../plugins/org.eclipse.osee.framework.core.dsl.ui.integration - ../../plugins/org.eclipse.osee.framework.core.dsl.ui.integration.test - ../../plugins/org.eclipse.osee.framework.ui.branch.graph ../../plugins/org.eclipse.osee.framework.ui.data.model.editor ../../plugins/org.eclipse.osee.framework.ui.product diff --git a/plugins/org.eclipse.osee.disposition.rest/OSGI-INF/connector.service.xml b/plugins/org.eclipse.osee.disposition.rest/OSGI-INF/connector.service.xml deleted file mode 100644 index 27c51f0cfd..0000000000 --- a/plugins/org.eclipse.osee.disposition.rest/OSGI-INF/connector.service.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.access.provider/.classpath b/plugins/org.eclipse.osee.framework.access.provider/.classpath deleted file mode 100644 index 1fa3e6803d..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.access.provider/.project b/plugins/org.eclipse.osee.framework.access.provider/.project deleted file mode 100644 index 17078c5e8f..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/.project +++ /dev/null @@ -1,39 +0,0 @@ - - - org.eclipse.osee.framework.access.provider - - - - - - org.eclipse.xtext.ui.shared.xtextBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - org.eclipse.xtext.ui.shared.xtextNature - - diff --git a/plugins/org.eclipse.osee.framework.access.provider/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.access.provider/META-INF/MANIFEST.MF deleted file mode 100644 index ddd6dc7a17..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/META-INF/MANIFEST.MF +++ /dev/null @@ -1,37 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Framework Access Provider -Bundle-SymbolicName: org.eclipse.osee.framework.access.provider;singleton:=true -Bundle-ActivationPolicy: lazy -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: Eclipse Open System Engineering Environment -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: org.eclipse.core.resources, - org.eclipse.core.runtime, - org.eclipse.osee.framework.core, - org.eclipse.osee.framework.core.access, - org.eclipse.osee.framework.core.data, - org.eclipse.osee.framework.core.dsl.integration, - org.eclipse.osee.framework.core.dsl.oseeDsl, - org.eclipse.osee.framework.core.dsl.ui.integration.operations, - org.eclipse.osee.framework.core.enums, - org.eclipse.osee.framework.core.enums.token, - org.eclipse.osee.framework.core.exception, - org.eclipse.osee.framework.core.model, - org.eclipse.osee.framework.core.model.access, - org.eclipse.osee.framework.core.model.type, - org.eclipse.osee.framework.core.services, - org.eclipse.osee.framework.core.util, - org.eclipse.osee.framework.database.init, - org.eclipse.osee.framework.jdk.core.type, - org.eclipse.osee.framework.jdk.core.util, - org.eclipse.osee.framework.logging, - org.eclipse.osee.framework.skynet.core.artifact, - org.eclipse.osee.framework.skynet.core.artifact.search, - org.eclipse.osee.framework.skynet.core.event, - org.eclipse.osee.framework.skynet.core.event.filter, - org.eclipse.osee.framework.skynet.core.event.listener, - org.eclipse.osee.framework.skynet.core.event.model, - org.eclipse.osee.framework.skynet.core.transaction, - org.osgi.framework -Service-Component: OSGI-INF/*.xml diff --git a/plugins/org.eclipse.osee.framework.access.provider/OSGI-INF/framework.access.control.xml b/plugins/org.eclipse.osee.framework.access.provider/OSGI-INF/framework.access.control.xml deleted file mode 100644 index 79db76c327..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/OSGI-INF/framework.access.control.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.access.provider/build.properties b/plugins/org.eclipse.osee.framework.access.provider/build.properties deleted file mode 100644 index 6210e849b5..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/ -source.. = src/ diff --git a/plugins/org.eclipse.osee.framework.access.provider/pom.xml b/plugins/org.eclipse.osee.framework.access.provider/pom.xml deleted file mode 100644 index 3b2e7438bd..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - - org.eclipse.osee - org.eclipse.osee.client.parent - 1.0.0-SNAPSHOT - ../../plugins/org.eclipse.osee.client.parent - - - org.eclipse.osee.framework.access.provider - eclipse-plugin - OSEE Framework Access (Incubation) - - - diff --git a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/DefaultFrameworkAccessConstants.java b/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/DefaultFrameworkAccessConstants.java deleted file mode 100644 index b14d141072..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/DefaultFrameworkAccessConstants.java +++ /dev/null @@ -1,33 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.provider.internal; - -import org.eclipse.osee.framework.core.data.AccessContextToken; - -/** - * @author John R. Misinco - */ -public final class DefaultFrameworkAccessConstants { - - private DefaultFrameworkAccessConstants() { - //do nothing - } - - public static final AccessContextToken DEFAULT_FRAMEWORK_CONTEXT = - AccessContextToken.valueOf(7441402941554657282L, "anonymous.context"); - - public final static AccessContextToken INVALID_ASSOC_ART_ID = - AccessContextToken.valueOf(8528534420990278776L, "famework.invalidAssocArtId"); - -} diff --git a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessControl.java b/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessControl.java deleted file mode 100644 index ff15a268d9..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessControl.java +++ /dev/null @@ -1,41 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.provider.internal; - -import java.util.Collection; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.integration.RoleContextProvider; -import org.eclipse.osee.framework.core.services.CmAccessControl; - -/** - * @author John R. Misinco - */ -public class FrameworkAccessControl implements CmAccessControl { - private final RoleContextProvider roleContextProvider; - - public FrameworkAccessControl(RoleContextProvider roleContextProvider) { - this.roleContextProvider = roleContextProvider; - } - - @Override - public boolean isApplicable(ArtifactToken user, Object object) { - return true; - } - - @Override - public Collection getContextId(ArtifactToken user, Object object) { - return roleContextProvider.getContextId(user); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessControlProxy.java b/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessControlProxy.java deleted file mode 100644 index 3d6d555350..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessControlProxy.java +++ /dev/null @@ -1,167 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.provider.internal; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.logging.Level; -import org.eclipse.osee.framework.core.OrcsTokenService; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter; -import org.eclipse.osee.framework.core.dsl.integration.RoleContextProvider; -import org.eclipse.osee.framework.core.dsl.ui.integration.operations.OseeDslRoleContextProvider; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; -import org.eclipse.osee.framework.core.enums.CoreBranches; -import org.eclipse.osee.framework.core.model.access.AccessModel; -import org.eclipse.osee.framework.core.model.access.HasAccessModel; -import org.eclipse.osee.framework.core.services.CmAccessControl; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.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.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.BranchIdEventFilter; -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.listener.IEventListener; -import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; -import org.eclipse.osee.framework.skynet.core.event.model.Sender; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -/** - * @author John R. Misinco - */ -public class FrameworkAccessControlProxy implements CmAccessControl, HasAccessModel { - - private ServiceReference reference; - private CmAccessControl frameworkAccessControl; - private AccessModel accessModel; - private IEventListener listener; - private OseeEventService eventService; - private BundleContext bundleContext; - private OrcsTokenService tokenService; - - private volatile boolean isInitialized = false; - - public void setOrcsTokenService(OrcsTokenService tokenService) { - this.tokenService = tokenService; - } - - public void setAccessModelInterpreter(ServiceReference reference) { - this.reference = reference; - } - - public void setEventService(OseeEventService eventService) { - this.eventService = eventService; - } - - public void start(BundleContext bundleContext) { - this.bundleContext = bundleContext; - } - - public void stop() { - if (listener != null) { - eventService.removeListener(EventQosType.NORMAL, listener); - listener = null; - } - frameworkAccessControl = null; - accessModel = null; - } - - private boolean isReady() { - return reference != null && eventService != null && bundleContext != null; - } - - private synchronized void ensureInitialized() { - if (isReady() && !isInitialized) { - AccessModelInterpreter interpreter = bundleContext.getService(reference); - - FrameworkDslProvider frameworkDslProvider = new FrameworkDslProvider("osee:/xtext/framework.access.osee"); - RoleContextProvider roleProvider = new OseeDslRoleContextProvider(frameworkDslProvider); - - accessModel = new FrameworkAccessModel(interpreter, frameworkDslProvider, tokenService); - frameworkAccessControl = new FrameworkAccessControl(roleProvider); - - listener = new DslUpdateListener(frameworkDslProvider); - eventService.addListener(EventQosType.NORMAL, listener); - isInitialized = true; - } - } - - private void checkInitialized() { - Conditions.checkNotNull(getAccessControl(), "frameworkAccess", - "FrameworkAccessControlService not properly initialized"); - } - - private CmAccessControl getAccessControl() { - ensureInitialized(); - return frameworkAccessControl; - } - - @Override - public AccessModel getAccessModel() { - ensureInitialized(); - return accessModel; - } - - @Override - public boolean isApplicable(ArtifactToken user, Object object) { - return getAccessControl().isApplicable(user, object); - } - - @Override - public Collection getContextId(ArtifactToken user, Object object) { - checkInitialized(); - return getAccessControl().getContextId(user, object); - } - - private final class DslUpdateListener implements IArtifactEventListener { - - private List eventFilters; - private final FrameworkDslProvider dslProvider; - - public DslUpdateListener(FrameworkDslProvider dslProvider) { - this.dslProvider = dslProvider; - } - - @Override - public synchronized List getEventFilters() { - if (eventFilters == null) { - Artifact artifact = dslProvider.getStorageArtifact(); - if (artifact != null) { - eventFilters = Arrays.asList(new ArtifactEventFilter(artifact)); - } else { - eventFilters = Arrays.asList(new ArtifactTypeEventFilter(CoreArtifactTypes.AccessControlModel), - new BranchIdEventFilter(CoreBranches.COMMON)); - } - } - return eventFilters; - } - - @Override - public void handleArtifactEvent(ArtifactEvent artifactEvent, Sender sender) { - try { - dslProvider.loadDsl(); - } catch (OseeCoreException ex) { - OseeLog.log(DefaultFrameworkAccessConstants.class, Level.SEVERE, ex); - } - } - } -} diff --git a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessModel.java b/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessModel.java deleted file mode 100644 index 25f44ca7be..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkAccessModel.java +++ /dev/null @@ -1,68 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.provider.internal; - -import java.util.Collection; -import org.eclipse.osee.framework.core.OrcsTokenService; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.data.RelationTypeSide; -import org.eclipse.osee.framework.core.data.RelationTypeToken; -import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter; -import org.eclipse.osee.framework.core.dsl.integration.OseeDslAccessModel; -import org.eclipse.osee.framework.core.dsl.integration.OseeDslProvider; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.enums.RelationSide; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; - -/** - * @author John Misinco - */ -public class FrameworkAccessModel extends OseeDslAccessModel { - - private final OrcsTokenService tokenService; - - public FrameworkAccessModel(AccessModelInterpreter interpreter, OseeDslProvider dslProvider, OrcsTokenService tokenService) { - super(interpreter, dslProvider); - this.tokenService = tokenService; - } - - @Override - public void computeAccess(AccessContextToken contextId, Collection objectsToCheck, AccessData accessData) { - if (contextId.equals(DefaultFrameworkAccessConstants.INVALID_ASSOC_ART_ID)) { - for (Object obj : objectsToCheck) { - AccessDetail data = new AccessDetail<>(obj, PermissionEnum.READ, Scope.createLegacyScope(), - "Invalid artifact Id associated with branch"); - accessData.add(obj, data); - addRelationAccess(obj, accessData); - } - } else { - super.computeAccess(contextId, objectsToCheck, accessData); - } - } - - private void addRelationAccess(Object object, AccessData accessData) { - if (object instanceof Artifact) { - for (RelationTypeToken relationType : tokenService.getValidRelationTypes( - ((Artifact) object).getArtifactType())) { - for (RelationSide relationSide : RelationSide.values()) { - accessData.add(object, new AccessDetail<>(new RelationTypeSide(relationType, relationSide), - PermissionEnum.READ, Scope.createLegacyScope())); - } - } - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkDslProvider.java b/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkDslProvider.java deleted file mode 100644 index cc2b896cb3..0000000000 --- a/plugins/org.eclipse.osee.framework.access.provider/src/org/eclipse/osee/framework/access/provider/internal/FrameworkDslProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.provider.internal; - -import org.eclipse.osee.framework.core.dsl.ui.integration.operations.AbstractOseeDslProvider; -import org.eclipse.osee.framework.core.enums.CoreArtifactTokens; -import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; - -/** - * @author John R. Misinco - */ -public class FrameworkDslProvider extends AbstractOseeDslProvider { - - public FrameworkDslProvider(String locationUri) { - super(locationUri); - } - - protected Artifact getStorageArtifact() { - try { - return ArtifactQuery.getArtifactFromToken(CoreArtifactTokens.FrameworkAccessModel); - } catch (OseeCoreException ex) { - return null; - } - } - - @Override - protected String getModelFromStorage() { - Artifact storageArtifact = getStorageArtifact(); - if (storageArtifact != null) { - return storageArtifact.getSoleAttributeValue(CoreAttributeTypes.GeneralStringData); - } else { - return Strings.EMPTY_STRING; - } - } - - @Override - protected void saveModelToStorage(String model) { - Artifact artifact = getStorageArtifact(); - if (artifact != null) { - artifact.setSoleAttributeFromString(CoreAttributeTypes.GeneralStringData, model); - artifact.persist(getClass().getSimpleName()); - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.access/.classpath b/plugins/org.eclipse.osee.framework.access/.classpath deleted file mode 100644 index 1fa3e6803d..0000000000 --- a/plugins/org.eclipse.osee.framework.access/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.access/.pmd b/plugins/org.eclipse.osee.framework.access/.pmd deleted file mode 100644 index c7b0a9fb3f..0000000000 --- a/plugins/org.eclipse.osee.framework.access/.pmd +++ /dev/null @@ -1,925 +0,0 @@ - - - false - .ruleset - - - LooseCoupling - Type Resolution Rules - - - CloneMethodMustImplementCloneable - Type Resolution Rules - - - UnusedImports - Type Resolution Rules - - - SignatureDeclareThrowsException - Type Resolution Rules - - - IfStmtsMustUseBraces - Braces Rules - - - WhileLoopsMustUseBraces - Braces Rules - - - IfElseStmtsMustUseBraces - Braces Rules - - - ForLoopsMustUseBraces - Braces Rules - - - UseSingleton - Design Rules - - - SimplifyBooleanReturns - Design Rules - - - SimplifyBooleanExpressions - Design Rules - - - SwitchStmtsShouldHaveDefault - Design Rules - - - AvoidDeeplyNestedIfStmts - Design Rules - - - AvoidReassigningParameters - Design Rules - - - SwitchDensity - Design Rules - - - ConstructorCallsOverridableMethod - Design Rules - - - AccessorClassGeneration - Design Rules - - - FinalFieldCouldBeStatic - Design Rules - - - CloseResource - Design Rules - - - NonStaticInitializer - Design Rules - - - DefaultLabelNotLastInSwitchStmt - Design Rules - - - NonCaseLabelInSwitchStatement - Design Rules - - - OptimizableToArrayCall - Design Rules - - - BadComparison - Design Rules - - - EqualsNull - Design Rules - - - ConfusingTernary - Design Rules - - - InstantiationToGetClass - Design Rules - - - IdempotentOperations - Design Rules - - - SimpleDateFormatNeedsLocale - Design Rules - - - ImmutableField - Design Rules - - - UseLocaleWithCaseConversions - Design Rules - - - AvoidProtectedFieldInFinalClass - Design Rules - - - AssignmentToNonFinalStatic - Design Rules - - - MissingStaticMethodInNonInstantiatableClass - Design Rules - - - AvoidSynchronizedAtMethodLevel - Design Rules - - - MissingBreakInSwitch - Design Rules - - - UseNotifyAllInsteadOfNotify - Design Rules - - - AvoidInstanceofChecksInCatchClause - Design Rules - - - AbstractClassWithoutAbstractMethod - Design Rules - - - SimplifyConditional - Design Rules - - - CompareObjectsWithEquals - Design Rules - - - PositionLiteralsFirstInComparisons - Design Rules - - - UnnecessaryLocalBeforeReturn - Design Rules - - - NonThreadSafeSingleton - Design Rules - - - UncommentedEmptyMethod - Design Rules - - - UncommentedEmptyConstructor - Design Rules - - - AvoidConstantsInterface - Design Rules - - - UnsynchronizedStaticDateFormatter - Design Rules - - - PreserveStackTrace - Design Rules - - - UseCollectionIsEmpty - Design Rules - - - ClassWithOnlyPrivateConstructorsShouldBeFinal - Design Rules - - - EmptyMethodInAbstractClassShouldBeAbstract - Design Rules - - - SingularField - Design Rules - - - ReturnEmptyArrayRatherThanNull - Design Rules - - - AbstractClassWithoutAnyMethod - Design Rules - - - TooFewBranchesForASwitchStatement - Design Rules - - - AvoidCatchingThrowable - Strict Exception Rules - - - SignatureDeclareThrowsException - Type Resolution Rules - - - ExceptionAsFlowControl - Strict Exception Rules - - - AvoidCatchingNPE - Strict Exception Rules - - - AvoidThrowingRawExceptionTypes - Strict Exception Rules - - - AvoidThrowingNullPointerException - Strict Exception Rules - - - AvoidRethrowingException - Strict Exception Rules - - - DoNotExtendJavaLangError - Strict Exception Rules - - - DoNotThrowExceptionInFinally - Strict Exception Rules - - - AvoidThrowingNewInstanceOfSameException - Strict Exception Rules - - - UnusedPrivateField - Unused Code Rules - - - UnusedLocalVariable - Unused Code Rules - - - UnusedPrivateMethod - Unused Code Rules - - - UnusedFormalParameter - Unused Code Rules - - - MoreThanOneLogger - Java Logging Rules - - - LoggerIsNotStaticFinal - Java Logging Rules - - - SystemPrintln - Java Logging Rules - - - AvoidPrintStackTrace - Java Logging Rules - - - AvoidDuplicateLiterals - String and StringBuffer Rules - - - StringInstantiation - String and StringBuffer Rules - - - StringToString - String and StringBuffer Rules - - - InefficientStringBuffering - String and StringBuffer Rules - - - UnnecessaryCaseChange - String and StringBuffer Rules - - - UseStringBufferLength - String and StringBuffer Rules - - - AppendCharacterWithChar - String and StringBuffer Rules - - - ConsecutiveLiteralAppends - String and StringBuffer Rules - - - UseIndexOfChar - String and StringBuffer Rules - - - InefficientEmptyStringCheck - String and StringBuffer Rules - - - InsufficientStringBufferDeclaration - String and StringBuffer Rules - - - UselessStringValueOf - String and StringBuffer Rules - - - StringBufferInstantiationWithChar - String and StringBuffer Rules - - - UseEqualsToCompareStrings - String and StringBuffer Rules - - - AvoidStringBufferField - String and StringBuffer Rules - - - ReplaceVectorWithList - Migration Rules - - - ReplaceHashtableWithMap - Migration Rules - - - ReplaceEnumerationWithIterator - Migration Rules - - - AvoidEnumAsIdentifier - Migration Rules - - - AvoidAssertAsIdentifier - Migration Rules - - - IntegerInstantiation - Migration Rules - - - ByteInstantiation - Migration Rules - - - ShortInstantiation - Migration Rules - - - LongInstantiation - Migration Rules - - - JUnit4TestShouldUseBeforeAnnotation - Migration Rules - - - JUnit4TestShouldUseAfterAnnotation - Migration Rules - - - JUnit4TestShouldUseTestAnnotation - Migration Rules - - - JUnit4SuitesShouldUseSuiteAnnotation - Migration Rules - - - JUnitUseExpected - Migration Rules - - - UseProperClassLoader - J2EE Rules - - - MDBAndSessionBeanNamingConvention - J2EE Rules - - - RemoteSessionInterfaceNamingConvention - J2EE Rules - - - LocalInterfaceSessionNamingConvention - J2EE Rules - - - LocalHomeNamingConvention - J2EE Rules - - - RemoteInterfaceNamingConvention - J2EE Rules - - - DoNotCallSystemExit - J2EE Rules - - - StaticEJBFieldShouldBeFinal - J2EE Rules - - - DoNotUseThreads - J2EE Rules - - - AvoidInstantiatingObjectsInLoops - Optimization Rules - - - UseArrayListInsteadOfVector - Optimization Rules - - - SimplifyStartsWith - Optimization Rules - - - UseStringBufferForStringAppends - Optimization Rules - - - UseArraysAsList - Optimization Rules - - - AvoidArrayLoops - Optimization Rules - - - UnnecessaryWrapperObjectCreation - Optimization Rules - - - AddEmptyString - Optimization Rules - - - EmptyCatchBlock - Basic Rules - - - EmptyIfStmt - Basic Rules - - - EmptyWhileStmt - Basic Rules - - - EmptyTryBlock - Basic Rules - - - EmptyFinallyBlock - Basic Rules - - - EmptySwitchStatements - Basic Rules - - - JumbledIncrementer - Basic Rules - - - ForLoopShouldBeWhileLoop - Basic Rules - - - UnnecessaryConversionTemporary - Basic Rules - - - OverrideBothEqualsAndHashcode - Basic Rules - - - DoubleCheckedLocking - Basic Rules - - - ReturnFromFinallyBlock - Basic Rules - - - EmptySynchronizedBlock - Basic Rules - - - UnnecessaryReturn - Basic Rules - - - EmptyStaticInitializer - Basic Rules - - - UnconditionalIfStatement - Basic Rules - - - EmptyStatementNotInLoop - Basic Rules - - - BooleanInstantiation - Basic Rules - - - UnnecessaryFinalModifier - Basic Rules - - - CollapsibleIfStatements - Basic Rules - - - UselessOverridingMethod - Basic Rules - - - ClassCastExceptionWithToArray - Basic Rules - - - AvoidDecimalLiteralsInBigDecimalConstructor - Basic Rules - - - UselessOperationOnImmutable - Basic Rules - - - MisplacedNullCheck - Basic Rules - - - UnusedNullCheckInEquals - Basic Rules - - - AvoidThreadGroup - Basic Rules - - - BrokenNullCheck - Basic Rules - - - BigIntegerInstantiation - Basic Rules - - - AvoidUsingOctalValues - Basic Rules - - - AvoidUsingHardCodedIP - Basic Rules - - - CheckResultSet - Basic Rules - - - AvoidMultipleUnaryOperators - Basic Rules - - - EmptyInitializer - Basic Rules - - - MethodReturnsInternalArray - Security Code Guidelines - - - ArrayIsStoredDirectly - Security Code Guidelines - - - CouplingBetweenObjects - Coupling Rules - - - ExcessiveImports - Coupling Rules - - - LooseCoupling - Type Resolution Rules - - - DuplicateImports - Import Statement Rules - - - DontImportJavaLang - Import Statement Rules - - - UnusedImports - Type Resolution Rules - - - ImportFromSamePackage - Import Statement Rules - - - TooManyStaticImports - Import Statement Rules - - - JUnitStaticSuite - JUnit Rules - - - JUnitSpelling - JUnit Rules - - - JUnitAssertionsShouldIncludeMessage - JUnit Rules - - - JUnitTestsShouldIncludeAssert - JUnit Rules - - - TestClassWithoutTestCases - JUnit Rules - - - UnnecessaryBooleanAssertion - JUnit Rules - - - UseAssertEqualsInsteadOfAssertTrue - JUnit Rules - - - UseAssertSameInsteadOfAssertTrue - JUnit Rules - - - UseAssertNullInsteadOfAssertTrue - JUnit Rules - - - SimplifyBooleanAssertion - JUnit Rules - - - UnnecessaryConstructor - Controversial Rules - - - NullAssignment - Controversial Rules - - - UnusedModifier - Controversial Rules - - - AssignmentInOperand - Controversial Rules - - - AtLeastOneConstructor - Controversial Rules - - - DontImportSun - Controversial Rules - - - SuspiciousOctalEscape - Controversial Rules - - - CallSuperInConstructor - Controversial Rules - - - UnnecessaryParentheses - Controversial Rules - - - DefaultPackage - Controversial Rules - - - BooleanInversion - Controversial Rules - - - DataflowAnomalyAnalysis - Controversial Rules - - - AvoidFinalLocalVariable - Controversial Rules - - - AvoidUsingShortType - Controversial Rules - - - AvoidUsingVolatile - Controversial Rules - - - AvoidUsingNativeCode - Controversial Rules - - - AvoidAccessibilityAlteration - Controversial Rules - - - DoNotCallGarbageCollectionExplicitly - Controversial Rules - - - MethodNamingConventions - Naming Rules - - - ClassNamingConventions - Naming Rules - - - AbstractNaming - Naming Rules - - - AvoidDollarSigns - Naming Rules - - - MethodWithSameNameAsEnclosingClass - Naming Rules - - - SuspiciousHashcodeMethodName - Naming Rules - - - SuspiciousConstantFieldName - Naming Rules - - - SuspiciousEqualsMethodName - Naming Rules - - - AvoidFieldNameMatchingTypeName - Naming Rules - - - AvoidFieldNameMatchingMethodName - Naming Rules - - - NoPackage - Naming Rules - - - PackageCase - Naming Rules - - - MisleadingVariableName - Naming Rules - - - BooleanGetMethodName - Naming Rules - - - NPathComplexity - Code Size Rules - - - ExcessiveMethodLength - Code Size Rules - - - ExcessiveParameterList - Code Size Rules - - - ExcessiveClassLength - Code Size Rules - - - CyclomaticComplexity - Code Size Rules - - - ExcessivePublicCount - Code Size Rules - - - TooManyFields - Code Size Rules - - - NcssMethodCount - Code Size Rules - - - NcssTypeCount - Code Size Rules - - - NcssConstructorCount - Code Size Rules - - - TooManyMethods - Code Size Rules - - - EmptyFinalizer - Finalizer Rules - - - FinalizeOnlyCallsSuperFinalize - Finalizer Rules - - - FinalizeOverloaded - Finalizer Rules - - - FinalizeDoesNotCallSuperFinalize - Finalizer Rules - - - FinalizeShouldBeProtected - Finalizer Rules - - - AvoidCallingFinalize - Finalizer Rules - - - UseCorrectExceptionLogging - Jakarta Commons Logging Rules - - - ProperLogger - Jakarta Commons Logging Rules - - - MissingSerialVersionUID - JavaBean Rules - - - ProperCloneImplementation - Clone Implementation Rules - - - CloneThrowsCloneNotSupportedException - Clone Implementation Rules - - - CloneMethodMustImplementCloneable - Type Resolution Rules - - - false - true - diff --git a/plugins/org.eclipse.osee.framework.access/.project b/plugins/org.eclipse.osee.framework.access/.project deleted file mode 100644 index 6ce0380f73..0000000000 --- a/plugins/org.eclipse.osee.framework.access/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - org.eclipse.osee.framework.access - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF deleted file mode 100644 index c3f0bcadfa..0000000000 --- a/plugins/org.eclipse.osee.framework.access/META-INF/MANIFEST.MF +++ /dev/null @@ -1,51 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Osee Access -Bundle-SymbolicName: org.eclipse.osee.framework.access;singleton:=true -Bundle-ActivationPolicy: lazy -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: Eclipse Open System Engineering Environment -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: com.google.common.cache, - org.eclipse.core.resources, - org.eclipse.core.runtime, - org.eclipse.jdt.annotation, - org.eclipse.osee.framework.core, - org.eclipse.osee.framework.core.access, - org.eclipse.osee.framework.core.data, - org.eclipse.osee.framework.core.enums, - org.eclipse.osee.framework.core.enums.token, - org.eclipse.osee.framework.core.exception, - org.eclipse.osee.framework.core.model, - org.eclipse.osee.framework.core.model.access, - org.eclipse.osee.framework.core.model.cache, - org.eclipse.osee.framework.core.model.event, - org.eclipse.osee.framework.core.model.type, - org.eclipse.osee.framework.core.operation, - org.eclipse.osee.framework.core.services, - org.eclipse.osee.framework.core.util, - org.eclipse.osee.framework.jdk.core.result, - org.eclipse.osee.framework.jdk.core.type, - org.eclipse.osee.framework.jdk.core.util, - org.eclipse.osee.framework.lifecycle, - org.eclipse.osee.framework.logging, - org.eclipse.osee.framework.skynet.core, - org.eclipse.osee.framework.skynet.core.access, - org.eclipse.osee.framework.skynet.core.artifact, - org.eclipse.osee.framework.skynet.core.artifact.search, - org.eclipse.osee.framework.skynet.core.event, - org.eclipse.osee.framework.skynet.core.event.filter, - org.eclipse.osee.framework.skynet.core.event.listener, - org.eclipse.osee.framework.skynet.core.event.model, - org.eclipse.osee.framework.skynet.core.relation, - org.eclipse.osee.framework.skynet.core.utility, - org.eclipse.osee.jdbc, - org.eclipse.osee.orcs.rest.client, - org.eclipse.osee.orcs.rest.model, - org.osgi.framework, - org.osgi.service.event, - org.osgi.util.tracker -Eclipse-ExtensibleAPI: true -Export-Package: org.eclipse.osee.framework.access, - org.eclipse.osee.framework.access.internal.data -Service-Component: OSGI-INF/*.xml diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.artifact.lock.topic.handler.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.artifact.lock.topic.handler.xml deleted file mode 100644 index 84d1e2e6cf..0000000000 --- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.artifact.lock.topic.handler.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.artifact.topic.handler.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.artifact.topic.handler.xml deleted file mode 100644 index 17351d7417..0000000000 --- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.artifact.topic.handler.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.branch.topic.handler.xml b/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.branch.topic.handler.xml deleted file mode 100644 index 04bb640f59..0000000000 --- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.branch.topic.handler.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - 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 deleted file mode 100644 index 0a63879dbb..0000000000 --- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/access.control.service.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - 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 deleted file mode 100644 index 1e3ab29816..0000000000 --- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/cm.access.provider.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - 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 deleted file mode 100644 index 43d1d9e975..0000000000 --- a/plugins/org.eclipse.osee.framework.access/OSGI-INF/object.access.provider.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.access/build.properties b/plugins/org.eclipse.osee.framework.access/build.properties deleted file mode 100644 index 6210e849b5..0000000000 --- a/plugins/org.eclipse.osee.framework.access/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/ -source.. = src/ diff --git a/plugins/org.eclipse.osee.framework.access/pom.xml b/plugins/org.eclipse.osee.framework.access/pom.xml deleted file mode 100644 index abbb34f3d6..0000000000 --- a/plugins/org.eclipse.osee.framework.access/pom.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - - org.eclipse.osee - org.eclipse.osee.client.parent - 1.0.0-SNAPSHOT - ../../plugins/org.eclipse.osee.client.parent - - - org.eclipse.osee.framework.access - eclipse-plugin - OSEE Access (Incubation) - - - diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlData.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlData.java deleted file mode 100644 index e9c5673b6a..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/AccessControlData.java +++ /dev/null @@ -1,127 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access; - -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; - -/** - * A data object in an access control list. Contains a subject (user artifact) and object (what the subject is trying to - * access) and a permission level - * - * @author Jeff C. Phillips - */ -public class AccessControlData implements Comparable { - - private boolean dirty = false; - private boolean birth = false; - private final Artifact subject; - private final AccessObject object; - private PermissionEnum permission; - private PermissionEnum branchPermission = null; - private PermissionEnum artifactTypePermission = null; - private PermissionEnum artifactPermission = null; - - public AccessControlData(Artifact subject, AccessObject object, PermissionEnum permission, boolean birth) { - this(subject, object, permission, birth, true); - } - - public AccessControlData(Artifact subject, AccessObject object, PermissionEnum permission, boolean birth, boolean dirty) { - super(); - this.subject = subject; - this.permission = permission; - this.dirty = dirty; - this.birth = birth; - this.object = object; - } - - public Artifact getSubject() { - return subject; - } - - public void setPermission(PermissionEnum permission) { - - if (this.permission == permission) { - return; - } - - this.permission = permission; - dirty = true; - } - - public PermissionEnum getBranchPermission() { - return branchPermission; - } - - public PermissionEnum getArtifactPermission() { - return artifactPermission; - } - - public PermissionEnum getArtifactTypePermission() { - return artifactTypePermission; - } - - public PermissionEnum getPermission() { - return permission; - } - - public boolean isDirty() { - return dirty; - } - - public void setNotDirty() { - this.dirty = false; - } - - public AccessObject getObject() { - return object; - } - - /** - * @return true if this is a new permission; false if update - */ - public boolean isBirth() { - return birth; - } - - @Override - public int compareTo(AccessControlData data) { - return subject.getName().compareTo(data.subject.getName()); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof AccessControlData)) { - return false; - } - return subject.getName().equals(((AccessControlData) obj).subject.getName()); - } - - @Override - public int hashCode() { - return subject.getName().hashCode(); - } - - public void setBranchPermission(PermissionEnum branchPermission) { - this.branchPermission = branchPermission; - } - - public void setArtifactTypePermission(PermissionEnum artifactTypePermission) { - this.artifactTypePermission = artifactTypePermission; - } - - public void setArtifactPermission(PermissionEnum artifactPermission) { - this.artifactPermission = artifactPermission; - } -} diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/IAccessProvider.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/IAccessProvider.java deleted file mode 100644 index a256457639..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/IAccessProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access; - -import java.util.Collection; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.lifecycle.LifecycleHandler; - -/** - * @author Roberto E. Escobar - */ -public interface IAccessProvider extends LifecycleHandler { - - void computeAccess(ArtifactToken userArtifact, Collection objToCheck, AccessData accessData); - -} diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessArtifactTopicEventHandler.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessArtifactTopicEventHandler.java deleted file mode 100644 index 88aa56591a..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessArtifactTopicEventHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -/********************************************************************* - * Copyright (c) 2015 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal; - -import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlManager; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; -import org.osgi.service.event.Event; -import org.osgi.service.event.EventHandler; - -/** - * Handler for {@link AccessTopicEvent.ACCESS_ARTIFACT_MODIFIED} - * - * @author Donald G. Dunne - */ -public class AccessArtifactTopicEventHandler implements EventHandler { - - @Override - public void handleEvent(Event event) { - try { - AccessControlManager.clearCaches(); - } catch (Exception ex) { - OseeLog.log(AccessControlManager.class, Level.SEVERE, ex); - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessArtifactTopicLockEventHandler.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessArtifactTopicLockEventHandler.java deleted file mode 100644 index e3fbae6400..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessArtifactTopicLockEventHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -/********************************************************************* - * Copyright (c) 2015 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal; - -import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlManager; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; -import org.osgi.service.event.Event; -import org.osgi.service.event.EventHandler; - -/** - * Handler for {@link AccessTopicEvent.ACCESS_ARTIFACT_LOCK_MODIFIED} - * - * @author Donald G. Dunne - */ -public class AccessArtifactTopicLockEventHandler implements EventHandler { - - @Override - public void handleEvent(Event event) { - try { - AccessControlManager.clearCaches(); - } catch (Exception ex) { - OseeLog.log(AccessControlManager.class, Level.SEVERE, ex); - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessBranchTopicEventHandler.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessBranchTopicEventHandler.java deleted file mode 100644 index 395e6ba8d1..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessBranchTopicEventHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -/********************************************************************* - * Copyright (c) 2015 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal; - -import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlManager; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; -import org.osgi.service.event.Event; -import org.osgi.service.event.EventHandler; - -/** - * Handler for {@link AccessTopicEvent.ACCESS_BRANCH_MODIFIED} - * - * @author Donald G. Dunne - */ -public class AccessBranchTopicEventHandler implements EventHandler { - - @Override - public void handleEvent(Event event) { - try { - AccessControlManager.clearCaches(); - } catch (Exception ex) { - OseeLog.log(AccessControlManager.class, Level.SEVERE, ex); - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlCacheHandler.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlCacheHandler.java deleted file mode 100644 index 8cac5a394a..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlCacheHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -/********************************************************************* - * Copyright (c) 2011 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal; - -import java.util.List; -import org.eclipse.osee.framework.access.AccessControlData; -import org.eclipse.osee.framework.access.AccessControlServiceImpl; -import org.eclipse.osee.framework.access.AccessObject; -import org.eclipse.osee.framework.access.internal.data.BranchAccessObject; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.BranchToken; - -/** - * @author Jeff C. Phillips - */ -public class AccessControlCacheHandler { - - public void updateAccessListForBranchObject(AccessControlServiceImpl service, BranchId branch) { - BranchAccessObject branchAccessObject = - BranchAccessObject.getBranchAccessObject(BranchToken.create(branch, "unknown")); - if (branchAccessObject != null) { - updateAccessList(service, branchAccessObject); - } - } - - public void updateAccessList(AccessControlServiceImpl service, AccessObject accessObject) { - List acl = service.generateAccessControlList(accessObject); - for (AccessControlData accessControlData : acl) { - service.removeAccessControlDataIf(false, accessControlData); - } - } - - public void reloadCache(AccessControlServiceImpl service) { - service.reloadCache(); - } -} 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 deleted file mode 100644 index ce70955a97..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java +++ /dev/null @@ -1,41 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal; - -import org.eclipse.osee.framework.access.AccessControlServiceImpl; -import org.eclipse.osee.framework.core.access.IAccessControlService; -import org.eclipse.osee.framework.core.util.OsgiUtil; - -/** - * @author Roberto E. Escobar - */ -public final class AccessControlHelper { - - public static final String PLUGIN_ID = "org.eclipse.osee.framework.access"; - - private AccessControlHelper() { - // Utility class - } - - @Deprecated - public static AccessControlServiceImpl getAccessControlService() { - IAccessControlService service = OsgiUtil.getService(AccessControlHelper.class, IAccessControlService.class); - AccessControlServiceImpl 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/AccessEventListener.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessEventListener.java deleted file mode 100644 index 8927dc6a1c..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessEventListener.java +++ /dev/null @@ -1,91 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal; - -import java.util.List; -import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlServiceImpl; -import org.eclipse.osee.framework.access.internal.data.ArtifactAccessObject; -import org.eclipse.osee.framework.core.data.BranchToken; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache; -import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter; -import org.eclipse.osee.framework.skynet.core.event.listener.IArtifactEventListener; -import org.eclipse.osee.framework.skynet.core.event.listener.IBranchEventListener; -import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; -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.EventBasicGuidArtifact; -import org.eclipse.osee.framework.skynet.core.event.model.EventModType; -import org.eclipse.osee.framework.skynet.core.event.model.Sender; - -/** - * @author Donald G. Dunne - */ -public final class AccessEventListener implements IBranchEventListener, IArtifactEventListener { - - private final AccessControlServiceImpl service; - private final AccessControlCacheHandler accessControlCacheHandler; - - public AccessEventListener(AccessControlServiceImpl service, AccessControlCacheHandler accessControlCacheHandler) { - this.accessControlCacheHandler = accessControlCacheHandler; - this.service = service; - } - - @Override - public void handleArtifactEvent(ArtifactEvent artifactEvent, Sender sender) { - for (EventBasicGuidArtifact guidArt : artifactEvent.getArtifacts()) { - if (guidArt.is(EventModType.Added) && guidArt.isTypeEqual(CoreArtifactTypes.User)) { - try { - accessControlCacheHandler.reloadCache(service); - } catch (OseeCoreException ex) { - OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex); - } - } - if (guidArt.is(EventModType.Purged)) { - try { - Artifact cacheArt = ArtifactCache.getActive(guidArt); - if (cacheArt != null) { - ArtifactAccessObject artifactAccessObject = ArtifactAccessObject.getArtifactAccessObject(cacheArt); - accessControlCacheHandler.updateAccessList(service, artifactAccessObject); - } - } catch (OseeCoreException ex) { - OseeLog.log(AccessControlHelper.class, Level.SEVERE, ex); - } - - } - } - } - - @Override - public List getEventFilters() { - return null; - } - - @Override - public void handleBranchEvent(Sender sender, final BranchEvent branchEvent) { - try { - if (branchEvent.getEventType() == BranchEventType.Deleted) { - accessControlCacheHandler.updateAccessListForBranchObject(service, - BranchToken.create(branchEvent.getSourceBranch(), "unknown")); - } - } catch (OseeCoreException 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/AccessProviderVisitor.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderVisitor.java deleted file mode 100644 index 52f2e32917..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessProviderVisitor.java +++ /dev/null @@ -1,61 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal; - -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.IAccessProvider; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.lifecycle.AbstractLifecycleVisitor; - -/** - * @author Jeff C. Phillips - */ -public class AccessProviderVisitor extends AbstractLifecycleVisitor { - - public static final Type TYPE = new Type<>(); - - private final ArtifactToken userArtifact; - private final Collection artsToCheck; - private final AccessData mainAccessData; - - public AccessProviderVisitor(ArtifactToken userArtifact, Collection artsToCheck, AccessData mainAccessData) { - super(); - this.userArtifact = userArtifact; - this.artsToCheck = artsToCheck; - this.mainAccessData = mainAccessData; - } - - @Override - public Type getAssociatedType() { - return TYPE; - } - - @Override - protected IStatus dispatch(IProgressMonitor monitor, IAccessProvider accessProvider, String sourceId) { - IStatus status = Status.OK_STATUS; - try { - accessProvider.computeAccess(userArtifact, artsToCheck, mainAccessData); - } catch (OseeCoreException 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/ObjectAccessProviderProxy.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java deleted file mode 100644 index e314f02ae8..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/ObjectAccessProviderProxy.java +++ /dev/null @@ -1,107 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * 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.AccessControlServiceImpl; -import org.eclipse.osee.framework.access.IAccessProvider; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.IAccessControlService; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.logging.OseeLog; -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.relation.RelationLink; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -/** - * @author Roberto E. Escobar - */ -public final class ObjectAccessProviderProxy implements IAccessProvider { - - private BundleContext bundleContext; - - public void start(BundleContext bundleContext) { - this.bundleContext = bundleContext; - } - - public void stop() { - bundleContext = null; - } - - private AccessControlServiceImpl getAccessService() { - AccessControlServiceImpl toReturn = null; - - ServiceReference 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; - } - - @Override - public void computeAccess(ArtifactToken userArtifact, Collection objToCheck, AccessData accessData) { - for (Object object : objToCheck) { - if (object instanceof Artifact) { - setArtifactAccessData(userArtifact, (Artifact) object, accessData); - } else if (object instanceof BranchId) { - setBranchAccessData(userArtifact, (BranchId) 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(ArtifactToken userArtifact, Artifact artifact, AccessData accessData) { - setBranchAccessData(userArtifact, artifact.getBranch(), accessData); - String reason = "Legacy Artifact Permission"; - PermissionEnum userPermission = getAccessService().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 (!BranchManager.isEditable(artifact.getBranch())) { - 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(artifact, userPermission, Scope.createLegacyScope(), reason)); - } - - private void setBranchAccessData(ArtifactToken userArtifact, BranchId branch, AccessData accessData) { - String reason = "Legacy Branch Permission"; - PermissionEnum userPermission = getAccessService().getBranchPermission(userArtifact, branch); - accessData.add(branch, new AccessDetail<>(branch, userPermission, Scope.createLegacyScope(), reason)); - } - -} diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessControlProviderImpl.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessControlProviderImpl.java deleted file mode 100644 index 80f233f39f..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessControlProviderImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal.cm; - -import java.util.ArrayList; -import java.util.Collection; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.services.CmAccessControl; -import org.eclipse.osee.framework.core.services.CmAccessControlProvider; -import org.eclipse.osee.framework.core.services.HasCmAccessControl; -import org.eclipse.osee.framework.jdk.core.type.OseeStateException; - -/** - * @author Roberto E. Escobar - */ -public class CmAccessControlProviderImpl implements CmAccessControlProvider { - - private final Collection cmServices; - private CmAccessControl defaultAccessControl; - - public CmAccessControlProviderImpl(Collection cmServices) { - this.cmServices = cmServices; - } - - public CmAccessControl getDefaultAccessControl() { - return defaultAccessControl; - } - - @Override - public void setDefaultAccessControl(CmAccessControl defaultAccessControl) { - this.defaultAccessControl = defaultAccessControl; - } - - @Override - public CmAccessControl getService(ArtifactToken userArtifact, Object object) { - if (object instanceof HasCmAccessControl) { - HasCmAccessControl cmContainer = (HasCmAccessControl) object; - return cmContainer.getAccessControl(); - } else { - CmAccessControl cmToReturn; - Collection applicableCms = new ArrayList<>(); - for (CmAccessControl cmService : cmServices) { - if (cmService.isApplicable(userArtifact, object)) { - applicableCms.add(cmService); - } - } - if (applicableCms.isEmpty()) { - cmToReturn = getDefaultAccessControl(); - } else if (applicableCms.size() == 1) { - cmToReturn = applicableCms.iterator().next(); - } else { - throw new OseeStateException("Multiple Configuration Management Systems managing: [%s] cms:%s", object, - applicableCms); - } - return cmToReturn; - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProvider.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProvider.java deleted file mode 100644 index 1faef69648..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProvider.java +++ /dev/null @@ -1,74 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal.cm; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import org.eclipse.osee.framework.access.IAccessProvider; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.model.access.AccessModel; -import org.eclipse.osee.framework.core.model.access.HasAccessModel; -import org.eclipse.osee.framework.core.services.CmAccessControl; -import org.eclipse.osee.framework.core.services.CmAccessControlProvider; -import org.eclipse.osee.framework.jdk.core.type.DoubleKeyHashMap; - -/** - * @author Roberto E. Escobar - */ -public class CmAccessProvider implements IAccessProvider { - - private final CmAccessControlProvider provider; - - public CmAccessProvider(CmAccessControlProvider provider) { - this.provider = provider; - } - - @Override - public void computeAccess(ArtifactToken userArtifact, Collection objToChecks, AccessData accessData) { - DoubleKeyHashMap> cmToCheckObjects = - new DoubleKeyHashMap<>(); - - for (Object objectToCheck : objToChecks) { - CmAccessControl management = provider.getService(userArtifact, objectToCheck); - if (management instanceof HasAccessModel) { - Collection contextIds = management.getContextId(userArtifact, objectToCheck); - if (contextIds != null) { - for (AccessContextToken contextId : contextIds) { - Collection entries = cmToCheckObjects.get(management, contextId); - if (entries == null) { - entries = new HashSet<>(); - cmToCheckObjects.put(management, contextId, entries); - } - entries.add(objectToCheck); - } - } - } - } - - for (CmAccessControl cm : cmToCheckObjects.getKeySetOne()) { - AccessModel accessModel = ((HasAccessModel) cm).getAccessModel(); - Map> sub = cmToCheckObjects.getSubHash(cm); - for (Entry> entry : sub.entrySet()) { - AccessContextToken contextId = entry.getKey(); - Collection objectsToCheck = entry.getValue(); - - accessModel.computeAccess(contextId, objectsToCheck, accessData); - } - } - } -} 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 deleted file mode 100644 index 0b7e57e2bc..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/cm/CmAccessProviderProxy.java +++ /dev/null @@ -1,157 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal.cm; - -import java.util.Collection; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.logging.Level; -import org.eclipse.osee.framework.access.IAccessProvider; -import org.eclipse.osee.framework.access.internal.AccessControlHelper; -import org.eclipse.osee.framework.access.internal.AccessControlServiceProxy; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.access.IAccessControlService; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.services.CmAccessControl; -import org.eclipse.osee.framework.core.services.CmAccessControlProvider; -import org.eclipse.osee.framework.jdk.core.util.Conditions; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.logging.OseeLog; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -/** - * @author Roberto E. Escobar - */ -public final class CmAccessProviderProxy implements IAccessProvider { - - private final List> pending = new CopyOnWriteArrayList<>(); - - private final Collection cmServices = new CopyOnWriteArraySet<>(); - - private IAccessProvider accessProvider; - private CmAccessControlProvider cmProvider; - private BundleContext bundleContext; - - private volatile boolean requiresReload = true; - - public void addCmAccessControl(ServiceReference reference) { - if (isReady()) { - register(bundleContext, reference); - } else { - pending.add(reference); - } - } - - public void removeCmAccessControl(ServiceReference reference) { - if (isReady()) { - unregister(bundleContext, reference); - } else { - pending.remove(reference); - } - } - - private boolean isReady() { - return bundleContext != null && cmProvider != null; - } - - private void register(BundleContext bundleContext, ServiceReference reference) { - CmAccessControl cmAccessControl = bundleContext.getService(reference); - if (isDefault(reference)) { - cmProvider.setDefaultAccessControl(cmAccessControl); - } else { - cmServices.add(cmAccessControl); - } - requiresReload = true; - } - - private void unregister(BundleContext bundleContext, ServiceReference reference) { - CmAccessControl cmAccessControl = bundleContext.getService(reference); - if (isDefault(reference)) { - cmProvider.setDefaultAccessControl(null); - } else { - cmServices.remove(cmAccessControl); - } - requiresReload = true; - } - - private boolean isDefault(ServiceReference reference) { - boolean toReturn = false; - String value = String.valueOf(reference.getProperty("default")); - if (Strings.isValid(value)) { - toReturn = Boolean.parseBoolean(value); - } - return toReturn; - } - - public void start(BundleContext context) { - this.bundleContext = context; - requiresReload = true; - - cmProvider = new CmAccessControlProviderImpl(cmServices); - accessProvider = new CmAccessProvider(cmProvider); - - for (ServiceReference reference : pending) { - register(bundleContext, reference); - } - pending.clear(); - } - - public void stop() { - accessProvider = null; - cmProvider.setDefaultAccessControl(null); - cmServices.clear(); - bundleContext = null; - } - - private AccessControlServiceProxy getAccessService() { - AccessControlServiceProxy toReturn = null; - ServiceReference reference = - bundleContext.getServiceReference(IAccessControlService.class); - IAccessControlService service = bundleContext.getService(reference); - if (service instanceof AccessControlServiceProxy) { - toReturn = (AccessControlServiceProxy) service; - } else { - OseeLog.log(AccessControlHelper.class, Level.SEVERE, "Error initializing ObjectAccessProvider"); - } - return toReturn; - } - - private void reloadCache() { - AccessControlServiceProxy service = getAccessService(); - if (service != null) { - service.reloadCache(); - } - } - - private IAccessProvider getAccessProvider() { - return accessProvider; - } - - private void checkInitialized() { - Conditions.checkNotNull(getAccessProvider(), "object access provider", - "Object Access Provider not properly initialized"); - if (requiresReload) { - requiresReload = false; - reloadCache(); - } - } - - @Override - public void computeAccess(ArtifactToken userArtifact, Collection objToCheck, AccessData accessData) { - 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/data/BranchAccessObject.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/BranchAccessObject.java deleted file mode 100644 index e255f5d581..0000000000 --- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/data/BranchAccessObject.java +++ /dev/null @@ -1,80 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.access.internal.data; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.osee.framework.access.AccessObject; -import org.eclipse.osee.framework.core.data.ArtifactId; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.BranchToken; -import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler; - -/** - * @author Jeff C. Phillips - */ -public class BranchAccessObject extends AccessObject { - private final BranchToken branch; - private static final Map cache = new HashMap<>(); - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + branch.hashCode(); - return result; - } - - public BranchAccessObject(BranchToken branch) { - this.branch = branch; - } - - @Override - public BranchToken getBranch() { - return branch; - } - - @Override - public void removeFromCache() { - cache.remove(branch); - } - - @Override - public void removeFromDatabase(ArtifactId subjectId) { - final String DELETE_BRANCH_ACL = "DELETE FROM OSEE_BRANCH_ACL WHERE privilege_entity_id = ? AND branch_id =?"; - ConnectionHandler.runPreparedUpdate(DELETE_BRANCH_ACL, subjectId, branch); - } - - public static BranchAccessObject getBranchAccessObject(BranchToken branch) { - BranchAccessObject branchAccessObject; - if (cache.containsKey(branch)) { - branchAccessObject = cache.get(branch); - } else { - branchAccessObject = new BranchAccessObject(branch); - cache.put(branch, branchAccessObject); - } - return branchAccessObject; - } - - public static BranchAccessObject getBranchAccessObjectFromCache(BranchId branch) { - return cache.get(branch); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof BranchAccessObject)) { - return false; - } - return branch.equals(((BranchAccessObject) obj).branch); - } -} diff --git a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/OseeClientProperties.java b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/OseeClientProperties.java index 9e54c6e908..1c5daf6328 100644 --- a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/OseeClientProperties.java +++ b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/OseeClientProperties.java @@ -31,18 +31,8 @@ public class OseeClientProperties extends OseeProperties { private static final String OSEE_CHOICE_ON_DB_INIT = "osee.choice.on.db.init"; - private static final String OSEE_IS_IN_DB_INIT = "osee.is.in.db.init"; - private static final String OSEE_COMMIT_SKIP_CHECKS_AND_EVENTS = "osee.commit.skipChecksAndEvents"; - public static boolean isInDbInit() { - return Boolean.valueOf(getProperty(OSEE_IS_IN_DB_INIT)); - } - - public static void setInDbInit(boolean value) { - System.setProperty(OSEE_IS_IN_DB_INIT, Boolean.toString(value)); - } - public static boolean isSkipCommitChecksAndEvents() { return Boolean.valueOf(getProperty(OSEE_COMMIT_SKIP_CHECKS_AND_EVENTS, "false")); } @@ -110,14 +100,6 @@ public class OseeClientProperties extends OseeProperties { return getProperty(OseeClient.OSEE_APPLICATION_SERVER, "http://localhost:8089"); } - private static String getProperty(String name) { - return getProperty(name, ""); - } - - private static String getProperty(String name, String defaultValue) { - return System.getProperty(name, defaultValue); - } - /** * A string representation of all the property setting specified by this class * diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/AllDslIntegrationTestSuite.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/AllDslIntegrationTestSuite.java index 369da1146c..25b12d4f24 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/AllDslIntegrationTestSuite.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/AllDslIntegrationTestSuite.java @@ -25,7 +25,6 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ // InternalTestSuite.class, // DslUtilTestSuite.class, // - OseeDslAccessModelTest.class, // }) public class AllDslIntegrationTestSuite { // Test Suite diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslAccessModelTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslAccessModelTest.java deleted file mode 100644 index 08e8adc0c0..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslAccessModelTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockDslProvider; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext; -import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.model.access.AccessModel; -import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; -import org.eclipse.osee.framework.jdk.core.util.Lib; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test Case for {@link OseeDslAccessModel} - * - * @author Roberto E. Escobar - */ -public class OseeDslAccessModelTest { - - private static AccessContextToken accessContextId; - - @BeforeClass - public static void setUp() { - accessContextId = AccessContextToken.valueOf(Lib.generateArtifactIdAsInt(), "Context 1"); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessNullAgumentCheck1() { - AccessModel accessModel = new OseeDslAccessModel(null, null); - accessModel.computeAccess(null, new ArrayList<>(), new AccessData()); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessNullAgumentCheck2() { - AccessModel accessModel = new OseeDslAccessModel(null, null); - accessModel.computeAccess(accessContextId, null, new AccessData()); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessNullAgumentCheck3() { - AccessModel accessModel = new OseeDslAccessModel(null, null); - accessModel.computeAccess(accessContextId, Collections.emptyList(), null); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessNullDsl() { - MockDslProvider dslProvider = new MockDslProvider(null); - AccessModel accessModel = new OseeDslAccessModel(null, dslProvider); - accessModel.computeAccess(accessContextId, Collections.emptyList(), new AccessData()); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessNullAccessContext() { - MockAccessModelInterpreter interpreter = new MockAccessModelInterpreter(null); - MockDslProvider dslProvider = new MockDslProvider(MockModel.createDsl()); - AccessModel accessModel = new OseeDslAccessModel(interpreter, dslProvider); - accessModel.computeAccess(accessContextId, Collections.emptyList(), new AccessData()); - } - - @Test - public void testComputeAccessTestCollection() { - - final Object checkedObject = new Object(); - - Scope detail1Scope = new Scope().add("fail"); - Scope detail2Scope = new Scope().add("fail"); - final AccessDetail detail1 = new AccessDetail<>(checkedObject, PermissionEnum.READ, detail1Scope, "detail 1"); - final AccessDetail detail2 = new AccessDetail<>(checkedObject, PermissionEnum.WRITE, detail2Scope, "detail 2"); - - final AccessData accessData = new AccessData(); - - final AccessContext accessContext = - MockModel.createAccessContext(Lib.generateArtifactIdAsInt(), "Access Context"); - - OseeDsl oseeDsl = MockModel.createDsl(); - oseeDsl.getAccessDeclarations().add(accessContext); - - MockDslProvider dslProvider = new MockDslProvider(oseeDsl); - MockAccessModelInterpreter interpreter = new MockAccessModelInterpreter(accessContext) { - - @Override - public void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck) { - super.computeAccessDetails(collector, accessContext, objectToCheck); - Assert.assertEquals(accessContext, context); - Assert.assertEquals(checkedObject, objectToCheck); - Assert.assertNotNull(collector); - - Assert.assertTrue(accessData.isEmpty()); - - collector.collect(detail1); - collector.collect(detail2); - } - - }; - - AccessModel accessModel = new OseeDslAccessModel(interpreter, dslProvider); - accessModel.computeAccess(accessContextId, Collections.singleton(checkedObject), accessData); - - Assert.assertEquals(accessContextId, interpreter.getContextId()); - Collection context = interpreter.getContexts(); - Assert.assertEquals(1, context.size()); - Assert.assertEquals(accessContext, context.iterator().next()); - Assert.assertTrue(interpreter.wasComputeCalled()); - - Assert.assertFalse(accessData.isEmpty()); - Collection> details = accessData.getAccess(checkedObject); - Assert.assertEquals(1, details.size()); - - AccessDetail actualDetail = details.iterator().next(); - Assert.assertEquals(PermissionEnum.READ, actualDetail.getPermission()); - Assert.assertEquals("detail 1", actualDetail.getReason()); - Assert.assertEquals(checkedObject, actualDetail.getAccessObject()); - Assert.assertEquals(detail1, actualDetail); - } - - private static class MockAccessModelInterpreter implements AccessModelInterpreter { - - private final AccessContext contextToReturn; - private Collection contexts; - private AccessContextToken contextId; - private boolean wasComputeCalled; - - public MockAccessModelInterpreter(AccessContext contextToReturn) { - this.contextToReturn = contextToReturn; - } - - public Collection getContexts() { - return contexts; - } - - public AccessContextToken getContextId() { - return contextId; - } - - @Override - public AccessContext getContext(Collection contexts, AccessContextToken contextId) { - this.contextId = contextId; - this.contexts = contexts; - return contextToReturn; - } - - @Override - public void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck) { - // - wasComputeCalled = true; - } - - public boolean wasComputeCalled() { - return wasComputeCalled; - } - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImplTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImplTest.java deleted file mode 100644 index 5be1b0e2ae..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImplTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.integration.AccessDataCollector; -import org.eclipse.osee.framework.core.dsl.integration.mocks.CheckAccessDetailCollectorNotCalled; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockArtifactDataProvider; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockRestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; -import org.eclipse.osee.framework.jdk.core.util.Lib; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * Test Case for {@link AccessModelInterpreterImpl} - * - * @author Roberto E. Escobar - */ -public class AccessModelInterpreterImplTest { - private AccessContextToken contextId1; - private AccessContextToken contextId2; - - private AccessContext expectedContext1; - private AccessContext expectedContext2; - - private AccessModelInterpreterImpl interpreterNoArtData; - - @Before - public void setup() { - interpreterNoArtData = new AccessModelInterpreterImpl(null, null); - - contextId1 = AccessContextToken.valueOf(Lib.generateArtifactIdAsInt(), "Context 1"); - contextId2 = AccessContextToken.valueOf(Lib.generateArtifactIdAsInt(), "Context 2"); - - expectedContext1 = MockModel.createAccessContext(contextId1.getId(), "c1"); - expectedContext2 = MockModel.createAccessContext(contextId2.getId(), "c2"); - } - - @Test - public void testGetContext() { - - Collection contexts = Arrays.asList(expectedContext1, expectedContext2); - AccessContext actualContext1 = interpreterNoArtData.getContext(contexts, contextId1); - Assert.assertEquals(expectedContext1, actualContext1); - - AccessContext actualContext2 = interpreterNoArtData.getContext(contexts, contextId2); - Assert.assertEquals(expectedContext2, actualContext2); - } - - @Test(expected = OseeArgumentException.class) - public void testGetContextNullCheck1() { - interpreterNoArtData.getContext(null, contextId1); - } - - @Test(expected = OseeArgumentException.class) - public void testGetContextNullCheck2() { - interpreterNoArtData.getContext(Collections. emptyList(), null); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessNullCheck1() { - interpreterNoArtData.computeAccessDetails(null, expectedContext1, new Object()); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessNullCheck2() { - interpreterNoArtData.computeAccessDetails(new AccessDataCollector(), null, new Object()); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessNullCheck3() { - interpreterNoArtData.computeAccessDetails(new AccessDataCollector(), expectedContext1, null); - } - - @Test - public void testComputeAccessNotApplicableObject() { - final Object objectToCheck = new Object(); - MockArtifactDataProvider provider = new MockArtifactDataProvider(false, objectToCheck, null); - AccessModelInterpreterImpl interpreter = new AccessModelInterpreterImpl(provider, null); - interpreter.computeAccessDetails(new CheckAccessDetailCollectorNotCalled(), expectedContext1, objectToCheck); - Assert.assertTrue("Provider isApplicableCalled failed", provider.wasIsApplicableCalled()); - Assert.assertFalse("Provider asCastedObjectCalled failed", provider.wasAsCastedObjectCalled()); - } - - @Test(expected = OseeArgumentException.class) - public void testComputeAccessCastedObjectNull() { - final Object objectToCheck = new Object(); - MockArtifactDataProvider provider = new MockArtifactDataProvider(true, objectToCheck, null); - AccessModelInterpreterImpl interpreter = new AccessModelInterpreterImpl(provider, null); - try { - interpreter.computeAccessDetails(new CheckAccessDetailCollectorNotCalled(), expectedContext1, objectToCheck); - } finally { - Assert.assertTrue("Provider isApplicableCalled failed", provider.wasIsApplicableCalled()); - Assert.assertTrue("Provider asCastedObjectCalled failed", provider.wasAsCastedObjectCalled()); - } - } - - @Test - public void testComputeAccessCheckRestriction() { - AccessContext accessContext = MockModel.createAccessContext(contextId2.getId(), "c2"); - - MockArtifactProxy artifactData = new MockArtifactProxy(); - - ObjectRestriction objectRestriction = null; - assertComputeDetails(accessContext, artifactData, objectRestriction, false); - } - - private static void assertComputeDetails(AccessContext accessContext, MockArtifactProxy artifactData, ObjectRestriction objectRestriction, boolean expectedProcessCalled) { - final Object objectToCheck = new Object(); - MockArtifactDataProvider provider = new MockArtifactDataProvider(true, objectToCheck, artifactData); - AccessDetailCollector collector = new CheckAccessDetailCollectorNotCalled(); - MockRestrictionHandler restrictionHandler = - new MockRestrictionHandler(objectRestriction, artifactData, collector); - AccessModelInterpreterImpl interpreter = new AccessModelInterpreterImpl(provider, null, restrictionHandler); - interpreter.computeAccessDetails(collector, accessContext, objectToCheck); - Assert.assertTrue("Provider isApplicableCalled failed", provider.wasIsApplicableCalled()); - Assert.assertTrue("Provider asCastedObjectCalled failed", provider.wasAsCastedObjectCalled()); - Assert.assertEquals("Restriction process called check failed", expectedProcessCalled, - restrictionHandler.wasProcessCalled()); - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreterTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreterTest.java deleted file mode 100644 index 34a71d1115..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchInterpreterTest.java +++ /dev/null @@ -1,288 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.osee.framework.core.data.ArtifactTypeToken; -import org.eclipse.osee.framework.core.data.BranchToken; -import org.eclipse.osee.framework.core.data.RelationTypeToken; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; -import org.eclipse.osee.framework.core.dsl.oseeDsl.CompareOp; -import org.eclipse.osee.framework.core.dsl.oseeDsl.CompoundCondition; -import org.eclipse.osee.framework.core.dsl.oseeDsl.Condition; -import org.eclipse.osee.framework.core.dsl.oseeDsl.MatchField; -import org.eclipse.osee.framework.core.dsl.oseeDsl.SimpleCondition; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XLogicOperator; -import org.eclipse.osee.framework.jdk.core.util.GUID; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test Case for {@link ArtifactMatchInterpreter} - * - * @author Roberto E. Escobar - */ -public class ArtifactMatchInterpreterTest { - - private final ArtifactMatchInterpreter interpreter = new ArtifactMatchInterpreter(); - private static final BranchToken randomBranch = BranchToken.create("Random Branch"); - - @Test - public void testMatchNoConditions() { - XArtifactMatcher matcher = MockModel.createXArtifactMatcherRef("TestArtifact"); - boolean actual = interpreter.matches(matcher, (ArtifactProxy) null); - Assert.assertEquals(false, actual); - } - - @Test - public void testArtifactNameEq() { - XArtifactMatcher matcher = - MockModel.createMatcher("artifactMatcher \"Test\" where artifactName EQ \"Test Artifact\";"); - - DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.ARTIFACT_NAME, CompareOp.EQ, - "Test Artifact"); - - ArtifactProxy proxy = createProxy(GUID.create(), "test Artifact"); - boolean actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(false, actual); - - proxy = createProxy(GUID.create(), "Test Artifact"); - actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(true, actual); - } - - @Test - public void testArtifactNameLike() { - XArtifactMatcher matcher = - MockModel.createMatcher("artifactMatcher \"Test\" where artifactName LIKE \".*arti.*\";"); - - DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.ARTIFACT_NAME, CompareOp.LIKE, - ".*arti.*"); - - ArtifactProxy proxy = createProxy(GUID.create(), "9999 arti_121341"); - boolean actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(true, actual); - } - - @Test - public void testartifactIdEq() { - String guid = GUID.create(); - XArtifactMatcher matcher = - MockModel.createMatcher("artifactMatcher \"Test\" where artifactId EQ \"" + guid + "\";"); - - DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.ARTIFACT_ID, CompareOp.EQ, guid); - - ArtifactProxy proxy = createProxy(guid, ""); - boolean actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(true, actual); - } - - @Test - public void testartifactIdLike() { - XArtifactMatcher matcher = MockModel.createMatcher("artifactMatcher \"Test\" where artifactId LIKE \"\\w+\";"); - - DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.ARTIFACT_ID, CompareOp.LIKE, - "\\w+"); - - ArtifactProxy proxy = createProxy("ABCDEFGHIJK123456789", ""); - boolean actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(true, actual); - } - - @Test - public void testArtifactBranchNameEq() { - XArtifactMatcher matcher = MockModel.createMatcher("artifactMatcher \"Test\" where branchName EQ \"branch1\";"); - - DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.BRANCH_NAME, CompareOp.EQ, - "branch1"); - - ArtifactProxy proxy = createProxy(GUID.create(), "art1", randomBranch, "branch2"); - boolean actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(false, actual); - - proxy = createProxy(GUID.create(), "art1", randomBranch, "branch1"); - actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(true, actual); - } - - @Test - public void testArtifactBranchNameLike() { - XArtifactMatcher matcher = - MockModel.createMatcher("artifactMatcher \"Test\" where branchName LIKE \".*hello.*\";"); - - DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.BRANCH_NAME, CompareOp.LIKE, - ".*hello.*"); - - ArtifactProxy proxy = createProxy(GUID.create(), "art1", randomBranch, "this is the hello branch"); - boolean actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(true, actual); - } - - @Test - public void testArtifactBranchUuidLike() { - XArtifactMatcher matcher = MockModel.createMatcher("artifactMatcher \"Test\" where branchUuid LIKE \"\\w+\";"); - - DslAsserts.assertEquals(matcher.getConditions().iterator().next(), MatchField.BRANCH_UUID, CompareOp.LIKE, - "\\w+"); - - ArtifactProxy proxy = createProxy(GUID.create(), "art1", randomBranch, ""); - boolean actual = interpreter.matches(matcher, proxy); - Assert.assertEquals(true, actual); - } - - @Test - public void testCompoundCondition1() { - XArtifactMatcher andMatcher = MockModel.createMatcher( - "artifactMatcher \"Test\" where artifactId EQ \"ABCDEFGHIJK123456789\" AND artifactName EQ \"myArtifact\";"); - - Iterator iterator = andMatcher.getConditions().iterator(); - DslAsserts.assertEquals(iterator.next(), MatchField.ARTIFACT_ID, CompareOp.EQ, "ABCDEFGHIJK123456789"); - DslAsserts.assertEquals(iterator.next(), MatchField.ARTIFACT_NAME, CompareOp.EQ, "myArtifact"); - - Assert.assertEquals(1, andMatcher.getOperators().size()); - Assert.assertEquals(XLogicOperator.AND, andMatcher.getOperators().iterator().next()); - - XArtifactMatcher orMatcher = MockModel.createMatcher( - "artifactMatcher \"Test\" where artifactId EQ \"ABCDEFGHIJK123456789\" OR artifactName EQ \"myArtifact\";"); - - Iterator iterator2 = orMatcher.getConditions().iterator(); - DslAsserts.assertEquals(iterator2.next(), MatchField.ARTIFACT_ID, CompareOp.EQ, "ABCDEFGHIJK123456789"); - DslAsserts.assertEquals(iterator2.next(), MatchField.ARTIFACT_NAME, CompareOp.EQ, "myArtifact"); - - Assert.assertEquals(1, orMatcher.getOperators().size()); - Assert.assertEquals(XLogicOperator.OR, orMatcher.getOperators().iterator().next()); - - ArtifactProxy proxy1 = createProxy("1BCDEFGHIJK123456789", "xArtifact"); - ArtifactProxy proxy2 = createProxy("1BCDEFGHIJK123456789", "myArtifact"); - ArtifactProxy proxy3 = createProxy("ABCDEFGHIJK123456789", "xArtifact"); - ArtifactProxy proxy4 = createProxy("ABCDEFGHIJK123456789", "myArtifact"); - - Assert.assertEquals(false, interpreter.matches(andMatcher, proxy1)); - Assert.assertEquals(false, interpreter.matches(andMatcher, proxy2)); - Assert.assertEquals(false, interpreter.matches(andMatcher, proxy3)); - Assert.assertEquals(true, interpreter.matches(andMatcher, proxy4)); - - Assert.assertEquals(false, interpreter.matches(orMatcher, proxy1)); - Assert.assertEquals(true, interpreter.matches(orMatcher, proxy2)); - Assert.assertEquals(true, interpreter.matches(orMatcher, proxy3)); - Assert.assertEquals(true, interpreter.matches(orMatcher, proxy4)); - } - - @Test - public void testCompoundCondition2() { - XArtifactMatcher matcher = MockModel.createMatcher( - "artifactMatcher \"Test\" where artifactId EQ \"ABCDEFGHIJK123456789\" AND (branchName EQ \"myArtifact\" OR branchUuid EQ \"3456789101112131415\");"); - - Assert.assertEquals(2, matcher.getConditions().size()); - Iterator iterator = matcher.getConditions().iterator(); - DslAsserts.assertEquals(iterator.next(), MatchField.ARTIFACT_ID, CompareOp.EQ, "ABCDEFGHIJK123456789"); - - Assert.assertEquals(1, matcher.getOperators().size()); - Assert.assertEquals(XLogicOperator.AND, matcher.getOperators().iterator().next()); - - Condition condition = iterator.next(); - - Assert.assertTrue(condition instanceof CompoundCondition); - CompoundCondition compoundCondition = (CompoundCondition) condition; - - Assert.assertEquals(2, compoundCondition.getConditions().size()); - - String badArtGuid = "1BCDEFGHIJK123456789"; - BranchToken badBranch = BranchToken.create(333333333123456789L, "Bad Branch"); - String badBranchName = "xArtifact"; - - String goodArtGuid = "ABCDEFGHIJK123456789"; - BranchToken goodBranch = BranchToken.create(3456789101112131415L, "Good Branch"); - String goodBranchName = "myArtifact"; - - Iterator iterator2 = compoundCondition.getConditions().iterator(); - DslAsserts.assertEquals(iterator2.next(), MatchField.BRANCH_NAME, CompareOp.EQ, "myArtifact"); - DslAsserts.assertEquals(iterator2.next(), MatchField.BRANCH_UUID, CompareOp.EQ, goodBranch.getIdString()); - - Assert.assertEquals(1, compoundCondition.getOperators().size()); - Assert.assertEquals(XLogicOperator.OR, compoundCondition.getOperators().iterator().next()); - - ArtifactProxy proxy1 = createProxy(badArtGuid, "", badBranch, badBranchName); - ArtifactProxy proxy2 = createProxy(badArtGuid, "", badBranch, goodBranchName); - ArtifactProxy proxy3 = createProxy(badArtGuid, "", goodBranch, badBranchName); - ArtifactProxy proxy4 = createProxy(badArtGuid, "", goodBranch, goodBranchName); - ArtifactProxy proxy5 = createProxy(goodArtGuid, "", badBranch, badBranchName); - ArtifactProxy proxy6 = createProxy(goodArtGuid, "", badBranch, goodBranchName); - ArtifactProxy proxy7 = createProxy(goodArtGuid, "", goodBranch, badBranchName); - ArtifactProxy proxy8 = createProxy(goodArtGuid, "", goodBranch, goodBranchName); - - Assert.assertEquals(false, interpreter.matches(matcher, proxy1)); - Assert.assertEquals(false, interpreter.matches(matcher, proxy2)); - Assert.assertEquals(false, interpreter.matches(matcher, proxy3)); - Assert.assertEquals(false, interpreter.matches(matcher, proxy4)); - - Assert.assertEquals(false, interpreter.matches(matcher, proxy5)); - Assert.assertEquals(true, interpreter.matches(matcher, proxy6)); - Assert.assertEquals(true, interpreter.matches(matcher, proxy7)); - Assert.assertEquals(true, interpreter.matches(matcher, proxy8)); - } - - private static ArtifactProxy createProxy(String artGuid, String artifactName) { - return createProxy(artGuid, artifactName, randomBranch, "dummy"); - } - - private static ArtifactProxy createProxy(final String artGuid, final String artifactName, BranchToken branch, final String branchName) { - return new ArtifactProxy() { - - @Override - public BranchToken getBranch() { - return branch; - } - - @Override - public BranchToken getBranchToken() { - return BranchToken.create(branch, branchName); - } - - @Override - public String getName() { - return artifactName; - } - - @Override - public String getGuid() { - return artGuid; - } - - @Override - public ArtifactTypeToken getArtifactType() { - return null; - } - - @Override - public Collection getValidRelationTypes() { - return null; - } - - @Override - public Collection getHierarchy() { - return null; - } - - @Override - public Long getId() { - return 0L; - } - }; - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandlerTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandlerTest.java deleted file mode 100644 index 8d5c8dfc46..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandlerTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactMatchRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.access.Scope; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test Case for {@link ArtifactMatchRestrictionHandler} - * - * @author Roberto E. Escobar - */ -public class ArtifactMatchRestrictionHandlerTest extends BaseRestrictionHandlerTest { - - private static final MockArtifactMatchInterpreter matcher = new MockArtifactMatchInterpreter(); - - public ArtifactMatchRestrictionHandlerTest() { - super(new ArtifactMatchRestrictionHandler(matcher), MockModel.createArtifactMatchRestriction(), - MockModel.createAttributeTypeRestriction()); - } - - @Test - public void testProcessDataNotMatchesRestriction() { - XArtifactMatcher artifactRef = MockModel.createXArtifactMatcherRef("TestArtifact"); - - ArtifactMatchRestriction restriction = MockModel.createArtifactMatchRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setArtifactMatcherRef(artifactRef); - - matcher.setMatchesResult(false); - - MockArtifactProxy artData = new MockArtifactProxy(); - Scope expectedScope = new Scope().add("fail"); - DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artData, expectedScope); - - Assert.assertEquals(artifactRef, matcher.getMatcher()); - Assert.assertEquals(artData, matcher.getProxy()); - } - - @Test - public void testProcessCreateAccessDetail() { - XArtifactMatcher artifactRef = MockModel.createXArtifactMatcherRef("TestArtifact"); - - ArtifactMatchRestriction restriction = MockModel.createArtifactMatchRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setArtifactMatcherRef(artifactRef); - - matcher.setMatchesResult(true); - ArtifactToken expectedAccessObject = ArtifactToken.valueOf(1, "Another Artifact", BranchId.SENTINEL); - MockArtifactProxy artData = new MockArtifactProxy(expectedAccessObject); - - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedAccessObject, - PermissionEnum.WRITE, expectedScope); - - Assert.assertEquals(artifactRef, matcher.getMatcher()); - Assert.assertEquals(artData, matcher.getProxy()); - } - - private static final class MockArtifactMatchInterpreter extends ArtifactMatchInterpreter { - - private boolean matchesResult; - private ArtifactProxy proxy; - private XArtifactMatcher matcher; - - @Override - public boolean matches(XArtifactMatcher matcher, ArtifactProxy proxy) { - this.matcher = matcher; - this.proxy = proxy; - return matchesResult; - } - - public ArtifactProxy getProxy() { - return proxy; - } - - public XArtifactMatcher getMatcher() { - return matcher; - } - - public void setMatchesResult(boolean matchesResult) { - this.matchesResult = matchesResult; - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandlerTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandlerTest.java deleted file mode 100644 index 6cf5bb3007..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandlerTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.AbstractSpecRequirement; -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Artifact; -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Requirement; -import org.eclipse.osee.framework.core.data.ArtifactTypeToken; -import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.access.Scope; -import org.junit.Test; - -/** - * Test Case for {@link ArtifactTypeRestrictionHandler} - * - * @author Roberto E. Escobar - */ -public class ArtifactTypeRestrictionHandlerTest extends BaseRestrictionHandlerTest { - - public ArtifactTypeRestrictionHandlerTest() { - super(new ArtifactTypeRestrictionHandler(), MockModel.createArtifactTypeRestriction(), - MockModel.createAttributeTypeRestriction()); - } - - @Test - public void testProcessDataNotMatchesRestriction() { - ArtifactTypeToken artifactType = Requirement; - XArtifactType artifactTypeRef = MockModel.createXArtifactType(artifactType); - - ArtifactTypeRestriction restriction = MockModel.createArtifactTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setArtifactTypeRef(artifactTypeRef); - - MockArtifactProxy artData = new MockArtifactProxy(CoreArtifactTypes.Folder); - Scope expectedScope = new Scope().add("fail"); - DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artData, expectedScope); - } - - @Test - public void testProcessCreateAccessDetail() { - ArtifactTypeToken artifactType = Requirement; - XArtifactType artifactTypeRef = MockModel.createXArtifactType(artifactType); - - ArtifactTypeRestriction restriction = MockModel.createArtifactTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setArtifactTypeRef(artifactTypeRef); - - MockArtifactProxy artData = new MockArtifactProxy(artifactType); - - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, artifactType, PermissionEnum.WRITE, - expectedScope); - } - - @Test - public void testProcessArtifactTypeInheritance() { - XArtifactType artifactTypeRef = MockModel.createXArtifactType(Requirement); - - ArtifactTypeRestriction restriction = MockModel.createArtifactTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setArtifactTypeRef(artifactTypeRef); - - MockArtifactProxy artData = new MockArtifactProxy(Artifact); - Scope expectedScope = new Scope(); - DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artData, expectedScope); - - MockArtifactProxy reqArtData = new MockArtifactProxy(AbstractSpecRequirement); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, reqArtData, AbstractSpecRequirement, - PermissionEnum.WRITE, expectedScope); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandlerTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandlerTest.java deleted file mode 100644 index b11fd6b255..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandlerTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Artifact; -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Requirement; -import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Name; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.ArtifactTypeToken; -import org.eclipse.osee.framework.core.data.AttributeTypeId; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.jdk.core.type.MutableBoolean; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test Case for {@link AttributeTypeRestrictionHandler} - * - * @author Roberto E. Escobar - */ -public class AttributeTypeRestrictionHandlerTest extends BaseRestrictionHandlerTest { - private static final XAttributeType attributeTypeRef = MockModel.createXAttributeType(Name, Name.getName()); - - public AttributeTypeRestrictionHandlerTest() { - super(new AttributeTypeRestrictionHandler(), MockModel.createAttributeTypeRestriction(), - MockModel.createArtifactTypeRestriction()); - } - - @Test - public void testProcessDataAttributeTypeNotApplicable() { - AttributeTypeRestriction restriction = MockModel.createAttributeTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setAttributeTypeRef(attributeTypeRef); - - final MutableBoolean wasIsAttributeTypeValidCalled = new MutableBoolean(false); - ArtifactProxy artifactProxy = createArtifactProxy(null, Name, wasIsAttributeTypeValidCalled, false); - Scope expectedScope = new Scope().add("fail"); - DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artifactProxy, expectedScope); - Assert.assertTrue(wasIsAttributeTypeValidCalled.getValue()); - } - - @Test - public void testProcessDataAttributeTypeIsApplicable() { - AttributeTypeRestriction restriction = MockModel.createAttributeTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setAttributeTypeRef(attributeTypeRef); - - final MutableBoolean wasIsAttributeTypeValidCalled = new MutableBoolean(false); - ArtifactProxy artifactProxy = createArtifactProxy(null, Name, wasIsAttributeTypeValidCalled, true); - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artifactProxy, Name, PermissionEnum.WRITE, - expectedScope); - Assert.assertTrue(wasIsAttributeTypeValidCalled.getValue()); - } - - @Test - public void testProcessDataAttributeTypeIsApplicableArtifactTypeBoundedNoMatch() { - AttributeTypeRestriction restriction = MockModel.createAttributeTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setAttributeTypeRef(attributeTypeRef); - - XArtifactType artifactTypeRef = MockModel.createXArtifactType(Requirement); - restriction.setArtifactTypeRef(artifactTypeRef); - - final MutableBoolean wasIsAttributeTypeValidCalled = new MutableBoolean(false); - ArtifactProxy artifactProxy = createArtifactProxy(Artifact, Name, wasIsAttributeTypeValidCalled, true); - Scope expectedScope = new Scope().add("fail"); - DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artifactProxy, expectedScope); - Assert.assertTrue(wasIsAttributeTypeValidCalled.getValue()); - } - - @Test - public void testProcessDataAttributeTypeIsApplicableArtifactTypeMatch() { - AttributeTypeRestriction restriction = MockModel.createAttributeTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setAttributeTypeRef(attributeTypeRef); - - XArtifactType artifactTypeRef = MockModel.createXArtifactType(Requirement); - restriction.setArtifactTypeRef(artifactTypeRef); - - final MutableBoolean wasIsAttributeTypeValidCalled = new MutableBoolean(false); - ArtifactProxy artifactProxy = createArtifactProxy(Requirement, Name, wasIsAttributeTypeValidCalled, true); - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artifactProxy, Name, PermissionEnum.WRITE, - expectedScope); - Assert.assertTrue(wasIsAttributeTypeValidCalled.getValue()); - } - - @Test - public void testProcessDataAttributeTypeIsApplicableArtifactTypeMatchWithInheritance() { - AttributeTypeRestriction restriction = MockModel.createAttributeTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setAttributeTypeRef(attributeTypeRef); - - XArtifactType artifactTypeRef = MockModel.createXArtifactType(Artifact); - restriction.setArtifactTypeRef(artifactTypeRef); - - ArtifactTypeToken artifactType2 = Requirement; - - final MutableBoolean wasIsAttributeTypeValidCalled = new MutableBoolean(false); - ArtifactProxy artifactProxy = createArtifactProxy(artifactType2, Name, wasIsAttributeTypeValidCalled, true); - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artifactProxy, Name, PermissionEnum.WRITE, - expectedScope); - Assert.assertTrue(wasIsAttributeTypeValidCalled.getValue()); - } - - private static ArtifactProxy createArtifactProxy(ArtifactTypeToken artifactType, final AttributeTypeId expectedAttributeType, final MutableBoolean wasIsAttributeTypeValidCalled, final boolean isTypeValid) { - MockArtifactProxy artData = new MockArtifactProxy(artifactType) { - - @Override - public boolean isAttributeTypeValid(AttributeTypeId attributeType) { - wasIsAttributeTypeValidCalled.setValue(true); - Assert.assertEquals(expectedAttributeType, attributeType); - return isTypeValid; - } - }; - return artData; - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/BaseRestrictionHandlerTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/BaseRestrictionHandlerTest.java deleted file mode 100644 index cc083b9fb1..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/BaseRestrictionHandlerTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.core.access.Scope; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test Case for {@link RestrictionHandler classes} - * - * @author Roberto E. Escobar - */ -public abstract class BaseRestrictionHandlerTest { - - private final RestrictionHandler restrictionHandler; - private final ObjectRestriction validRestriction; - private final ObjectRestriction invalidRestriction; - - protected BaseRestrictionHandlerTest(RestrictionHandler restrictionHandler, ObjectRestriction validRestriction, ObjectRestriction invalidRestriction) { - this.restrictionHandler = restrictionHandler; - this.validRestriction = validRestriction; - this.invalidRestriction = invalidRestriction; - } - - protected RestrictionHandler getRestrictionHandler() { - return restrictionHandler; - } - - @Test - public void testAsCastedObject() { - T actualObject = restrictionHandler.asCastedObject(validRestriction); - Assert.assertNotNull(actualObject); - Assert.assertEquals(validRestriction, actualObject); - } - - @Test - public void testAsCastedObjectReturnsNull() { - ObjectRestriction objectRestriction = MockModel.createObjectRestriction(); - T actualObject = restrictionHandler.asCastedObject(objectRestriction); - Assert.assertNull(actualObject); - } - - @Test - public void testProcessNullObjectRestriction() { - Scope expectedScope = new Scope().add("fail"); - DslAsserts.assertNullAccessDetail(restrictionHandler, null, null, expectedScope); - } - - @Test - public void testProcessInvalidObjectRestriction() { - Scope expectedScope = new Scope().add("fail"); - DslAsserts.assertNullAccessDetail(restrictionHandler, invalidRestriction, null, expectedScope); - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java index 7a6128d42f..f7c6b97fb5 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/InternalTestSuite.java @@ -20,14 +20,7 @@ import org.junit.runners.Suite; * @author Roberto E. Escobar */ @RunWith(Suite.class) -@Suite.SuiteClasses({ - AccessModelInterpreterImplTest.class, - ArtifactMatchInterpreterTest.class, - ArtifactMatchRestrictionHandlerTest.class, - ArtifactTypeRestrictionHandlerTest.class, - AttributeTypeRestrictionHandlerTest.class, - RelationTypeRestrictionHandlerTest.class, - OseeUtilTest.class}) +@Suite.SuiteClasses({OseeUtilTest.class}) public class InternalTestSuite { // Test Suite } diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandlerTest.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandlerTest.java deleted file mode 100644 index 7d4293d7e1..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandlerTest.java +++ /dev/null @@ -1,272 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.AbstractSoftwareRequirement; -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.SoftwareRequirementMsWord; -import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.DevelopmentalVerification; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.RelationTypeSide; -import org.eclipse.osee.framework.core.data.RelationTypeToken; -import org.eclipse.osee.framework.core.dsl.integration.mocks.DslAsserts; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.mocks.MockModel; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeArtifactPredicate; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeArtifactTypePredicate; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationSideEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType; -import org.eclipse.osee.framework.core.enums.CoreRelationTypes; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.enums.RelationSide; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test Case for {@link RelationTypeRestrictionHandler} - * - * @author Roberto E. Escobar - */ -public class RelationTypeRestrictionHandlerTest extends BaseRestrictionHandlerTest { - - public RelationTypeRestrictionHandlerTest() { - super(new RelationTypeRestrictionHandler(new ArtifactMatchInterpreter()), - MockModel.createRelationTypeRestriction(), MockModel.createAttributeTypeRestriction()); - } - - @Test - public void testProcessDataRelationTypeNoMatch() { - XRelationType relationTypeRef = MockModel.createXRelationType(CoreRelationTypes.Allocation); - - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeRef(relationTypeRef); - - // Artifact Data has no relation types therefore relation type will not match - MockArtifactProxy artData = new MockArtifactProxy(); - Scope expectedScope = new Scope().add("fail"); - DslAsserts.assertNullAccessDetail(getRestrictionHandler(), restriction, artData, expectedScope); - } - - @Test - public void testProcessDataRelationTypeMatchSideANoMatch() { - RelationTypeToken testRelationType = CoreRelationTypes.CodeRequirement; - XRelationType relationTypeRef = MockModel.createXRelationType(testRelationType); - - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeRef(relationTypeRef); - restriction.setRestrictedToSide(XRelationSideEnum.SIDE_A); - - MockArtifactProxy artData = new MockArtifactProxy(SoftwareRequirementMsWord, testRelationType); - RelationTypeSide expectedObject = new RelationTypeSide(testRelationType, RelationSide.SIDE_A); - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedObject, PermissionEnum.WRITE, - expectedScope); - } - - @Test - public void testProcessDataRelationTypeMatchSideAMatch() { - RelationTypeToken testRelationType = CoreRelationTypes.CodeRequirement; - XRelationType relationTypeRef = MockModel.createXRelationType(testRelationType); - - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeRef(relationTypeRef); - restriction.setRestrictedToSide(XRelationSideEnum.SIDE_A); - - MockArtifactProxy artData = new MockArtifactProxy(SoftwareRequirementMsWord, testRelationType); - RelationTypeSide expectedObject = new RelationTypeSide(testRelationType, RelationSide.SIDE_A); - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedObject, PermissionEnum.WRITE, - expectedScope); - } - - @Test - public void testProcessDataRelationTypeMatchSideBNoMatch() { - RelationTypeToken testRelationType = DevelopmentalVerification; - XRelationType relationTypeRef = MockModel.createXRelationType(testRelationType); - - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeRef(relationTypeRef); - restriction.setRestrictedToSide(XRelationSideEnum.SIDE_B); - - MockArtifactProxy artData = new MockArtifactProxy(SoftwareRequirementMsWord, testRelationType); - - RelationTypeSide expectedObject = new RelationTypeSide(testRelationType, RelationSide.SIDE_B); - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedObject, PermissionEnum.WRITE, - expectedScope); - } - - @Test - public void testProcessDataRelationTypeMatchSideBMatch() { - RelationTypeToken testRelationType = DevelopmentalVerification; - XRelationType relationTypeRef = MockModel.createXRelationType(testRelationType); - - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeRef(relationTypeRef); - restriction.setRestrictedToSide(XRelationSideEnum.SIDE_B); - - MockArtifactProxy artData = new MockArtifactProxy(SoftwareRequirementMsWord, testRelationType); - RelationTypeSide expectedObject = new RelationTypeSide(testRelationType, RelationSide.SIDE_B); - Scope expectedScope = new Scope(); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedObject, PermissionEnum.WRITE, - expectedScope); - } - - @Test - public void testProcessDataRelationTypeMatchBothMatch() { - RelationTypeToken testRelationType = DevelopmentalVerification; - - XRelationType relationTypeRef = MockModel.createXRelationType(testRelationType); - - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeRef(relationTypeRef); - restriction.setRestrictedToSide(XRelationSideEnum.BOTH); - - MockArtifactProxy artData = new MockArtifactProxy(SoftwareRequirementMsWord, testRelationType); - RelationTypeSide expectedObject1 = new RelationTypeSide(testRelationType, RelationSide.SIDE_A); - RelationTypeSide expectedObject2 = new RelationTypeSide(testRelationType, RelationSide.SIDE_B); - - final List> actualAccesses = new ArrayList<>(); - AccessDetailCollector collector = new AccessDetailCollector() { - - @Override - public void collect(AccessDetail accessDetail) { - Assert.assertNotNull(accessDetail); - actualAccesses.add(accessDetail); - } - }; - - Scope expectedScope = new Scope(); - getRestrictionHandler().process(restriction, artData, collector, expectedScope); - - AccessDetail actualAccess = actualAccesses.get(0); - Assert.assertEquals(actualAccess.getPermission(), PermissionEnum.WRITE); - Assert.assertEquals(expectedObject1, actualAccess.getAccessObject()); - - actualAccess = actualAccesses.get(1); - Assert.assertEquals(actualAccess.getPermission(), PermissionEnum.WRITE); - Assert.assertEquals(expectedObject2, actualAccess.getAccessObject()); - } - - @Test - public void testProcessRelationWithRelationTypeAll() { - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeMatch(true); - restriction.setRestrictedToSide(XRelationSideEnum.BOTH); - - RelationTypeToken testRelationType = DevelopmentalVerification; - - MockArtifactProxy artData = new MockArtifactProxy(SoftwareRequirementMsWord, testRelationType); - RelationTypeSide expectedObject1 = new RelationTypeSide(testRelationType, RelationSide.SIDE_A); - RelationTypeSide expectedObject2 = new RelationTypeSide(testRelationType, RelationSide.SIDE_B); - - final List> actualAccesses = new ArrayList<>(); - AccessDetailCollector collector = new AccessDetailCollector() { - - @Override - public void collect(AccessDetail accessDetail) { - Assert.assertNotNull(accessDetail); - actualAccesses.add(accessDetail); - } - }; - - Scope expectedScope = new Scope(); - getRestrictionHandler().process(restriction, artData, collector, expectedScope); - - AccessDetail actualAccess = actualAccesses.get(0); - Assert.assertEquals(actualAccess.getPermission(), PermissionEnum.WRITE); - Assert.assertEquals(expectedObject1, actualAccess.getAccessObject()); - - actualAccess = actualAccesses.get(1); - Assert.assertEquals(actualAccess.getPermission(), PermissionEnum.WRITE); - Assert.assertEquals(expectedObject2, actualAccess.getAccessObject()); - } - - @Test - public void testProcessDataArtifactTypeMatch() { - XArtifactType artifactTypeRef = MockModel.createXArtifactType(AbstractSoftwareRequirement); - - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeMatch(true); - - RelationTypeArtifactTypePredicate predicate = OseeDslFactory.eINSTANCE.createRelationTypeArtifactTypePredicate(); - predicate.setArtifactTypeRef(artifactTypeRef); - - restriction.setPredicate(predicate); - restriction.setRestrictedToSide(XRelationSideEnum.SIDE_B); - - RelationTypeToken testRelationType = DevelopmentalVerification; - - ArtifactToken expectedAccessObject = ArtifactToken.valueOf(1, "Another Artifact", SoftwareRequirementMsWord); - MockArtifactProxy artData = new MockArtifactProxy(expectedAccessObject, testRelationType); - - RelationTypeSide expectedObject = new RelationTypeSide(testRelationType, RelationSide.SIDE_B); - - Scope expectedScope = new Scope(); - expectedScope.addSubPath(artData.getName()); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedObject, PermissionEnum.WRITE, - expectedScope); - } - - private void testProcessRelationWithArtifactHelper(String artifactName, String matcherArtifactName, Scope expectedScope) { - RelationTypeToken testRelationType = DevelopmentalVerification; - XRelationType relationTypeRef = MockModel.createXRelationType(testRelationType); - - RelationTypeRestriction restriction = MockModel.createRelationTypeRestriction(); - restriction.setPermission(AccessPermissionEnum.ALLOW); - restriction.setRelationTypeRef(relationTypeRef); - restriction.setRestrictedToSide(XRelationSideEnum.SIDE_B); - - XArtifactMatcher matcher = - MockModel.createMatcher("artifactMatcher \"Test\" where artifactName EQ \"" + matcherArtifactName + "\";"); - - RelationTypeArtifactPredicate predicate = OseeDslFactory.eINSTANCE.createRelationTypeArtifactPredicate(); - predicate.setArtifactMatcherRef(matcher); - restriction.setPredicate(predicate); - - ArtifactToken dummy = ArtifactToken.valueOf(43, artifactName, SoftwareRequirementMsWord); - MockArtifactProxy artData = new MockArtifactProxy(dummy, testRelationType); - RelationTypeSide expectedObject = new RelationTypeSide(testRelationType, RelationSide.SIDE_B); - DslAsserts.assertAccessDetail(getRestrictionHandler(), restriction, artData, expectedObject, PermissionEnum.WRITE, - expectedScope); - } - - @Test - public void testProcessRelationWithArtifactMatch() { - testProcessRelationWithArtifactHelper("artifactToMatch", "artifactToMatch", - new Scope().addSubPath("artifactToMatch")); - } - - @Test - public void testProcessRelationWithArtifactNoMatch() { - testProcessRelationWithArtifactHelper("artifactToMatch", "differentArtifactToMatch", new Scope()); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/CheckAccessDetailCollectorNotCalled.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/CheckAccessDetailCollectorNotCalled.java deleted file mode 100644 index 866e20ef41..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/CheckAccessDetailCollectorNotCalled.java +++ /dev/null @@ -1,30 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.mocks; - -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.junit.Assert; - -/** - * @author Roberto E. Escobar - */ -public final class CheckAccessDetailCollectorNotCalled implements AccessDetailCollector { - - @Override - public void collect(AccessDetail accessDetail) { - Assert.fail("Method was unexpectedly called"); - } - -}; \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/DslAsserts.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/DslAsserts.java deleted file mode 100644 index 26ceb596f8..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/DslAsserts.java +++ /dev/null @@ -1,175 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.mocks; - -import java.util.List; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.dsl.integration.AccessDataCollector; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessPermissionEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.CompareOp; -import org.eclipse.osee.framework.core.dsl.oseeDsl.Condition; -import org.eclipse.osee.framework.core.dsl.oseeDsl.HierarchyRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.MatchField; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationMultiplicityEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.SimpleCondition; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeTypeRef; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationSideEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.junit.Assert; - -/** - * @author Roberto E. Escobar - */ -public final class DslAsserts { - - private DslAsserts() { - // Utility class - } - - public static void assertNullAccessDetail(RestrictionHandler handler, ObjectRestriction restriction, ArtifactProxy artifactProxy, Scope expectedScopeLevel) { - assertAccessDetail(handler, restriction, artifactProxy, null, null, expectedScopeLevel); - } - - public static void assertAccessDetail(RestrictionHandler handler, ObjectRestriction restriction, ArtifactProxy artifactProxy, Object expectedAccessObject, PermissionEnum expectedPermission, Scope expectedScopeLevel) { - AccessDetailCollector collector = new AccessDataCollector(); - handler.process(restriction, artifactProxy, collector, new Scope()); - List> actualDetails = collector.getAccessDetails(); - if (expectedAccessObject == null) { - Assert.assertTrue(actualDetails.isEmpty()); - } else { - Assert.assertTrue(collector.contains(expectedAccessObject, expectedPermission, expectedScopeLevel)); - } - } - - public static void assertEquals(OseeDsl model1, OseeDsl model2) { - Assert.assertEquals(model1.getAccessDeclarations().size(), model2.getAccessDeclarations().size()); - Assert.assertEquals(model1.getArtifactMatchRefs().size(), model2.getArtifactMatchRefs().size()); - Assert.assertEquals(model1.getArtifactTypes().size(), model2.getArtifactTypes().size()); - Assert.assertEquals(model1.getAttributeTypes().size(), model2.getAttributeTypes().size()); - Assert.assertEquals(model1.getEnumOverrides().size(), model2.getEnumOverrides().size()); - Assert.assertEquals(model1.getEnumTypes().size(), model2.getEnumTypes().size()); - Assert.assertEquals(model1.getImports().size(), model2.getImports().size()); - Assert.assertEquals(model1.getRelationTypes().size(), model2.getRelationTypes().size()); - } - - public static void assertEquals(Condition condition, MatchField expField, CompareOp expOp, String expExpression) { - SimpleCondition simpCondition = (SimpleCondition) condition; - Assert.assertEquals(expField, simpCondition.getField()); - Assert.assertEquals(expOp, simpCondition.getOp()); - Assert.assertEquals(expExpression, simpCondition.getExpression()); - } - - public static void assertEquals(XArtifactMatcher matcher, String name) { - Assert.assertEquals(name, matcher.getName()); - } - - public static void assertEquals(XArtifactType artifactType, String expName, String expGuid, String[] inheritsFrom, String... attributeNames) { - Assert.assertEquals(expName, artifactType.getName()); - Assert.assertEquals(expGuid, artifactType.getId()); - - int index = 0; - Assert.assertEquals(inheritsFrom.length, artifactType.getSuperArtifactTypes().size()); - for (XArtifactType ref : artifactType.getSuperArtifactTypes()) { - Assert.assertEquals(inheritsFrom[index++], ref.getName()); - } - - index = 0; - Assert.assertEquals(attributeNames.length, artifactType.getValidAttributeTypes().size()); - for (XAttributeTypeRef ref : artifactType.getValidAttributeTypes()) { - Assert.assertEquals(attributeNames[index++], ref.getValidAttributeType().getName()); - } - } - - public static void assertEquals(XAttributeType type, String expName, String expGuid, String baseType, String dataProvider, String min, String max, String tagger, String description, String defaultValue, String ext) { - Assert.assertEquals(expName, type.getName()); - Assert.assertEquals(expGuid, type.getId()); - - Assert.assertEquals(baseType, type.getBaseAttributeType()); - Assert.assertEquals(dataProvider, type.getDataProvider()); - Assert.assertEquals(min, type.getMin()); - Assert.assertEquals(max, type.getMax()); - Assert.assertEquals(tagger, type.getTaggerId()); - Assert.assertEquals(description, type.getDescription()); - Assert.assertEquals(defaultValue, type.getDefaultValue()); - Assert.assertEquals(ext, type.getFileExtension()); - } - - public static void assertEquals(XRelationType type, String expName, String expGuid, String sideA, String aName, String aGuid, String sideB, String bName, String bGuid, String orderType, RelationMultiplicityEnum mult) { - Assert.assertEquals(expName, type.getName()); - Assert.assertEquals(expGuid, type.getId()); - - XArtifactType aArt = type.getSideAArtifactType(); - Assert.assertEquals(sideA, type.getSideAName()); - Assert.assertEquals(aName, aArt.getName()); - Assert.assertEquals(aGuid, aArt.getId()); - - XArtifactType bArt = type.getSideBArtifactType(); - Assert.assertEquals(sideB, type.getSideBName()); - Assert.assertEquals(bName, bArt.getName()); - Assert.assertEquals(bGuid, bArt.getId()); - - Assert.assertEquals(orderType, type.getDefaultOrderType()); - Assert.assertEquals(mult, type.getMultiplicity()); - } - - public static void assertEquals(AccessContext context, String expName, Long expId, String[] inheritsFrom) { - Assert.assertEquals(expName, context.getName()); - Assert.assertEquals(expId, Long.valueOf(context.getId())); - - int index = 0; - Assert.assertEquals(inheritsFrom.length, context.getSuperAccessContexts().size()); - for (AccessContext ref : context.getSuperAccessContexts()) { - Assert.assertEquals(inheritsFrom[index++], ref.getName()); - } - } - - public static void assertEquals(ArtifactTypeRestriction restriction, AccessPermissionEnum permission, String artTypeName) { - Assert.assertEquals(permission, restriction.getPermission()); - XArtifactType ref = restriction.getArtifactTypeRef(); - Assert.assertEquals(artTypeName, ref.getName()); - } - - public static void assertEquals(AttributeTypeRestriction restriction, AccessPermissionEnum permission, String attrTypeName, String artTypeName) { - Assert.assertEquals(permission, restriction.getPermission()); - - Assert.assertEquals(attrTypeName, restriction.getAttributeTypeRef().getName()); - - XArtifactType ref = restriction.getArtifactTypeRef(); - Assert.assertEquals(artTypeName, ref.getName()); - } - - public static void assertEquals(RelationTypeRestriction restriction, AccessPermissionEnum permission, String relType, XRelationSideEnum sideEnum) { - Assert.assertEquals(permission, restriction.getPermission()); - Assert.assertEquals(relType, restriction.getRelationTypeRef().getName()); - Assert.assertEquals(sideEnum, restriction.getRestrictedToSide()); - } - - public static void assertEquals(HierarchyRestriction restriction, String matcherName) { - Assert.assertEquals(matcherName, restriction.getArtifactMatcherRef().getName()); - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/MockRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/MockRestrictionHandler.java deleted file mode 100644 index f61f2c4361..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration.test/src/org/eclipse/osee/framework/core/dsl/integration/mocks/MockRestrictionHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.mocks; - -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.junit.Assert; - -/** - * @author Roberto E. Escobar - */ -public class MockRestrictionHandler implements RestrictionHandler { - - private final ObjectRestriction expectedObjectRestriction; - private final ArtifactProxy expectedArtifactProxy; - private final AccessDetailCollector expectedCollector; - private boolean wasProcessCalled; - - public MockRestrictionHandler(ObjectRestriction expectedObjectRestriction, ArtifactProxy expectedArtifactProxy, AccessDetailCollector expectedCollector) { - super(); - this.expectedObjectRestriction = expectedObjectRestriction; - this.expectedArtifactProxy = expectedArtifactProxy; - this.expectedCollector = expectedCollector; - reset(); - } - - @Override - public Object asCastedObject(ObjectRestriction objectRestriction) { - return null; - } - - public void reset() { - wasProcessCalled = false; - } - - public boolean wasProcessCalled() { - return wasProcessCalled; - } - - @Override - public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector, Scope scopeLevel) { - wasProcessCalled = true; - Assert.assertEquals(expectedObjectRestriction, objectRestriction); - Assert.assertEquals(expectedArtifactProxy, artifactProxy); - Assert.assertEquals(expectedCollector, collector); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/OSGI-INF/access.model.interpreter.xml b/plugins/org.eclipse.osee.framework.core.dsl.integration/OSGI-INF/access.model.interpreter.xml deleted file mode 100644 index 1ca5d47756..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/OSGI-INF/access.model.interpreter.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessDataCollector.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessDataCollector.java deleted file mode 100644 index ffff89ed23..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessDataCollector.java +++ /dev/null @@ -1,55 +0,0 @@ -/********************************************************************* - * Copyright (c) 2020 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration; - -import java.util.LinkedList; -import java.util.List; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.enums.PermissionEnum; - -/** - * @author Ryan D. Brooks - */ -public final class AccessDataCollector implements AccessDetailCollector { - private final List> accessDetails; - - public AccessDataCollector() { - this.accessDetails = new LinkedList<>(); - } - - @Override - public void collect(AccessDetail accessDetail) { - if (accessDetail != null) { - accessDetails.add(accessDetail); - } - } - - @Override - public List> getAccessDetails() { - return accessDetails; - } - - @Override - public boolean contains(Object expectedAccessObject, PermissionEnum expectedPermission, Scope expectedScopeLevel) { - for (AccessDetail accessDetail : accessDetails) { - if (expectedPermission.equals(accessDetail.getPermission()) && expectedAccessObject.equals( - accessDetail.getAccessObject()) && expectedScopeLevel.equals(accessDetail.getScope())) { - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java deleted file mode 100644 index ab829cc31c..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/AccessModelInterpreter.java +++ /dev/null @@ -1,30 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration; - -import java.util.Collection; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext; - -/** - * @author Roberto E. Escobar - */ -public interface AccessModelInterpreter { - - AccessContext getContext(Collection contexts, AccessContextToken contextId); - - void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck); - -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslAccessModel.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslAccessModel.java deleted file mode 100644 index 13a958c4e0..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/OseeDslAccessModel.java +++ /dev/null @@ -1,57 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration; - -import java.util.Collection; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext; -import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl; -import org.eclipse.osee.framework.core.model.access.AccessModel; -import org.eclipse.osee.framework.jdk.core.util.Conditions; - -/** - * @author Roberto E. Escobar - */ -public class OseeDslAccessModel implements AccessModel { - private final AccessModelInterpreter interpreter; - private final OseeDslProvider dslProvider; - - public OseeDslAccessModel(AccessModelInterpreter interpreter, OseeDslProvider dslProvider) { - this.interpreter = interpreter; - this.dslProvider = dslProvider; - } - - @Override - public void computeAccess(AccessContextToken contextId, Collection objectsToCheck, AccessData accessData) { - Conditions.checkNotNull(contextId, "contextId"); - Conditions.checkNotNull(objectsToCheck, "objectsToCheck"); - Conditions.checkNotNull(accessData, "accessData"); - - OseeDsl oseeDsl = dslProvider.getDsl(); - Conditions.checkNotNull(oseeDsl, "oseeDsl", "dsl provider returned null"); - - Collection contexts = oseeDsl.getAccessDeclarations(); - AccessContext context = interpreter.getContext(contexts, contextId); - Conditions.checkNotNull(context, "interpreted accessContext", - "No matching access context was found in access dsl for [%s]", contextId); - - for (Object objectToCheck : objectsToCheck) { - AccessDetailCollector collector = new AccessDataCollector(); - interpreter.computeAccessDetails(collector, context, objectToCheck); - accessData.addAll(objectToCheck, collector.getAccessDetails()); - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java deleted file mode 100644 index 2c3c34aa73..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/RestrictionHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration; - -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; - -/** - * @author Roberto E. Escobar - */ -public interface RestrictionHandler { - public T asCastedObject(ObjectRestriction objectRestriction); - - public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector, Scope scopeLevel); -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java deleted file mode 100644 index 56658f1e1f..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import java.util.Collection; -import java.util.HashSet; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext; -import org.eclipse.osee.framework.core.dsl.oseeDsl.HierarchyRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher; -import org.eclipse.osee.framework.jdk.core.util.Conditions; -import org.eclipse.osee.framework.jdk.core.util.Strings; - -/** - * @author Roberto E. Escobar - */ -public class AccessModelInterpreterImpl implements AccessModelInterpreter { - - private final ArtifactDataProvider provider; - private final ArtifactMatchInterpreter matcher; - private final Collection> restrictionHandlers; - - public AccessModelInterpreterImpl(ArtifactDataProvider provider, ArtifactMatchInterpreter matcher, RestrictionHandler... restricitionHandlers) { - this.provider = provider; - this.matcher = matcher; - this.restrictionHandlers = new HashSet<>(); - for (RestrictionHandler handler : restricitionHandlers) { - restrictionHandlers.add(handler); - } - } - - @Override - public AccessContext getContext(Collection contexts, AccessContextToken contextId) { - Conditions.checkNotNull(contexts, "accessContext collection"); - Conditions.checkNotNull(contextId, "accessContextId"); - AccessContext toReturn = null; - for (AccessContext accessContext : contexts) { - if (contextId.equals(Long.valueOf(Strings.unquote(accessContext.getId())))) { - toReturn = accessContext; - } - } - return toReturn; - } - - @Override - public void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck) { - Conditions.checkNotNull(collector, "accessDetailCollector"); - Conditions.checkNotNull(context, "accessContext"); - Conditions.checkNotNull(objectToCheck, "objectToCheck"); - - if (provider.isApplicable(objectToCheck)) { - ArtifactProxy data = provider.asCastedObject(objectToCheck); - Conditions.checkNotNull(data, "artifactData", - "artifact data provider returned null - provider has an isApplicable error"); - - collectApplicable(collector, context, data); - } - } - - private void collectApplicable(AccessDetailCollector collector, AccessContext context, ArtifactProxy artifactData) { - Scope scope = getScope(context); - processContext(collector, context, artifactData, scope); - - for (AccessContext superContext : context.getSuperAccessContexts()) { - collectApplicable(collector, superContext, artifactData); - } - } - - private Scope getScope(AccessContext context) { - Scope scope = new Scope(); - scopeHelper(scope, context); - return scope; - } - - private void scopeHelper(Scope scope, AccessContext context) { - for (AccessContext parent : context.getSuperAccessContexts()) { - scopeHelper(scope, parent); - } - scope.add(context.getName()); - } - - private void processContext(AccessDetailCollector collector, AccessContext context, ArtifactProxy artifactData, Scope scope) { - collectRestrictions(collector, artifactData, context.getAccessRules(), scope); - - Collection restrictions = context.getHierarchyRestrictions(); - Collection proxyHierarchy = artifactData.getHierarchy(); - - for (HierarchyRestriction hierarchy : restrictions) { - XArtifactMatcher artifactRef = hierarchy.getArtifactMatcherRef(); - if (matcher.matches(artifactRef, proxyHierarchy)) { - String tag = String.format("childOf-%s", artifactRef.getName()); - Scope child = scope.clone().addSubPath(tag); - collectRestrictions(collector, artifactData, hierarchy.getAccessRules(), child); - } - } - } - - private void collectRestrictions(AccessDetailCollector collector, ArtifactProxy artifactData, Collection restrictions, Scope scope) { - for (ObjectRestriction objectRestriction : restrictions) { - for (RestrictionHandler restrictionHandler : restrictionHandlers) { - restrictionHandler.process(objectRestriction, artifactData, collector, scope); - } - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterProxy.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterProxy.java deleted file mode 100644 index f0e28cf955..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AccessModelInterpreterProxy.java +++ /dev/null @@ -1,79 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import java.util.Collection; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.data.AccessContextToken; -import org.eclipse.osee.framework.core.dsl.integration.AccessModelInterpreter; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider; -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AccessContext; -import org.eclipse.osee.framework.jdk.core.util.Conditions; - -/** - * @author Roberto E. Escobar - */ -public class AccessModelInterpreterProxy implements AccessModelInterpreter { - - private ArtifactDataProvider artifactDataProvider; - private AccessModelInterpreter proxiedService; - - public void setArtifactDataProvider(ArtifactDataProvider artifactDataProvider) { - this.artifactDataProvider = artifactDataProvider; - } - - public void start() { - // Do Nothing - } - - public void stop() { - proxiedService = null; - } - - private boolean isReady() { - return artifactDataProvider != null; - } - - private synchronized AccessModelInterpreter getProxiedService() { - if (isReady() && proxiedService == null) { - ArtifactMatchInterpreter matcher = new ArtifactMatchInterpreter(); - - RestrictionHandler[] restrictionHandlers = new RestrictionHandler[] { - new ArtifactMatchRestrictionHandler(matcher), - new ArtifactTypeRestrictionHandler(), - new AttributeTypeRestrictionHandler(), - new RelationTypeRestrictionHandler(matcher)}; - - proxiedService = new AccessModelInterpreterImpl(artifactDataProvider, matcher, restrictionHandlers); - } - return proxiedService; - } - - private void checkInitialized() { - Conditions.checkNotNull(getProxiedService(), "AccessModelInterpreter"); - } - - @Override - public AccessContext getContext(Collection contexts, AccessContextToken contextId) { - checkInitialized(); - return getProxiedService().getContext(contexts, contextId); - } - - @Override - public void computeAccessDetails(AccessDetailCollector collector, AccessContext context, Object objectToCheck) { - checkInitialized(); - getProxiedService().computeAccessDetails(collector, context, objectToCheck); - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandler.java deleted file mode 100644 index 1b8b8baeb1..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactMatchRestrictionHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactMatchRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher; -import org.eclipse.osee.framework.core.enums.PermissionEnum; - -/** - * @author Roberto E. Escobar - */ -public class ArtifactMatchRestrictionHandler implements RestrictionHandler { - - private final ArtifactMatchInterpreter matcherInterpreter; - - public ArtifactMatchRestrictionHandler(ArtifactMatchInterpreter matcherInterpreter) { - this.matcherInterpreter = matcherInterpreter; - } - - @Override - public ArtifactMatchRestriction asCastedObject(ObjectRestriction objectRestriction) { - ArtifactMatchRestriction toReturn = null; - if (objectRestriction instanceof ArtifactMatchRestriction) { - toReturn = (ArtifactMatchRestriction) objectRestriction; - } - return toReturn; - } - - @Override - public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector, Scope scope) { - ArtifactMatchRestriction restriction = asCastedObject(objectRestriction); - if (restriction != null) { - XArtifactMatcher artifactMatcher = restriction.getArtifactMatcherRef(); - if (matcherInterpreter.matches(artifactMatcher, artifactProxy)) { - PermissionEnum permission = OseeUtil.getPermission(restriction); - collector.collect(new AccessDetail<>(artifactProxy, permission, scope)); - } - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java deleted file mode 100644 index c16266e796..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/ArtifactTypeRestrictionHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.ArtifactTypeToken; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ArtifactTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType; -import org.eclipse.osee.framework.core.enums.PermissionEnum; - -/** - * @author Roberto E. Escobar - */ -public class ArtifactTypeRestrictionHandler implements RestrictionHandler { - - @Override - public ArtifactTypeRestriction asCastedObject(ObjectRestriction objectRestriction) { - ArtifactTypeRestriction toReturn = null; - if (objectRestriction instanceof ArtifactTypeRestriction) { - toReturn = (ArtifactTypeRestriction) objectRestriction; - } - return toReturn; - } - - @Override - public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector, Scope scope) { - ArtifactTypeRestriction restriction = asCastedObject(objectRestriction); - if (restriction != null) { - XArtifactType artifactTypeRef = restriction.getArtifactTypeRef(); - ArtifactTypeToken typeToMatch = OseeUtil.toToken(artifactTypeRef); - - if (artifactProxy.isOfType(typeToMatch)) { - PermissionEnum permission = OseeUtil.getPermission(restriction); - collector.collect(new AccessDetail(artifactProxy.getArtifactType(), permission, scope)); - } - } - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java deleted file mode 100644 index f9fc9e43a9..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/AttributeTypeRestrictionHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.ArtifactTypeToken; -import org.eclipse.osee.framework.core.data.AttributeTypeId; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType; -import org.eclipse.osee.framework.core.enums.PermissionEnum; - -/** - * @author Roberto E. Escobar - */ -public class AttributeTypeRestrictionHandler implements RestrictionHandler { - - @Override - public AttributeTypeRestriction asCastedObject(ObjectRestriction objectRestriction) { - AttributeTypeRestriction toReturn = null; - if (objectRestriction instanceof AttributeTypeRestriction) { - toReturn = (AttributeTypeRestriction) objectRestriction; - } - return toReturn; - } - - @Override - public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector, Scope scopeLevel) { - AttributeTypeRestriction restriction = asCastedObject(objectRestriction); - if (restriction != null) { - XAttributeType attributeTypeRef = restriction.getAttributeTypeRef(); - AttributeTypeId attributeTypeToMatch = OseeUtil.toToken(attributeTypeRef); - boolean isApplicable = artifactProxy.isAttributeTypeValid(attributeTypeToMatch); - if (isApplicable) { - XArtifactType artifactTypeRef = restriction.getArtifactTypeRef(); - if (artifactTypeRef != null) { - isApplicable = false; - ArtifactTypeToken typeToMatch = OseeUtil.toToken(artifactTypeRef); - isApplicable = artifactProxy.isOfType(typeToMatch); - } - } - - if (isApplicable) { - PermissionEnum permission = OseeUtil.getPermission(restriction); - collector.collect(new AccessDetail<>(attributeTypeToMatch, permission, scopeLevel)); - } - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java b/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java deleted file mode 100644 index f24df33c37..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl.integration/src/org/eclipse/osee/framework/core/dsl/integration/internal/RelationTypeRestrictionHandler.java +++ /dev/null @@ -1,130 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.dsl.integration.internal; - -import java.util.Collection; -import java.util.Collections; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.AccessDetailCollector; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.ArtifactTypeToken; -import org.eclipse.osee.framework.core.data.RelationTypeSide; -import org.eclipse.osee.framework.core.data.RelationTypeToken; -import org.eclipse.osee.framework.core.dsl.integration.ArtifactDataProvider.ArtifactProxy; -import org.eclipse.osee.framework.core.dsl.integration.RestrictionHandler; -import org.eclipse.osee.framework.core.dsl.oseeDsl.ObjectRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeArtifactPredicate; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeArtifactTypePredicate; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypePredicate; -import org.eclipse.osee.framework.core.dsl.oseeDsl.RelationTypeRestriction; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactMatcher; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationSideEnum; -import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.enums.RelationSide; - -/** - * @author Roberto E. Escobar - */ -public class RelationTypeRestrictionHandler implements RestrictionHandler { - - private final ArtifactMatchInterpreter matcherInterpreter; - - public RelationTypeRestrictionHandler(ArtifactMatchInterpreter matcherInterpreter) { - this.matcherInterpreter = matcherInterpreter; - } - - @Override - public RelationTypeRestriction asCastedObject(ObjectRestriction objectRestriction) { - RelationTypeRestriction toReturn = null; - if (objectRestriction instanceof RelationTypeRestriction) { - toReturn = (RelationTypeRestriction) objectRestriction; - } - return toReturn; - } - - @Override - public void process(ObjectRestriction objectRestriction, ArtifactProxy artifactProxy, AccessDetailCollector collector, Scope scope) { - RelationTypeRestriction restriction = asCastedObject(objectRestriction); - if (restriction != null) { - XRelationSideEnum restrictedSide = restriction.getRestrictedToSide(); - - Scope toUse = scope; - - RelationTypePredicate predicate = restriction.getPredicate(); - if (predicate instanceof RelationTypeArtifactPredicate) { - RelationTypeArtifactPredicate artifactPredicate = (RelationTypeArtifactPredicate) predicate; - XArtifactMatcher artifactMatcher = artifactPredicate.getArtifactMatcherRef(); - - if (artifactMatcher != null && matcherInterpreter != null) { - if (matcherInterpreter.matches(artifactMatcher, artifactProxy)) { - toUse = scope.clone().addSubPath(artifactProxy.getName()); - } - } - } else if (predicate instanceof RelationTypeArtifactTypePredicate) { - RelationTypeArtifactTypePredicate artifactTypePredicate = (RelationTypeArtifactTypePredicate) predicate; - XArtifactType artifactTypeRef = artifactTypePredicate.getArtifactTypeRef(); - if (artifactTypeRef != null) { - ArtifactTypeToken ruleType = - ArtifactTypeToken.valueOf(Long.valueOf(artifactTypeRef.getId()), artifactTypeRef.getName()); - if (artifactProxy.isOfType(ruleType)) { - toUse = scope.clone().addSubPath(artifactProxy.getName()); - } - } - } - - Collection relationTypes = getRelationTypes(artifactProxy, restriction); - PermissionEnum permission = OseeUtil.getPermission(restriction); - - for (RelationTypeToken relationType : relationTypes) { - for (RelationSide relationSide : RelationSide.values()) { - if (OseeUtil.isRestrictedSide(restrictedSide, relationSide)) { - collector.collect( - new AccessDetail<>(new RelationTypeSide(relationType, relationSide), permission, toUse)); - } - } - } - } - } - - private Collection getRelationTypes(ArtifactProxy artifactProxy, RelationTypeRestriction restriction) { - Collection types; - if (restriction.isRelationTypeMatch()) { - types = artifactProxy.getValidRelationTypes(); - } else { - XRelationType xRelationType = restriction.getRelationTypeRef(); - Long typeToMatch = OseeUtil.checkAndGetUuid(xRelationType); - RelationTypeToken relationType = getRelationType(typeToMatch, artifactProxy); - if (relationType != null) { - types = Collections.singleton(relationType); - } else { - types = Collections.emptyList(); - } - } - return types; - } - - private RelationTypeToken getRelationType(Long typeToMatch, ArtifactProxy artifactProxy) { - RelationTypeToken toReturn = null; - Collection relationTypes = artifactProxy.getValidRelationTypes(); - for (RelationTypeToken relationType : relationTypes) { - if (relationType.equals(typeToMatch)) { - toReturn = relationType; - break; - } - } - return toReturn; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.dsl/src/org/eclipse/osee/framework/core/dsl/GenerateOseeDsl.mwe2 b/plugins/org.eclipse.osee.framework.core.dsl/src/org/eclipse/osee/framework/core/dsl/GenerateOseeDsl.mwe2 deleted file mode 100644 index 8348c701ad..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl/src/org/eclipse/osee/framework/core/dsl/GenerateOseeDsl.mwe2 +++ /dev/null @@ -1,126 +0,0 @@ -module org.eclipse.osee.framework.core.dsl.OseeDsl - -import org.eclipse.emf.mwe.utils.* -import org.eclipse.xtext.generator.* -import org.eclipse.xtext.ui.generator.* - -var grammarURI = "classpath:/org/eclipse/osee/framework/core/dsl/OseeDsl.xtext" -var file.extensions = "osee" -var projectName = "org.eclipse.osee.framework.core.dsl" -var runtimeProject = "../${projectName}" - -Workflow { - bean = StandaloneSetup { - platformUri = "${runtimeProject}/.." - } - - component = DirectoryCleaner { - directory = "${runtimeProject}/src-gen" - } - - component = DirectoryCleaner { - directory = "${runtimeProject}.ui/src-gen" - } - - component = Generator { - pathRtProject = runtimeProject - pathUiProject = "${runtimeProject}.ui" - projectNameRt = projectName - projectNameUi = "${projectName}.ui" - language = { - uri = grammarURI - fileExtensions = file.extensions - - // Java API to access grammar elements (required by several other fragments) - fragment = grammarAccess.GrammarAccessFragment {} - - // generates Java API for the generated EPackages - fragment = ecore.EcoreGeneratorFragment { - // referencedGenModels = "uri to genmodel, uri to next genmodel" - } - - fragment = serializer.SerializerFragment { - generateStub = false - } - - // the serialization component - // fragment = parseTreeConstructor.ParseTreeConstructorFragment {} - - // a custom ResourceFactory for use with EMF - fragment = resourceFactory.ResourceFactoryFragment { - fileExtensions = file.extensions - } - - // The antlr parser generator fragment. - fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject { - antlrParam = "-Xconversiontimeout" - antlrParam = "200000"// options = { -// backtrack = true -// } - } - - // java-based API for validation - fragment = validation.JavaValidatorFragment { - composedCheck = "org.eclipse.xtext.validation.ImportUriValidator" - composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"// registerForImportedPackages = true - } - - // scoping and exporting API - // fragment = scoping.ImportURIScopingFragment {} - // fragment = exporting.SimpleNamesFragment {} - - // scoping and exporting API - fragment = scoping.ImportNamespacesScopingFragment {} - fragment = exporting.QualifiedNamesFragment {} - fragment = builder.BuilderIntegrationFragment {} - - // generator API - fragment = generator.GeneratorFragment { - generateMwe = false - generateJavaMain = false - } - - // formatter API - fragment = formatting.FormatterFragment {} - - // labeling API - fragment = labeling.LabelProviderFragment {} - - // outline API - fragment = outline.OutlineTreeProviderFragment {} - fragment = outline.QuickOutlineFragment {} - - // quickfix API - fragment = quickfix.QuickfixProviderFragment {} - - // content assist API - fragment = contentAssist.JavaBasedContentAssistFragment {} - - // generates a more lightweight Antlr parser and lexer tailored for content assist - fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject { - antlrParam = "-Xconversiontimeout" - antlrParam = "200000" - } - - // project wizard (optional) - // fragment = projectWizard.SimpleProjectWizardFragment { - // generatorProjectName = "${projectName}.generator" - // modelFileExtension = file.extensions - // } - - // renamerefactoring - fragment = refactoring.RefactorElementNameFragment {} - // provides the necessary bindings for java types integration - fragment = types.TypesGeneratorFragment {} - // generates the required bindings only if the grammar inherits fromXbase - fragment = xbase.XbaseGeneratorFragment {} - // provides a preference page for template proposals - fragment = templates.CodetemplatesGeneratorFragment {} - // provides a compare view - fragment = compare.CompareFragment { - fileExtensions = file.extensions - } - - } - } -} diff --git a/plugins/org.eclipse.osee.framework.core.dsl/src/org/eclipse/osee/framework/core/dsl/generator/OseeDslGenerator.xtend b/plugins/org.eclipse.osee.framework.core.dsl/src/org/eclipse/osee/framework/core/dsl/generator/OseeDslGenerator.xtend deleted file mode 100644 index ea6d345095..0000000000 --- a/plugins/org.eclipse.osee.framework.core.dsl/src/org/eclipse/osee/framework/core/dsl/generator/OseeDslGenerator.xtend +++ /dev/null @@ -1,24 +0,0 @@ -/* - * generated by Xtext - */ -package org.eclipse.osee.framework.core.dsl.generator - -import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.xtext.generator.IGenerator -import org.eclipse.xtext.generator.IFileSystemAccess - -/** - * Generates code from your model files on save. - * - * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation - */ -class OseeDslGenerator implements IGenerator { - - override void doGenerate(Resource resource, IFileSystemAccess fsa) { -// fsa.generateFile('greetings.txt', 'People to greet: ' + -// resource.allContents -// .filter(typeof(Greeting)) -// .map[name] -// .join(', ')) - } -} diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDataQueryTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDataQueryTest.java deleted file mode 100644 index 031dac1a34..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDataQueryTest.java +++ /dev/null @@ -1,218 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.model.access; - -import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Folder; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.access.AccessDataQuery; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.PermissionStatus; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.ArtifactTypeToken; -import org.eclipse.osee.framework.core.data.AttributeTypeId; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.BranchToken; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; -import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.core.enums.CoreBranches; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.model.mocks.MockDataFactory; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test Case for {@link AccessDataQuery} - * - * @author Jeff C. Phillips - */ -public class AccessDataQueryTest { - - @Test - public void testBranch() { - BranchId branchToCheck = CoreBranches.SYSTEM_ROOT; - - TestObject testObject = getTestData(); - AccessData data = testObject.getAccessData(); - - AccessDataQuery query = new AccessDataQuery(data); - PermissionStatus status = new PermissionStatus(); - - query.branchMatches(PermissionEnum.WRITE, branchToCheck, status); - Assert.assertTrue(status.matched()); - - query.branchMatches(PermissionEnum.FULLACCESS, branchToCheck, status); - Assert.assertFalse(status.matched()); - } - - @Test - public void testArtifactType() { - TestObject testObject = getTestData(); - AccessData data = testObject.getAccessData(); - ArtifactToken artifactToCheck = testObject.getArtifact(); - - AccessDataQuery query = new AccessDataQuery(data); - PermissionStatus status = new PermissionStatus(); - - query.artifactTypeMatches(PermissionEnum.WRITE, artifactToCheck, status); - Assert.assertTrue(status.matched()); - - query.artifactTypeMatches(PermissionEnum.FULLACCESS, artifactToCheck, status); - Assert.assertFalse(status.matched()); - } - - @Test - public void testArtifact() { - TestObject testObject = getTestData(); - AccessData data = testObject.getAccessData(); - ArtifactToken artifactToCheck = testObject.getArtifact(); - - AccessDataQuery query = new AccessDataQuery(data); - PermissionStatus status = new PermissionStatus(); - - query.artifactMatches(PermissionEnum.WRITE, artifactToCheck, status); - Assert.assertTrue(status.matched()); - } - - @Test - public void testAttributeType() { - TestObject testObject = getTestData(); - AccessData data = testObject.getAccessData(); - ArtifactToken artifactToCheck = testObject.getArtifact(); - - AttributeTypeId attributeType = CoreAttributeTypes.ParagraphNumber; - AttributeTypeId wordAttributeType = CoreAttributeTypes.WordTemplateContent; - - data.add(artifactToCheck, new AccessDetail<>(attributeType, PermissionEnum.WRITE, new Scope())); - data.add(artifactToCheck, new AccessDetail<>(wordAttributeType, PermissionEnum.READ, new Scope())); - - AccessDataQuery query = new AccessDataQuery(data); - PermissionStatus status = new PermissionStatus(); - - query.artifactMatches(PermissionEnum.WRITE, artifactToCheck, status); - Assert.assertTrue(status.matched()); - - query.attributeTypeMatches(PermissionEnum.READ, artifactToCheck, wordAttributeType, status); - Assert.assertTrue(status.matched()); - - query.attributeTypeMatches(PermissionEnum.WRITE, artifactToCheck, wordAttributeType, status); - Assert.assertFalse(status.matched()); - - query.artifactTypeMatches(PermissionEnum.WRITE, artifactToCheck, status); - Assert.assertTrue(status.matched()); - - query.artifactTypeMatches(PermissionEnum.FULLACCESS, artifactToCheck, status); - Assert.assertFalse(status.matched()); - } - - @Test - public void testArtifactMatchesAll() { - AccessData data = new AccessData(); - BranchToken branch = CoreBranches.COMMON; - ArtifactTypeToken artifactType = CoreArtifactTypes.AbstractSoftwareRequirement; - - ArtifactToken artifact1 = ArtifactToken.valueOf(1, "one", branch, artifactType); - ArtifactToken artifact2 = ArtifactToken.valueOf(2, "two", branch, artifactType); - - data.add(artifact1, new AccessDetail<>(artifact1, PermissionEnum.READ, new Scope())); - data.add(artifact2, new AccessDetail<>(artifact2, PermissionEnum.WRITE, new Scope())); - - AccessDataQuery query = new AccessDataQuery(data); - - Assert.assertTrue(query.matchesAll(PermissionEnum.READ)); - Assert.assertFalse(query.matchesAll(PermissionEnum.WRITE)); - } - - @Test - public void testBranchMatchesAll() { - AccessData data = new AccessData(); - BranchId common = CoreBranches.COMMON; - BranchId branch = CoreBranches.SYSTEM_ROOT; - - data.add(common, new AccessDetail<>(common, PermissionEnum.READ, new Scope())); - data.add(branch, new AccessDetail<>(branch, PermissionEnum.WRITE, new Scope())); - - AccessDataQuery query = new AccessDataQuery(data); - - Assert.assertTrue(query.matchesAll(PermissionEnum.READ)); - Assert.assertFalse(query.matchesAll(PermissionEnum.WRITE)); - } - - @Test - public void testArtifactMatches() { - BranchToken branch = CoreBranches.COMMON; - ArtifactToken accessArtifact = ArtifactToken.valueOf(45, "test1", branch, Folder); - ArtifactToken typeAccessArtifact = ArtifactToken.valueOf(46, "test2", branch, Folder); - ArtifactToken noAccessArtifact = ArtifactToken.valueOf(47, "test3", branch, Folder); - ArtifactTypeToken artType = CoreArtifactTypes.Folder; - - AccessDetail specificArtDetail = MockDataFactory.createAccessDetails(accessArtifact, PermissionEnum.DENY, "", - new Scope().add("very").add("specific")); - AccessDetail legacyArtDetail = - MockDataFactory.createAccessDetails(accessArtifact, PermissionEnum.FULLACCESS, "", Scope.createLegacyScope()); - AccessDetail typeDetail = - MockDataFactory.createAccessDetails(artType, PermissionEnum.WRITE, "", new Scope().add("very")); - - AccessData data = new AccessData(); - data.add(accessArtifact, specificArtDetail); - data.add(accessArtifact, legacyArtDetail); - data.add(accessArtifact, typeDetail); - data.add(typeAccessArtifact, typeDetail); - - AccessDataQuery query = new AccessDataQuery(data); - PermissionStatus ps = new PermissionStatus(); - query.artifactMatches(PermissionEnum.WRITE, accessArtifact, ps); - Assert.assertFalse(ps.matched()); - - ps = new PermissionStatus(); - query.artifactMatches(PermissionEnum.WRITE, typeAccessArtifact, ps); - Assert.assertTrue(ps.matched()); - - ps = new PermissionStatus(); - query.artifactMatches(PermissionEnum.WRITE, noAccessArtifact, ps); - Assert.assertTrue(ps.matched()); - } - - private TestObject getTestData() { - BranchToken branchToCheck = CoreBranches.SYSTEM_ROOT; - ArtifactTypeToken artifactType = CoreArtifactTypes.AbstractSoftwareRequirement; - ArtifactToken artifactToCheck = ArtifactToken.valueOf(12, "Hello", branchToCheck, artifactType); - AccessData data = new AccessData(); - - data.add(branchToCheck, new AccessDetail(branchToCheck, PermissionEnum.WRITE, new Scope())); - data.add(artifactToCheck, new AccessDetail<>(artifactToCheck, PermissionEnum.WRITE, new Scope())); - data.add(artifactToCheck, new AccessDetail<>(artifactType, PermissionEnum.WRITE, new Scope())); - - return new TestObject(artifactToCheck, data); - } - - private class TestObject { - final ArtifactToken artifact; - final AccessData accessData; - - public TestObject(ArtifactToken artifact, AccessData accessData) { - super(); - this.artifact = artifact; - this.accessData = accessData; - } - - public ArtifactToken getArtifact() { - return artifact; - } - - public AccessData getAccessData() { - return accessData; - } - } -} diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDataTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDataTest.java deleted file mode 100644 index e7639ca8a1..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDataTest.java +++ /dev/null @@ -1,270 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.model.access; - -import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.ArtifactTypeToken; -import org.eclipse.osee.framework.core.data.AttributeTypeId; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.RelationTypeSide; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; -import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.core.enums.CoreBranches; -import org.eclipse.osee.framework.core.enums.CoreRelationTypes; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.enums.RelationSide; -import org.eclipse.osee.framework.core.model.mocks.MockDataFactory; -import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; -import org.eclipse.osee.framework.jdk.core.util.Compare; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * Test Case for {@link AccessData} - * - * @author Roberto E. Escobar - */ -public class AccessDataTest { - - private BranchId branchToCheck1; - private BranchId branchToCheck2; - private ArtifactTypeToken artifactType; - private AttributeTypeId attributeType; - private AttributeTypeId wordAttributeType; - - private RelationTypeSide relTypeSide1; - private RelationTypeSide relTypeSide2; - - private ArtifactToken artifactToCheck; - - @Before - public void setup() { - branchToCheck1 = CoreBranches.SYSTEM_ROOT; - branchToCheck2 = CoreBranches.COMMON; - - artifactType = CoreArtifactTypes.AbstractSoftwareRequirement; - attributeType = CoreAttributeTypes.ParagraphNumber; - wordAttributeType = CoreAttributeTypes.WordTemplateContent; - - relTypeSide1 = new RelationTypeSide(CoreRelationTypes.DEFAULT_HIERARCHY, RelationSide.SIDE_A); - relTypeSide2 = new RelationTypeSide(CoreRelationTypes.DEFAULT_HIERARCHY, RelationSide.SIDE_B); - - artifactToCheck = ArtifactToken.valueOf(12, "Hello", COMMON); - } - - @Test - public void testIsEmpty() { - AccessData data = new AccessData(); - Assert.assertTrue(data.isEmpty()); - data.add(new Object(), createDetail(7, new Object())); - Assert.assertFalse(data.isEmpty()); - } - - @Test(expected = OseeArgumentException.class) - public void testAddNullCheck1() { - AccessData data = new AccessData(); - data.add(null, createDetail(4, new Object())); - } - - @Test(expected = OseeArgumentException.class) - public void testAddNullCheck2() { - AccessData data = new AccessData(); - data.add(new Object(), null); - } - - @Test(expected = OseeArgumentException.class) - public void testAddAllCheck1() { - AccessData data = new AccessData(); - data.addAll(null, Collections.> emptyList()); - } - - @Test(expected = OseeArgumentException.class) - public void testAddAllCheck2() { - AccessData data = new AccessData(); - data.addAll(new Object(), null); - } - - @Test(expected = OseeArgumentException.class) - public void testGetAccessNullCheck() { - AccessData data = new AccessData(); - data.getAccess(null); - } - - @Test - public void testAddAll() { - Collection> expectedDetails = new ArrayList<>(); - createTestObjects(expectedDetails, branchToCheck1, artifactType, attributeType, wordAttributeType, - artifactToCheck, relTypeSide1, relTypeSide2, branchToCheck2); - - AccessData data = new AccessData(); - data.addAll(artifactToCheck, expectedDetails); - Collection> actualDetails = data.getAccess(artifactToCheck); - Assert.assertEquals(expectedDetails.size(), actualDetails.size()); - Assert.assertFalse(Compare.isDifferent(expectedDetails, actualDetails)); - - for (AccessDetail expectedDetail : expectedDetails) { - AccessDetail actualDetail = findObject(expectedDetail, actualDetails); - Assert.assertEquals(expectedDetail, actualDetail); - Assert.assertEquals(expectedDetail.getPermission(), actualDetail.getPermission()); - Assert.assertEquals(expectedDetail.getAccessObject(), actualDetail.getAccessObject()); - Assert.assertEquals(expectedDetail.getReason(), actualDetail.getReason()); - } - } - - @Test - public void testAccessDetailMerge() { - AccessData data = new AccessData(); - - AccessDetail detail1 = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.DENY, "item 1 - deny", - new Scope().add("same_scope")); - AccessDetail detail2 = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.WRITE, - "item 2 - write", new Scope().add("same_scope")); - data.add(artifactToCheck, detail1); - data.add(artifactToCheck, detail2); - - Collection> details = data.getAccess(artifactToCheck); - Assert.assertTrue(details.size() == 1); - AccessDetail actualDetail = details.iterator().next(); - Assert.assertEquals(detail1.getAccessObject(), actualDetail.getAccessObject()); - Assert.assertEquals(detail2.getAccessObject(), actualDetail.getAccessObject()); - - Assert.assertEquals(PermissionEnum.DENY, actualDetail.getPermission()); - Assert.assertEquals("item 1 - deny", actualDetail.getReason()); - Assert.assertEquals("/same_scope", actualDetail.getScope().getPath()); - } - - @Test - public void testAccessDetailMultipleKeys() { - AccessDetail detail1 = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.DENY, "item 1 - deny", - new Scope().add("same_scope")); - AccessDetail detail2 = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.WRITE, - "item 2 - write", new Scope().add("same_scope")); - - AccessData data = new AccessData(); - data.add(branchToCheck1, detail1); - data.add(branchToCheck2, detail2); - - Set keys = data.keySet(); - Assert.assertEquals(2, keys.size()); - Assert.assertTrue(keys.contains(branchToCheck1)); - Assert.assertTrue(keys.contains(branchToCheck2)); - - Collection> details = data.getAccess(branchToCheck1); - Assert.assertTrue(details.size() == 1); - AccessDetail actualDetail = details.iterator().next(); - Assert.assertEquals(detail1, actualDetail); - - details = data.getAccess(branchToCheck2); - Assert.assertTrue(details.size() == 1); - actualDetail = details.iterator().next(); - Assert.assertEquals(detail2, actualDetail); - Assert.assertEquals("/same_scope", actualDetail.getScope().getPath()); - } - - @Test - public void testAccessDetailMultipleScopeLevels() { - AccessDetail detail1 = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.DENY, "item 1 - deny", - new Scope().add("more").add("specific").add("scope")); - AccessDetail detail2 = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.WRITE, - "item 2 - write", new Scope().add("less").add("specific")); - - AccessData data = new AccessData(); - data.add(branchToCheck1, detail1); - data.add(branchToCheck1, detail2); - - Collection> details = data.getAccess(branchToCheck1); - Assert.assertTrue(details.size() == 1); - AccessDetail actualDetail = details.iterator().next(); - Assert.assertEquals(detail1, actualDetail); - Assert.assertEquals("/more/specific/scope", actualDetail.getScope().getPath()); - } - - @Test - public void testAccessDetailLegacyScope() { - AccessDetail specificDetail = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.DENY, - "item 1 - deny", new Scope().add("more").add("specific").add("scope")); - AccessDetail lessSpecificDetail = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.WRITE, - "item 2 - write", new Scope().add("less").add("specific")); - AccessDetail legacyDetail = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.WRITE, - "item 2 - write", Scope.createLegacyScope()); - - AccessData data = new AccessData(); - data.add(branchToCheck1, specificDetail); - data.add(branchToCheck1, legacyDetail); - data.add(branchToCheck1, lessSpecificDetail); - - Collection> details = data.getAccess(branchToCheck1); - Assert.assertTrue(details.size() == 1); - AccessDetail actualDetail = details.iterator().next(); - Assert.assertEquals(specificDetail, actualDetail); - Assert.assertEquals("/more/specific/scope", actualDetail.getScope().getPath()); - Assert.assertEquals(PermissionEnum.DENY, actualDetail.getPermission()); - } - - @Test - public void testToString() { - AccessDetail detail1 = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.DENY, "item 1 - deny", - new Scope().add("scope 1")); - AccessDetail detail2 = MockDataFactory.createAccessDetails(relTypeSide1, PermissionEnum.WRITE, - "item 2 - write", new Scope().add("scope 2")); - - AccessData data = new AccessData(); - Assert.assertEquals("accessData []", data.toString()); - data.add(branchToCheck1, detail1); - data.add(branchToCheck2, detail2); - - String branch1 = - "System Root Branch - AccessDetail [permission=DENY, scope=/scope_1, accessObject=RelationTypeSide [type=Default Hierarchical, side=SIDE_A], reason=item 1 - deny]"; - String branch2 = - "Common - AccessDetail [permission=WRITE, scope=/scope_2, accessObject=RelationTypeSide [type=Default Hierarchical, side=SIDE_A], reason=item 2 - write]"; - String message = "accessData [\n\t%s,\n\t%s,\n]"; - String forward = String.format(message, branch1, branch2); - String backward = String.format(message, branch2, branch1); - Assert.assertTrue(data.toString().equals(forward) || data.toString().equals(backward)); - } - - private static AccessDetail findObject(AccessDetail item, Collection> details) { - AccessDetail toReturn = null; - for (AccessDetail detail : details) { - if (item.equals(detail)) { - toReturn = detail; - break; - } - } - return toReturn; - } - - private static AccessDetail createDetail(int index, Object expAccessObject) { - PermissionEnum expPermission = PermissionEnum.values()[Math.abs(index % PermissionEnum.values().length)]; - return MockDataFactory.createAccessDetails(expAccessObject, expPermission, "reason: " + index, - new Scope().add("scope: " + index)); - } - - private static void createTestObjects(Collection> expectedDetails, Object... objects) { - int cnt = 1; - for (Object expAccessObject : objects) { - AccessDetail detail = createDetail(cnt++, expAccessObject); - expectedDetails.add(detail); - } - } -} diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDetailTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDetailTest.java deleted file mode 100644 index 3208f8c79c..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessDetailTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.model.access; - -import java.util.ArrayList; -import java.util.Collection; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.Scope; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; -import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.model.mocks.MockDataFactory; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -/** - * Test Case for {@link AccessDetail} - * - * @author Roberto E. Escobar - */ -@RunWith(Parameterized.class) -public class AccessDetailTest { - - private final Object expAccessObject; - private final PermissionEnum expPermission; - private final String expReason; - private final AccessDetail target; - private final Scope scope; - - public AccessDetailTest(AccessDetail target, Object expAccessObject, PermissionEnum expPermission, String expReason, Scope scope) { - this.target = target; - this.expAccessObject = expAccessObject; - this.expPermission = expPermission; - this.expReason = expReason; - this.scope = scope; - } - - @Test - public void testGetReason() { - Assert.assertEquals(Strings.isValid(expReason) ? expReason : scope.getPath(), target.getReason()); - } - - @Test - public void testGetPermission() { - Assert.assertEquals(expPermission, target.getPermission()); - } - - @Test - public void testGetAccessObject() { - Assert.assertEquals(expAccessObject, target.getAccessObject()); - } - - @Test - public void testSetPermission() { - Assert.assertEquals(expPermission, target.getPermission()); - PermissionEnum anotherPermission = PermissionEnum.NONE; - - target.setPermission(anotherPermission); - Assert.assertEquals(anotherPermission, target.getPermission()); - - target.setPermission(expPermission); - Assert.assertEquals(expPermission, target.getPermission()); - } - - @Test - public void testHashCodeAndEquals() { - Assert.assertTrue(target.equals(target)); - Assert.assertTrue(target.hashCode() == target.hashCode()); - - AccessDetail other = - MockDataFactory.createAccessDetails(expAccessObject, PermissionEnum.NONE, null, new Scope().add("other")); - Assert.assertTrue(target.equals(other)); - Assert.assertTrue(target.hashCode() == other.hashCode()); - - AccessDetail nulled = - MockDataFactory.createAccessDetails(null, PermissionEnum.NONE, null, new Scope().add("nulled")); - Assert.assertFalse(target.equals(nulled)); - Assert.assertTrue(target.hashCode() != nulled.hashCode()); - - Collection> collect = new ArrayList<>(); - collect.add(target); - Assert.assertEquals(1, collect.size()); - Assert.assertTrue(collect.contains(target)); - Assert.assertTrue(collect.contains(other)); - Assert.assertFalse(collect.contains(nulled)); - } - - @Test - public void testToString() { - String expected = - "AccessDetail [permission=" + expPermission + ", scope=" + scope + ", accessObject=" + expAccessObject + ", reason=" + (Strings.isValid( - expReason) ? expReason : scope) + "]"; - Assert.assertEquals(expected, target.toString()); - } - - @Parameters - public static Collection getData() { - Collection data = new ArrayList<>(); - addTest(data, "Hello", PermissionEnum.DENY, "A reason", new Scope().add("hello_scope")); - addTest(data, 456, PermissionEnum.WRITE, null, new Scope().add("456_scope")); - addTest(data, CoreArtifactTypes.TestUnit, PermissionEnum.FULLACCESS, "reason3", new Scope()); - addTest(data, CoreAttributeTypes.Name, PermissionEnum.READ, "xx", new Scope().add("xx")); - return data; - } - - private static void addTest(Collection data, T expAccessObject, PermissionEnum expPermission, String expReason, Scope scope) { - String reasonToCheck = expReason; - if (expReason == null) { - reasonToCheck = Strings.emptyString(); - } - AccessDetail target = MockDataFactory.createAccessDetails(expAccessObject, expPermission, expReason, scope); - data.add(new Object[] {target, expAccessObject, expPermission, reasonToCheck, scope}); - } - -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessTestSuite.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessTestSuite.java index d35ee07200..0ebf57a96d 100644 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessTestSuite.java +++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/AccessTestSuite.java @@ -18,11 +18,7 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({// - AccessDataTest.class, // - AccessDataQueryTest.class, // - AccessDetailTest.class, // PermissionStatusTest.class, // - ScopeTest.class, // }) /** * @author Roberto E. Escobar diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/ScopeTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/ScopeTest.java deleted file mode 100644 index 4e4a937042..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/access/ScopeTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.model.access; - -import org.eclipse.osee.framework.core.access.Scope; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author John R. Misinco - */ -public class ScopeTest { - - @Test - public void testGetPath() { - Scope scope = new Scope(); - scope.add("foo"); - scope.add("bar bar"); - scope.addSubPath("baz"); - String expectedPath = "/foo/bar_bar#baz"; - Assert.assertEquals(expectedPath, scope.getPath()); - } - - @Test - public void testEquals() { - Scope legacyScopeA = Scope.createLegacyScope(); - Scope legacyScopeB = Scope.createLegacyScope(); - legacyScopeA.add("foo"); - legacyScopeB.addSubPath("bar"); - Assert.assertTrue(legacyScopeA.equals(legacyScopeB)); - - Scope scopeA = new Scope(); - Scope scopeB = new Scope(); - scopeA.add("foo"); - scopeA.addSubPath("bar"); - scopeA.add("baz"); - scopeB.add("foo"); - scopeB.addSubPath("bar"); - scopeB.add("baz"); - Assert.assertTrue(scopeA.equals(scopeB)); - - Scope scopeC = new Scope(); - Assert.assertFalse(legacyScopeA.equals(scopeA)); - Assert.assertFalse(legacyScopeA.equals(scopeC)); - } - - @Test - public void testIsLegacy() { - Scope legacyScope = Scope.createLegacyScope(); - Scope scope = new Scope(); - legacyScope.add("foo"); - legacyScope.addSubPath("bar"); - String expectedScope = "##"; - Assert.assertEquals(expectedScope, legacyScope.getPath()); - Assert.assertTrue(legacyScope.isLegacy()); - Assert.assertFalse(scope.isLegacy()); - } - - @Test - public void testClone() { - Scope scope = new Scope(); - Scope legacyScope = Scope.createLegacyScope(); - - scope.add("foo").add("bar").addSubPath("baz").addSubPath("baz"); - Scope scopeClone = scope.clone(); - Assert.assertEquals(scope, scopeClone); - - scopeClone = legacyScope.clone(); - Assert.assertTrue(legacyScope.equals(scopeClone)); - } - -} diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockDataFactory.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockDataFactory.java index b06dacc110..527c7585b4 100644 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockDataFactory.java +++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockDataFactory.java @@ -14,12 +14,9 @@ package org.eclipse.osee.framework.core.model.mocks; import java.util.Date; -import org.eclipse.osee.framework.core.access.AccessDetail; -import org.eclipse.osee.framework.core.access.Scope; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.DemoUsers; -import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.framework.core.model.TransactionRecord; @@ -31,16 +28,6 @@ public final class MockDataFactory { // Utility Class } - public static AccessDetail createAccessDetails(T expAccessObject, PermissionEnum expPermission, String expReason, Scope scope) { - AccessDetail target; - if (expReason != null) { - target = new AccessDetail<>(expAccessObject, expPermission, scope, expReason); - } else { - target = new AccessDetail<>(expAccessObject, expPermission, scope); - } - return target; - } - public static TransactionRecord createTransaction(int index, long branchUuid) { TransactionDetailsType type = TransactionDetailsType.values[Math.abs(index % TransactionDetailsType.values.length)]; diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessModel.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessModel.java deleted file mode 100644 index d0555ded17..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/AccessModel.java +++ /dev/null @@ -1,26 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.model.access; - -import java.util.Collection; -import org.eclipse.osee.framework.core.access.AccessData; -import org.eclipse.osee.framework.core.data.AccessContextToken; - -/** - * @author Roberto E. Escobar - */ -public interface AccessModel { - - void computeAccess(AccessContextToken contextId, Collection objectsToCheck, AccessData accessData); -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/HasAccessModel.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/HasAccessModel.java deleted file mode 100644 index 7e1eb584bf..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/access/HasAccessModel.java +++ /dev/null @@ -1,21 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.model.access; - -/** - * @author Roberto E. Escobar - */ -public interface HasAccessModel { - AccessModel getAccessModel(); -} diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/CmAccessControl.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/CmAccessControl.java deleted file mode 100644 index 4ff2e9247b..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/CmAccessControl.java +++ /dev/null @@ -1,29 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.services; - -import java.util.Collection; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.AccessContextToken; - -/** - * @author Roberto E. Escobar - */ -public interface CmAccessControl { - - boolean isApplicable(ArtifactToken user, Object object); - - Collection getContextId(ArtifactToken user, Object object); - -} diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/CmAccessControlProvider.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/CmAccessControlProvider.java deleted file mode 100644 index f8b158a6a0..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/CmAccessControlProvider.java +++ /dev/null @@ -1,26 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.services; - -import org.eclipse.osee.framework.core.data.ArtifactToken; - -/** - * @author Roberto E. Escobar - */ -public interface CmAccessControlProvider { - - CmAccessControl getService(ArtifactToken user, Object object); - - void setDefaultAccessControl(CmAccessControl defaultAccessControl); -} diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/HasCmAccessControl.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/HasCmAccessControl.java deleted file mode 100644 index 8dc2e33a78..0000000000 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/HasCmAccessControl.java +++ /dev/null @@ -1,22 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.services; - -/** - * @author Roberto E. Escobar - */ -public interface HasCmAccessControl { - - CmAccessControl getAccessControl(); -} diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/AuthenticationManager.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/AuthenticationManager.java index c5f05ab83c..be6739349b 100644 --- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/AuthenticationManager.java +++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/AuthenticationManager.java @@ -42,7 +42,7 @@ public class AuthenticationManager implements IAuthenticationManager { } public void removeAuthenticationProvider(IAuthenticationProvider authenticationProvider) { - authenticationProviders.remove(authenticationProvider).toString(); + authenticationProviders.remove(authenticationProvider.getProtocol()).toString(); } @Override diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/authentication/DemoAuthenticationProvider.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/authentication/DemoAuthenticationProvider.java index 9a9106ffad..69327572e0 100644 --- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/authentication/DemoAuthenticationProvider.java +++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/authentication/DemoAuthenticationProvider.java @@ -29,14 +29,10 @@ public class DemoAuthenticationProvider extends AbstractAuthenticationProvider { @Override public UserToken asOseeUserId(OseeCredential credential) { - for (UserToken token : DemoUsers.values()) { - if (credential.getUserName().equals(token.getName().toLowerCase())) { - UserToken userToken = getUserTokenFromOseeDb(token.getName()); - if (userToken != null) { - return userToken; - } else { - return createUserToken(token.getName(), token.getUserId(), "", true); - } + for (UserToken userToken : DemoUsers.values()) { + if (credential.getUserName().equals(userToken.getUserId()) || credential.getUserName().equals( + userToken.getName().toLowerCase())) { + return userToken; } } return createUserToken(DemoUsers.Joe_Smith.getName(), DemoUsers.Joe_Smith.getUserId(), "joe@boeing.com", true); diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/DatabaseSessionAccessor.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/DatabaseSessionAccessor.java index 31d3076a93..08f9ed2b40 100644 --- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/DatabaseSessionAccessor.java +++ b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/session/DatabaseSessionAccessor.java @@ -61,7 +61,9 @@ public final class DatabaseSessionAccessor implements CacheDataLoader sessions) { - jdbcClient.runTransaction(new SessionTx(getJdbcClient(), op, sessions)); + JdbcClient jdbcClient2 = getJdbcClient(); + SessionTx transaction = new SessionTx(jdbcClient2, op, sessions); + jdbcClient.runTransaction(transaction); } @Override diff --git a/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/enums/PermissionEnumTest.java b/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/enums/PermissionEnumTest.java index fbdeb67a74..ba4ea5ce8b 100644 --- a/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/enums/PermissionEnumTest.java +++ b/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/enums/PermissionEnumTest.java @@ -15,9 +15,9 @@ package org.eclipse.osee.framework.core.enums; import static org.eclipse.osee.framework.core.enums.PermissionEnum.DENY; import static org.eclipse.osee.framework.core.enums.PermissionEnum.FULLACCESS; -import static org.eclipse.osee.framework.core.enums.PermissionEnum.USER_LOCK; import static org.eclipse.osee.framework.core.enums.PermissionEnum.NONE; import static org.eclipse.osee.framework.core.enums.PermissionEnum.READ; +import static org.eclipse.osee.framework.core.enums.PermissionEnum.USER_LOCK; import static org.eclipse.osee.framework.core.enums.PermissionEnum.WRITE; import java.util.ArrayList; import java.util.Collection; diff --git a/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF index 0927e63895..710bdb940e 100644 --- a/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF @@ -49,6 +49,10 @@ Import-Package: com.fasterxml.jackson.annotation, org.osgi.util.tracker Export-Package: org.eclipse.osee.framework.core, org.eclipse.osee.framework.core.access, + org.eclipse.osee.framework.core.access.context, + org.eclipse.osee.framework.core.access.event, + org.eclipse.osee.framework.core.access.object, + org.eclipse.osee.framework.core.access.operation, org.eclipse.osee.framework.core.applicability, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.data.computed, diff --git a/plugins/org.eclipse.osee.framework.core/OSGI-INF/artifact.check.provider.xml b/plugins/org.eclipse.osee.framework.core/OSGI-INF/artifact.check.provider.xml deleted file mode 100644 index 714e0911a5..0000000000 --- a/plugins/org.eclipse.osee.framework.core/OSGI-INF/artifact.check.provider.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.core/src-gen/org/eclipse/osee/framework/core/grammar/ApplicabilityGrammarParser.java b/plugins/org.eclipse.osee.framework.core/src-gen/org/eclipse/osee/framework/core/grammar/ApplicabilityGrammarParser.java index 11c90a95e3..44368e06b5 100644 --- a/plugins/org.eclipse.osee.framework.core/src-gen/org/eclipse/osee/framework/core/grammar/ApplicabilityGrammarParser.java +++ b/plugins/org.eclipse.osee.framework.core/src-gen/org/eclipse/osee/framework/core/grammar/ApplicabilityGrammarParser.java @@ -2,18 +2,24 @@ package org.eclipse.osee.framework.core.grammar; - import java.util.HashMap; - import java.util.Arrays; - import java.util.Collections; - - -import org.antlr.runtime.*; -import java.util.Stack; + import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; import java.util.List; -import java.util.ArrayList; - - -import org.antlr.runtime.tree.*; +import org.antlr.runtime.BitSet; +import org.antlr.runtime.EarlyExitException; +import org.antlr.runtime.MismatchedSetException; +import org.antlr.runtime.NoViableAltException; +import org.antlr.runtime.Parser; +import org.antlr.runtime.ParserRuleReturnScope; +import org.antlr.runtime.RecognitionException; +import org.antlr.runtime.RecognizerSharedState; +import org.antlr.runtime.Token; +import org.antlr.runtime.TokenStream; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.tree.CommonTreeAdaptor; +import org.antlr.runtime.tree.TreeAdaptor; public class ApplicabilityGrammarParser extends Parser { public static final String[] tokenNames = new String[] { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OseeApi.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OseeApi.java index 0e98df0066..466c6f2530 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OseeApi.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OseeApi.java @@ -13,6 +13,8 @@ package org.eclipse.osee.framework.core; +import org.eclipse.osee.framework.core.access.IAccessControlService; + /** * @author Ryan D. Brooks */ @@ -22,4 +24,6 @@ public interface OseeApi { OrcsTokenService tokenService(); -} \ No newline at end of file + IAccessControlService getAccessControlService(); + +} diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OseeApiBase.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OseeApiBase.java index ba0c826be2..9c9fb2b1b3 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OseeApiBase.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OseeApiBase.java @@ -38,4 +38,5 @@ public abstract class OseeApiBase implements OseeApi { public OrcsTokenService tokenService() { return tokenService; } + } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessData.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessData.java deleted file mode 100644 index 6e589cb791..0000000000 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessData.java +++ /dev/null @@ -1,90 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.access; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; -import org.eclipse.osee.framework.jdk.core.type.Pair; -import org.eclipse.osee.framework.jdk.core.util.Conditions; - -/** - * @author Jeff C. Phillips - * @author Roberto E. Escobar - */ -public final class AccessData { - - private final CompositeKeyHashMap> accessMap = - new CompositeKeyHashMap<>(); - - public AccessData() { - super(); - } - - public boolean isEmpty() { - return accessMap.isEmpty(); - } - - public void addAll(Object key, Collection> datas) { - Conditions.checkNotNull(key, "access key"); - Conditions.checkNotNull(datas, "accessDetails"); - for (AccessDetail data : datas) { - add(key, data); - } - } - - public Set keySet() { - Set toReturn = new HashSet<>(); - for (Pair key : accessMap.keySet()) { - toReturn.add(key.getFirst()); - } - return toReturn; - } - - public void add(Object key, AccessDetail data) { - Conditions.checkNotNull(key, "access key"); - Conditions.checkNotNull(data, "access data"); - - AccessDetail original = accessMap.get(key, data.getAccessObject()); - - AccessDetail resolvedAccess = AccessDetail.resolveAccess(original, data); - accessMap.put(key, data.getAccessObject(), resolvedAccess); - } - - public Collection> getAccess(Object key) { - Conditions.checkNotNull(key, "access key"); - return accessMap.getValues(key); - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("accessData ["); - if (!accessMap.isEmpty()) { - builder.append("\n"); - for (Object key : keySet()) { - for (AccessDetail detail : accessMap.getValues(key)) { - builder.append("\t"); - builder.append(key); - builder.append(" - "); - builder.append(detail); - builder.append(",\n"); - } - } - } - builder.append("]"); - return builder.toString(); - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDataQuery.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDataQuery.java deleted file mode 100644 index a254b4768a..0000000000 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDataQuery.java +++ /dev/null @@ -1,190 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.access; - -import java.util.Collection; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.ArtifactTypeId; -import org.eclipse.osee.framework.core.data.AttributeTypeId; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.RelationTypeSide; -import org.eclipse.osee.framework.core.enums.PermissionEnum; - -/** - * @author Jeff C. Phillips - * @author Roberto E. Escobar - */ -public class AccessDataQuery { - - private final AccessData accessData; - - public AccessDataQuery(AccessData accessData) { - this.accessData = accessData; - } - - @Override - public String toString() { - return accessData.toString(); - } - - public void branchMatches(PermissionEnum permissionToMatch, BranchId branchToMatch, PermissionStatus permissionStatus) { - Collection> branchAccessDetails = accessData.getAccess(branchToMatch); - setTypePermissionStatus(permissionStatus, permissionToMatch, branchAccessDetails, branchToMatch); - } - - public void branchArtifactTypeMatches(PermissionEnum permissionToMatch, BranchId branchToMatch, ArtifactTypeId artifactType, PermissionStatus permissionStatus) { - branchMatches(permissionToMatch, branchToMatch, permissionStatus); - if (permissionStatus.matched()) { - Collection> branchAccessDetails = accessData.getAccess(branchToMatch); - setTypePermissionStatus(permissionStatus, permissionToMatch, branchAccessDetails, artifactType); - } - } - - public void artifactTypeMatches(PermissionEnum permissionToMatch, ArtifactToken artifact, PermissionStatus permissionStatus) { - ArtifactTypeId typeToMatch = artifact.getArtifactType(); - BranchId branchToMatch = artifact.getBranch(); - branchArtifactTypeMatches(permissionToMatch, branchToMatch, typeToMatch, permissionStatus); - if (permissionStatus.matched()) { - Collection> artifactAccessDetails = accessData.getAccess(artifact); - setTypePermissionStatus(permissionStatus, permissionToMatch, artifactAccessDetails, artifact); - } - } - - public void artifactMatches(PermissionEnum permissionToMatch, ArtifactToken artifact, PermissionStatus permissionStatus) { - BranchId branchToMatch = artifact.getBranch(); - branchMatches(permissionToMatch, branchToMatch, permissionStatus); - if (permissionStatus.matched()) { - Collection> mainList = accessData.getAccess(artifact); - AccessDetail mostSpecific = getNetAccess(mainList, new AccessFilter() { - - @Override - public boolean accept(AccessDetail access) { - return access.getAccessObject().equals(artifact) || access.getAccessObject().equals( - artifact.getArtifactType()); - } - }); - - setPermissionStatus(permissionStatus, permissionToMatch, mostSpecific); - } - } - - private class ObjectFilter implements AccessFilter { - Object toFilter; - - ObjectFilter(Object toFilter) { - this.toFilter = toFilter; - } - - @Override - public boolean accept(AccessDetail access) { - return access.getAccessObject().equals(toFilter); - } - } - - private class RelationTypeSideFilter implements AccessFilter { - RelationTypeSide toFilter; - - RelationTypeSideFilter(RelationTypeSide toFilter) { - this.toFilter = toFilter; - } - - @Override - public boolean accept(AccessDetail access) { - if (access.getAccessObject() instanceof RelationTypeSide) { - RelationTypeSide toCheck = (RelationTypeSide) access.getAccessObject(); - return toCheck.getSide().equals(toFilter.getSide()) && toCheck.getGuid().equals(toFilter.getGuid()); - } - return false; - } - } - - public void attributeTypeMatches(PermissionEnum permissionToMatch, ArtifactToken artifact, final AttributeTypeId attributeType, PermissionStatus permissionStatus) { - artifactMatches(permissionToMatch, artifact, permissionStatus); - if (permissionStatus.matched()) { - Collection> branchAccessDetails = accessData.getAccess(artifact.getBranch()); - AccessFilter filter = new ObjectFilter(attributeType); - AccessDetail branchPermission = getNetAccess(branchAccessDetails, filter); - setPermissionStatus(permissionStatus, permissionToMatch, branchPermission); - - if (permissionStatus.matched()) { - Collection> artifactAccessDetails = accessData.getAccess(artifact); - AccessDetail attributePermission = getNetAccess(artifactAccessDetails, filter); - setPermissionStatus(permissionStatus, permissionToMatch, attributePermission); - } - } - } - - public void relationTypeMatches(PermissionEnum permissionToMatch, ArtifactToken artifact, RelationTypeSide relationTypeSide, PermissionStatus permissionStatus) { - BranchId branchToMatch = artifact.getBranch(); - branchMatches(permissionToMatch, branchToMatch, permissionStatus); - if (permissionStatus.matched()) { - Collection> relationAccessDetails = accessData.getAccess(artifact); - AccessFilter filter = new RelationTypeSideFilter(relationTypeSide); - AccessDetail relationDetail = getNetAccess(relationAccessDetails, filter); - setPermissionStatus(permissionStatus, permissionToMatch, relationDetail); - } - } - - public boolean matchesAll(PermissionEnum permissionToMatch) { - PermissionStatus permissionStatus = new PermissionStatus(); - for (Object objectKey : accessData.keySet()) { - if (objectKey instanceof ArtifactToken) { - artifactMatches(permissionToMatch, (ArtifactToken) objectKey, permissionStatus); - } else if (objectKey instanceof BranchId) { - branchMatches(permissionToMatch, (BranchId) objectKey, permissionStatus); - } - if (!permissionStatus.matched()) { - break; - } - } - return permissionStatus.matched(); - } - - private void setTypePermissionStatus(PermissionStatus permissionStatus, PermissionEnum permissionToMatch, Collection> accessDetails, T toMatch) { - AccessFilter filter = new ObjectFilter(toMatch); - AccessDetail accessDetail = getNetAccess(accessDetails, filter); - setPermissionStatus(permissionStatus, permissionToMatch, accessDetail); - } - - private void setPermissionStatus(PermissionStatus status, PermissionEnum permissionToMatch, AccessDetail mostSpecific) { - if (mostSpecific == null) { - return; - } - if (mostSpecific.getPermission() == null) { - status.setMatches(false); - } else { - boolean matches = mostSpecific.getPermission().matches(permissionToMatch); - if (!matches) { - status.setReason(mostSpecific.getReason()); - } - status.setMatches(matches); - } - } - - private interface AccessFilter { - - public boolean accept(AccessDetail access); - - } - - private AccessDetail getNetAccess(Collection> toFilter, AccessFilter filter) { - AccessDetail mostSpecific = null; - for (AccessDetail entry : toFilter) { - if (filter.accept(entry)) { - mostSpecific = AccessDetail.resolveAccess(mostSpecific, entry); - } - } - return mostSpecific; - } -} diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDetail.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDetail.java deleted file mode 100644 index 11257853f7..0000000000 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDetail.java +++ /dev/null @@ -1,142 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.access; - -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.jdk.core.util.Strings; - -/** - * @author Roberto E. Escobar - */ -public class AccessDetail { //implements Comparable> { - - private final T accessObject; - private PermissionEnum permission; - private Scope scope; - private String reason; - - public AccessDetail(T accessObject, PermissionEnum permission, Scope scope) { - this(accessObject, permission, scope, Strings.emptyString()); - } - - public AccessDetail(T accessObject, PermissionEnum permission, Scope scope, String reason) { - this.accessObject = accessObject; - this.permission = permission; - this.reason = reason; - this.scope = scope; - } - - public String getReason() { - return Strings.isValid(reason) ? reason : scope.getPath(); - } - - public void setReason(String reason) { - this.reason = reason; - } - - public PermissionEnum getPermission() { - return permission; - } - - public Scope getScope() { - return scope; - } - - public void setScope(Scope scope) { - this.scope = scope; - } - - public T getAccessObject() { - return accessObject; - } - - public void setPermission(PermissionEnum permission) { - this.permission = permission; - } - - @Override - public int hashCode() { - int hashCode = 11; - return hashCode * 37 + (accessObject != null ? accessObject.hashCode() : 0); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof AccessDetail) { - AccessDetail other = (AccessDetail) obj; - Object object1 = getAccessObject(); - Object object2 = other.getAccessObject(); - boolean result = false; - if (object1 == null && object2 == null) { - result = true; - } else if (object1 != null && object2 != null) { - result = getAccessObject().equals(other.getAccessObject()); - } - return result; - } - return false; - } - - @Override - public String toString() { - return "AccessDetail [permission=" + getPermission() + ", scope=" + getScope() + ", accessObject=" + getAccessObject() + ", reason=" + getReason() + "]"; - } - - public static AccessDetail resolveAccess(AccessDetail original, AccessDetail data) { - AccessDetail toReturn = data; - if (original != null) { - Scope origScope = original.getScope(); - Scope dataScope = data.getScope(); - - if (origScope.isLegacy() || dataScope.isLegacy() || origScope.getPath().equals(dataScope.getPath())) { - toReturn = getMostRestrictive(original, data); - } else { - if (dataScope.getScopeDepth() > origScope.getScopeDepth()) { - toReturn = data; - } else { - toReturn = original; - } - } - - } - return toReturn; - } - - private static AccessDetail getMostRestrictive(AccessDetail original, AccessDetail data) { - PermissionEnum origPermission = original.getPermission(); - PermissionEnum newPermission = data.getPermission(); - - AccessDetail toReturn = original; - if (!origPermission.equals(newPermission)) { - PermissionEnum netPermission = PermissionEnum.getMostRestrictive(origPermission, newPermission); - if (netPermission.equals(newPermission)) { - toReturn = data; - } - } else { - String netReason = merge(toReturn.getReason(), data.getReason()); - toReturn.setReason(netReason); - } - return toReturn; - } - - public static String merge(String reason1, String reason2) { - StringBuilder builder = new StringBuilder(); - builder.append(reason1); - if (!reason1.equals(reason2)) { - builder.append(", "); - builder.append(reason2); - } - return builder.toString(); - } -} diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDetailCollector.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDetailCollector.java deleted file mode 100644 index b0f0cf6bb1..0000000000 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/AccessDetailCollector.java +++ /dev/null @@ -1,32 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.access; - -import java.util.List; -import org.eclipse.osee.framework.core.enums.PermissionEnum; - -/** - * @author Roberto E. Escobar - */ -public interface AccessDetailCollector { - void collect(AccessDetail accessDetail); - - default List> getAccessDetails() { - return null; - } - - default boolean contains(Object expectedAccessObject, PermissionEnum expectedPermission, Scope expectedScopeLevel) { - return false; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/IAccessControlService.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/IAccessControlService.java index be8be9cbbb..cd35bf6ec7 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/IAccessControlService.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/IAccessControlService.java @@ -14,28 +14,148 @@ package org.eclipse.osee.framework.core.access; import java.util.Collection; +import java.util.List; +import org.eclipse.osee.framework.core.access.event.AccessTopicEventPayload; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; +import org.eclipse.osee.framework.core.data.ArtifactTypeToken; +import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.BranchToken; +import org.eclipse.osee.framework.core.data.IUserGroupService; +import org.eclipse.osee.framework.core.data.RelationTypeToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.jdk.core.result.XResultData; /** * @author Roberto E. Escobar */ public interface IAccessControlService extends ArtifactCheck { + public static final String DEBUG_BRANCH_ACCESS = "DebugBranchAccess"; + + //////////////////////////////////// + // Store Permission + //////////////////////////////////// + + void persistPermission(AccessControlData data); + + void persistPermission(AccessControlData data, boolean recurse); + + void setPermission(ArtifactToken subject, ArtifactToken artifact, PermissionEnum permission); + + void removeAccessControlDataIf(boolean removeFromDb, AccessControlData data); + + //////////////////////////////////// + // Branch Permission + //////////////////////////////////// + + XResultData isModifyAccessEnabled(ArtifactToken subject, BranchToken branch, XResultData rd); + + PermissionEnum getPermission(BranchToken branch); + + void removePermissions(BranchId branch); + + void setPermission(ArtifactToken subject, BranchId branch, PermissionEnum permissionEnum); + + XResultData hasBranchPermission(BranchToken branch, PermissionEnum permission, XResultData rd); + + XResultData hasBranchPermission(ArtifactToken subject, BranchToken branch, PermissionEnum permission, XResultData rd); + + //////////////////////////////////// + // Artifact Permission + //////////////////////////////////// + + XResultData isModifyAccessEnabled(ArtifactToken subject, ArtifactToken artifact, XResultData rd); + + PermissionEnum getPermission(ArtifactToken artifact); + /** - * @param object Artifact, Branch or collection of either + * Check rollup permission for current user including Branch, ACL and Branch Context. Preferred method. */ - boolean hasPermission(Object object, PermissionEnum permission); + XResultData hasArtifactPermission(ArtifactToken artifact, PermissionEnum permission, XResultData rd); - void removePermissions(BranchId branch); + // Check rollup permission for current user including Branch ACL, Artifact ACL and Branch Context. + XResultData hasArtifactPermission(Collection artifacts, PermissionEnum permission, XResultData rd); - AccessDataQuery getAccessData(ArtifactToken userArtifact, Collection itemsToCheck); + // Check rollup permission for current user including Branch ACL, Artifact ACL and Branch Context. + XResultData hasArtifactPermission(ArtifactToken subject, Collection artifact, PermissionEnum permission, XResultData rd); - void ensurePopulated(); + // Return artifact or sentinel + ArtifactToken getSubjectFromLockedObject(ArtifactToken artifact); + + void lockArtifacts(ArtifactToken subject, Collection artifacts); + + void unLockArtifacts(ArtifactToken subject, Collection artifacts); + + boolean canUnlockObject(ArtifactToken subject, ArtifactToken artifact); + + boolean hasLock(ArtifactToken artifact); + + //////////////////////////////////// + // Attribute Type Permission + //////////////////////////////////// + + /** + * Check rollup permission for current user including Branch ACL, Artifact ACL and Branch Context for Attr Type + */ + XResultData hasAttributeTypePermission(Collection artifacts, AttributeTypeToken attributeType, PermissionEnum permission, XResultData rd); + + /** + * Check rollup permission for current user including Branch ACL, Artifact ACL and Branch Context for Attr Type + */ + XResultData hasAttributeTypePermission(ArtifactToken subject, Collection artifacts, AttributeTypeToken attributeType, PermissionEnum permission, XResultData rd); + + //////////////////////////////////// + // Relation Permission + //////////////////////////////////// + + /** + * Check rollup permission for current user including Branch ACL, Artifact ACL and Branch Context for Rel Type + * + * @param related list to relate or null to check permission without specific artifacts + */ + XResultData hasRelationTypePermission(ArtifactToken user, ArtifactToken artifact, RelationTypeToken relationType, Collection related, PermissionEnum permission, XResultData rd); + + /** + * Check rollup permission for current user including Branch ACL, Artifact ACL and Branch Context for Rel Type + * + * @param related list to relate or null to check permission without specific artifacts + */ + XResultData hasRelationTypePermission(ArtifactToken artifact, RelationTypeToken relationType, Collection related, PermissionEnum permission, XResultData rd); + + //////////////////////////////////// + // Supporting Methods + //////////////////////////////////// + + boolean isInDb(ArtifactToken artifact); - void clearCache(); + boolean isReadOnly(ArtifactToken artifact); boolean isOseeAdmin(); -} \ No newline at end of file + void ensurePopulated(); + + void clearCaches(); + + void reloadCache(); + + List getAccessControlList(Object object); + + ArtifactToken getUserByArtId(ArtifactId subjectArtId); + + Collection getOseeAccessProviders(); + + void kickAccessTopicEvent(AccessTopicEventPayload event); + + IUserGroupService getUserGroupService(); + + Collection getArtifactListFromType(ArtifactTypeToken artType, BranchToken branch); + + boolean isBaselineBranch(BranchToken branch); + + void populateGroupMembers(ArtifactId groupId); + + ArtifactToken getUser(); + +} diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/Scope.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/Scope.java deleted file mode 100644 index e1678bbeb5..0000000000 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/access/Scope.java +++ /dev/null @@ -1,157 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.core.access; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Roberto E. Escobar - * @author John R. Misinco - */ -public class Scope implements Cloneable { - - private static final String LEGACY_SCOPE = "##"; - private static final String ARTIFACT_LOCK_SCOPE = "##**"; - - private final List scopePath = new ArrayList<>(); - - public Scope() { - // Do nothing - } - - public int getScopeDepth() { - return scopePath.size(); - } - - public Scope add(String value) { - scopePath.add(normalize(value)); - return this; - } - - public String getPath() { - StringBuilder builder = new StringBuilder(); - for (String entry : scopePath) { - if (!entry.startsWith("#")) { - builder.append("/"); - } - builder.append(entry); - } - return builder.toString(); - } - - private String normalize(String value) { - return value.replaceAll(" ", "_"); - } - - public Scope addSubPath(String value) { - scopePath.add("#" + normalize(value)); - return this; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (scopePath == null ? 0 : scopePath.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Scope other = (Scope) obj; - if (scopePath == null) { - if (other.scopePath != null) { - return false; - } - } else if (!scopePath.equals(other.scopePath)) { - return false; - } - return true; - } - - public boolean isLegacy() { - return this instanceof LegacyScope; - } - - @Override - public String toString() { - return getPath(); - } - - @Override - public Scope clone() { - Scope scope = new Scope(); - for (String value : this.scopePath) { - scope.add(value); - } - return scope; - } - - public static Scope createLegacyScope() { - return new LegacyScope(); - } - - public static Scope createArtifactLockScope() { - return new ArtifactLockScope(); - } - - private static abstract class NonCmScope extends Scope { - @Override - public Scope add(String path) { - return this; - } - - @Override - public Scope addSubPath(String path) { - return this; - } - } - - private static final class LegacyScope extends NonCmScope { - - @Override - public String getPath() { - return LEGACY_SCOPE; - } - - @Override - public Scope clone() { - return Scope.createLegacyScope(); - } - } - - private static final class ArtifactLockScope extends NonCmScope { - - @Override - public String getPath() { - return ARTIFACT_LOCK_SCOPE; - } - - @Override - public Scope clone() { - return Scope.createArtifactLockScope(); - } - } - -} diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactToken.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactToken.java index dcb88065fb..b63603cf83 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactToken.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactToken.java @@ -14,13 +14,16 @@ package org.eclipse.osee.framework.core.data; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import java.util.logging.Level; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.osee.framework.jdk.core.type.Id; import org.eclipse.osee.framework.jdk.core.type.Identity; import org.eclipse.osee.framework.jdk.core.type.NamedId; import org.eclipse.osee.framework.jdk.core.type.NamedIdBase; import org.eclipse.osee.framework.jdk.core.type.NamedIdSerializer; +import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.framework.logging.OseeLog; /** * @author Ryan D. Brooks @@ -115,6 +118,16 @@ public interface ArtifactToken extends ArtifactId, HasBranch, NamedId, Identity< public ArtifactTokenImpl(Long id, String guid, String name, BranchId branch, ArtifactTypeToken artifactType) { super(id, name); + // Until artifacts can have long in db, ensure that tokens aren't negative when turned to int + int idInt = Long.valueOf(id).intValue(); + if (idInt <= 0 && idInt != -1) { + String msg = String.format( + "Token id (as int) must be > 0 or SENTINAL, not int [%s] for long id [%s] name [%s] and type [%s])", + idInt, id, name, artifactType.getName()); + // Log to console which shows the id, name and type on contruction where exception doesn't show till loading + OseeLog.log(ArtifactToken.class, Level.SEVERE, msg); + throw new OseeArgumentException(msg); + } this.branch = branch; this.artifactType = artifactType; this.guid = guid; diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IUserGroup.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IUserGroup.java index d23f8ca023..9d8f6a853a 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IUserGroup.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IUserGroup.java @@ -22,16 +22,18 @@ public interface IUserGroup { ArtifactToken getArtifact(); - boolean addMember(UserId user); + boolean addMember(UserId user, boolean persist); boolean isMember(UserId user); boolean isCurrentUserMember(); - boolean removeMember(UserId user); + boolean removeMember(UserId user, boolean persist); Collection getMembers(); boolean isMember(Long id); + Long getId(); + } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IUserGroupService.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IUserGroupService.java index 165ca4ad0b..857dbdefc2 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IUserGroupService.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/IUserGroupService.java @@ -29,7 +29,11 @@ public interface IUserGroupService { /** * Checks for existence of user group, then if member */ - public boolean isUserMember(IUserGroupArtifactToken amsUsers, Long id); + public boolean isUserMember(IUserGroupArtifactToken userGroup, Long id); + + public boolean isUserMember(IUserGroupArtifactToken userGroup, ArtifactId user); public Collection getUsers(IUserGroupArtifactToken userGroup); + + IUserGroup getUserGroup(ArtifactToken userGroupArt); } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreUserGroups.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreUserGroups.java index e779c7096d..5c257f8087 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreUserGroups.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreUserGroups.java @@ -23,11 +23,11 @@ public class CoreUserGroups { public static final IUserGroupArtifactToken Everyone = UserGroupArtifactToken.valueOf(48656L, "Everyone"); public static final IUserGroupArtifactToken OseeAccessAdmin = - UserGroupArtifactToken.valueOf(8033605L, "OseeAccessAdmin"); - public static final IUserGroupArtifactToken OseeAdmin = UserGroupArtifactToken.valueOf(52247L, "OseeAdmin"); + UserGroupArtifactToken.valueOf(8033605L, "Osee Access Admin"); + public static final IUserGroupArtifactToken OseeAdmin = UserGroupArtifactToken.valueOf(52247L, "Osee Admin"); public static final IUserGroupArtifactToken OseeDeveloper = - UserGroupArtifactToken.valueOf(464565465L, "OseeDeveloper"); - public static final IUserGroupArtifactToken OseeSupport = UserGroupArtifactToken.valueOf(10865894L, "OseeSupport"); + UserGroupArtifactToken.valueOf(464565465L, "Osee Developer"); + public static final IUserGroupArtifactToken OseeSupport = UserGroupArtifactToken.valueOf(10865894L, "Osee Support"); public static IUserGroupArtifactToken AgileUser = UserGroupArtifactToken.valueOf(10635635L, "Agile User"); public static IUserGroupArtifactToken EarnedValueUser = UserGroupArtifactToken.valueOf(10635662L, "Earner Value User"); diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/DemoBranches.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/DemoBranches.java index 2477823441..ac3d53a300 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/DemoBranches.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/DemoBranches.java @@ -26,6 +26,8 @@ public final class DemoBranches { public static final BranchToken SAW_Bld_2 = BranchToken.create(5, "SAW_Bld_2"); public static final BranchToken SAW_Bld_3 = BranchToken.create(6, "SAW_Bld_3"); + public static final BranchToken SAW_PL_Access_Baseline_Test = BranchToken.create(5432, "SAW Access Control Baseline Test"); + public static final BranchToken SAW_PL = BranchToken.create(8, "SAW Product Line"); public static final BranchToken SAW_PL_Hardening_Branch = BranchToken.create(9, "SAW PL Hardening Branch"); public static final BranchToken SAW_PL_Working_Branch = BranchToken.create(10, "SAW PL Working Branch"); diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/PermissionEnum.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/PermissionEnum.java index a278b5d241..2e697d8681 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/PermissionEnum.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/PermissionEnum.java @@ -21,12 +21,13 @@ import java.util.Map; */ public enum PermissionEnum { + // Update FrameworkAccessDesign.adoc if these are changed NONE(5, "None", "Open Access for all Users"), READ(10, "Read", "Read only access for specified user"), WRITE(20, "Write", "Write access for specified user"), USER_LOCK(25, "Lock", "Locked for write by only the specified user"), FULLACCESS(30, "Full Access", "Full Access to Read, Write and Change Permissions"), - DENY(65535, "Deny", "Deny all access. Usually only if something is "); + DENY(65535, "Deny", "Deny all access"); // keeping this in sync with the number of permissions will ensure optimal memory usage private static final int COUNT = 4; @@ -119,4 +120,5 @@ public enum PermissionEnum { public int getPermId() { return permissionId; } + } diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/result/XResultData.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/result/XResultData.java index d835d002d1..fff2d4fd70 100644 --- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/result/XResultData.java +++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/result/XResultData.java @@ -45,6 +45,7 @@ public class XResultData { ConsoleOut; } + public static XResultData EMPTY_RD = new XResultData(); public static final Pattern ErrorPattern = Pattern.compile("Error: "); public static final Pattern WarningPattern = Pattern.compile("Warning: "); @JsonIgnore diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/OseeProperties.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/OseeProperties.java index 5d5ecc3a1f..e55666768d 100644 --- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/OseeProperties.java +++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/OseeProperties.java @@ -41,11 +41,28 @@ public class OseeProperties { public static final String OSEE_SHOW_TOKEN_FOR_CHANGE_NAME = "osee.show.token.for.change.name"; public static final String OSEE_DB = "osee.db"; public static final String OSEE_HEALTH_SERVERS_KEY = "osee.health.servers"; + public static final String OSEE_IS_IN_DB_INIT = "osee.is.in.db.init"; protected OseeProperties() { // Utility Class } + protected static String getProperty(String name) { + return getProperty(name, ""); + } + + protected static String getProperty(String name, String defaultValue) { + return System.getProperty(name, defaultValue); + } + + public static boolean isInDbInit() { + return Boolean.valueOf(getProperty(OSEE_IS_IN_DB_INIT)); + } + + public static void setInDbInit(boolean value) { + System.setProperty(OSEE_IS_IN_DB_INIT, Boolean.toString(value)); + } + public static String getOseeDefaultBrokerUri() { return System.getProperty(OSEE_DEFAULT_BROKER_URI); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionTest.java index 6401bec90f..861777a28c 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionTest.java +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransactionTest.java @@ -30,7 +30,6 @@ import org.junit.Test; /** * @author Jonas Khan */ - public class SkynetTransactionTest { public static final ArtifactToken token = @@ -52,26 +51,6 @@ public class SkynetTransactionTest { Assert.assertTrue(errorMsg, errorMsg.contains(bID.getIdString())); } - @Test - public void getCheckBranchArtifactErrorTest() { - SkynetTransaction test = new SkynetTransaction(null, DemoBranches.SAW_Bld_1, ""); - String errorMsg = test.getCheckBranchError(token, DemoBranches.SAW_Bld_1); - Assert.assertTrue(errorMsg, errorMsg.contains(token.getIdString())); - Assert.assertTrue(errorMsg, errorMsg.contains(token.getName())); - Assert.assertTrue(errorMsg, errorMsg.contains(DemoBranches.SAW_Bld_1.getIdString())); - Assert.assertTrue(errorMsg, errorMsg.contains(DemoBranches.SAW_Bld_1.getName())); - } - - @Test - public void getCheckBranchRelationErrorTest() { - SkynetTransaction test = new SkynetTransaction(null, DemoBranches.SAW_Bld_1, ""); - String errorMsg = test.getCheckBranchError(link, DemoBranches.SAW_Bld_1); - Assert.assertTrue(errorMsg, errorMsg.contains(artifactA.getIdString())); - Assert.assertTrue(errorMsg, errorMsg.contains(artifactB.getIdString())); - Assert.assertTrue(errorMsg, errorMsg.contains(DemoBranches.SAW_Bld_1.getIdString())); - Assert.assertTrue(errorMsg, errorMsg.contains(DemoBranches.SAW_Bld_1.getName())); - } - @Test public void getCheckNotHistoricalErrorTest() { SkynetTransaction test = new SkynetTransaction(null, DemoBranches.SAW_Bld_1, ""); diff --git a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF index a93c7eff60..3de3d4487c 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF @@ -63,9 +63,6 @@ Import-Package: com.fasterxml.jackson.core.type, org.eclipse.osee.framework.core.client, org.eclipse.osee.framework.core.client.server, org.eclipse.osee.framework.core.data, - org.eclipse.osee.framework.core.dsl, - org.eclipse.osee.framework.core.dsl.oseeDsl, - org.eclipse.osee.framework.core.dsl.oseeDsl.util, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.event, org.eclipse.osee.framework.core.exception, diff --git a/plugins/org.eclipse.osee.framework.skynet.core/OSEE-INF/extensionPts/ArtifactCheck.exsd b/plugins/org.eclipse.osee.framework.skynet.core/OSEE-INF/extensionPts/ArtifactCheck.exsd deleted file mode 100644 index 49cc86fa45..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/OSEE-INF/extensionPts/ArtifactCheck.exsd +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.skynet.core/OSGI-INF/access.policy.service.xml b/plugins/org.eclipse.osee.framework.skynet.core/OSGI-INF/access.policy.service.xml deleted file mode 100644 index aec108dbe0..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/OSGI-INF/access.policy.service.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/plugins/org.eclipse.osee.framework.skynet.core/plugin.xml b/plugins/org.eclipse.osee.framework.skynet.core/plugin.xml index 3f61f16cda..98506ca0f7 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/plugin.xml +++ b/plugins/org.eclipse.osee.framework.skynet.core/plugin.xml @@ -9,7 +9,6 @@ - diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/AccessPolicy.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/AccessPolicy.java deleted file mode 100644 index ee619ba71c..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/AccessPolicy.java +++ /dev/null @@ -1,49 +0,0 @@ -/********************************************************************* - * Copyright (c) 2010 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.skynet.core; - -import java.util.Collection; -import java.util.logging.Level; -import org.eclipse.osee.framework.core.access.ArtifactCheck; -import org.eclipse.osee.framework.core.access.PermissionStatus; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.ArtifactTypeId; -import org.eclipse.osee.framework.core.data.AttributeTypeId; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.RelationTypeSide; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; - -/** - * @author Roberto E. Escobar - */ -public interface AccessPolicy extends ArtifactCheck { - - boolean isReadOnly(Artifact artifact); - - void removePermissions(BranchId branch); - - PermissionStatus hasBranchPermission(BranchId branch, PermissionEnum permission, Level level); - - PermissionStatus hasAttributeTypePermission(Collection artifacts, AttributeTypeId attributeType, PermissionEnum permission, Level level); - - PermissionStatus hasArtifactTypePermission(BranchId branch, Collection artifactTypes, PermissionEnum permission, Level level); - - PermissionStatus hasArtifactPermission(Collection artifacts, PermissionEnum permission, Level level); - - PermissionStatus canRelationBeModified(Artifact subject, Collection toBeRelated, RelationTypeSide relationTypeSide, Level level); - - void ensurePopulated(); - -} diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/access/UserGroupImpl.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/access/UserGroupImpl.java index 8211744fe0..4f504f7a04 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/access/UserGroupImpl.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/access/UserGroupImpl.java @@ -63,10 +63,20 @@ public class UserGroupImpl extends AbstractUserGroupImpl { } @Override - public boolean addMember(UserId user) { + public boolean addMember(UserId user, boolean persist) { checkGroupExists(); - if (!getArtifact().isRelated(CoreRelationTypes.Users_User, (Artifact) user)) { - getArtifact().addRelation(CoreRelationTypes.Users_User, (Artifact) user); + Artifact userArt = null; + if (user instanceof Artifact) { + userArt = (Artifact) user; + } else { + userArt = UserManager.getUserByArtId(user); + } + Artifact group = getArtifact(); + if (!group.isRelated(CoreRelationTypes.Users_User, userArt)) { + group.addRelation(CoreRelationTypes.Users_User, userArt); + if (persist) { + group.persist("Add Member"); + } return true; } return false; @@ -126,10 +136,20 @@ public class UserGroupImpl extends AbstractUserGroupImpl { } @Override - public boolean removeMember(UserId user) { + public boolean removeMember(UserId user, boolean persist) { checkGroupExists(); - if (getArtifact().isRelated(CoreRelationTypes.Users_User, (Artifact) user)) { - getArtifact().deleteRelation(CoreRelationTypes.Users_User, (Artifact) user); + Artifact userArt = null; + if (user instanceof Artifact) { + userArt = (Artifact) user; + } else { + userArt = UserManager.getUserByArtId(user); + } + Artifact group = getArtifact(); + if (group.isRelated(CoreRelationTypes.Users_User, userArt)) { + group.deleteRelation(CoreRelationTypes.Users_User, userArt); + if (persist) { + group.persist("Remove Member"); + } return true; } return false; diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/access/UserGroupService.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/access/UserGroupService.java index b738012874..f58c0cab1c 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/access/UserGroupService.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/access/UserGroupService.java @@ -16,6 +16,7 @@ package org.eclipse.osee.framework.skynet.core.access; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.IUserGroup; import org.eclipse.osee.framework.core.data.IUserGroupArtifactToken; @@ -39,7 +40,7 @@ public class UserGroupService implements IUserGroupService { private static List userGrps; public static IUserGroupService instance() { - return userGroupService; + return getUserGroupService(); } public static IUserGroup getOseeAdmin() { @@ -70,6 +71,11 @@ public class UserGroupService implements IUserGroupService { } } + @Override + public IUserGroup getUserGroup(ArtifactToken userGroupArt) { + return new UserGroupImpl(userGroupArt); + } + private static IUserGroupService getUserGroupService() { if (userGroupService == null) { userGroupService = new UserGroupService(); @@ -133,4 +139,9 @@ public class UserGroupService implements IUserGroupService { } return getUserGroup(userGroup).isMember(id); } + + @Override + public boolean isUserMember(IUserGroupArtifactToken userGroup, ArtifactId user) { + return isUserMember(userGroup, user.getId()); + } } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java index 90733ccbc1..09a9cef242 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java @@ -81,7 +81,6 @@ import org.eclipse.osee.framework.jdk.core.util.GUID; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts; import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.UserManager; @@ -90,7 +89,7 @@ import org.eclipse.osee.framework.skynet.core.attribute.ArtifactReferenceAttribu import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.eclipse.osee.framework.skynet.core.event.model.AttributeChange; import org.eclipse.osee.framework.skynet.core.internal.Activator; -import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; +import org.eclipse.osee.framework.skynet.core.internal.OseeApiService; import org.eclipse.osee.framework.skynet.core.relation.RelationLink; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; @@ -1223,16 +1222,7 @@ public class Artifact extends NamedIdBase implements ArtifactToken, Adaptable, F } public final boolean isReadOnly() { - boolean result = true; - AccessPolicy service = null; - try { - service = ServiceUtil.getAccessPolicy(); - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - if (service != null) { - result = service.isReadOnly(this); - } + boolean result = OseeApiService.get().getAccessControlService().isReadOnly(this); return result; } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java index 4bcda429b5..246e8a855e 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java @@ -23,10 +23,8 @@ import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.OseeStateException; -import org.eclipse.osee.framework.jdk.core.util.Collections; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; -import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; +import org.eclipse.osee.framework.skynet.core.internal.OseeApiService; import org.eclipse.osee.framework.skynet.core.relation.RelationLink; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; @@ -64,8 +62,7 @@ public class ArtifactPersistenceManager { // Confirm artifacts are fit to delete private static void performDeleteChecks(Collection artifacts) { - AccessPolicy policy = ServiceUtil.getAccessPolicy(); - XResultData results = policy.isDeleteable(Collections.castAll(artifacts), new XResultData()); + XResultData results = OseeApiService.get().getAccessControlService().isDeleteable(artifacts, new XResultData()); if (results.isErrors()) { throw new OseeStateException(results.toString()); } @@ -73,8 +70,8 @@ public class ArtifactPersistenceManager { // Confirm relations are fit to delete public static void performDeleteRelationChecks(Artifact artifact, RelationTypeToken relationType) { - AccessPolicy policy = ServiceUtil.getAccessPolicy(); - XResultData results = policy.isDeleteableRelation(artifact, relationType, new XResultData()); + XResultData results = + OseeApiService.get().getAccessControlService().isDeleteableRelation(artifact, relationType, new XResultData()); if (results.isErrors()) { throw new OseeStateException(results.toString()); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java index 45454f5388..088184a684 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Attribute.java @@ -34,12 +34,11 @@ import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.messaging.event.res.AttributeEventModificationType; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.eclipse.osee.framework.skynet.core.attribute.providers.IAttributeDataProvider; import org.eclipse.osee.framework.skynet.core.event.model.AttributeChange; import org.eclipse.osee.framework.skynet.core.internal.Activator; -import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; +import org.eclipse.osee.framework.skynet.core.internal.OseeApiService; /** * @author Ryan D. Brooks @@ -141,8 +140,8 @@ public abstract class Attribute implements Comparable>, IAttribu private void checkIsRenameable(T value) { if (getAttributeType().equals(CoreAttributeTypes.Name) && !value.equals(getValue())) { - AccessPolicy policy = ServiceUtil.getAccessPolicy(); - XResultData results = policy.isRenamable(Collections.singleton(getArtifact()), new XResultData()); + XResultData results = OseeApiService.get().getAccessControlService().isRenamable( + Collections.singleton(getArtifact()), new XResultData()); if (results.isErrors()) { throw new OseeStateException(results.toString()); } @@ -162,6 +161,7 @@ public abstract class Attribute implements Comparable>, IAttribu setToDefaultValue(); } + @SuppressWarnings("unchecked") protected void setToDefaultValue() { AttributeTypeGeneric attributeType = AttributeTypeManager.getAttributeType(attributeTypeToken.getId()); T defaultValue = (T) getArtifact().getArtifactType().getAttributeDefault(attributeType); 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 388a1ddc3d..a249a06eae 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 @@ -767,4 +767,5 @@ public final class BranchManager { return getBranch(transaction.getBranch()); } -} \ No newline at end of file +} + diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/checks/AssociatedArtifactCheck.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/checks/AssociatedArtifactCheck.java deleted file mode 100644 index 5fc88f178f..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/checks/AssociatedArtifactCheck.java +++ /dev/null @@ -1,32 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.skynet.core.artifact.checks; - -import java.util.Collection; -import org.eclipse.osee.framework.core.access.ArtifactCheck; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.jdk.core.result.XResultData; -import org.eclipse.osee.framework.jdk.core.util.Collections; -import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; - -/** - * @author John Misinco - */ -public class AssociatedArtifactCheck implements ArtifactCheck { - - @Override - public XResultData isDeleteable(Collection artifacts, XResultData results) { - return BranchManager.isDeleteable(Collections.castAll(artifacts), results); - } -} diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/OseeEventManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/OseeEventManager.java index 44510172c0..dc8d13b0a3 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/OseeEventManager.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/OseeEventManager.java @@ -19,6 +19,8 @@ import java.util.List; import java.util.logging.Level; import org.eclipse.core.runtime.Assert; import org.eclipse.osee.activity.api.ActivityLog; +import org.eclipse.osee.framework.core.access.event.AccessTopicEvent; +import org.eclipse.osee.framework.core.access.event.AccessTopicEventPayload; import org.eclipse.osee.framework.core.client.TopicEventUtil; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.BranchId; @@ -35,8 +37,6 @@ import org.eclipse.osee.framework.skynet.core.event.filter.BranchIdEventFilter; 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.IEventListener; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEventPayload; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent.ArtifactEventType; import org.eclipse.osee.framework.skynet.core.event.model.BranchEvent; diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessArtifactLockTopicEvent.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessArtifactLockTopicEvent.java deleted file mode 100644 index b1ac4d8fda..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessArtifactLockTopicEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/********************************************************************* - * Copyright (c) 2015 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.skynet.core.event.model; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * @author Donald G. Dunne - */ -@XmlRootElement -public class AccessArtifactLockTopicEvent extends AccessTopicEventPayload { - - boolean locked; - - public boolean isLocked() { - return locked; - } - - public void setLocked(boolean locked) { - this.locked = locked; - } - -} diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessTopicEvent.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessTopicEvent.java deleted file mode 100644 index 074587ed39..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessTopicEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/********************************************************************* - * Copyright (c) 2016 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.skynet.core.event.model; - -import org.eclipse.osee.framework.core.data.TransactionToken; -import org.eclipse.osee.framework.core.event.AbstractTopicEvent; -import org.eclipse.osee.framework.core.event.EventType; - -/** - * @author Donald G. Dunne - */ -public class AccessTopicEvent extends AbstractTopicEvent { - - public static final AccessTopicEvent ACCESS_ARTIFACT_MODIFIED = - new AccessTopicEvent(EventType.LocalAndRemote, "framework/access/artifact/modified"); - public static final AccessTopicEvent ACCESS_ARTIFACT_LOCK_MODIFIED = - new AccessTopicEvent(EventType.LocalAndRemote, "framework/access/artifact/lock/modified"); - public static final AccessTopicEvent ACCESS_BRANCH_MODIFIED = - new AccessTopicEvent(EventType.LocalAndRemote, "framework/access/branch/modified"); - public static final AccessTopicEvent USER_AUTHENTICATED = - new AccessTopicEvent(EventType.LocalOnly, "framework/access/user/authenticated"); - - private AccessTopicEvent(EventType eventType, String topic) { - super(eventType, TransactionToken.SENTINEL, topic); - } - -} diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessTopicEventPayload.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessTopicEventPayload.java deleted file mode 100644 index 8c0fd457aa..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/AccessTopicEventPayload.java +++ /dev/null @@ -1,68 +0,0 @@ -/********************************************************************* - * Copyright (c) 2015 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.skynet.core.event.model; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.osee.framework.core.data.ArtifactId; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.BranchId; - -/** - * Payload for the Access Topic Event - * - * @author Donald G. Dunne - */ -public class AccessTopicEventPayload implements ISerializeableTopicPayload { - BranchId branch; - List artifactUuids = new ArrayList<>(); - - public BranchId getBranch() { - return branch; - } - - public void setBranch(BranchId branch) { - this.branch = branch; - } - - public List getArtifactUuids() { - return artifactUuids; - } - - public void setArtifactUuids(List artifactUuids) { - this.artifactUuids = artifactUuids; - } - - public void addArtifact(ArtifactId artifact) { - addArtifact(artifact.getUuid()); - } - - public void addArtifact(Long artifactUuid) { - getArtifactUuids().add(String.valueOf(artifactUuid)); - } - - public void addArtifact(Integer artifactId) { - getArtifactUuids().add(String.valueOf(Long.valueOf(artifactId))); - } - - /** - * @return true if this artifact matches event branch and contains artifact - */ - public boolean matches(ArtifactToken artifact) { - if (!artifactUuids.isEmpty()) { - return artifact.isOnBranch(branch) && artifactUuids.contains(artifact.getIdString()); - } - return false; - } -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/ISerializeableTopicPayload.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/ISerializeableTopicPayload.java deleted file mode 100644 index dabce1df58..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/model/ISerializeableTopicPayload.java +++ /dev/null @@ -1,23 +0,0 @@ -/********************************************************************* - * Copyright (c) 2015 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.skynet.core.event.model; - -/** - * Class that is serializable for use in Topic Event as payload - * - * @author Donald G. Dunne - */ -public interface ISerializeableTopicPayload { - // do nothing -} diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java index bc624e5eb1..ef664539be 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java @@ -30,7 +30,6 @@ import org.eclipse.osee.framework.core.operation.AbstractOperation; import org.eclipse.osee.framework.core.operation.IOperation; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.messaging.event.res.AttributeEventModificationType; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache; import org.eclipse.osee.framework.skynet.core.artifact.Attribute; @@ -46,6 +45,7 @@ import org.eclipse.osee.framework.skynet.core.event.model.BranchEventType; import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidRelation; import org.eclipse.osee.framework.skynet.core.event.model.EventModifiedBasicGuidArtifact; import org.eclipse.osee.framework.skynet.core.internal.Activator; +import org.eclipse.osee.framework.skynet.core.internal.OseeApiService; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.relation.RelationEventType; import org.eclipse.osee.framework.skynet.core.revision.ChangeManager; @@ -106,8 +106,7 @@ public final class CommitBranchHttpRequestOperation extends AbstractOperation { } private void handleResponse(TransactionToken newTransaction, IProgressMonitor monitor, BranchId sourceBranch, BranchId destinationBranch) { - AccessPolicy accessPolicy = ServiceUtil.getAccessPolicy(); - accessPolicy.removePermissions(sourceBranch); + OseeApiService.get().getAccessControlService().removePermissions(sourceBranch); // Update commit artifact cache with new information Artifact associatedArtifact = BranchManager.getAssociatedArtifact(sourceBranch); diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/AccessPolicyImpl.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/AccessPolicyImpl.java deleted file mode 100644 index 09b68eb48a..0000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/AccessPolicyImpl.java +++ /dev/null @@ -1,259 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.skynet.core.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.logging.Level; -import org.eclipse.osee.framework.core.access.AccessDataQuery; -import org.eclipse.osee.framework.core.access.IAccessControlService; -import org.eclipse.osee.framework.core.access.PermissionStatus; -import org.eclipse.osee.framework.core.client.OseeClientProperties; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.ArtifactTypeId; -import org.eclipse.osee.framework.core.data.AttributeTypeId; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.RelationTypeSide; -import org.eclipse.osee.framework.core.data.RelationTypeToken; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.core.enums.RelationSide; -import org.eclipse.osee.framework.jdk.core.result.XResultData; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; -import org.eclipse.osee.framework.skynet.core.User; -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; - -/** - * @author Roberto E. Escobar - */ -public class AccessPolicyImpl implements AccessPolicy { - - public IAccessControlService accessControlService; - - public void setAccessControlService(IAccessControlService service) { - this.accessControlService = service; - } - - private User getCurrentUser() { - return UserManager.getUser(); - } - - private IAccessControlService getAccessService() { - return accessControlService; - } - - private boolean printErrorMessage(User user, Collection objects, PermissionStatus permissionStatus, Level level) { - boolean notMatched = !permissionStatus.matched(); - - if (notMatched) { - String objectString = org.eclipse.osee.framework.jdk.core.util.Collections.toString("; ", objects); - String reasonString = permissionStatus.getReason(); - if (Strings.isValid(reasonString)) { - reasonString = String.format("\n reason:[%s]", reasonString); - } else { - reasonString = ""; - } - OseeLog.logf(Activator.class, level, - "Access Denied - [%s] does not have valid permission to edit\n item(s) : [%s]%s", user, objectString, - reasonString); - } - return notMatched; - } - - @Override - public void removePermissions(BranchId branch) { - getAccessService().removePermissions(branch); - } - - @Override - public boolean isReadOnly(Artifact artifact) { - try { - return artifact.isDeleted() || artifact.isHistorical() || !BranchManager.isEditable( - artifact.getBranch()) || !getAccessService().hasPermission(artifact, PermissionEnum.WRITE); - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - return true; - } - } - - @Override - public PermissionStatus hasBranchPermission(BranchId branch, PermissionEnum permission, Level level) { - User currentUser = getCurrentUser(); - AccessDataQuery query = getAccessService().getAccessData(currentUser, java.util.Collections.singleton(branch)); - PermissionStatus permissionStatus = null; - if (!OseeClientProperties.isInDbInit()) { - permissionStatus = new PermissionStatus(); - query.branchMatches(permission, branch, permissionStatus); - printErrorMessage(currentUser, java.util.Collections.singleton(branch), permissionStatus, level); - } else { - permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled"); - } - return permissionStatus; - } - - /** - * @param level - A level of OseeLevel.SEVERE_POPUP will cause an error dialog to be displayed to the user. All - * others will write to the log. - */ - @Override - public PermissionStatus hasAttributeTypePermission(Collection artifacts, AttributeTypeId attributeType, PermissionEnum permission, Level level) { - User currentUser = getCurrentUser(); - AccessDataQuery query = getAccessService().getAccessData(currentUser, artifacts); - - PermissionStatus permissionStatus = null; - if (!OseeClientProperties.isInDbInit()) { - permissionStatus = new PermissionStatus(); - if (artifacts != null) { - for (ArtifactToken artifact : artifacts) { - query.attributeTypeMatches(permission, artifact, attributeType, permissionStatus); - - if (printErrorMessage(currentUser, artifacts, permissionStatus, level)) { - break; - } - } - } - } else { - permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled"); - } - - return permissionStatus; - } - - @Override - public PermissionStatus hasArtifactPermission(Collection artifacts, PermissionEnum permission, Level level) { - User currentUser = getCurrentUser(); - AccessDataQuery query = getAccessService().getAccessData(currentUser, artifacts); - - PermissionStatus permissionStatus = null; - if (!OseeClientProperties.isInDbInit()) { - permissionStatus = new PermissionStatus(); - if (artifacts != null) { - for (Artifact artifact : artifacts) { - if (artifact.isInDb()) { - query.artifactMatches(permission, artifact, permissionStatus); - } - if (printErrorMessage(currentUser, artifacts, permissionStatus, level)) { - break; - } - } - } - } else { - permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled"); - } - - return permissionStatus; - } - - @Override - public PermissionStatus hasArtifactTypePermission(BranchId branch, Collection artifactTypes, PermissionEnum permission, Level level) { - User currentUser = getCurrentUser(); - AccessDataQuery query = getAccessService().getAccessData(currentUser, java.util.Collections.singleton(branch)); - - PermissionStatus permissionStatus = null; - if (!OseeClientProperties.isInDbInit()) { - permissionStatus = new PermissionStatus(); - if (artifactTypes != null) { - for (ArtifactTypeId artifactType : artifactTypes) { - query.branchArtifactTypeMatches(permission, branch, artifactType, permissionStatus); - - if (printErrorMessage(currentUser, artifactTypes, permissionStatus, level)) { - break; - } - } - } - } else { - permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled"); - } - - return permissionStatus; - } - - @Override - public PermissionStatus canRelationBeModified(Artifact subject, Collection toBeRelated, RelationTypeSide relationTypeSide, Level level) { - PermissionStatus subjectPermission = canRelationBeModifiedHelper(subject, null, relationTypeSide, level); - if (subjectPermission.matched() && toBeRelated != null && !toBeRelated.isEmpty()) { - for (Artifact art : toBeRelated) { - RelationSide otherSide = relationTypeSide.getSide().oppositeSide(); - PermissionStatus toBeRelatedPermission = - canRelationBeModifiedHelper(art, null, new RelationTypeSide(relationTypeSide, otherSide), level); - if (!toBeRelatedPermission.matched()) { - return toBeRelatedPermission; - } - } - } - return subjectPermission; - } - - private PermissionStatus canRelationBeModifiedHelper(Artifact subject, Collection toBeRelated, RelationTypeSide relationTypeSide, Level level) { - PermissionStatus status = hasArtifactRelationPermission(java.util.Collections.singleton(subject), - java.util.Collections.singleton(relationTypeSide), PermissionEnum.WRITE, level); - - if (!status.matched()) { - ArrayList artifacts = new ArrayList<>(); - artifacts.add(subject); - if (toBeRelated != null) { - artifacts.addAll(toBeRelated); - } - status = hasArtifactPermission(artifacts, PermissionEnum.WRITE, level); - } - return status; - } - - private PermissionStatus hasArtifactRelationPermission(Collection artifacts, Collection relationTypeSides, PermissionEnum permission, Level level) { - AccessDataQuery query = getAccessService().getAccessData(getCurrentUser(), artifacts); - - PermissionStatus permissionStatus = null; - if (!OseeClientProperties.isInDbInit()) { - permissionStatus = new PermissionStatus(); - if (!OseeClientProperties.isInDbInit()) { - permissionStatus = new PermissionStatus(); - for (ArtifactToken artifact : artifacts) { - for (RelationTypeSide relationTypeSide : relationTypeSides) { - query.relationTypeMatches(permission, artifact, relationTypeSide, permissionStatus); - } - } - } else { - permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled"); - } - } else { - permissionStatus = new PermissionStatus(true, "In DB Init; All permission enabled"); - } - - return permissionStatus; - } - - @Override - public XResultData isDeleteable(Collection artifacts, XResultData results) { - return accessControlService.isDeleteable(artifacts, results); - } - - @Override - public XResultData isRenamable(Collection artifacts, XResultData results) { - return accessControlService.isRenamable(artifacts, results); - } - - @Override - public XResultData isDeleteableRelation(ArtifactToken artifact, RelationTypeToken relationType, XResultData results) { - return accessControlService.isDeleteableRelation(artifact, relationType, results); - } - - @Override - public void ensurePopulated() { - accessControlService.ensurePopulated(); - } -} diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/OseeApiImpl.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/OseeApiImpl.java index 9efe1fea2d..7f32f147e1 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/OseeApiImpl.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/OseeApiImpl.java @@ -11,6 +11,9 @@ package org.eclipse.osee.framework.skynet.core.internal; import org.eclipse.osee.framework.core.OseeApiBase; +import org.eclipse.osee.framework.core.access.IAccessControlService; +import org.eclipse.osee.framework.skynet.core.access.internal.AccessControlServiceImpl; +import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler; /** * @author Donald G. Dunne @@ -19,9 +22,18 @@ public class OseeApiImpl extends OseeApiBase { // for ReviewOsgiXml public void setOrcsTokenService(OrcsTokenService tokenService) // for ReviewOsgiXml public void setJaxRsApi(JaxRsApi jaxRsApi) + IAccessControlService accessControlService; public OseeApiImpl() { // for jas-rs } + @Override + public IAccessControlService getAccessControlService() { + if (accessControlService == null) { + accessControlService = new AccessControlServiceImpl(ConnectionHandler.getJdbcClient(), tokenService()); + } + return accessControlService; + } + } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java index daf919f1a8..2fb4a23c90 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java @@ -14,8 +14,6 @@ package org.eclipse.osee.framework.skynet.core.internal; import java.util.Properties; -import java.util.logging.Level; -import org.eclipse.core.runtime.Platform; import org.eclipse.osee.cache.admin.CacheAdmin; import org.eclipse.osee.framework.core.OrcsTokenService; import org.eclipse.osee.framework.core.client.ClientSessionManager; @@ -23,12 +21,8 @@ import org.eclipse.osee.framework.core.services.IOseeCachingService; import org.eclipse.osee.framework.core.sql.OseeSql; import org.eclipse.osee.framework.core.util.OsgiUtil; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.event.OseeEventService; import org.eclipse.osee.orcs.rest.client.OseeClient; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; public final class ServiceUtil { @@ -65,18 +59,6 @@ public final class ServiceUtil { return getService(OseeClient.class); } - public static AccessPolicy getAccessPolicy() { - try { - Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.access"); - if (bundle.getState() != Bundle.ACTIVE) { - bundle.start(); - } - } catch (BundleException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - return getService(AccessPolicy.class); - } - public static boolean useOracleHints() { return ClientSessionManager.useOracleHints(); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/BootStrapUser.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/BootStrapUser.java index fa4bf3cc2d..119d69ca5e 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/BootStrapUser.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/BootStrapUser.java @@ -22,10 +22,10 @@ import org.eclipse.osee.framework.skynet.core.User; */ public class BootStrapUser extends User { - public static BootStrapUser instance; + private static BootStrapUser instance; private BootStrapUser() { - super(CoreBranches.COMMON); + super(SystemUser.BootStrap.getId(), "guid", CoreBranches.COMMON); } public static BootStrapUser getInstance() { diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/CurrentUserProvider.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/CurrentUserProvider.java index 7bd0372eb9..dabcdc46de 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/CurrentUserProvider.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/users/CurrentUserProvider.java @@ -18,6 +18,8 @@ import java.util.concurrent.FutureTask; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import org.eclipse.osee.cache.admin.Cache; +import org.eclipse.osee.framework.core.access.event.AccessTopicEvent; +import org.eclipse.osee.framework.core.access.event.AccessTopicEventPayload; import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.data.IdeClientSession; import org.eclipse.osee.framework.core.data.UserToken; @@ -31,8 +33,6 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEventPayload; import org.eclipse.osee.framework.skynet.core.internal.Activator; import org.eclipse.osee.jaxrs.JaxRsClient; diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java index 7201b002a6..850e1ad1b7 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java @@ -26,9 +26,7 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.logging.Level; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.osee.framework.core.access.PermissionStatus; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.AttributeId; @@ -39,6 +37,7 @@ import org.eclipse.osee.framework.core.data.OseeCodeVersion; import org.eclipse.osee.framework.core.data.RelationTypeSide; import org.eclipse.osee.framework.core.data.RelationTypeToken; import org.eclipse.osee.framework.core.data.TransactionId; +import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.RelationSide; @@ -48,21 +47,24 @@ import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.core.operation.IOperation; import org.eclipse.osee.framework.core.operation.Operations; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.jdk.core.type.Id; +import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.jdk.core.util.OseeProperties; import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.UserManager; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTransactionData; import org.eclipse.osee.framework.skynet.core.artifact.Attribute; 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.attribute.AttributeTransactionData; -import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; +import org.eclipse.osee.framework.skynet.core.internal.OseeApiService; import org.eclipse.osee.framework.skynet.core.relation.RelationEventType; import org.eclipse.osee.framework.skynet.core.relation.RelationLink; import org.eclipse.osee.framework.skynet.core.relation.RelationTransactionData; @@ -88,9 +90,8 @@ public final class SkynetTransaction extends TransactionOperation { private String comment; private User user; - - private AccessPolicy access; private TransactionRecord transaction; + private static boolean overrideAccess; protected SkynetTransaction(TxMonitor txMonitor, BranchId branch, String comment) { super(txMonitor, branch, comment); @@ -126,10 +127,29 @@ public final class SkynetTransaction extends TransactionOperation { String msg = getCheckAccessError(artifact, txBranch, branch); throw new OseeStateException(msg); } - - checkBranch(artifact); + if (!SkynetTransaction.isOverrideAccess()) { + for (Attribute attr : artifact.getAttributes()) { + if (attr.isDirty()) { + XResultData rd = OseeApiService.get().getAccessControlService().hasAttributeTypePermission( + Collections.singleton(artifact), attr.getAttributeType(), PermissionEnum.WRITE, + AccessControlArtifactUtil.getXResultAccessHeader("Skynet Transaction: " + comment, artifact)); + if (rd.isErrors()) { + throw new OseeCoreException(rd.toString()); + } + } + } + for (RelationLink rel : artifact.getRelationsAll(DeletionFlag.EXCLUDE_DELETED)) { + if (rel.isDirty()) { + XResultData rd = OseeApiService.get().getAccessControlService().hasRelationTypePermission(artifact, + rel.getRelationType(), Collections.emptyList(), PermissionEnum.WRITE, + AccessControlArtifactUtil.getXResultAccessHeader("Skynet Transaction: " + comment, artifact)); + if (rd.isErrors()) { + throw new OseeCoreException(rd.toString()); + } + } + } + } checkNotHistorical(artifact); - getAccess().hasArtifactPermission(Collections.singleton(artifact), PermissionEnum.WRITE, Level.FINE); } public String getCheckAccessError(ArtifactToken artifact, BranchId txBranch, BranchToken branch) { @@ -139,34 +159,6 @@ public final class SkynetTransaction extends TransactionOperation { return msg; } - private void checkBranch(ArtifactToken artifact) { - if (!isBranchWritable(artifact.getBranch())) { - Branch branch = BranchManager.getBranch(artifact.getBranch()); - String msg = getCheckBranchError(artifact, branch); - throw new OseeStateException(msg); - } - } - - public String getCheckBranchError(ArtifactToken artifact, BranchToken branch) { - String msg = String.format("The artifact\n\n%s\n\nis on a non-editable branch\n\n%s\n\n", - artifact.toStringWithId(), branch.toStringWithId()); - return msg; - } - - private void checkBranch(RelationLink link) { - if (!isBranchWritable(link.getBranch())) { - Branch branch = BranchManager.getBranch(link.getBranch()); - String msg = getCheckBranchError(link, branch); - throw new OseeStateException(msg); - } - } - - public String getCheckBranchError(RelationLink link, BranchToken branch) { - String msg = String.format("The relation link\n\n%s\n\nis on a non-editable branch\n\n%s\n\n", link, - branch.toStringWithId()); - return msg; - } - private void checkNotHistorical(Artifact artifact) { if (artifact.isHistorical()) { String msg = getCheckNotHistoricalError(artifact); @@ -180,45 +172,24 @@ public final class SkynetTransaction extends TransactionOperation { return msg; } - private boolean isBranchWritable(BranchId branch) { - boolean toReturn = true; - if (!UserManager.duringMainUserCreation()) { - toReturn = getAccess().hasBranchPermission(branch, PermissionEnum.WRITE, - Level.FINE).matched() && BranchManager.isEditable(branch); - } - return toReturn; - } - private void checkAccess(Artifact artifact, RelationLink link) { if (UserManager.duringMainUserCreation()) { return; } - checkBranch(link); - BranchId txBranch = getBranch(); - if (!link.isOnBranch(txBranch)) { - Branch branch = BranchManager.getBranch(link.getBranch()); - String msg = String.format( - "The relation link\n\n%s\n\nis on branch\n\n%s\n\nbut this transaction is for branch\n\n%s\n\n", - link.getId(), branch.toStringWithId(), txBranch); - throw new OseeStateException(msg); - } - - RelationSide sideToCheck = link.getSide(artifact).oppositeSide(); - PermissionStatus status = getAccess().canRelationBeModified(artifact, null, - new RelationTypeSide(link.getRelationType(), sideToCheck), Level.FINE); - - if (!status.matched()) { - throw new OseeCoreException( - "Access Denied - [%s] does not have valid permission to edit this relation\n itemsToPersist:[%s]\n reason:[%s]", - getAuthor(), link, status.getReason()); - } - } - - private AccessPolicy getAccess() { - if (access == null) { - access = ServiceUtil.getAccessPolicy(); + if (!SkynetTransaction.isOverrideAccess()) { + BranchId txBranch = getBranch(); + if (!link.isOnBranch(txBranch)) { + RelationSide sideToCheck = link.getSide(artifact).oppositeSide(); + RelationTypeSide relTypeSide = new RelationTypeSide(link.getRelationType(), sideToCheck); + XResultData rd = + OseeApiService.get().getAccessControlService().hasRelationTypePermission(artifact, relTypeSide, null, + PermissionEnum.WRITE, AccessControlArtifactUtil.getXResultAccessHeader("Relation Access Denied", + Collections.singleton(artifact), relTypeSide)); + if (rd.isErrors()) { + throw new OseeCoreException(rd.toString()); + } + } } - return access; } private Collection getTransactionData() { @@ -270,7 +241,9 @@ public final class SkynetTransaction extends TransactionOperation { } return; } - checkAccess(artifact); + if (!SkynetTransaction.isOverrideAccess()) { + checkAccess(artifact); + } setTxState(TxState.MODIFIED); if (!artifact.isInDb() || artifact.hasDirtyArtifactType() || artifact.getModType().isDeleted() || artifact.getModType() == REPLACED_WITH_VERSION || artifact.isUseBackingdata()) { @@ -350,7 +323,9 @@ public final class SkynetTransaction extends TransactionOperation { private void addRelation(Artifact artifact, RelationLink link) { synchronized (getTxMonitor()) { - checkAccess(artifact, link); + if (!SkynetTransaction.isOverrideAccess()) { + checkAccess(artifact, link); + } setTxState(TxState.MODIFIED); link.setNotDirty(); @@ -471,4 +446,16 @@ public final class SkynetTransaction extends TransactionOperation { getTxMonitor().cancel(getBranch(), this); } + public static boolean isOverrideAccess() { + return overrideAccess; + } + + public static void setOverrideAccess(boolean overrideAccess) { + if (OseeProperties.isInTest()) { + SkynetTransaction.overrideAccess = overrideAccess; + } else { + throw new OseeArgumentException("Access Control can not be overridden in production"); + } + } + } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Artifacts.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Artifacts.java index 3e8d8ff0b8..ae9dfb7aa6 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Artifacts.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Artifacts.java @@ -180,4 +180,13 @@ public final class Artifacts { strB.append(RelationManager.reportHasDirtyLinks(artifact)); return strB.toString(); } + + public static Object toStringWithIds(Collection artifacts) { + StringBuilder sb = new StringBuilder(); + for (ArtifactToken art : artifacts) { + sb.append(art.toStringWithId()); + sb.append(", "); + } + return sb.toString().replaceFirst(", $", ""); + } } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.data.model.editor/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.data.model.editor/META-INF/MANIFEST.MF index a9e3eb1527..a62f1c5977 100644 --- a/plugins/org.eclipse.osee.framework.ui.data.model.editor/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.ui.data.model.editor/META-INF/MANIFEST.MF @@ -33,7 +33,6 @@ Import-Package: org.eclipse.core.commands, org.eclipse.graphiti.util, org.eclipse.jface.resource, org.eclipse.osee.framework.core.data, - org.eclipse.osee.framework.core.dsl.oseeDsl, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.enums.token, org.eclipse.osee.framework.core.exception, diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet.test/META-INF/MANIFEST.MF index d86cc2c036..6e58f10b6d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet.test/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/META-INF/MANIFEST.MF @@ -10,7 +10,6 @@ Export-Package: org.eclipse.osee.framework.ui.skynet Import-Package: org.eclipse.nebula.widgets.xviewer.core.model, org.apache.cxf.jaxrs.client, org.apache.cxf.jaxrs.client.spec, - org.eclipse.osee.framework.access, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.enums.token, org.eclipse.osee.framework.jdk.core.util.windows, diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/AllUiSkynetJunitTestSuite.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/AllUiSkynetJunitTestSuite.java index db3d6d1b1d..396875c3e9 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/AllUiSkynetJunitTestSuite.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/AllUiSkynetJunitTestSuite.java @@ -13,7 +13,6 @@ package org.eclipse.osee.framework.ui.skynet; -import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTestSuite; import org.eclipse.osee.framework.ui.skynet.renderer.RendererTestSuite; import org.eclipse.osee.framework.ui.skynet.results.ResultsTestSuite; import org.eclipse.osee.framework.ui.skynet.util.UtilTestSuite; @@ -24,7 +23,6 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ - ArtifactTestSuite.class, RendererTestSuite.class, ResultsTestSuite.class, UtilTestSuite.class, diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPromptChangeTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPromptChangeTest.java deleted file mode 100644 index e8b92acafc..0000000000 --- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPromptChangeTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/********************************************************************* - * Copyright (c) 2004, 2007 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.ui.skynet.artifact; - -import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Annotation; -import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Name; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.logging.Level; -import org.eclipse.osee.framework.core.access.PermissionStatus; -import org.eclipse.osee.framework.core.data.ArtifactToken; -import org.eclipse.osee.framework.core.data.ArtifactTypeId; -import org.eclipse.osee.framework.core.data.AttributeTypeId; -import org.eclipse.osee.framework.core.data.AttributeTypeToken; -import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.RelationTypeSide; -import org.eclipse.osee.framework.core.data.RelationTypeToken; -import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.jdk.core.result.XResultData; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.ui.skynet.artifact.prompt.IHandlePromptChange; -import org.eclipse.osee.framework.ui.skynet.artifact.prompt.IPromptFactory; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test Case for {@link ArtifactPromptChange} - * - * @author Jeff C. Phillips - */ -public class ArtifactPromptChangeTest { - - @Test - public void test() { - boolean persist = true; - List artifacts = new ArrayList<>(); - - MockPromptFactory MockPromptFactory = new MockPromptFactory(); - AccessPolicy policyHandler = new MockAccessPolicyHandler(); - MockPromptFactory.createPrompt(Annotation, "", artifacts, persist, false); - - ArtifactPrompt artifactPromptChange = new ArtifactPrompt(MockPromptFactory, policyHandler); - - Assert.assertFalse(artifactPromptChange.promptChangeAttribute(Annotation, artifacts, persist, false)); - Assert.assertTrue(artifactPromptChange.promptChangeAttribute(Name, artifacts, persist, false)); - } - - private static class MockAccessPolicyHandler implements AccessPolicy { - - @Override - public PermissionStatus hasArtifactTypePermission(BranchId branch, Collection artifactTypes, PermissionEnum permission, Level level) { - return new PermissionStatus(); - } - - @Override - public boolean isReadOnly(Artifact artifact) { - return false; - } - - @Override - public PermissionStatus hasBranchPermission(BranchId branch, PermissionEnum permission, Level level) { - return new PermissionStatus(); - } - - @Override - public PermissionStatus hasAttributeTypePermission(Collection artifacts, AttributeTypeId attributeType, PermissionEnum permission, Level level) { - return new PermissionStatus(); - } - - @Override - public PermissionStatus hasArtifactPermission(Collection artifacts, PermissionEnum permission, Level level) { - return new PermissionStatus(); - } - - @Override - public PermissionStatus canRelationBeModified(Artifact subject, Collection toBeRelated, RelationTypeSide relationTypeSide, Level level) { - return new PermissionStatus(); - } - - @Override - public void removePermissions(BranchId branch) { - // - } - - @Override - public XResultData isDeleteable(Collection artifacts, XResultData results) { - return new XResultData(); - } - - @Override - public XResultData isRenamable(Collection artifacts, XResultData results) { - return new XResultData(); - } - - @Override - public XResultData isDeleteableRelation(ArtifactToken artifact, RelationTypeToken relationType, XResultData results) { - return new XResultData(); - } - - @Override - public void ensurePopulated() { - // do nothing - } - - } - - private static class MockPromptFactory implements IPromptFactory { - @Override - public IHandlePromptChange createPrompt(AttributeTypeToken attributeType, String displayName, Collection artifacts, boolean persist, boolean multiLine) { - return new TestPromptChange(attributeType, persist); - } - } - private static class TestPromptChange implements IHandlePromptChange { - private final AttributeTypeId attributeType; - private final boolean persist; - - public TestPromptChange(AttributeTypeId attributeType, boolean persist) { - super(); - this.attributeType = attributeType; - this.persist = persist; - } - - @Override - public boolean promptOk() { - return true; - } - - @Override - public boolean store() { - return persist && attributeType.equals(Name); - } - } -} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactTestSuite.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactTestSuite.java deleted file mode 100644 index 1e5e9c37e4..0000000000 --- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactTestSuite.java +++ /dev/null @@ -1,26 +0,0 @@ -/********************************************************************* - * Copyright (c) 2012 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.ui.skynet.artifact; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ArtifactPromptChangeTest.class}) -/** - * @author Roberto E. Escobar - */ -public class ArtifactTestSuite { - // Test Suite -} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF index a36d3a2676..f0ae4f7cba 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF @@ -10,8 +10,6 @@ Service-Component: OSGI-INF/*.xml Bundle-Vendor: Eclipse Open System Engineering Environment Import-Package: com.fasterxml.jackson.core.type, com.fasterxml.jackson.databind, - org.apache.cxf.jaxrs.client, - org.apache.cxf.jaxrs.client.spec, com.google.common.base, com.google.common.cache, com.google.common.collect, @@ -27,6 +25,8 @@ Import-Package: com.fasterxml.jackson.core.type, org.apache.commons.io, org.apache.commons.lang, org.apache.commons.lang.mutable, + org.apache.cxf.jaxrs.client, + org.apache.cxf.jaxrs.client.spec, org.eclipse.compare, org.eclipse.compare.structuremergeviewer, org.eclipse.core.commands, @@ -68,9 +68,10 @@ Import-Package: com.fasterxml.jackson.core.type, org.eclipse.osee.account.rest.model, org.eclipse.osee.ats.api.data, org.eclipse.osee.define.api, - org.eclipse.osee.framework.access, org.eclipse.osee.framework.core, org.eclipse.osee.framework.core.access, + org.eclipse.osee.framework.core.access.event, + org.eclipse.osee.framework.core.access.object, org.eclipse.osee.framework.core.client, org.eclipse.osee.framework.core.client.server, org.eclipse.osee.framework.core.data, diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/OSGI-INF/access.control.service.ref.xml b/plugins/org.eclipse.osee.framework.ui.skynet/OSGI-INF/access.control.service.ref.xml deleted file mode 100644 index e553ff6084..0000000000 --- a/plugins/org.eclipse.osee.framework.ui.skynet/OSGI-INF/access.control.service.ref.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/OSGI-INF/artifact.prompt.change.xml b/plugins/org.eclipse.osee.framework.ui.skynet/OSGI-INF/artifact.prompt.change.xml deleted file mode 100644 index c94091ad49..0000000000 --- a/plugins/org.eclipse.osee.framework.ui.skynet/OSGI-INF/artifact.prompt.change.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactContentProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactContentProvider.java index e4bdcfdb9b..4b94a11142 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactContentProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactContentProvider.java @@ -24,7 +24,6 @@ import org.eclipse.jface.viewers.IContentProvider; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.enums.PermissionEnum; @@ -34,6 +33,7 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactChangeListener; import org.eclipse.osee.framework.skynet.core.relation.RelationLink; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.explorer.ArtifactExplorerLinkNode; import org.eclipse.osee.framework.ui.skynet.internal.Activator; @@ -86,7 +86,8 @@ public class ArtifactContentProvider implements ITreeContentProvider, ArtifactCh if (parentElement instanceof Artifact) { Artifact parentItem = (Artifact) parentElement; try { - if (AccessControlManager.hasPermission(parentItem, PermissionEnum.READ)) { + if (OseeApiService.get().getAccessControlService().hasArtifactPermission(parentItem, PermissionEnum.READ, + null).isSuccess()) { Collection children = parentItem.getChildren(); List relationsAll = parentItem.getRelationsAll(DeletionFlag.EXCLUDE_DELETED); List allChildren = new ArrayList<>(); @@ -180,7 +181,8 @@ public class ArtifactContentProvider implements ITreeContentProvider, ArtifactCh if (element instanceof Artifact) { Artifact artifact = (Artifact) element; try { - if (AccessControlManager.hasPermission(artifact, PermissionEnum.READ)) { + if (OseeApiService.get().getAccessControlService().hasArtifactPermission(artifact, PermissionEnum.READ, + null).isSuccess()) { if (artifact.isDeleted()) { return false; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactImageManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactImageManager.java index 76b40bc24d..1aaa806316 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactImageManager.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactImageManager.java @@ -21,7 +21,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.model.change.ChangeIgnoreType; @@ -35,6 +34,7 @@ import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.skynet.core.conflict.ArtifactConflict; import org.eclipse.osee.framework.skynet.core.conflict.AttributeConflict; import org.eclipse.osee.framework.skynet.core.conflict.Conflict; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.annotation.ArtifactAnnotation; import org.eclipse.osee.framework.ui.skynet.artifact.annotation.AttributeAnnotationManager; import org.eclipse.osee.framework.ui.skynet.internal.Activator; @@ -300,7 +300,7 @@ public final class ArtifactImageManager { } else { KeyedImage imageKey = getArtifactTypeImage(type); if (imageKey != null) { - if (AccessControlManager.hasLock(artifact)) { + if (OseeApiService.get().getAccessControlService().hasLock(artifact)) { return getLockedImage(imageKey, artifact); } return ImageManager.setupImage(imageKey); @@ -318,7 +318,7 @@ public final class ArtifactImageManager { try { baseImageEnum = BaseImage.getBaseImageEnum(artifact); - if (AccessControlManager.hasLock(artifact)) { + if (OseeApiService.get().getAccessControlService().hasLock(artifact)) { return getLockedImage(baseImageEnum, artifact); } @@ -335,7 +335,7 @@ public final class ArtifactImageManager { private static String getLockedImage(KeyedImage baseImageEnum, Artifact artifact) { KeyedImage locked = FrameworkImage.LOCKED_NO_ACCESS; - if (AccessControlManager.hasLockAccess(artifact)) { + if (OseeApiService.get().getAccessControlService().isReadOnly(artifact)) { locked = FrameworkImage.LOCKED_WITH_ACCESS; } return ImageManager.setupImageWithOverlay(baseImageEnum, locked, Location.TOP_LEFT).getImageKey(); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/FrameworkImage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/FrameworkImage.java index ea4457e8b4..c6b00fe650 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/FrameworkImage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/FrameworkImage.java @@ -145,6 +145,7 @@ public enum FrameworkImage implements KeyedImage { LINK("link.gif"), LOAD("load.gif"), LOCKED("lock.gif"), + LOCK_DETAILS("lock_details.gif"), LOCK_LOCKED("lock_locked.gif"), LOCK_UNLOCKED("lock_unlocked.gif"), LOCK_OVERLAY("lock_overlay.gif"), diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationCellModifier.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationCellModifier.java index 07c41826e6..f274e64fb1 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationCellModifier.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationCellModifier.java @@ -18,14 +18,14 @@ import java.util.logging.Level; import org.eclipse.jface.viewers.ICellModifier; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.osee.framework.core.data.RelationTypeSide; +import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.relation.RelationLink; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.swt.IDirtiableEditor; import org.eclipse.swt.widgets.Item; @@ -45,22 +45,12 @@ public class RelationCellModifier implements ICellModifier { public boolean canModify(Object element, String property) { if (element instanceof WrapperForRelationLink) { WrapperForRelationLink relLink = (WrapperForRelationLink) element; - RelationTypeSide rts = new RelationTypeSide(relLink.getRelationType(), relLink.getRelationSide()); - boolean canModify = false; - AccessPolicy policyHandlerService = null; - try { - policyHandlerService = ServiceUtil.getAccessPolicy(); - } catch (OseeCoreException ex1) { - OseeLog.log(Activator.class, Level.SEVERE, ex1); - } - if (policyHandlerService != null) { - try { - canModify = policyHandlerService.canRelationBeModified(relLink.getArtifactA(), - Arrays.asList(relLink.getArtifactB()), rts, Level.INFO).matched(); - } catch (OseeCoreException ex) { - canModify = false; - } - } + RelationTypeSide relationTypeSide = new RelationTypeSide(relLink.getRelationType(), relLink.getRelationSide()); + + boolean canModify = + OseeApiService.get().getAccessControlService().hasRelationTypePermission(relLink.getArtifactA(), + relationTypeSide, Arrays.asList(relLink.getArtifactB()), PermissionEnum.WRITE, null).isSuccess(); + return canModify; } return false; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationLabelProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationLabelProvider.java index c45d951754..501070722b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationLabelProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationLabelProvider.java @@ -13,23 +13,23 @@ package org.eclipse.osee.framework.ui.skynet; +import java.util.Collections; import java.util.logging.Level; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.osee.framework.core.access.PermissionStatus; import org.eclipse.osee.framework.core.data.RelationTypeSide; import org.eclipse.osee.framework.core.data.RelationTypeToken; +import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.RelationSide; import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.relation.RelationLink; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.swt.graphics.Image; @@ -65,12 +65,11 @@ public class RelationLabelProvider implements ITableLabelProvider, ILabelProvide private boolean isLocked(RelationTypeSide relationTypeSide) { boolean isLocked = true; - AccessPolicy policyHandlerService; try { - policyHandlerService = ServiceUtil.getAccessPolicy(); - PermissionStatus permissionStatus = - policyHandlerService.canRelationBeModified(artifact, null, relationTypeSide, Level.FINE); - isLocked = !permissionStatus.matched(); + + boolean hasPermission = OseeApiService.get().getAccessControlService().hasRelationTypePermission(artifact, + relationTypeSide, Collections.emptyList(), PermissionEnum.WRITE, null).isSuccess(); + isLocked = !hasPermission; } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationSkynetDragAndDrop.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationSkynetDragAndDrop.java index e41efb974b..ddf5cee9dd 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationSkynetDragAndDrop.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationSkynetDragAndDrop.java @@ -15,9 +15,11 @@ package org.eclipse.osee.framework.ui.skynet; import java.io.File; import java.net.URI; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.LinkedList; +import java.util.List; import java.util.logging.Level; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.IJobChangeEvent; @@ -28,6 +30,7 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.osee.framework.core.data.RelationTypeSide; import org.eclipse.osee.framework.core.data.RelationTypeToken; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; +import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.RelationSide; import org.eclipse.osee.framework.core.operation.AbstractOperation; import org.eclipse.osee.framework.core.operation.IOperation; @@ -35,15 +38,14 @@ import org.eclipse.osee.framework.core.operation.Operations; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactData; import org.eclipse.osee.framework.skynet.core.importing.parsers.HandleImport; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; import org.eclipse.osee.framework.skynet.core.relation.RelationTypeSideSorter; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer; import org.eclipse.osee.framework.ui.skynet.internal.Activator; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.relation.explorer.RelationExplorerWindow; import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop; import org.eclipse.osee.framework.ui.swt.Displays; @@ -117,36 +119,38 @@ public final class RelationSkynetDragAndDrop extends SkynetDragAndDrop { if (selected != null && selected.getData() instanceof RelationTypeSideSorter) { ArtifactTransfer artTransfer = ArtifactTransfer.getInstance(); FileTransfer fileTransfer = FileTransfer.getInstance(); - RelationTypeSideSorter data = (RelationTypeSideSorter) selected.getData(); + RelationTypeSideSorter relTypeSorter = (RelationTypeSideSorter) selected.getData(); if (artTransfer.isSupportedType(event.currentDataType)) { try { ArtifactData artData = artTransfer.nativeToJava(event.currentDataType); - Artifact[] selectedArtifacts = artData.getArtifacts(); + List relatedArts = new ArrayList(); + for (Artifact relatedArt : artData.getArtifacts()) { + relatedArts.add(relatedArt); + } + String toolTipText = ""; - Artifact relationArtifact = data.getArtifact(); + Artifact relationArtifact = relTypeSorter.getArtifact(); boolean canRelate = false; - for (Artifact i : selectedArtifacts) { - Artifact sideA = i; + for (Artifact art : relatedArts) { + Artifact sideA = art; Artifact sideB = relationArtifact; - if (data.getSide() == RelationSide.SIDE_B) { + if (relTypeSorter.getSide() == RelationSide.SIDE_B) { sideA = relationArtifact; - sideB = i; + sideB = art; } - canRelate = ensureRelationCanBeAdded(data.getRelationType(), sideA, sideB); + canRelate = ensureRelationCanBeAdded(relTypeSorter.getRelationType(), sideA, sideB); if (!canRelate) { toolTipText += String.format("Relation: [%s] \n\tcannot be added to [%s]\n\tof [%s]\n", - i.getName(), data.getSide().name(), data.getRelationType().getName()); + art.getName(), relTypeSorter, relTypeSorter.getRelationType().getName()); } } - AccessPolicy policyHandlerService = ServiceUtil.getAccessPolicy(); - - boolean matched = policyHandlerService.canRelationBeModified(artifact, Arrays.asList(selectedArtifacts), - data, Level.INFO).matched(); + boolean hadPermission = OseeApiService.get().getAccessControlService().hasRelationTypePermission(artifact, + relTypeSorter, relatedArts, PermissionEnum.WRITE, null).isSuccess(); - if (matched) { + if (canRelate) { event.detail = DND.DROP_COPY; tree.setInsertMark(null, false); } else { @@ -154,7 +158,7 @@ public final class RelationSkynetDragAndDrop extends SkynetDragAndDrop { toolTipText += "Access: Access Control has prevented this relation"; } - if (!matched || !canRelate) { + if (!hadPermission || !canRelate) { getErrorToolTip().setText("RELATION ERROR"); getErrorToolTip().setMessage(toolTipText); getErrorToolTip().setVisible(true); @@ -164,29 +168,33 @@ public final class RelationSkynetDragAndDrop extends SkynetDragAndDrop { } } else if (fileTransfer.isSupportedType(event.currentDataType)) { - RelationTypeToken relationType = data.getRelationType(); + RelationTypeToken relationType = relTypeSorter.getRelationType(); if (relationType.equals(CoreRelationTypes.Verification_Verifier) || relationType.equals( CoreRelationTypes.Uses_TestUnit)) { - AccessPolicy policyHandlerService = null; - try { - policyHandlerService = ServiceUtil.getAccessPolicy(); - } catch (OseeCoreException ex1) { - OseeLog.log(Activator.class, Level.SEVERE, ex1); + RelationTypeSide relTypeSide = null; + if (relationType.equals(CoreRelationTypes.Verification_Verifier)) { + relTypeSide = CoreRelationTypes.Verification_Verifier; + } else { + relTypeSide = CoreRelationTypes.Verification_Verifier; } - boolean matched = false; - if (policyHandlerService != null) { - try { - matched = policyHandlerService.canRelationBeModified(artifact, null, data, Level.INFO).matched(); - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } + ArtifactData artData = artTransfer.nativeToJava(event.currentDataType); + List relatedArts = new ArrayList(); + for (Artifact relatedArt : artData.getArtifacts()) { + relatedArts.add(relatedArt); } + Artifact artifact = relTypeSorter.getArtifact(); - if (matched) { + boolean hasPermission = false; + try { + hasPermission = OseeApiService.get().getAccessControlService().hasRelationTypePermission(artifact, + relTypeSide, relatedArts, PermissionEnum.WRITE, null).isSuccess(); + } catch (OseeCoreException ex) { + OseeLog.log(Activator.class, Level.SEVERE, ex); + } + if (hasPermission) { event.detail = DND.DROP_COPY; } } - } } else if (selected != null && selected.getData() instanceof WrapperForRelationLink) { @@ -195,18 +203,19 @@ public final class RelationSkynetDragAndDrop extends SkynetDragAndDrop { Object obj = selection.getFirstElement(); if (obj instanceof WrapperForRelationLink) { WrapperForRelationLink dropTarget = (WrapperForRelationLink) obj; - boolean matched = false; + boolean hasPermission = false; try { - AccessPolicy policyHandlerService = ServiceUtil.getAccessPolicy(); RelationTypeSide rts = new RelationTypeSide(dropTarget.getRelationType(), dropTarget.getRelationSide()); + List related = Arrays.asList( + artifact.equals(dropTarget.getArtifactA()) ? dropTarget.getArtifactB() : dropTarget.getArtifactA()); + + hasPermission = OseeApiService.get().getAccessControlService().hasRelationTypePermission(artifact, rts, + related, PermissionEnum.WRITE, null).isSuccess(); - matched = policyHandlerService.canRelationBeModified(artifact, Arrays.asList( - artifact.equals(dropTarget.getArtifactA()) ? dropTarget.getArtifactB() : dropTarget.getArtifactA()), - rts, Level.INFO).matched(); } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } - if (!matched) { + if (!hasPermission) { event.detail = DND.DROP_NONE; getErrorToolTip().setText("MOVE ERROR"); getErrorToolTip().setMessage("Access Control has restricted this action."); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java index 3359144cc5..1d3766c8d4 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java @@ -34,6 +34,7 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.osee.framework.core.OrcsTokenService; import org.eclipse.osee.framework.core.data.RelationTypeSide; import org.eclipse.osee.framework.core.data.RelationTypeToken; +import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; import org.eclipse.osee.framework.core.enums.RelationSorter; import org.eclipse.osee.framework.help.ui.OseeHelpContext; @@ -41,7 +42,6 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Collections; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ISelectedArtifacts; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; @@ -49,6 +49,7 @@ import org.eclipse.osee.framework.skynet.core.relation.RelationTypeSideSorter; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; import org.eclipse.osee.framework.ui.skynet.RelationOrderContributionItem.SelectionListener; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; @@ -395,15 +396,15 @@ public class RelationsComposite extends Composite implements ISelectedArtifacts if (selection.getFirstElement() instanceof WrapperForRelationLink) { WrapperForRelationLink data = (WrapperForRelationLink) selection.getFirstElement(); - AccessPolicy policyHandlerService; try { - policyHandlerService = ServiceUtil.getAccessPolicy(); - RelationTypeSide rts = new RelationTypeSide(data.getRelationType(), data.getRelationSide()); - valid = policyHandlerService.canRelationBeModified(artifact, - java.util.Collections.singleton( - data.getArtifactA().equals(artifact) ? data.getArtifactB() : data.getArtifactA()), - rts, Level.INFO).matched(); + RelationTypeSide relationTypeSide = new RelationTypeSide(data.getRelationType(), data.getRelationSide()); + Set relArts = java.util.Collections.singleton( + data.getArtifactA().equals(artifact) ? data.getArtifactB() : data.getArtifactA()); + + valid = OseeApiService.get().getAccessControlService().hasRelationTypePermission(artifact, relationTypeSide, + relArts, PermissionEnum.WRITE, null).isSuccess(); + } catch (OseeCoreException ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } @@ -553,11 +554,8 @@ public class RelationsComposite extends Composite implements ISelectedArtifacts artifacts.add(group.getArtifact()); } - AccessPolicy policyHandlerService = ServiceUtil.getAccessPolicy(); - - hasPermission = - policyHandlerService.canRelationBeModified(toCheck, artifacts, relationTypeSide, Level.INFO).matched(); - + hasPermission = OseeApiService.get().getAccessControlService().hasRelationTypePermission(toCheck, relationTypeSide, + artifacts, PermissionEnum.WRITE, null).isSuccess(); } catch (OseeCoreException ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SessionContributionItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SessionContributionItem.java index 11695ec7ae..44620f74fb 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SessionContributionItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SessionContributionItem.java @@ -17,13 +17,13 @@ import java.util.logging.Level; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osee.framework.core.access.event.AccessTopicEvent; +import org.eclipse.osee.framework.core.access.event.AccessTopicEventPayload; import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEventPayload; import org.eclipse.osee.framework.ui.plugin.OseeStatusContributionItem; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.dialogs.AuthenticationDialog; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/AccessControlService.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/AccessControlService.java deleted file mode 100644 index 574c63ad9f..0000000000 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/AccessControlService.java +++ /dev/null @@ -1,33 +0,0 @@ -/********************************************************************* - * Copyright (c) 2014 Boeing - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Boeing - initial API and implementation - **********************************************************************/ - -package org.eclipse.osee.framework.ui.skynet.access; - -import org.eclipse.osee.framework.core.access.IAccessControlService; - -/** - * @author Donald G. Dunne - */ -public class AccessControlService { - - private static IAccessControlService accessService; - - public static IAccessControlService getAccessService() { - return accessService; - } - - public void setAccessService(IAccessControlService accessService) { - AccessControlService.accessService = accessService; - } - -} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyContentProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyContentProvider.java index 76e7f5b076..0f345d101a 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyContentProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyContentProvider.java @@ -18,16 +18,17 @@ import java.util.Collection; import java.util.Map; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.osee.framework.access.AccessControlData; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.access.AccessControlData; +import org.eclipse.osee.framework.core.data.ArtifactToken; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; public class PolicyContentProvider implements ITreeContentProvider { - private final Map accessControlList; + private final Map accessControlList; private final Collection deleteControlList; private final Object accessControlledObject; - public PolicyContentProvider(Map accessControlList, Object accessControlledObject, Collection deleteControlList) { + public PolicyContentProvider(Map accessControlList, Object accessControlledObject, Collection deleteControlList) { this.accessControlList = accessControlList; this.accessControlledObject = accessControlledObject; this.deleteControlList = deleteControlList; @@ -46,16 +47,17 @@ public class PolicyContentProvider implements ITreeContentProvider { @Override public Object[] getElements(Object object) { - Collection data = AccessControlManager.getAccessControlList(accessControlledObject); + Collection data = + OseeApiService.get().getAccessControlService().getAccessControlList(accessControlledObject); for (AccessControlData entry : data) { if (!deleteControlList.contains(entry)) { - accessControlList.put(entry.getSubject().getGuid(), entry); + accessControlList.put(entry.getSubject(), entry); } } - AccessControlData lockData = AccessControlManager.getAccessControlForLock(accessControlledObject); - if (lockData != null) { - accessControlList.put(lockData.getSubject().getGuid(), lockData); + for (AccessControlData lockData : OseeApiService.get().getAccessControlService().getAccessControlList( + accessControlledObject)) { + accessControlList.put(lockData.getSubject(), lockData); } Object[] accessControlListArray = accessControlList.values().toArray(); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyDialog.java index 489732ed8b..11af8eeed9 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyDialog.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyDialog.java @@ -20,27 +20,35 @@ import java.util.List; import java.util.logging.Level; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.osee.framework.access.AccessControlData; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.access.AccessControlData; +import org.eclipse.osee.framework.core.access.event.AccessArtifactLockTopicEvent; +import org.eclipse.osee.framework.core.access.event.AccessTopicEvent; +import org.eclipse.osee.framework.core.access.object.AccessObject; +import org.eclipse.osee.framework.core.access.object.ArtifactAccessObject; +import org.eclipse.osee.framework.core.access.object.BranchAccessObject; import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.BranchToken; -import org.eclipse.osee.framework.core.data.IUserGroup; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.jdk.core.result.XResultData; +import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.UserManager; -import org.eclipse.osee.framework.skynet.core.access.UserGroupService; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; 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.model.AccessArtifactLockTopicEvent; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; +import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI; import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.osee.framework.ui.swt.FontManager; +import org.eclipse.osee.framework.ui.swt.HyperLinkLabel; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -50,8 +58,10 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; /** @@ -65,39 +75,47 @@ public class PolicyDialog extends Dialog { private Button chkChildrenPermission; private Combo userCombo; private Combo permissionLevelCombo; - private final Object accessControlledObject; - private Label accessLabel, objectLabel; + private final AccessObject accessControlledObject; + private Label accessErrorLabel, accessTitleLabel; private final Shell parentShell; - Boolean isArtifactLockedBeforeDialog = null; + Boolean isArtifactLockedBeforeDialog; + private XResultData accessModifyEnabled; - public PolicyDialog(Shell parentShell, Object accessControlledObject) { + public PolicyDialog(Shell parentShell, AccessObject accessControlledObject) { super(parentShell); this.parentShell = parentShell; this.accessControlledObject = accessControlledObject; setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | getDefaultOrientation() | SWT.RESIZE); } + public static PolicyDialog createPolicyDialog(Shell activeShell, Object object) { + if (object instanceof ArtifactToken) { + return new PolicyDialog(activeShell, ArtifactAccessObject.valueOf((ArtifactToken) object)); + } else if (object instanceof BranchToken) { + return new PolicyDialog(activeShell, BranchAccessObject.valueOf((BranchToken) object)); + } + throw new OseeArgumentException("Unhandled object %", object); + } + @Override protected Control createDialogArea(Composite parent) { - getShell().setText("Access Control List: " + getHeaderName(accessControlledObject)); + final String title = "Access Control for " + (accessControlledObject.isArtifact() ? "Artifact" : "Branch"); + getShell().setText(title); Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setFont(parent.getFont()); mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); mainComposite.setLayout(new GridLayout(1, false)); - accessLabel = new Label(mainComposite, SWT.NONE); - accessLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED)); + createTitleComp(mainComposite, title); + + accessErrorLabel = new Label(mainComposite, SWT.NONE); + accessErrorLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED)); Group group = new Group(mainComposite, SWT.NULL); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); group.setLayout(new GridLayout(1, false)); - // Setup policy table - objectLabel = new Label(group, SWT.NONE); - objectLabel.setText( - String.format("Access Control for [%s]", Strings.truncate(accessControlledObject.toString(), 70))); - policyTableViewer = new PolicyTableViewer(group, accessControlledObject); // Create Input Widgets @@ -136,13 +154,46 @@ public class PolicyDialog extends Dialog { checkEnabled(); setMaxModificationLevel(); - if (accessControlledObject instanceof Artifact) { - isArtifactLockedBeforeDialog = AccessControlManager.hasLock((Artifact) accessControlledObject); + if (accessControlledObject instanceof ArtifactAccessObject) { + isArtifactLockedBeforeDialog = OseeApiService.get().getAccessControlService().hasLock( + ((ArtifactAccessObject) accessControlledObject).getArtifact()); } return mainComposite; } + private void createTitleComp(Composite parent, final String title) { + Composite titleComposite = new Composite(parent, SWT.NONE); + titleComposite.setFont(parent.getFont()); + titleComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + titleComposite.setLayout(new GridLayout(2, false)); + + accessTitleLabel = new Label(titleComposite, SWT.NONE); + accessTitleLabel.setText(String.format("Access Control for %s\nUser %s", + Strings.truncate(accessControlledObject.toString(), 70), UserManager.getUser().toStringWithId())); + accessTitleLabel.setFont(FontManager.getCourierNew12Bold()); + + HyperLinkLabel edit = new HyperLinkLabel(titleComposite, SWT.None); + edit.setText(" Show Access Details"); + edit.addListener(SWT.MouseUp, new Listener() { + + @Override + public void handleEvent(Event event) { + XResultData rd = null; + String useTitle = "Modify " + title; + if (accessControlledObject.isArtifact()) { + rd = AccessControlArtifactUtil.getXResultAccessHeader(useTitle, + (Artifact) ((ArtifactAccessObject) accessControlledObject).getArtifact()); + } else { + rd = AccessControlArtifactUtil.getXResultAccessHeader(useTitle, accessControlledObject.getBranch()); + } + rd.addRaw(accessModifyEnabled.toString()); + XResultDataUI.report(rd, useTitle); + close(); + } + }); + } + private void populateInputWidgets() { // Setup permissions combo @@ -207,26 +258,29 @@ public class PolicyDialog extends Dialog { } private void setMaxModificationLevel() { - PermissionEnum permission = AccessControlManager.getPermission(accessControlledObject); + PermissionEnum permission = null; + if (accessControlledObject.isArtifact()) { + permission = OseeApiService.get().getAccessControlService().getPermission( + ((ArtifactAccessObject) accessControlledObject).getArtifact()); + } else if (accessControlledObject.isBranch()) { + permission = OseeApiService.get().getAccessControlService().getPermission( + ((BranchAccessObject) accessControlledObject).getBranch()); + } else { + throw new OseeArgumentException("Unhandled object %s", accessControlledObject); + } policyTableViewer.setMaxModificationLevel(permission); } private void checkEnabled() { - boolean isAccessEnabled = isAddAccessEnabled(); - boolean isModifyEnabled = isModifyAccessEnabled(); + boolean isAccessEnabled = isAccessEnabled(); String displayText = ""; if (!isAccessEnabled) { - displayText = "You do not have permissions to add/delete users"; - if (!isModifyEnabled) { - displayText += " or modify access"; - } - } else if (!isModifyEnabled) { displayText = "You do not have permissions to modify access"; } - accessLabel.setText(displayText); - boolean isArtifact = accessControlledObject instanceof Artifact; + accessErrorLabel.setText(displayText); + boolean isArtifact = accessControlledObject.isArtifact(); userCombo.setEnabled(isAccessEnabled); permissionLevelCombo.setEnabled(isAccessEnabled); @@ -236,35 +290,18 @@ public class PolicyDialog extends Dialog { } private boolean isAccessEnabled() { - return isModifyAccessEnabled() || isAddAccessEnabled(); - } - - private boolean isModifyAccessEnabled() { - return isAccessEnabled(PermissionEnum.USER_LOCK); - } - - private boolean isAddAccessEnabled() { - return isAccessEnabled(PermissionEnum.FULLACCESS); - } - - private boolean isAccessEnabled(PermissionEnum permission) { - boolean enabled; - try { - IUserGroup oseeAccessGroup = UserGroupService.getOseeAccessAdmin(); - boolean isOseeAccessAdmin = oseeAccessGroup.isCurrentUserMember(); - boolean objectHasAccessSet = !policyTableViewer.getAccessControlList().isEmpty(); - if (isOseeAccessAdmin) { - enabled = true; - } else if (objectHasAccessSet) { - enabled = AccessControlManager.hasPermission(accessControlledObject, permission); - } else { - enabled = false; - } - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - enabled = false; + accessModifyEnabled = new XResultData(); + if (accessControlledObject.isArtifact()) { + OseeApiService.get().getAccessControlService().isModifyAccessEnabled(UserManager.getUser(), + ((ArtifactAccessObject) accessControlledObject).getArtifact(), accessModifyEnabled); + } else if (accessControlledObject.isBranch()) { + OseeApiService.get().getAccessControlService().isModifyAccessEnabled(UserManager.getUser(), + accessControlledObject.getBranch(), accessModifyEnabled); + } else { + accessModifyEnabled.errorf("User %s DOES NOT have Access Modify rights for %s: Reason [Unhandled Object]", + UserManager.getUser().getName(), accessControlledObject); } - return enabled; + return accessModifyEnabled.isSuccess(); } @Override @@ -272,17 +309,17 @@ public class PolicyDialog extends Dialog { for (AccessControlData data : policyTableViewer.getAccessControlList().values()) { if (data.isDirty()) { boolean isRecursionAllowed = chkChildrenPermission.getSelection(); - AccessControlManager.persistPermission(data, isRecursionAllowed); + OseeApiService.get().getAccessControlService().persistPermission(data, isRecursionAllowed); } } policyTableViewer.removeDataFromDB(); - AccessControlManager.clearCaches(); + OseeApiService.get().getAccessControlService().clearCaches(); // Send artifact locked event if changed in dialog if (isArtifactLockedBeforeDialog != null) { try { - Artifact artifact = (Artifact) accessControlledObject; - boolean isArtifactLockedAfterDialog = AccessControlManager.hasLock(artifact); + Artifact artifact = (Artifact) ((ArtifactAccessObject) accessControlledObject).getArtifact(); + boolean isArtifactLockedAfterDialog = OseeApiService.get().getAccessControlService().hasLock(artifact); if (isArtifactLockedAfterDialog != isArtifactLockedBeforeDialog) { AccessArtifactLockTopicEvent event = new AccessArtifactLockTopicEvent(); event.setBranch(artifact.getBranch()); @@ -297,16 +334,6 @@ public class PolicyDialog extends Dialog { super.okPressed(); } - private String getHeaderName(Object object) { - String name = ""; - if (object instanceof Artifact) { - name = ((Artifact) object).getName(); - } else if (object instanceof BranchToken) { - name = ((BranchToken) object).getName(); - } - return name; - } - private static final class UserComparator implements Comparator { @Override public int compare(T o1, T o2) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyLabelProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyLabelProvider.java index 9ea5cec201..2da3da6e4d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyLabelProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyLabelProvider.java @@ -17,7 +17,7 @@ import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.nebula.widgets.xviewer.XViewer; import org.eclipse.nebula.widgets.xviewer.XViewerLabelProvider; import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; -import org.eclipse.osee.framework.access.AccessControlData; +import org.eclipse.osee.framework.core.access.AccessControlData; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.swt.ImageManager; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableCellModifier.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableCellModifier.java index fc3bdeee79..79ca4780b4 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableCellModifier.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableCellModifier.java @@ -15,10 +15,10 @@ package org.eclipse.osee.framework.ui.skynet.access; import java.util.Collections; import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.osee.framework.access.AccessControlData; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.access.AccessControlData; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.skynet.core.UserManager; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.swt.widgets.TreeItem; /** @@ -60,8 +60,8 @@ public class PolicyTableCellModifier implements ICellModifier { TreeItem item = (TreeItem) element; AccessControlData data = (AccessControlData) item.getData(); if (policyTableViewer.isArtifact() && data.getPermission() == PermissionEnum.USER_LOCK) { - AccessControlManager.unLockObjects(Collections.singleton(policyTableViewer.getArtifact()), - UserManager.getUser()); + OseeApiService.get().getAccessControlService().unLockArtifacts(UserManager.getUser(), + Collections.singleton(policyTableViewer.getArtifact())); policyTableViewer.removeData(data); } else { if (canDelete() && property.equals(PolicyTableColumns.delete.toString())) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableViewer.java index 72fb223506..36bba40c20 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableViewer.java @@ -21,9 +21,9 @@ import java.util.logging.Level; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CheckboxCellEditor; import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.osee.framework.access.AccessControlData; -import org.eclipse.osee.framework.access.AccessControlManager; -import org.eclipse.osee.framework.access.AccessObject; +import org.eclipse.osee.framework.core.access.AccessControlData; +import org.eclipse.osee.framework.core.access.object.AccessObject; +import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.IUserGroup; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -32,6 +32,7 @@ import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.access.UserGroupService; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.PolicyTableXViewerFactory; import org.eclipse.swt.SWT; @@ -45,7 +46,7 @@ import org.eclipse.swt.widgets.Composite; */ public class PolicyTableViewer { - private final Map accessControlList = new HashMap<>(); + private final Map accessControlList = new HashMap<>(); private final Collection deleteControlList = new ArrayList<>(); private final Object object; private final Composite parent; @@ -65,14 +66,14 @@ public class PolicyTableViewer { } public void addOrModifyItem(Artifact subject, Object object, PermissionEnum permission) { - AccessObject accessObject = AccessControlManager.getAccessObject(object); - AccessControlData data = accessControlList.get(subject.getGuid()); + AccessObject accessObject = AccessObject.valueOf(object); + AccessControlData data = accessControlList.get(subject); if (data == null) { data = new AccessControlData(subject, accessObject, permission, true); } else { modifyPermissionLevel(data, permission); } - accessControlList.put(data.getSubject().getGuid(), data); + accessControlList.put(data.getSubject(), data); tableXViewer.refresh(); } @@ -107,7 +108,7 @@ public class PolicyTableViewer { tableXViewer.setTableViewer(this); } - public Map getAccessControlList() { + public Map getAccessControlList() { return accessControlList; } @@ -121,13 +122,13 @@ public class PolicyTableViewer { } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } - accessControlList.remove(data.getSubject().getGuid()); + accessControlList.remove(data.getSubject()); } public void removeDataFromDB() { try { for (AccessControlData data : deleteControlList) { - AccessControlManager.removeAccessControlDataIf(true, data); + OseeApiService.get().getAccessControlService().removeAccessControlDataIf(true, data); } } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); @@ -162,8 +163,10 @@ public class PolicyTableViewer { IUserGroup oseeAccessGroup = UserGroupService.getOseeAccessAdmin(); boolean isOseeAccessAdmin = oseeAccessGroup.isCurrentUserMember(); - boolean canUnlockObject = AccessControlManager.canUnlockObject(artifact, UserManager.getUser()); - boolean isUserFullAccess = AccessControlManager.getPermission(artifact).matches(PermissionEnum.FULLACCESS); + boolean canUnlockObject = + OseeApiService.get().getAccessControlService().canUnlockObject(artifact, UserManager.getUser()); + boolean isUserFullAccess = OseeApiService.get().getAccessControlService().hasArtifactPermission(artifact, + PermissionEnum.FULLACCESS, null).isSuccess(); return isOseeAccessAdmin || canUnlockObject || isUserFullAccess; } return false; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableXviewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableXviewer.java index 27de196983..c5b69ff1e0 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableXviewer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/access/PolicyTableXviewer.java @@ -30,7 +30,7 @@ import org.eclipse.jface.window.Window; import org.eclipse.nebula.widgets.xviewer.IMultiColumnEditProvider; import org.eclipse.nebula.widgets.xviewer.IXViewerFactory; import org.eclipse.nebula.widgets.xviewer.XViewer; -import org.eclipse.osee.framework.access.AccessControlData; +import org.eclipse.osee.framework.core.access.AccessControlData; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.StringLabelProvider; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPrompt.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPrompt.java index 828c5c9723..ab12cf7d5d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPrompt.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPrompt.java @@ -16,11 +16,13 @@ package org.eclipse.osee.framework.ui.skynet.artifact; import java.util.Collection; import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.logging.OseeLevel; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; +import org.eclipse.osee.framework.jdk.core.result.XResultData; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.prompt.IHandlePromptChange; import org.eclipse.osee.framework.ui.skynet.artifact.prompt.IPromptFactory; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; /** * @author Jeff C. Phillips @@ -29,24 +31,27 @@ import org.eclipse.osee.framework.ui.skynet.artifact.prompt.IPromptFactory; public final class ArtifactPrompt { private final IPromptFactory promptFactory; - private final AccessPolicy policyHandler; - public ArtifactPrompt(IPromptFactory promptFactory, AccessPolicy policyHandler) { + public ArtifactPrompt(IPromptFactory promptFactory) { this.promptFactory = promptFactory; - this.policyHandler = policyHandler; } - public boolean promptChangeAttribute(AttributeTypeToken attributeType, final Collection artifacts, boolean persist, boolean multiLine) { + public boolean promptChangeAttribute(AttributeTypeToken attributeType, final Collection artifacts, boolean persist, boolean multiLine) { boolean toReturn = false; - boolean hasPermission = policyHandler.hasAttributeTypePermission(artifacts, attributeType, PermissionEnum.WRITE, - OseeLevel.SEVERE_POPUP).matched(); - - if (hasPermission) { - IHandlePromptChange promptChange = promptFactory.createPrompt(attributeType, - attributeType.getUnqualifiedName(), artifacts, persist, multiLine); - if (promptChange.promptOk()) { - toReturn = promptChange.store(); - } + XResultData rd = + OseeApiService.get().getAccessControlService().hasAttributeTypePermission(artifacts, attributeType, + PermissionEnum.WRITE, AccessControlArtifactUtil.getXResultAccessHeader("Change Attribute", artifacts, attributeType)); + + if (rd.isErrors()) { + XResultDataDialog.open(rd, "Change Attribute", "Permission Denied Changing Attribute %s", + attributeType.toStringWithId()); + return false; + } + + IHandlePromptChange promptChange = + promptFactory.createPrompt(attributeType, attributeType.getUnqualifiedName(), artifacts, persist, multiLine); + if (promptChange.promptOk()) { + toReturn = promptChange.store(); } return toReturn; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPromptChange.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPromptChange.java index e9819d58f9..ad210852be 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPromptChange.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactPromptChange.java @@ -17,7 +17,6 @@ import java.util.Collection; import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.skynet.artifact.prompt.PromptFactory; import org.eclipse.osee.framework.ui.skynet.internal.Activator; @@ -30,21 +29,10 @@ public final class ArtifactPromptChange { private static ArtifactPrompt prompt; - private AccessPolicy accessPolicy; - - public void setAccessPolicy(AccessPolicy accessPolicy) { - this.accessPolicy = accessPolicy; - } - - public void start() { - prompt = new ArtifactPrompt(new PromptFactory(), accessPolicy); - } - - public void stop() { - prompt = null; - } - private static ArtifactPrompt getArtifactPrompt() { + if (prompt == null) { + prompt = new ArtifactPrompt(new PromptFactory()); + } return ArtifactPromptChange.prompt; } @@ -52,12 +40,13 @@ public final class ArtifactPromptChange { return promptChangeAttribute(attributeType, artifacts, persist, true); } + @SuppressWarnings("unchecked") public static boolean promptChangeAttribute(AttributeTypeToken attributeType, final Collection artifacts, boolean persist, boolean multiLine) { boolean result = false; ArtifactPrompt prompt = getArtifactPrompt(); if (prompt != null) { try { - result = prompt.promptChangeAttribute(attributeType, artifacts, persist, multiLine); + result = prompt.promptChangeAttribute(attributeType, (Collection) artifacts, persist, multiLine); } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/OpenArtifactEditorLoopbackCmd.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/OpenArtifactEditorLoopbackCmd.java index 0f4e2efcb2..ba85c78e78 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/OpenArtifactEditorLoopbackCmd.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/OpenArtifactEditorLoopbackCmd.java @@ -16,7 +16,6 @@ package org.eclipse.osee.framework.ui.skynet.artifact; import java.net.HttpURLConnection; import java.util.Map; import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.client.server.HttpResponse; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.jdk.core.type.MutableBoolean; @@ -25,6 +24,7 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.httpRequests.BaseArtifactLoopbackCmd; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor; import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditorInput; import org.eclipse.osee.framework.ui.skynet.internal.Activator; @@ -47,7 +47,8 @@ public class OpenArtifactEditorLoopbackCmd extends BaseArtifactLoopbackCmd { try { boolean hasPermissionToRead = false; try { - hasPermissionToRead = AccessControlManager.hasPermission(artifact, PermissionEnum.READ); + hasPermissionToRead = OseeApiService.get().getAccessControlService().hasArtifactPermission(artifact, + PermissionEnum.READ, null).isSuccess(); } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java index 3671f58a0e..58ebcc310d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java @@ -17,22 +17,25 @@ import java.util.logging.Level; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.plugin.core.util.Jobs; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.OseeStatusContributionItemFactory; import org.eclipse.osee.framework.ui.skynet.RelationsComposite; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.editor.pages.ArtifactEditorOutlinePage; import org.eclipse.osee.framework.ui.skynet.artifact.editor.pages.ArtifactEditorReloadTab; import org.eclipse.osee.framework.ui.skynet.artifact.editor.pages.ArtifactFormPage; import org.eclipse.osee.framework.ui.skynet.artifact.editor.tab.attr.ArtEdAttrTab; import org.eclipse.osee.framework.ui.skynet.internal.Activator; +import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.Widgets; import org.eclipse.ui.IEditorReference; @@ -109,7 +112,10 @@ public class ArtifactEditor extends AbstractEventArtifactEditor { firePropertyChange(PROP_DIRTY); } catch (OseeCoreException ex) { onDirtied(); - OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); + XResultData rd = + AccessControlArtifactUtil.getXResultAccessHeader("Artifact Editor - Save", getEditorInput().getArtifact()); + rd.logf("\n\n%s", Lib.exceptionToString(ex)); + XResultDataUI.report(rd, "Artifact Editor - Save"); } } @@ -191,7 +197,7 @@ public class ArtifactEditor extends AbstractEventArtifactEditor { } private void createAttributesTab() { - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { attrTab = new ArtEdAttrTab(this, getArtifactFromEditorInput()); try { addPage(attrTab); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorActionBarContributor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorActionBarContributor.java index fa2ab212b3..9b63bad508 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorActionBarContributor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorActionBarContributor.java @@ -22,19 +22,25 @@ import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.window.Window; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.access.AccessControlUtil; +import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ISelectedArtifacts; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.OpenContributionItem; +import org.eclipse.osee.framework.ui.skynet.access.AccessControlDetails; import org.eclipse.osee.framework.ui.skynet.access.PolicyDialog; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.action.RevealInExplorerAction; import org.eclipse.osee.framework.ui.skynet.artifact.editor.action.CopyArtifactURLAction; import org.eclipse.osee.framework.ui.skynet.artifact.editor.action.OpenArtifactInBrowserAction; import org.eclipse.osee.framework.ui.skynet.artifact.editor.action.OpenHistoryAction; import org.eclipse.osee.framework.ui.skynet.internal.Activator; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.BranchView; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; @@ -63,13 +69,16 @@ public class ArtifactEditorActionBarContributor implements IActionContributor, I manager.add(new RevealBranchAction()); manager.add(new Separator()); manager.add(new AccessControlAction()); + if (AccessControlUtil.isDebugOn()) { + manager.add(new AccessControlDetails(artifact)); + } manager.add(new Separator()); if (CopyArtifactURLAction.isApplicable(artifact)) { manager.add(new CopyArtifactURLAction(artifact)); } manager.add(new OpenArtifactInBrowserAction(artifact)); manager.add(new Separator()); - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { manager.add(new DirtyReportAction(artifact)); } } @@ -108,6 +117,15 @@ public class ArtifactEditorActionBarContributor implements IActionContributor, I @Override public void run() { try { + XResultData rd = OseeApiService.get().getAccessControlService().hasArtifactPermission( + Collections.singleton(artifact), PermissionEnum.WRITE, + AccessControlArtifactUtil.getXResultAccessHeader("Delete Artifact Failed", artifact)); + if (rd.isErrors()) { + XResultDataDialog.open(rd, "Delete Artifact Failed", "You do not have valid access to delete %s", + artifact.toStringWithId()); + return; + } + MessageDialog dialog = new MessageDialog(Displays.getActiveShell(), "Confirm Artifact Deletion", null, String.format( "Are you sure you want to delete the artifact\n\n%s\n\nand all of the default hierarchy children?", @@ -133,7 +151,7 @@ public class ArtifactEditorActionBarContributor implements IActionContributor, I @Override public void run() { try { - PolicyDialog pd = new PolicyDialog(Displays.getActiveShell(), artifact); + PolicyDialog pd = PolicyDialog.createPolicyDialog(Displays.getActiveShell(), artifact); pd.open(); } catch (Exception ex) { OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java index 6f2a8f68d1..2e1d81ac10 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java @@ -17,6 +17,8 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Level; +import org.eclipse.osee.framework.core.access.event.AccessArtifactLockTopicEvent; +import org.eclipse.osee.framework.core.access.event.AccessTopicEvent; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.event.EventUtil; import org.eclipse.osee.framework.logging.OseeLog; @@ -25,8 +27,6 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter; import org.eclipse.osee.framework.skynet.core.event.listener.IArtifactEventListener; import org.eclipse.osee.framework.skynet.core.event.listener.IBranchEventListener; -import org.eclipse.osee.framework.skynet.core.event.model.AccessArtifactLockTopicEvent; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; import org.eclipse.osee.framework.skynet.core.event.model.BranchEvent; import org.eclipse.osee.framework.skynet.core.event.model.BranchEventType; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactFormPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactFormPage.java index bf055a248c..390464d053 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactFormPage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactFormPage.java @@ -28,7 +28,7 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.operation.AbstractOperation; import org.eclipse.osee.framework.core.operation.IOperation; import org.eclipse.osee.framework.core.operation.Operations; @@ -43,6 +43,7 @@ import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.RelationsComposite; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor; import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditorInput; import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditorProviders; @@ -317,8 +318,8 @@ public class ArtifactFormPage extends FormPage { } private String getLockedString(Artifact artifact) { - Artifact subject = AccessControlManager.getSubjectFromLockedObject(artifact); - if (subject != null) { + ArtifactToken subject = OseeApiService.get().getAccessControlService().getSubjectFromLockedObject(artifact); + if (subject.isValid()) { return "LOCKED: " + subject.getName() + " "; } return ""; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/AttributeFormPart.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/AttributeFormPart.java index a418fab1f8..7b7775e226 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/AttributeFormPart.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/AttributeFormPart.java @@ -27,14 +27,12 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.utility.OseeInfo; import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor; import org.eclipse.osee.framework.ui.skynet.artifact.editor.sections.AttributeTypeUtil; import org.eclipse.osee.framework.ui.skynet.internal.Activator; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.widgets.ArtifactStoredWidget; import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener; import org.eclipse.osee.framework.ui.skynet.widgets.XOption; @@ -89,8 +87,7 @@ public class AttributeFormPart extends AbstractFormPart { public AttributeFormPart(ArtifactEditor editor) { this.editor = editor; try { - AccessPolicy policy = ServiceUtil.getAccessPolicy(); - decorator.addProvider(new XWidgetAccessDecorationProvider(policy)); + decorator.addProvider(new XWidgetAccessDecorationProvider()); } catch (Exception ex) { OseeLog.log(Activator.class, Level.SEVERE, ex.toString(), ex); } @@ -378,4 +375,4 @@ public class AttributeFormPart extends AbstractFormPart { } } } -} \ No newline at end of file +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/DetailsFormSection.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/DetailsFormSection.java index e75daa4740..d951e8c97c 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/DetailsFormSection.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/DetailsFormSection.java @@ -18,8 +18,11 @@ import org.eclipse.osee.framework.help.ui.OseeHelpContext; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.skynet.core.utility.Artifacts; import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; +import org.eclipse.osee.framework.ui.skynet.access.AccessControlDetails; import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor; +import org.eclipse.osee.framework.ui.skynet.widgets.XButtonViaAction; import org.eclipse.osee.framework.ui.swt.ALayout; +import org.eclipse.osee.framework.ui.swt.FontManager; import org.eclipse.osee.framework.ui.swt.Widgets; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; @@ -31,6 +34,7 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; @@ -54,6 +58,7 @@ public class DetailsFormSection extends ArtifactEditorFormSection { super.initialize(form); section = getSection(); section.setText("Details"); + section.setExpanded(false); section.setLayout(new GridLayout()); section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); // Only load when users selects section @@ -71,7 +76,7 @@ public class DetailsFormSection extends ArtifactEditorFormSection { if (!sectionCreated) { final FormToolkit toolkit = getManagedForm().getToolkit(); Composite composite = toolkit.createComposite(getSection(), toolkit.getBorderStyle() | SWT.WRAP); - composite.setLayout(ALayout.getZeroMarginLayout()); + composite.setLayout(ALayout.getZeroMarginLayout(2, false)); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); composite.addDisposeListener(new DisposeListener() { @@ -84,16 +89,8 @@ public class DetailsFormSection extends ArtifactEditorFormSection { } }); - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint = 200; - gd.heightHint = 250; - - try { - browser = new Browser(composite, SWT.NONE); - browser.setLayoutData(gd); - } catch (SWTError e) { - // do nothing - } + createDetailsBrowser(composite); + createOperationsSection(composite); getSection().setClient(composite); toolkit.paintBordersFor(composite); @@ -114,8 +111,8 @@ public class DetailsFormSection extends ArtifactEditorFormSection { try { FontData systemFont = browser.getDisplay().getSystemFont().getFontData()[0]; Map detailsKeyValues = Artifacts.getDetailsKeyValues(getEditorInput().getArtifact()); - browser.setText( - Artifacts.getDetailsFormText(detailsKeyValues, systemFont.getName(), systemFont.getHeight())); + String html = Artifacts.getDetailsFormText(detailsKeyValues, systemFont.getName(), systemFont.getHeight()); + browser.setText(html); } catch (Exception ex) { browser.setText(Lib.exceptionToString(ex)); } @@ -123,4 +120,31 @@ public class DetailsFormSection extends ArtifactEditorFormSection { } } + private void createOperationsSection(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout(1, false)); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + Label opsLabel = new Label(composite, SWT.BOLD); + opsLabel.setFont(FontManager.getDefaultLabelFont()); + opsLabel.setText("Operations"); + + new XButtonViaAction(new AccessControlDetails(getEditor().getArtifactFromEditorInput())).createWidgets( + composite, 1); + + } + + private void createDetailsBrowser(Composite composite) { + try { + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.widthHint = 200; + gd.heightHint = 250; + + browser = new Browser(composite, SWT.NONE); + browser.setLayoutData(gd); + } catch (SWTError e) { + // do nothing + } + } + } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java index 1f837e13ac..0e0922476b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java @@ -27,7 +27,6 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.nebula.widgets.xviewer.XViewer; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.help.ui.OseeHelpContext; @@ -42,6 +41,7 @@ import org.eclipse.osee.framework.ui.plugin.PluginUiImage; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.editor.AbstractArtifactEditor; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.swt.ALayout; @@ -103,7 +103,8 @@ public class MassArtifactEditor extends AbstractArtifactEditor { try { Set accessibleArts = new HashSet<>(); for (Artifact artifact : artifacts) { - if (!AccessControlManager.hasPermission(artifact, PermissionEnum.READ)) { + if (OseeApiService.get().getAccessControlService().hasArtifactPermission(artifact, + PermissionEnum.READ, null).isErrors()) { OseeLog.log(Activator.class, Level.INFO, "The user " + UserManager.getUser() + " does not have read access to " + artifact); accessControlFilteredResults = true; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java index f5fb5fa790..8a3909f2c4 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java @@ -27,15 +27,16 @@ import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.nebula.widgets.xviewer.XViewer; import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; import org.eclipse.osee.framework.core.exception.OseeTypeDoesNotExist; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.UserManager; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.access.UserGroupService; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactData; @@ -46,6 +47,7 @@ import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.ArtifactDoubleClick; import org.eclipse.osee.framework.ui.skynet.action.PurgeAction; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactPromptChange; import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer; import org.eclipse.osee.framework.ui.skynet.artifact.editor.action.AddRelationColumnAction; @@ -53,6 +55,7 @@ import org.eclipse.osee.framework.ui.skynet.change.ChangeUiUtil; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredCheckboxAttributeTypeDialog; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.ViewApplicabilityColumn; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.IDirtiableEditor; @@ -199,7 +202,7 @@ public class MassXViewer extends XViewer implements IMassViewerEventHandler { @Override public void run() { try { - handleDeleteArtifacts(); + handleDeleteArtifactsAdminOnly(); } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } @@ -217,12 +220,14 @@ public class MassXViewer extends XViewer implements IMassViewerEventHandler { }; } - protected void handleDeleteArtifacts() { + protected void handleDeleteArtifactsAdminOnly() { ArrayList selectedArtifacts = getSelectedArtifacts(); if (selectedArtifacts.isEmpty()) { AWorkbench.popup("Must select items to delete"); return; } + + // Admin-Only action, no access control is checked if (MessageDialog.openConfirm(Displays.getActiveShell(), "Delete Artifacts", "Delete " + selectedArtifacts.size() + " Artifacts")) { SkynetTransaction transaction = TransactionManager.createTransaction( @@ -241,6 +246,12 @@ public class MassXViewer extends XViewer implements IMassViewerEventHandler { AWorkbench.popup("Must select items to delete"); return; } + XResultData rd = OseeApiService.get().getAccessControlService().hasArtifactPermission(selectedArtifacts, + PermissionEnum.WRITE, AccessControlArtifactUtil.getXResultAccessHeader("Delete Attributes Error", selectedArtifacts)); + if (rd.isErrors()) { + XResultDataDialog.open(rd, "Delete Attributes Failed", "Access Denied for artifacts"); + return; + } // get attributes that can be deleted (from artifact and validity) Set attrTypesUsed = new HashSet<>(); for (Artifact art : artifacts) { @@ -372,7 +383,7 @@ public class MassXViewer extends XViewer implements IMassViewerEventHandler { PresentationType type = ArtifactDoubleClick.getPresentationType(artifact); PermissionEnum perEnum = ArtifactDoubleClick.getPermissionEnum(artifact); - if (AccessControlManager.hasPermission(artifacts, perEnum)) { + if (OseeApiService.get().getAccessControlService().hasArtifactPermission(artifacts, perEnum, null).isSuccess()) { RendererManager.openInJob(getSelectedArtifacts(), type); } else { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/BlamContributionManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/BlamContributionManager.java index 3eee332ff7..febcd46ba3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/BlamContributionManager.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/BlamContributionManager.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.IUserGroupArtifactToken; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Collections; @@ -32,6 +31,7 @@ import org.eclipse.osee.framework.ui.plugin.xnavigate.IXNavigateCommonItem; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateCommonItems; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateItemBlam; @@ -105,8 +105,9 @@ public class BlamContributionManager implements IXNavigateCommonItem { // Create categories first (so can have them up top) for (String category : blamOperation.getCategories()) { try { - if (AccessControlManager.isOseeAdmin() || !category.contains("Admin") || category.contains( - "Admin") && AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin() || !category.contains( + "Admin") || category.contains( + "Admin") && OseeApiService.get().getAccessControlService().isOseeAdmin()) { createCategories(category.split("\\."), 0, blamOperationItems, nameToParent); } } catch (OseeCoreException ex) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java index adff5736a1..3beccbfe40 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/DatabaseHealth.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.IUserGroupArtifactToken; import org.eclipse.osee.framework.core.enums.CoreUserGroups; import org.eclipse.osee.framework.core.exception.OseeAccessDeniedException; @@ -29,6 +28,7 @@ import org.eclipse.osee.framework.jdk.core.result.Manipulations; import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.util.AXml; import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; import org.eclipse.osee.framework.ui.skynet.dbHealth.DatabaseHealthOperation; @@ -155,7 +155,7 @@ public class DatabaseHealth extends AbstractBlam { protected void doWork(IProgressMonitor monitor) throws Exception { int totalTasks = fixOperations.size() + verifyOperations.size(); double workPercentage = 1.0 / totalTasks; - if (!AccessControlManager.isOseeAdmin()) { + if (!OseeApiService.get().getAccessControlService().isOseeAdmin()) { throw new OseeAccessDeniedException("Must be a Developer to run this BLAM"); } else { for (DatabaseHealthOperation operation : fixOperations) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReportAttributeTypesUsageBlam.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReportAttributeTypesUsageBlam.java index 94fa018671..640dc38000 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReportAttributeTypesUsageBlam.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ReportAttributeTypesUsageBlam.java @@ -43,7 +43,7 @@ public class ReportAttributeTypesUsageBlam extends AbstractBlam { @Override public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception { - monitor.beginTask("Report Usage of AttributeTypes on Branch", IProgressMonitor.UNKNOWN); + monitor.beginTask("Report Usage of AttributeType on Branch", IProgressMonitor.UNKNOWN); XResultData xResultData = new XResultData(); BranchId branch = variableMap.getBranch("Branch"); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ValidateArtifactsToDelete.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ValidateArtifactsToDelete.java index e6efabbc2b..89bb033b53 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ValidateArtifactsToDelete.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ValidateArtifactsToDelete.java @@ -21,11 +21,10 @@ import org.eclipse.osee.framework.core.data.IUserGroupArtifactToken; import org.eclipse.osee.framework.core.enums.CoreUserGroups; import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.util.Collections; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI; /** @@ -57,8 +56,7 @@ public class ValidateArtifactsToDelete extends AbstractBlam { rd.log("Validation Artifacts: " + Collections.toString("; ", artifacts)); // Confirm artifacts are fit to delete try { - AccessPolicy policy = ServiceUtil.getAccessPolicy(); - policy.isDeleteable(Collections.castAll(artifacts), rd); + OseeApiService.get().getAccessControlService().isDeleteable(Collections.castAll(artifacts), rd); rd.log("\n"); rd.log("Validation Complete - Any errors will be displayed."); XResultDataUI.report(rd, "Validate Artifacts to Delete"); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/ViewApplicabilityUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/ViewApplicabilityUtil.java index e603afa279..f3c3528981 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/ViewApplicabilityUtil.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/ViewApplicabilityUtil.java @@ -19,17 +19,18 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; import org.eclipse.jface.window.Window; -import org.eclipse.osee.framework.core.access.PermissionStatus; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.Pair; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; +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.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ViewApplicabilityFilterTreeDialog; @@ -42,7 +43,6 @@ public class ViewApplicabilityUtil { public static String CHANGE_APPLICABILITY_INVAILD = "User does not have permissions to change View Applicability"; public static String SAVE_OTHER_CHANGES = "Save all other changes before making View Applicability update"; - private static AccessPolicy policy; public static Pair changeApplicability(List artifacts) { BranchId branch = artifacts.iterator().next().getBranch(); @@ -62,13 +62,6 @@ public class ViewApplicabilityUtil { return new Pair<>(false, ""); } - private static AccessPolicy getAccessPolicy() { - if (policy == null) { - policy = ServiceUtil.getAccessPolicy(); - } - return policy; - } - public static boolean isChangeApplicabilityValid(Collection artifacts) { try { for (Artifact artifact : artifacts) { @@ -76,9 +69,9 @@ public class ViewApplicabilityUtil { return false; } } - PermissionStatus permissionStatus = new PermissionStatus(); - permissionStatus = getAccessPolicy().hasArtifactPermission(artifacts, PermissionEnum.WRITE, Level.FINE); - boolean isWriteable = permissionStatus.matched(); + XResultData rd = OseeApiService.get().getAccessControlService().hasArtifactPermission(UserManager.getUser(), artifacts, + PermissionEnum.WRITE, null); + boolean isWriteable = rd.isSuccess(); if (!isWriteable) { return false; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/ChangeUiUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/ChangeUiUtil.java index 79f36ac296..565f37481d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/ChangeUiUtil.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/ChangeUiUtil.java @@ -17,7 +17,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.TransactionToken; @@ -25,14 +24,18 @@ import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionDelta; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.framework.plugin.core.util.Jobs; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.change.view.ChangeReportEditor; import org.eclipse.osee.framework.ui.skynet.internal.Activator; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.ui.PartInitException; import org.eclipse.ui.progress.UIJob; @@ -59,10 +62,12 @@ public final class ChangeUiUtil { * @return true if permissions denied */ public static boolean permissionsDeniedWithDialog(BranchToken branch) { - boolean hasPermission = AccessControlManager.hasPermission(branch, PermissionEnum.READ); - if (!hasPermission) { - AWorkbench.popup("Access Denied", - String.format("Access denied to branch:\n\n%s", BranchManager.toStringWithId(branch))); + XResultData rd = + OseeApiService.get().getAccessControlService().hasBranchPermission(BranchManager.getBranch(branch), + PermissionEnum.READ, AccessControlArtifactUtil.getXResultAccessHeader("Branch Access Denied", branch)); + if (rd.isErrors()) { + XResultDataDialog.open(rd, "Branch Access Denied", "Access denied to branch:\n\n%s", + BranchManager.toStringWithId(branch)); return true; } return false; @@ -140,16 +145,16 @@ public final class ChangeUiUtil { Jobs.startJob(job, true); } - public static void open(BranchToken workingBranchId, BranchId parentBranchId, boolean b) { - Branch workingBranch = BranchManager.getBranch(workingBranchId); - if (workingBranch.isInvalid() || permissionsDeniedWithDialog(workingBranchId)) { + public static void open(BranchToken workingBranch, BranchId parentBranchId, boolean loadOnOpen) { + Branch branch = BranchManager.getBranch(workingBranch); + if (branch.isInvalid() || permissionsDeniedWithDialog(workingBranch)) { return; } Branch parentBranch = BranchManager.getBranch(parentBranchId); if (parentBranch.isInvalid() || permissionsDeniedWithDialog(parentBranch)) { return; } - ChangeReportEditorInput input = createInput(workingBranch, true); + ChangeReportEditorInput input = createInput(workingBranch, loadOnOpen); open(input); } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/AccessControlHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/AccessControlHandler.java index b7545b65fb..e24775c99e 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/AccessControlHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/AccessControlHandler.java @@ -32,7 +32,7 @@ public class AccessControlHandler extends CommandHandler { public Object executeWithException(ExecutionEvent event, IStructuredSelection selection) { Object object = getSelection(selection); if (object != null) { - PolicyDialog pd = new PolicyDialog(Displays.getActiveShell(), object); + PolicyDialog pd = PolicyDialog.createPolicyDialog(Displays.getActiveShell(), object); pd.open(); } else { AWorkbench.popup("Selection can not be determined"); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CompressWordAttributesHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CompressWordAttributesHandler.java index b5cfebc346..71a87b3cea 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CompressWordAttributesHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CompressWordAttributesHandler.java @@ -21,12 +21,12 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.word.WordUtil; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.ui.PlatformUI; @@ -43,8 +43,9 @@ public class CompressWordAttributesHandler extends CommandHandler { artifacts = Handlers.getArtifactsFromStructuredSelection(structuredSelection); if (!artifacts.isEmpty()) { - boolean writePermission = AccessControlManager.hasPermission(artifacts.get(0), PermissionEnum.WRITE); - enabled = writePermission && AccessControlManager.isOseeAdmin(); + boolean writePermission = OseeApiService.get().getAccessControlService().hasArtifactPermission(artifacts.get(0), + PermissionEnum.WRITE, null).isSuccess(); + enabled = writePermission && OseeApiService.get().getAccessControlService().isOseeAdmin(); } return enabled; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java index c09ca86753..22a229a278 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CopyHandler.java @@ -25,7 +25,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.util.ArtifactClipboard; import org.eclipse.search.ui.text.Match; import org.eclipse.ui.IWorkbenchPartSite; @@ -78,7 +77,7 @@ public class CopyHandler extends AbstractHandler { clipboard.setTextToClipboard(names); } else if (!names.isEmpty() && !artifacts.isEmpty()) { try { - clipboard.setArtifactsToClipboard(ServiceUtil.getAccessPolicy(), artifacts); + clipboard.setArtifactsToClipboard(artifacts); } catch (OseeCoreException ex) { clipboard.dispose(); throw new ExecutionException(ex.getLocalizedMessage()); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/DeleteArtifactHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/DeleteArtifactHandler.java index b8c1022ac3..2c515a7ea5 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/DeleteArtifactHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/DeleteArtifactHandler.java @@ -18,13 +18,13 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.swt.Displays; /** @@ -55,7 +55,8 @@ public class DeleteArtifactHandler extends CommandHandler { boolean enabled = false; artifacts = Handlers.getArtifactsFromStructuredSelection(structuredSelection); if (!artifacts.isEmpty()) { - enabled = AccessControlManager.hasPermission(artifacts, PermissionEnum.WRITE); + enabled = OseeApiService.get().getAccessControlService().hasArtifactPermission(artifacts, PermissionEnum.WRITE, + null).isSuccess(); } return enabled; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/PurgeArtifactHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/PurgeArtifactHandler.java index ba10bd7910..8ece1fb21d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/PurgeArtifactHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/PurgeArtifactHandler.java @@ -22,7 +22,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.operation.Operations; import org.eclipse.osee.framework.logging.OseeLog; @@ -30,6 +29,7 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.PurgeArtifacts; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.ui.PlatformUI; @@ -70,6 +70,7 @@ public class PurgeArtifactHandler extends CommandHandler { @Override public boolean isEnabledWithException(IStructuredSelection structuredSelection) { artifacts = Handlers.getArtifactsFromStructuredSelection(structuredSelection); - return AccessControlManager.isOseeAdmin() && AccessControlManager.hasPermission(artifacts, PermissionEnum.WRITE); + return OseeApiService.get().getAccessControlService().isOseeAdmin() && OseeApiService.get().getAccessControlService().hasArtifactPermission( + artifacts, PermissionEnum.WRITE, null).isSuccess(); } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/ReplaceWithBaselineHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/ReplaceWithBaselineHandler.java index 0255e75370..98ca892041 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/ReplaceWithBaselineHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/ReplaceWithBaselineHandler.java @@ -26,7 +26,6 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.Window; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.model.change.ChangeType; import org.eclipse.osee.framework.core.operation.AbstractOperation; @@ -38,6 +37,7 @@ import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.blam.operation.ReplaceArtifactWithBaselineOperation; import org.eclipse.osee.framework.ui.skynet.blam.operation.ReplaceAttributeWithBaselineOperation; import org.eclipse.osee.framework.ui.skynet.change.view.ChangeReportEditor; @@ -85,7 +85,8 @@ public class ReplaceWithBaselineHandler extends AbstractHandler { try { isEnabled = - isEnabled && AccessControlManager.hasPermission(change.getChangeArtifact(), PermissionEnum.WRITE); + isEnabled && OseeApiService.get().getAccessControlService().hasArtifactPermission(change.getChangeArtifact(), + PermissionEnum.WRITE, null).isSuccess(); } catch (OseeCoreException ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, "Error loading changes for change report handler"); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ArchiveBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ArchiveBranchHandler.java index 6f3ae6bdee..ef69f0154e 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ArchiveBranchHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ArchiveBranchHandler.java @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; @@ -26,6 +25,7 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; 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.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; import org.eclipse.osee.framework.ui.swt.Displays; @@ -37,7 +37,7 @@ public class ArchiveBranchHandler extends CommandHandler { @Override public boolean isEnabledWithException(IStructuredSelection structuredSelection) { List branches = Handlers.getBranchesFromStructuredSelection(structuredSelection); - return !branches.isEmpty() && AccessControlManager.isOseeAdmin(); + return !branches.isEmpty() && OseeApiService.get().getAccessControlService().isOseeAdmin(); } @Override diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java index c5b8255cad..bcc2200278 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java @@ -19,9 +19,9 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.enums.DemoUsers; @@ -33,6 +33,7 @@ import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryCheckDialog; import org.eclipse.osee.framework.ui.swt.Displays; @@ -70,8 +71,8 @@ public class BranchCreationHandler extends CommandHandler { BranchId branch = parentTransactionId.getBranch(); if (branch.equals(CoreBranches.SYSTEM_ROOT)) { BranchManager.createTopLevelBranch(dialog.getEntry()); - AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, - PermissionEnum.FULLACCESS); + OseeApiService.get().getAccessControlService().setPermission(UserManager.getUser(DemoUsers.Joe_Smith), + branch, PermissionEnum.FULLACCESS); } else { if (dialog.isChecked()) { BranchManager.createWorkingBranchFromTx(parentTransactionId, dialog.getEntry(), null); @@ -98,19 +99,20 @@ public class BranchCreationHandler extends CommandHandler { } Object object = structuredSelection.getFirstElement(); - BranchId branch = null; + BranchToken branch = null; if (object instanceof BranchId) { - branch = (BranchId) object; + branch = BranchManager.getBranch((BranchId) object); } else if (object instanceof TransactionToken) { - branch = ((TransactionToken) object).getBranch(); + branch = BranchManager.getBranch(((TransactionToken) object).getBranch()); } if (branch == null || BranchManager.isArchived(branch)) { return false; } - enabled = AccessControlManager.hasPermission(branch, PermissionEnum.READ); + enabled = OseeApiService.get().getAccessControlService().hasBranchPermission(branch, PermissionEnum.READ, + null).isSuccess(); return enabled; } } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java index 8559e7af30..89c9d51e79 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java @@ -17,14 +17,15 @@ import java.util.List; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.osee.framework.ui.swt.Displays; /** @@ -63,7 +64,8 @@ public abstract class GeneralBranchHandler extends CommandHandler { List selectedBranches = Handlers.getBranchesFromStructuredSelection(selection); for (BranchToken branch : selectedBranches) { confirmDialogResults.logf("Branch: %s\n", branch.toStringWithId()); - if (!AccessControlManager.hasPermission(branch, PermissionEnum.WRITE)) { + if (!OseeApiService.get().getAccessControlService().hasBranchPermission(branch, PermissionEnum.WRITE, + errorResults).isSuccess()) { errorResults.errorf("No write permission for Branch %s.\n\n", branch.toStringWithId()); } if (BranchManager.hasChildren(branch)) { @@ -72,7 +74,7 @@ public abstract class GeneralBranchHandler extends CommandHandler { } if (errorResults.isErrors()) { - MessageDialog.openError(Displays.getActiveShell(), type.dialogTitle, errorResults.toString()); + XResultDataDialog.open(errorResults, type.dialogTitle, type.dialogTitle); } else { if (MessageDialog.openQuestion(Displays.getActiveShell(), type.dialogTitle, confirmDialogResults.toString())) { performOperation(selectedBranches); @@ -85,7 +87,8 @@ public abstract class GeneralBranchHandler extends CommandHandler { @Override public boolean isEnabledWithException(IStructuredSelection structuredSelection) { List branches = Handlers.getBranchesFromStructuredSelection(structuredSelection); - return !branches.isEmpty() && (AccessControlManager.isOseeAdmin() || canEnableBranches(branches)); + return !branches.isEmpty() && (OseeApiService.get().getAccessControlService().isOseeAdmin() || canEnableBranches( + branches)); } private boolean canEnableBranches(List branches) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/OpenAssociatedArtifactHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/OpenAssociatedArtifactHandler.java index d9303aa482..5c1d02d60d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/OpenAssociatedArtifactHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/OpenAssociatedArtifactHandler.java @@ -16,7 +16,6 @@ package org.eclipse.osee.framework.ui.skynet.commandHandlers.branch; import java.util.List; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; @@ -28,6 +27,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.cm.IOseeCmService; import org.eclipse.osee.framework.ui.skynet.cm.OseeCmEditor; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; @@ -54,7 +54,8 @@ public class OpenAssociatedArtifactHandler extends CommandHandler { AWorkbench.popup("ERROR", "No Associated Artifact"); return null; } - if (AccessControlManager.hasPermission(associatedArtifact, PermissionEnum.READ)) { + if (OseeApiService.get().getAccessControlService().hasArtifactPermission(associatedArtifact, PermissionEnum.READ, + null).isSuccess()) { IOseeCmService cmService = ServiceUtil.getOseeCmService(); if (cmService.isPcrArtifact(associatedArtifact)) { cmService.openArtifact(associatedArtifact, OseeCmEditor.CmPcrEditor); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeTransactionHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeTransactionHandler.java index d32c6834c6..abdf0de291 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeTransactionHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeTransactionHandler.java @@ -16,9 +16,9 @@ package org.eclipse.osee.framework.ui.skynet.commandHandlers.branch; import java.util.List; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.action.PurgeTransactionAction; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; @@ -40,6 +40,6 @@ public class PurgeTransactionHandler extends CommandHandler { @Override public boolean isEnabledWithException(IStructuredSelection structuredSelection) { List transactions = Handlers.getTransactionsFromStructuredSelection(structuredSelection); - return transactions.size() > 0 && AccessControlManager.isOseeAdmin(); + return transactions.size() > 0 && OseeApiService.get().getAccessControlService().isOseeAdmin(); } } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/RenameBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/RenameBranchHandler.java index ded99d54c9..af019d0e3f 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/RenameBranchHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/RenameBranchHandler.java @@ -18,11 +18,11 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.BranchXViewerFactory; import org.eclipse.osee.framework.ui.swt.Widgets; @@ -124,7 +124,7 @@ public class RenameBranchHandler extends CommandHandler { return false; } BranchToken branch = branches.get(0); - return AccessControlManager.isOseeAdmin() || BranchManager.getType( + return OseeApiService.get().getAccessControlService().isOseeAdmin() || BranchManager.getType( branch).isWorkingBranch() || BranchManager.getBaseTransaction(branch).getAuthor().equals( UserManager.getUser()); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/SetAssociatedBranchArtifactHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/SetAssociatedBranchArtifactHandler.java index 664e355c6c..fb2f878b73 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/SetAssociatedBranchArtifactHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/SetAssociatedBranchArtifactHandler.java @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; @@ -26,6 +25,7 @@ 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.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialog; import org.eclipse.osee.framework.ui.swt.Displays; @@ -57,6 +57,6 @@ public class SetAssociatedBranchArtifactHandler extends CommandHandler { @Override public boolean isEnabledWithException(IStructuredSelection structuredSelection) { List branches = Handlers.getBranchesFromStructuredSelection(structuredSelection); - return branches.size() == 1 && AccessControlManager.isOseeAdmin(); + return branches.size() == 1 && OseeApiService.get().getAccessControlService().isOseeAdmin(); } } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ShowArchivedBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ShowArchivedBranchHandler.java index f35e2bbc30..ee9dfe0aac 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ShowArchivedBranchHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ShowArchivedBranchHandler.java @@ -20,11 +20,11 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.utility.DbUtil; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.util.DbConnectionUtility; import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.BranchOptionsEnum; @@ -79,7 +79,7 @@ public class ShowArchivedBranchHandler extends CommandHandler implements IElemen if (!DbUtil.isDbInit() && DbConnectionUtility.isApplicationServerAlive()) { service.refreshElements(COMMAND_ID, null); try { - isValid = AccessControlManager.isOseeAdmin(); + isValid = OseeApiService.get().getAccessControlService().isOseeAdmin(); } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ShowMergeBranchPresentationHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ShowMergeBranchPresentationHandler.java index a56681d997..6825b0a0f9 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ShowMergeBranchPresentationHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/ShowMergeBranchPresentationHandler.java @@ -20,10 +20,10 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.utility.DbUtil; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.BranchOptionsEnum; import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.BranchView; @@ -72,7 +72,7 @@ public final class ShowMergeBranchPresentationHandler extends AbstractHandler im IWorkbench workbench = PlatformUI.getWorkbench(); if (!workbench.isStarting() && !workbench.isClosing()) { try { - isValid = AccessControlManager.isOseeAdmin(); + isValid = OseeApiService.get().getAccessControlService().isOseeAdmin(); } catch (OseeCoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitHandler.java index 17a4224c31..ed75c360fa 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitHandler.java @@ -25,7 +25,6 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.Window; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.TransactionResult; @@ -36,6 +35,7 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.conflict.ConflictManagerExternal; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.util.MergeInProgressHandler; @@ -140,7 +140,8 @@ public abstract class CommitHandler extends CommandHandler { if (branches.size() == 1) { BranchToken branch = branches.iterator().next(); - return useParentBranchValid(branch) || !useParentBranch && AccessControlManager.isOseeAdmin(); + return useParentBranchValid( + branch) || !useParentBranch && OseeApiService.get().getAccessControlService().isOseeAdmin(); } return false; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitIntoHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitIntoHandler.java index ceb442128e..d6b68724b4 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitIntoHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitIntoHandler.java @@ -19,13 +19,13 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.Window; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.core.enums.BranchType; import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectionDialog; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.CheckBoxDialog; @@ -47,7 +47,7 @@ public class CommitIntoHandler extends CommitHandler { BranchId sourceBranch = Handlers.getBranchesFromStructuredSelection(selection).iterator().next(); BranchType[] allowedTypes; - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { allowedTypes = new BranchType[] {BranchType.WORKING, BranchType.BASELINE}; } else { allowedTypes = new BranchType[] {BranchType.WORKING}; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/SingleNativeDiffHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/SingleNativeDiffHandler.java index 094d364a76..ee13efc77c 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/SingleNativeDiffHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/SingleNativeDiffHandler.java @@ -19,7 +19,6 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.util.RendererOption; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; @@ -27,6 +26,7 @@ import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta; import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.skynet.core.revision.ChangeManager; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.render.RenderingUtil; @@ -42,7 +42,8 @@ public class SingleNativeDiffHandler extends CommandHandler { changes = new ArrayList<>(Handlers.getArtifactChangesFromStructuredSelection(structuredSelection)); if (changes.size() == 1) { Artifact sampleArtifact = changes.iterator().next().getChangeArtifact(); - return AccessControlManager.hasPermission(sampleArtifact, PermissionEnum.READ); + return OseeApiService.get().getAccessControlService().hasArtifactPermission(sampleArtifact, PermissionEnum.READ, + null).isSuccess(); } return false; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/AbstractEditorHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/AbstractEditorHandler.java index 61f07ffe52..16f627492c 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/AbstractEditorHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/AbstractEditorHandler.java @@ -16,10 +16,10 @@ package org.eclipse.osee.framework.ui.skynet.commandHandlers.renderer.handlers; import java.util.List; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; /** @@ -39,7 +39,8 @@ public abstract class AbstractEditorHandler extends CommandHandler { public boolean isEnabledWithException(IStructuredSelection structuredSelection) { artifacts = Handlers.getArtifactsFromStructuredSelection(structuredSelection); if (!artifacts.isEmpty()) { - return AccessControlManager.hasPermission(artifacts, getPermissionLevel()); + return OseeApiService.get().getAccessControlService().hasArtifactPermission(artifacts, getPermissionLevel(), + null).isSuccess(); } return false; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java index b3a868992d..a94327d718 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java @@ -13,6 +13,7 @@ package org.eclipse.osee.framework.ui.skynet.explorer; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.LinkedList; @@ -23,7 +24,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; @@ -53,6 +53,7 @@ import org.eclipse.osee.framework.ui.skynet.ArtifactLabelProvider; import org.eclipse.osee.framework.ui.skynet.ArtifactStructuredSelection; import org.eclipse.osee.framework.ui.skynet.IArtifactExplorerEventHandler; import org.eclipse.osee.framework.ui.skynet.OseeStatusContributionItemFactory; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.explorer.menu.ArtifactExplorerMenu; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.listener.IRebuildMenuListener; @@ -76,9 +77,11 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Tree; import org.eclipse.ui.IMemento; +import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; /** * @author Ryan D. Brooks @@ -330,8 +333,8 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor if (memento != null && memento.getString(ROOT_UUID) != null && memento.getString(ROOT_BRANCH) != null) { BranchId branch = BranchId.valueOf(memento.getString(ROOT_BRANCH)); - if (BranchManager.branchExists( - branch) && !BranchManager.isArchived(branch) || AccessControlManager.isOseeAdmin()) { + if (BranchManager.branchExists(branch) && !BranchManager.isArchived( + branch) || OseeApiService.get().getAccessControlService().isOseeAdmin()) { Artifact previousArtifact = ArtifactQuery.checkArtifactFromId(ArtifactId.valueOf(memento.getString(ROOT_UUID)), branch); if (previousArtifact != null) { @@ -464,6 +467,18 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor return this; } + public static List getEditors() { + List results = new ArrayList<>(); + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IViewReference views[] = page.getViewReferences(); + for (IViewReference view : views) { + if (view.getPart(false) instanceof ArtifactExplorer) { + results.add((ArtifactExplorer) view.getPart(false)); + } + } + return results; + } + @Override public boolean isDisposed() { return treeViewer.getTree() == null || treeViewer.getTree().isDisposed(); @@ -513,4 +528,8 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor this.refreshing = refreshing; } + public void resetMenu() { + artifactExplorerMenu.resetMenu(); + } + } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerDragAndDrop.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerDragAndDrop.java index 4ac8745765..aa64d14067 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerDragAndDrop.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerDragAndDrop.java @@ -16,9 +16,9 @@ package org.eclipse.osee.framework.ui.skynet.explorer; import static org.eclipse.osee.framework.core.enums.RelationSorter.USER_DEFINED; import java.io.File; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedList; import java.util.List; -import java.util.logging.Level; import org.apache.commons.io.FilenameUtils; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; @@ -31,13 +31,13 @@ import org.eclipse.osee.framework.core.data.JsonAttribute; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; +import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.operation.IOperation; import org.eclipse.osee.framework.core.operation.Operations; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactData; @@ -55,6 +55,7 @@ import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportOperationParame import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportWizard; import org.eclipse.osee.framework.ui.skynet.Import.ArtifactResolverFactory; import org.eclipse.osee.framework.ui.skynet.Import.ArtifactResolverFactory.ArtifactCreationStrategy; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; @@ -123,7 +124,6 @@ public class ArtifactExplorerDragAndDrop extends SkynetDragAndDrop { ArtifactData toBeDropped = ArtifactTransfer.getInstance().nativeToJava(event.currentDataType); if (dropTarget != null) { try { - AccessPolicy policy = ServiceUtil.getAccessPolicy(); Artifact[] artifactsBeingDropped = toBeDropped.getArtifacts(); List artsOnSameBranchAsDestination = new LinkedList<>(); BranchId destinationBranch = dropTarget.getBranch(); @@ -132,15 +132,19 @@ public class ArtifactExplorerDragAndDrop extends SkynetDragAndDrop { artsOnSameBranchAsDestination.add(art); } } - valid = policy.canRelationBeModified(dropTarget, artsOnSameBranchAsDestination, - CoreRelationTypes.DefaultHierarchical_Child, Level.FINE).matched(); + + valid = OseeApiService.get().getAccessControlService().hasRelationTypePermission(dropTarget, + CoreRelationTypes.DefaultHierarchical_Child, artsOnSameBranchAsDestination, PermissionEnum.WRITE, + null).isSuccess(); // if we are deparenting ourself, make sure our parent's child side can be modified if (valid) { for (Artifact art : artsOnSameBranchAsDestination) { if (art.hasParent()) { - valid = policy.canRelationBeModified(art.getParent(), null, - CoreRelationTypes.DefaultHierarchical_Child, Level.FINE).matched(); + valid = + OseeApiService.get().getAccessControlService().hasRelationTypePermission(art.getParent(), + CoreRelationTypes.DefaultHierarchical_Child, Collections.emptyList(), + PermissionEnum.WRITE, null).isSuccess(); } if (!valid) { break; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerEventManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerEventManager.java index 9cee894142..33f6c2f46c 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerEventManager.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerEventManager.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Level; +import org.eclipse.osee.framework.core.access.event.AccessTopicEvent; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.event.EventUtil; @@ -27,7 +28,6 @@ import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter; import org.eclipse.osee.framework.skynet.core.event.listener.IArtifactEventListener; -import org.eclipse.osee.framework.skynet.core.event.model.AccessTopicEvent; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidArtifact; import org.eclipse.osee.framework.skynet.core.event.model.EventModType; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerToolbar.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerToolbar.java index d5f543647b..d9c430faf1 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerToolbar.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerToolbar.java @@ -22,7 +22,7 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.window.Window; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.access.IAccessControlService; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.GUID; @@ -34,7 +34,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; -import org.eclipse.osee.framework.ui.skynet.access.AccessControlService; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.action.OpenAssociatedArtifactFromBranchProvider; import org.eclipse.osee.framework.ui.skynet.change.ChangeUiUtil; import org.eclipse.osee.framework.ui.skynet.internal.Activator; @@ -109,8 +109,8 @@ public class ArtifactExplorerToolbar { @Override protected IStatus run(IProgressMonitor monitor) { - AccessControlService.getAccessService().clearCache(); - AccessControlService.getAccessService().ensurePopulated(); + OseeApiService.get().getAccessControlService().clearCaches(); + OseeApiService.get().getAccessControlService().ensurePopulated(); Displays.ensureInDisplayThread(new Runnable() { @@ -119,14 +119,14 @@ public class ArtifactExplorerToolbar { artifactExplorer.setRefreshing(false); artifactExplorer.refreshBranchWarning(); ArtifactExplorer.exploreBranch(artifactExplorer.getBranch()); - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { CheckBoxDialog dialog = new CheckBoxDialog("Admin - Enable Debug", "Enable Branch Access Debug", "Check to enable Branch Access Debug if instructed to do so"); if (dialog.open() == Window.OK) { - System.setProperty(AccessControlManager.DEBUG_BRANCH_ACCESS, "true"); + System.setProperty(IAccessControlService.DEBUG_BRANCH_ACCESS, "true"); } else { - System.setProperty(AccessControlManager.DEBUG_BRANCH_ACCESS, "false"); + System.setProperty(IAccessControlService.DEBUG_BRANCH_ACCESS, "false"); } } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerUtil.java index ad29e63020..47bce876cf 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerUtil.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerUtil.java @@ -22,12 +22,13 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.operation.IOperation; import org.eclipse.osee.framework.core.operation.Operations; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.GUID; import org.eclipse.osee.framework.logging.OseeLog; @@ -36,6 +37,7 @@ import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.Widgets; @@ -77,7 +79,7 @@ public class ArtifactExplorerUtil { } } - public static void refreshBranchWarning(ArtifactExplorer artifactExplorer, TreeViewer treeViewer, BranchId branch, BranchWarningComposite branchWarningComposite) { + public static void refreshBranchWarning(ArtifactExplorer artifactExplorer, TreeViewer treeViewer, BranchToken branch, BranchWarningComposite branchWarningComposite) { Displays.ensureInDisplayThread(new Runnable() { @Override public void run() { @@ -89,7 +91,8 @@ public class ArtifactExplorerUtil { Control control = treeViewer.getTree(); if (branch.isValid()) { String warningStr = null; - boolean branchReadable = AccessControlManager.hasPermission(branch, PermissionEnum.READ); + boolean branchReadable = OseeApiService.get().getAccessControlService().hasBranchPermission(branch, + PermissionEnum.READ, new XResultData()).isSuccess(); if (artifactExplorer.isRefreshing()) { warningStr = "Refreshing Artifact Explorer"; } else if (!branchReadable) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/MenuPermissions.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/MenuPermissions.java index 93059b4345..fd8ebf8291 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/MenuPermissions.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/MenuPermissions.java @@ -16,12 +16,13 @@ package org.eclipse.osee.framework.ui.skynet.explorer; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.PermissionEnum; 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.ui.skynet.access.internal.OseeApiService; /** * @author Donald G. Dunne @@ -46,21 +47,27 @@ public class MenuPermissions { fullAccess = true; isLocked = false; accessToRemoveLock = true; - Artifact combinationSubject = null; + ArtifactToken combinationSubject = null; for (Artifact objectArtifact : artifacts) { - writePermission = writePermission && AccessControlManager.hasPermission(objectArtifact, - PermissionEnum.WRITE) && BranchManager.isEditable(objectArtifact.getBranch()); - readPermission = readPermission && AccessControlManager.hasPermission(objectArtifact, PermissionEnum.READ); - fullAccess = fullAccess && AccessControlManager.hasPermission(objectArtifact, PermissionEnum.FULLACCESS); - isLocked = isLocked || AccessControlManager.hasLock(objectArtifact); + writePermission = + writePermission && OseeApiService.get().getAccessControlService().hasArtifactPermission(objectArtifact, + PermissionEnum.WRITE, null).isSuccess() && BranchManager.isEditable(objectArtifact.getBranch()); + readPermission = + readPermission && OseeApiService.get().getAccessControlService().hasArtifactPermission(objectArtifact, + PermissionEnum.READ, null).isSuccess(); + fullAccess = fullAccess && OseeApiService.get().getAccessControlService().hasArtifactPermission(objectArtifact, + PermissionEnum.FULLACCESS, null).isSuccess(); + isLocked = isLocked || OseeApiService.get().getAccessControlService().hasLock(objectArtifact); accessToRemoveLock = - accessToRemoveLock && AccessControlManager.canUnlockObject(objectArtifact, UserManager.getUser()); + accessToRemoveLock && OseeApiService.get().getAccessControlService().canUnlockObject(objectArtifact, + UserManager.getUser()); // acquire the name of the subject that has the lock - Artifact subject = AccessControlManager.getSubjectFromLockedObject(objectArtifact); + ArtifactToken subject = + OseeApiService.get().getAccessControlService().getSubjectFromLockedObject(objectArtifact); - if (isLocked && subject != null) { + if (isLocked && subject.isValid()) { if (combinationSubject == null) { combinationSubject = subject; subjectFromLockedObjectName = combinationSubject.getName(); @@ -96,7 +103,8 @@ public class MenuPermissions { } public boolean isBranchReadable(BranchId branch) { - return AccessControlManager.hasPermission(branch, PermissionEnum.READ); + return OseeApiService.get().getAccessControlService().hasBranchPermission(BranchManager.getBranch(branch), + PermissionEnum.READ, null).isSuccess(); } public boolean isHasArtifacts() { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/ArtifactExplorerMenu.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/ArtifactExplorerMenu.java index 4cfaebade8..892680f6dc 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/ArtifactExplorerMenu.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/ArtifactExplorerMenu.java @@ -20,28 +20,29 @@ import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.logging.Level; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.window.Window; -import org.eclipse.osee.framework.access.AccessControlManager; -import org.eclipse.osee.framework.core.access.PermissionStatus; +import org.eclipse.osee.framework.core.access.AccessControlUtil; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.RelationTypeSide; import org.eclipse.osee.framework.core.enums.CoreArtifactTokens; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; import org.eclipse.osee.framework.core.operation.Operations; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.framework.jdk.core.util.Collections; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts; import org.eclipse.osee.framework.skynet.core.UserManager; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; @@ -54,7 +55,9 @@ import org.eclipse.osee.framework.ui.skynet.ArtifactContentProvider; import org.eclipse.osee.framework.ui.skynet.ArtifactStructuredSelection; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.OpenContributionItem; +import org.eclipse.osee.framework.ui.skynet.access.AccessControlDetails; import org.eclipse.osee.framework.ui.skynet.access.PolicyDialog; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.action.DeleteAction; import org.eclipse.osee.framework.ui.skynet.action.PurgeAction; import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactNameConflictHandler; @@ -71,6 +74,7 @@ import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.util.ArtifactClipboard; import org.eclipse.osee.framework.ui.skynet.util.ArtifactPasteConfiguration; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredTreeArtifactTypeEntryDialog; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.osee.framework.ui.swt.MenuItems; @@ -107,6 +111,7 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { private MenuItem createMenuItem; private CreateRelatedMenuItem createRelatedMenuItem; private MenuItem accessControlMenuItem; + private MenuItem showAccessControlMenuItem; private MenuItem lockMenuItem; private MenuItem goIntoMenuItem; private MenuItem copyMenuItem; @@ -122,6 +127,7 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { private Text myTextBeingRenamed; private MenuItem deleteMenuItem; private MenuItem purgeMenuItem; + private Menu popupMenu; public ArtifactExplorerMenu(ArtifactExplorer artifactExplorer) { this.artifactExplorer = artifactExplorer; @@ -138,22 +144,22 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { try { IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); Object obj = selection.getFirstElement(); - AccessPolicy service = ServiceUtil.getAccessPolicy(); boolean canModifyDH = false; boolean isArtifact = false; MenuPermissions permiss; if (obj instanceof Artifact) { isArtifact = true; Artifact art = (Artifact) obj; - canModifyDH = service.canRelationBeModified(art, null, CoreRelationTypes.DefaultHierarchical_Child, - Level.FINE).matched(); + canModifyDH = OseeApiService.get().getAccessControlService().hasRelationTypePermission(art, + CoreRelationTypes.DefaultHierarchical_Child, java.util.Collections.emptyList(), PermissionEnum.WRITE, + null).isSuccess(); permiss = new MenuPermissions(art); } else { permiss = new MenuPermissions((Artifact) null); } boolean isBranchEditable = - BranchManager.isEditable(getBranch()) && AccessControlManager.hasPermission(getBranch(), - PermissionEnum.WRITE); + BranchManager.isEditable(getBranch()) && OseeApiService.get().getAccessControlService().hasBranchPermission( + getBranch(), PermissionEnum.WRITE, null).isSuccess(); boolean locked = permiss.isLocked(); if (isArtifact) { @@ -183,11 +189,11 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { accessControlMenuItem.setEnabled(isArtifact); refreshMenuItem.setEnabled(isArtifact); - createRelatedMenuItem.setCreateRelatedEnabled(obj, service); + createRelatedMenuItem.setCreateRelatedEnabled(obj); deleteMenuItem.setEnabled(isArtifact && permiss.isWritePermission()); purgeMenuItem.setEnabled( - isArtifact && permiss.isHasArtifacts() && permiss.isWritePermission() && AccessControlManager.isOseeAdmin()); + isArtifact && permiss.isHasArtifacts() && permiss.isWritePermission() && UserManager.getUser().isOseeAdmin()); } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); @@ -197,7 +203,7 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { public void setupPopupMenu() { - Menu popupMenu = new Menu(treeViewer.getTree().getParent()); + popupMenu = new Menu(treeViewer.getTree().getParent()); needArtifactListener = new NeedArtifactMenuListener(artifactExplorer); needProjectListener = new NeedProjectMenuListener(artifactExplorer); popupMenu.addMenuListener(needArtifactListener); @@ -243,10 +249,13 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { new MenuItem(popupMenu, SWT.SEPARATOR); createAccessControlMenuItem(popupMenu); + if (AccessControlUtil.isDebugOn()) { + createShowAccessControlMenuItem(popupMenu); + } treeViewer.getTree().setMenu(popupMenu); } - private BranchId getBranch() { + private BranchToken getBranch() { return artifactExplorer.getBranch(); } @@ -261,32 +270,22 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); Artifact parent = null; - // If artifact is selected, check permissions of artifact - if (selection.size() == 1) { + // Get selected and check permissions + if (selection.size() > 1) { + AWorkbench.popup("Select single or no artifact to Add Child"); + return; + } else if (selection.size() == 1) { parent = getParent(); - - AccessPolicy policy = ServiceUtil.getAccessPolicy(); - - PermissionStatus status = policy.canRelationBeModified(parent, null, - CoreRelationTypes.DefaultHierarchical_Child, Level.FINE); - if (!status.matched()) { - MessageDialog.openError(AWorkbench.getActiveShell(), "New Child Error", - "Access control has restricted this action. The current user does not have sufficient permission to create relations on this artifact."); - return; - } + } else { + parent = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(getBranch()); } - // check branch permissions - else { - boolean isBranchEditable = - BranchManager.isEditable(getBranch()) && AccessControlManager.hasPermission(getBranch(), - PermissionEnum.WRITE); - if (!isBranchEditable) { - MessageDialog.openError(AWorkbench.getActiveShell(), "New Child Error", - "Access control has restricted this action. The current user does not have sufficient permission to create relations on this artifact."); - return; - } - parent = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(getBranch()); + XResultData rd = OseeApiService.get().getAccessControlService().hasArtifactPermission(parent, + PermissionEnum.WRITE, AccessControlArtifactUtil.getXResultAccessHeader("New Child Error", parent)); + if (rd.isErrors()) { + XResultDataDialog.open(rd, "New Child Error", + "You do not have permissions to add related to artifact %s", parent.toStringWithId()); + return; } handleCreateChild(parent, treeViewer); } catch (Exception ex) { @@ -586,7 +585,7 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { Artifact selectedArtifact = (Artifact) selection.getFirstElement(); try { if (selectedArtifact != null) { - PolicyDialog pd = new PolicyDialog(Displays.getActiveShell(), selectedArtifact); + PolicyDialog pd = PolicyDialog.createPolicyDialog(Displays.getActiveShell(), selectedArtifact); pd.open(); artifactExplorer.refreshBranchWarning(); } @@ -597,6 +596,25 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { }); } + private void createShowAccessControlMenuItem(Menu parentMenu) { + showAccessControlMenuItem = new MenuItem(parentMenu, SWT.PUSH); + showAccessControlMenuItem.setImage(ImageManager.getImage(FrameworkImage.LOCK_DETAILS)); + showAccessControlMenuItem.setText(AccessControlDetails.NAME); + showAccessControlMenuItem.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); + Artifact selectedArtifact = (Artifact) selection.getFirstElement(); + try { + (new AccessControlDetails(selectedArtifact)).run(); + } catch (Exception ex) { + OseeLog.log(Activator.class, Level.SEVERE, ex); + } + } + }); + } + private void createLockMenuItem(Menu parentMenu) { lockMenuItem = new MenuItem(parentMenu, SWT.PUSH); lockMenuItem.addSelectionListener(new SelectionAdapter() { @@ -622,10 +640,11 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { try { if (!unlockArtifacts.isEmpty()) { - AccessControlManager.unLockObjects(unlockArtifacts, UserManager.getUser()); + OseeApiService.get().getAccessControlService().unLockArtifacts(UserManager.getUser(), + Collections.castAll(unlockArtifacts)); } if (!lockArtifacts.isEmpty()) { - AccessControlManager.lockObjects(lockArtifacts, UserManager.getUser()); + OseeApiService.get().getAccessControlService().lockArtifacts(UserManager.getUser(), lockArtifacts); } } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); @@ -668,7 +687,7 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { artifactTransferData.add(artifact); } } - artifactClipboard.setArtifactsToClipboard(ServiceUtil.getAccessPolicy(), artifactTransferData); + artifactClipboard.setArtifactsToClipboard(artifactTransferData); } } @@ -799,4 +818,8 @@ public class ArtifactExplorerMenu implements ISelectedArtifacts { return getSelection().toList(); } + public void resetMenu() { + setupPopupMenu(); + } + } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/CreateRelatedMenuItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/CreateRelatedMenuItem.java index 570f146e72..14af4fadc1 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/CreateRelatedMenuItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/CreateRelatedMenuItem.java @@ -15,25 +15,26 @@ package org.eclipse.osee.framework.ui.skynet.explorer.menu; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.List; -import java.util.logging.Level; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.osee.framework.core.OrcsTokenService; -import org.eclipse.osee.framework.core.access.PermissionStatus; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.RelationTypeSide; import org.eclipse.osee.framework.core.data.RelationTypeToken; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; +import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; import org.eclipse.osee.framework.core.enums.RelationSide; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; @@ -41,6 +42,7 @@ import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.StringLabelProvider; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.explorer.ArtifactExplorer; import org.eclipse.osee.framework.ui.skynet.explorer.ArtifactExplorerLinkNode; import org.eclipse.osee.framework.ui.skynet.explorer.MenuPermissions; @@ -50,6 +52,7 @@ import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialog; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredTreeArtifactTypeEntryDialog; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredTreeRelationTypeDialog; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -93,25 +96,23 @@ public class CreateRelatedMenuItem implements SelectionListener { relationTypeSide = RelationTypeSide.create(relationType, RelationSide.SIDE_A); } - AccessPolicy service = ServiceUtil.getAccessPolicy(); + XResultData rd = OseeApiService.get().getAccessControlService().hasRelationTypePermission(existingArtifact, + relationTypeSide, null, PermissionEnum.WRITE, AccessControlArtifactUtil.getXResultAccessHeader("New Related", + Collections.singleton(existingArtifact), relationTypeSide)); - // check permissions - PermissionStatus status = - service.canRelationBeModified(existingArtifact, null, relationTypeSide, Level.FINE); - if (status.matched()) { + if (rd.isSuccess()) { handleCreateRelated(existingArtifact, relationType, relationTypeSide, relationSide); } else { - MessageDialog.openError(AWorkbench.getActiveShell(), "New Child Error", - "Access control has restricted this action. The current user does not have sufficient permission to create relations on this artifact."); + XResultDataDialog.open(rd, "New Child Error", + "You do not have permissions to add a New Related artifact"); } } else if (obj instanceof Artifact) { Artifact parentArt = (Artifact) obj; - AccessPolicy policy = ServiceUtil.getAccessPolicy(); + boolean hasPermission = OseeApiService.get().getAccessControlService().hasRelationTypePermission(parentArt, + CoreRelationTypes.DefaultHierarchical_Child, null, PermissionEnum.WRITE, null).isSuccess(); - PermissionStatus status = - policy.canRelationBeModified(parentArt, null, CoreRelationTypes.DefaultHierarchical_Child, Level.FINE); - if (!status.matched()) { + if (!hasPermission) { MessageDialog.openError(AWorkbench.getActiveShell(), "New Child Error", "Access control has restricted this action. The current user does not have sufficient permission to create relations on this artifact."); return; @@ -208,7 +209,7 @@ public class CreateRelatedMenuItem implements SelectionListener { return dialog; } - public void setCreateRelatedEnabled(Object obj, AccessPolicy service) { + public void setCreateRelatedEnabled(Object obj) { if (obj instanceof ArtifactExplorerLinkNode) { ArtifactExplorerLinkNode linkNode = (ArtifactExplorerLinkNode) obj; Artifact artifact = linkNode.getArtifact(); @@ -222,8 +223,10 @@ public class CreateRelatedMenuItem implements SelectionListener { MenuPermissions permiss = new MenuPermissions(artifact); - boolean canModifyRelation = service.canRelationBeModified(artifact, null, relationSide, Level.FINE).matched(); - menuItem.setEnabled(permiss.isWritePermission() && canModifyRelation); + boolean hasPermission = OseeApiService.get().getAccessControlService().hasRelationTypePermission(artifact, + relationSide, Collections.emptyList(), PermissionEnum.WRITE, null).isSuccess(); + + menuItem.setEnabled(permiss.isWritePermission() && hasPermission); } else if (obj instanceof Artifact) { Artifact artifact = (Artifact) obj; MenuPermissions permiss = new MenuPermissions(artifact); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java index b54ea2898c..3614236549 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java @@ -13,19 +13,13 @@ package org.eclipse.osee.framework.ui.skynet.internal; -import java.util.logging.Level; -import org.eclipse.core.runtime.Platform; import org.eclipse.osee.account.rest.client.AccountClient; import org.eclipse.osee.framework.core.OrcsTokenService; import org.eclipse.osee.framework.core.services.IOseeCachingService; import org.eclipse.osee.framework.core.util.OsgiUtil; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.ui.skynet.cm.IOseeCmService; import org.eclipse.osee.orcs.rest.client.OseeClient; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; import org.osgi.service.packageadmin.PackageAdmin; @SuppressWarnings("deprecation") @@ -59,18 +53,6 @@ public final class ServiceUtil { return getService(PackageAdmin.class); } - public static AccessPolicy getAccessPolicy() { - try { - Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.access"); - if (bundle.getState() != Bundle.ACTIVE) { - bundle.start(); - } - } catch (BundleException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - return getService(AccessPolicy.class); - } - public static IOseeCmService getOseeCmService() { return getService(IOseeCmService.class); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ConfigurationDetails.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ConfigurationDetails.java index a0ba09c53b..952777caee 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ConfigurationDetails.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ConfigurationDetails.java @@ -131,7 +131,7 @@ public class ConfigurationDetails extends PreferencePage implements IWorkbenchPr String bundleVerStr = OseeCodeVersion.getBundleVersion(); String display = verStr; if (!verStr.equals(bundleVerStr)) { - display = String.format("%s / %s/", verStr, bundleVerStr); + display = String.format("%s / %s", verStr, bundleVerStr); } builder.append("OSEE Client Version" + display + ""); } catch (NullPointerException ex) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/EditorsPreferencePage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/EditorsPreferencePage.java index 4eaa95b9a7..df6bdc3e6d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/EditorsPreferencePage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/EditorsPreferencePage.java @@ -246,9 +246,9 @@ public class EditorsPreferencePage extends PreferencePage implements IWorkbenchP boolean editOnOpen = editButton.getSelection(); UserManager.setSetting(UserManager.DOUBLE_CLICK_SETTING_KEY_EDIT, String.valueOf(editOnOpen)); if (editOnOpen) { - UserGroupService.get(CoreUserGroups.DefaultArtifactEditor).removeMember(UserManager.getUser()); + UserGroupService.get(CoreUserGroups.DefaultArtifactEditor).removeMember(UserManager.getUser(), true); } else { - UserGroupService.get(CoreUserGroups.DefaultArtifactEditor).addMember(UserManager.getUser()); + UserGroupService.get(CoreUserGroups.DefaultArtifactEditor).addMember(UserManager.getUser(), true); } RendererManager.clearCaches(); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/example/XResultDataDialogExample.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/example/XResultDataDialogExample.java index 0b562cca84..4937d304e3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/example/XResultDataDialogExample.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/example/XResultDataDialogExample.java @@ -37,9 +37,8 @@ public final class XResultDataDialogExample extends XNavigateItemAction { rd.log("This is a log message"); rd.error("This is a error message"); rd.warning("This is a warn message"); - XResultDataDialog diag = new XResultDataDialog(getName(), - "This is the message.\n\nTo XResultData contents, select the hyperlink below.", rd); - diag.open(); + XResultDataDialog.open(rd, getName(), + "This is the message.\n\nTo XResultData contents, select the hyperlink below."); } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java index bb087b6921..bd7f881f7d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java @@ -30,24 +30,24 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.osee.framework.core.OrcsTokenService; import org.eclipse.osee.framework.core.data.ArtifactTypeToken; import org.eclipse.osee.framework.core.data.AttributeTypeToken; -import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.RelationTypeToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.RelationSide; import org.eclipse.osee.framework.help.ui.OseeHelpContext; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; 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.attribute.AttributeTypeManager; -import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.ArrayTreeContentProvider; import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; import org.eclipse.osee.framework.ui.plugin.util.StringLabelProvider; import org.eclipse.osee.framework.ui.skynet.ToStringViewerSorter; -import org.eclipse.osee.framework.ui.skynet.access.AccessControlService; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.change.ChangeUiUtil; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; @@ -60,6 +60,7 @@ import org.eclipse.osee.framework.ui.skynet.util.NamedLabelProvider; import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredCheckboxTree; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredTree; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.HyperLinkLabel; import org.eclipse.osee.framework.ui.swt.ToStringContainsPatternFilter; @@ -161,9 +162,10 @@ public class ArtifactSearchPage extends DialogPage implements ISearchPage, IRepl @Override public void handleEvent(Event event) { - BranchId branch = branchSelect.getSelection(); - if (!isBranchReadable(branch)) { - AWorkbench.popup(String.format("Read Access Denied for branch [%s]", branch)); + BranchToken branch = branchSelect.getSelection(); + XResultData rd = isBranchReadable(branch); + if (rd.isErrors()) { + XResultDataDialog.open(rd, "Branch Access", "Read Access Denied for branch %s", branch.toStringWithId()); } } } @@ -557,20 +559,20 @@ public class ArtifactSearchPage extends DialogPage implements ISearchPage, IRepl } public void updateOKStatus() { - if (isBranchReadable( - getSelectedBranch()) && filterviewer == null || filterviewer.getFilterList().getFilters().isEmpty()) { + XResultData rd = isBranchReadable(getSelectedBranch()); + if (rd.isSuccess() && filterviewer == null || filterviewer.getFilterList().getFilters().isEmpty()) { getContainer().setPerformActionEnabled(false); } else { getContainer().setPerformActionEnabled(true); } } - private static boolean isBranchReadable(BranchId branch) { - boolean read = false; + private static XResultData isBranchReadable(BranchToken branch) { if (branch != null) { - read = AccessControlService.getAccessService().hasPermission(branch, PermissionEnum.READ); + return OseeApiService.get().getAccessControlService().hasBranchPermission(branch, PermissionEnum.READ, + AccessControlArtifactUtil.getXResultAccessHeader("Branch Selection", branch)); } - return read; + return null; } private String asString(FilterModel model) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java index 847e6772ae..3223134127 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.logging.Level; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ApplicabilityToken; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; @@ -32,20 +31,23 @@ import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.util.ArtifactSearchOptions; import org.eclipse.osee.framework.help.ui.OseeHelpContext; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Collections; import org.eclipse.osee.framework.jdk.core.util.GUID; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.OseeStatusContributionItemFactory; -import org.eclipse.osee.framework.ui.skynet.access.AccessControlService; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.panels.SearchComposite; import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite; import org.eclipse.osee.framework.ui.skynet.widgets.GenericViewPart; import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.osee.framework.ui.swt.ALayout; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; @@ -246,7 +248,7 @@ public class QuickSearchView extends GenericViewPart { panel.setLayout(gL); panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { idSearchComposite = new SearchComposite(panel, SWT.NONE, "Search", "Search by ID:", this, false); idSearchComposite.addListener(idSearchListener); } @@ -274,7 +276,7 @@ public class QuickSearchView extends GenericViewPart { applicability = new QuickSearchApplicabilityToken(appSearchGroup, this); applicability.create(); - if (!AccessControlManager.isOseeAdmin()) { + if (!OseeApiService.get().getAccessControlService().isOseeAdmin()) { idSearchComposite = new SearchComposite(panel, SWT.NONE, "Search", "Search by ID:", this, false); idSearchComposite.addListener(idSearchListener); } @@ -345,11 +347,15 @@ public class QuickSearchView extends GenericViewPart { public void handleEvent(Event event) { if (Widgets.isAccessible(branchLabel) && branchSelect != null) { branchLabel.setText(""); - final BranchId branch = branchSelect.getData(); + final BranchToken branch = branchSelect.getData(); if (branch == null) { branchLabel.setText("Error: Must Select a Branch"); - } else if (!AccessControlService.getAccessService().hasPermission(branch, PermissionEnum.READ)) { - AWorkbench.popup(String.format("Access Denied for branch [%s]", branch)); + } + + XResultData rd = OseeApiService.get().getAccessControlService().hasBranchPermission(branch, + PermissionEnum.READ, AccessControlArtifactUtil.getXResultAccessHeader("Select Branch", branch)); + if (rd.isErrors()) { + XResultDataDialog.open(rd, "Branch Select Failed", "Access Denied for branch [%s]", branch); } else if (Widgets.isAccessible(attrSearchComposite) && attrSearchComposite.isExecuteSearchEvent( event) && Widgets.isAccessible(optionsComposite)) { @@ -393,11 +399,12 @@ public class QuickSearchView extends GenericViewPart { public void handleEvent(Event event) { if (Widgets.isAccessible(branchLabel) && branchSelect != null) { branchLabel.setText(""); - final BranchId branch = branchSelect.getData(); + final BranchToken branch = branchSelect.getData(); if (branch == null) { branchLabel.setText("Error: Must Select a Branch"); - } else if (!AccessControlService.getAccessService().hasPermission(branch, PermissionEnum.READ)) { - // since AttributeSearchListener is called when Select Branch is actioned, only display if this is the guid search button + } else if (!OseeApiService.get().getAccessControlService().hasBranchPermission(branch, PermissionEnum.READ, + null).isSuccess()) { + // since AttributeSearchListener is called when Select Branch is selected, only display if this is the guid search button if (event.widget instanceof Button && ((Button) event.widget).getText().equals("Search")) { AWorkbench.popup(String.format("Access Denied for branch [%s]", branch)); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/update/InterArtifactExplorerDropHandlerOperation.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/update/InterArtifactExplorerDropHandlerOperation.java index 5d19111a20..8461a1793f 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/update/InterArtifactExplorerDropHandlerOperation.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/update/InterArtifactExplorerDropHandlerOperation.java @@ -20,22 +20,25 @@ import java.util.List; import java.util.logging.Level; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.operation.AbstractOperation; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; 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.IntroduceArtifactOperation; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.CheckBoxDialog; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.osee.framework.ui.swt.Displays; /** @@ -66,7 +69,7 @@ public class InterArtifactExplorerDropHandlerOperation extends AbstractOperation if (destinationParentArtifact == null || sourceArtifacts == null || sourceArtifacts.isEmpty()) { throw new OseeArgumentException("Invalid arguments"); } - BranchId sourceBranch = sourceArtifacts.iterator().next().getBranchToken(); + BranchToken sourceBranch = sourceArtifacts.iterator().next().getBranchToken(); final BranchToken destinationBranch = destinationParentArtifact.getBranchToken(); if (isUpdateFromParent(sourceBranch, destinationBranch)) { @@ -76,7 +79,9 @@ public class InterArtifactExplorerDropHandlerOperation extends AbstractOperation MessageDialog.openError(Displays.getActiveShell(), ACCESS_ERROR_MSG_TITLE, UPDATE_FROM_PARENT_ERROR_MSG); } }); - } else if (isAccessAllowed(sourceBranch, destinationBranch)) { + } + XResultData rd = isAccessAllowed(sourceBranch, destinationBranch); + if (rd.isSuccess()) { Displays.ensureInDisplayThread(new Runnable() { @Override public void run() { @@ -108,16 +113,22 @@ public class InterArtifactExplorerDropHandlerOperation extends AbstractOperation Displays.ensureInDisplayThread(new Runnable() { @Override public void run() { - MessageDialog.openError(Displays.getActiveShell(), ACCESS_ERROR_MSG_TITLE, ACCESS_ERROR_MSG); + XResultDataDialog.open(rd, ACCESS_ERROR_MSG_TITLE, ACCESS_ERROR_MSG); } }); } monitor.done(); } - private boolean isAccessAllowed(BranchId sourceBranch, BranchId destinationBranch) { - return AccessControlManager.hasPermission(destinationBranch, - PermissionEnum.WRITE) && AccessControlManager.hasPermission(sourceBranch, PermissionEnum.READ); + private XResultData isAccessAllowed(BranchToken sourceBranch, BranchToken destinationBranch) { + XResultData rd = OseeApiService.get().getAccessControlService().hasBranchPermission(destinationBranch, + PermissionEnum.WRITE, AccessControlArtifactUtil.getXResultAccessHeader("Drag/Drop Artifact", sourceBranch)); + if (rd.isErrors()) { + return rd; + } + rd = OseeApiService.get().getAccessControlService().hasBranchPermission(sourceBranch, PermissionEnum.READ, + AccessControlArtifactUtil.getXResultAccessHeader("Drag/Drop Artifact", sourceBranch)); + return rd; } private boolean isUpdateFromParent(BranchId sourceBranch, BranchId destinationBranch) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/user/UserNavigateViewItems.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/user/UserNavigateViewItems.java index 1abd9316a2..55cfc4382d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/user/UserNavigateViewItems.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/user/UserNavigateViewItems.java @@ -17,7 +17,6 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.Active; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; @@ -28,6 +27,7 @@ import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateViewItems; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.blam.operation.CreateNewUser; import org.eclipse.osee.framework.ui.skynet.blam.operation.PopulateUserGroupBlam; import org.eclipse.osee.framework.ui.skynet.internal.Activator; @@ -77,7 +77,7 @@ public class UserNavigateViewItems implements XNavigateViewItems, IXNavigateComm items.add(new XNavigateItemAction(parentItem, new OpenUsersInMassEditor("Open All Users", Active.Both), FrameworkImage.USER)); - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { items.add(new XNavigateItemBlam(parentItem, new CreateNewUser(), FrameworkImage.ADD_GREEN)); items.add(new XNavigateItemBlam(parentItem, new PopulateUserGroupBlam(), FrameworkImage.GROUP)); } @@ -98,7 +98,7 @@ public class UserNavigateViewItems implements XNavigateViewItems, IXNavigateComm @Override public void createCommonSection(List items, List excludeSectionIds) { try { - boolean admin = AccessControlManager.isOseeAdmin(); + boolean admin = OseeApiService.get().getAccessControlService().isOseeAdmin(); if (admin) { XNavigateItem reviewItem = new XNavigateItem(null, "User Management", FrameworkImage.USER); addOseeUserSectionChildren(reviewItem); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java index bc9657cbe3..316f58d9e3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/ArtifactClipboard.java @@ -18,14 +18,13 @@ import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.List; -import java.util.logging.Level; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.jdk.core.util.Collections; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactData; import org.eclipse.osee.framework.ui.skynet.HTMLTransferFormatter; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.dnd.Clipboard; @@ -46,15 +45,14 @@ public class ArtifactClipboard { this.viewId = viewId; } - private List getArtifactsWithPermission(AccessPolicy accessService, PermissionEnum permission, List artifacts) { + private List getArtifactsWithPermission(PermissionEnum permission, List artifacts) { ArrayList toReturn = new ArrayList<>(artifacts); Iterator artIterator = toReturn.iterator(); // Remove Artifact that do not have write permission. while (artIterator.hasNext()) { - Artifact cur = artIterator.next(); - if (!accessService.hasArtifactPermission(java.util.Collections.singleton(cur), permission, - Level.WARNING).matched()) { + Artifact art = artIterator.next(); + if (!OseeApiService.get().getAccessControlService().hasArtifactPermission(art, permission, null).isSuccess()) { artIterator.remove(); } } @@ -67,7 +65,7 @@ public class ArtifactClipboard { } } - public void setArtifactsToClipboard(AccessPolicy policyHandlerService, List artifactTransferData) { + public void setArtifactsToClipboard(List artifactTransferData) { if (artifactTransferData == null) { throw new IllegalArgumentException("Artifacts can not be null for artifact copy."); } @@ -79,8 +77,7 @@ public class ArtifactClipboard { } List authFailedList = new ArrayList<>(artifactTransferData); - List authorizedArtifacts = - getArtifactsWithPermission(policyHandlerService, PermissionEnum.READ, artifactTransferData); + List authorizedArtifacts = getArtifactsWithPermission(PermissionEnum.READ, artifactTransferData); authFailedList.removeAll(authorizedArtifacts); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/MergeInProgressHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/MergeInProgressHandler.java index 925eb2054e..870b9c2483 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/MergeInProgressHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/MergeInProgressHandler.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.logging.Level; import org.apache.commons.lang.mutable.MutableBoolean; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionResult; import org.eclipse.osee.framework.jdk.core.type.MutableInteger; @@ -30,6 +29,7 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.conflict.ConflictManagerExternal; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.widgets.xmerge.MergeView; import org.eclipse.osee.framework.ui.swt.Displays; @@ -173,7 +173,7 @@ public class MergeInProgressHandler { String[] choices; boolean isAdmin = false; try { - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { isAdmin = true; } } catch (OseeCoreException ex) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/email/EmailUserGroups.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/email/EmailUserGroups.java index bfa87c363e..ffa562558c 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/email/EmailUserGroups.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/email/EmailUserGroups.java @@ -17,7 +17,6 @@ import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; import java.util.HashSet; import java.util.Set; import java.util.logging.Level; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; import org.eclipse.osee.framework.core.enums.DeletionFlag; @@ -35,6 +34,7 @@ import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLo import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.results.ResultsEditor; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredCheckboxTreeArtifactDialog; @@ -57,7 +57,8 @@ public class EmailUserGroups extends XNavigateItemAction { for (Artifact art : ArtifactQuery.getArtifactListFromTypeWithInheritence(CoreArtifactTypes.UserGroup, COMMON, DeletionFlag.EXCLUDE_DELETED)) { // Only add group if have read permissions - if (!art.getName().equals("Root Artifact") && AccessControlManager.hasPermission(art, PermissionEnum.READ)) { + if (!art.getName().equals("Root Artifact") && OseeApiService.get().getAccessControlService().hasArtifactPermission(art, + PermissionEnum.READ, null).isSuccess()) { artifacts.add(art); } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XTextDam.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XTextDam.java index 01df07e256..6465ca29bf 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XTextDam.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XTextDam.java @@ -31,7 +31,7 @@ import org.eclipse.osee.framework.ui.skynet.internal.Activator; */ public class XTextDam extends XText implements AttributeWidget { - public static final String WIDGET_ID = XStackedDam.class.getSimpleName(); + public static final String WIDGET_ID = XTextDam.class.getSimpleName(); private Artifact artifactStrongRef; private AttributeTypeToken attributeType; private final boolean isWeakReference; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XWidgetAccessDecorationProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XWidgetAccessDecorationProvider.java index 6a592ca2fa..3c78ddaea5 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XWidgetAccessDecorationProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XWidgetAccessDecorationProvider.java @@ -15,18 +15,23 @@ package org.eclipse.osee.framework.ui.skynet.widgets; import java.util.Collections; import java.util.logging.Level; -import org.eclipse.osee.framework.core.access.PermissionStatus; -import org.eclipse.osee.framework.core.data.AttributeTypeId; +import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.jdk.core.result.XResultData; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.AccessPolicy; +import org.eclipse.osee.framework.skynet.core.access.AccessControlArtifactUtil; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.internal.Activator; +import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI; import org.eclipse.osee.framework.ui.skynet.widgets.XWidgetDecorator.Decorator; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.osee.framework.ui.swt.Widgets; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; @@ -37,12 +42,7 @@ import org.eclipse.swt.widgets.Label; public class XWidgetAccessDecorationProvider implements XWidgetDecorator.DecorationProvider { private static final Image LOCK_IMAGE = ImageManager.getImage(FrameworkImage.LOCK_OVERLAY); - - private final AccessPolicy policyHandlerService; - - public XWidgetAccessDecorationProvider(AccessPolicy policyHandlerService) { - this.policyHandlerService = policyHandlerService; - } + private static final Image UNLOCK_IMAGE = ImageManager.getImage(FrameworkImage.LOCK_UNLOCKED); @Override public int getPriority() { @@ -53,34 +53,45 @@ public class XWidgetAccessDecorationProvider implements XWidgetDecorator.Decorat public void onUpdate(XWidget xWidget, Decorator decorator) { if (xWidget instanceof AttributeWidget) { AttributeWidget attributeWidget = (AttributeWidget) xWidget; - AttributeTypeId attributeType = attributeWidget.getAttributeType(); + AttributeTypeToken attributeType = attributeWidget.getAttributeType(); - PermissionStatus permissionStatus = new PermissionStatus(); Artifact artifact = attributeWidget.getArtifact(); + final XResultData rd = AccessControlArtifactUtil.getXResultAccessHeader("Change Attribute", + Collections.singleton(artifact), attributeType); try { - permissionStatus = policyHandlerService.hasAttributeTypePermission(Collections.singletonList(artifact), - attributeType, PermissionEnum.WRITE, Level.FINE); + OseeApiService.get().getAccessControlService().hasAttributeTypePermission(Collections.singleton(artifact), + attributeType, PermissionEnum.WRITE, rd); } catch (OseeCoreException ex) { + rd.errorf("Error computing access permissions %s", Lib.exceptionToString(ex)); OseeLog.log(Activator.class, Level.SEVERE, ex); } // Get Info from AccessControlServiceImpl and take in to account if widget was editable before; - boolean isWriteable = permissionStatus.matched(); - boolean isLocked = !isWriteable || artifact.isReadOnly(); - String reason = permissionStatus.getReason(); + boolean isWriteable = rd.isSuccess(); + String reason = rd.toString(); Control control = xWidget.getControl(); if (Widgets.isAccessible(control)) { - xWidget.setEditable(!isLocked); + xWidget.setEditable(isWriteable); } Label label = xWidget.getLabelWidget(); if (Widgets.isAccessible(label)) { - label.setEnabled(!isLocked); + label.setEnabled(isWriteable); + label.addMouseListener(new MouseAdapter() { + + @Override + public void mouseUp(MouseEvent e) { + if (e.button == 3) { + XResultDataUI.report(rd, "Access Control Details"); + } + } + + }); } - decorator.setImage(isLocked ? LOCK_IMAGE : null); - decorator.setDescription(isLocked ? reason : null); - decorator.setVisible(isLocked); + decorator.setImage(isWriteable ? UNLOCK_IMAGE : LOCK_IMAGE); + decorator.setDescription(reason); + decorator.setVisible(!isWriteable); } } }; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/XResultDataDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/XResultDataDialog.java index 6bad95a079..6d152fe3d0 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/XResultDataDialog.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/XResultDataDialog.java @@ -45,12 +45,15 @@ public class XResultDataDialog extends MessageDialog { private final List closeEventListeners = new ArrayList<>(); private final String dialogTitle; - private XResultData rd; + private XResultData detailsResultsData; - public XResultDataDialog(String dialogTitle, String dialogMessage, XResultData rd) { + /** + * @param detailsResultsData - Will open if Show Details is selected + */ + public XResultDataDialog(String dialogTitle, String dialogMessage, XResultData detailsResultsData) { this(Displays.getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.QUESTION, new String[] {"OK", "Cancel"}, 0); - this.rd = rd; + this.detailsResultsData = detailsResultsData; } public XResultDataDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) { @@ -84,7 +87,7 @@ public class XResultDataDialog extends MessageDialog { @Override public void handleEvent(Event event) { - XResultDataUI.report(rd, dialogTitle); + XResultDataUI.report(detailsResultsData, dialogTitle); close(); } }); @@ -113,4 +116,9 @@ public class XResultDataDialog extends MessageDialog { closeEventListeners.add(event); } + public static void open(XResultData rd, String title, String format, Object... data) { + XResultDataDialog diag = new XResultDataDialog(title, String.format(format, data), rd); + diag.open(); + } + } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java index 906cae4cf7..60f8bd67f9 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java @@ -26,7 +26,6 @@ import org.eclipse.osee.framework.skynet.core.utility.AttributeTypeToXWidgetName import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget; import org.eclipse.osee.framework.ui.skynet.widgets.XIntegerDam; import org.eclipse.osee.framework.ui.skynet.widgets.XOption; -import org.eclipse.osee.framework.ui.skynet.widgets.XStackedDam; import org.eclipse.osee.framework.ui.skynet.widgets.XTextDam; import org.eclipse.osee.framework.ui.skynet.widgets.XTextFlatDam; @@ -72,8 +71,9 @@ public class DefaultAttributeXWidgetProvider implements IAttributeXWidgetProvide defaultData.getXOptionHandler().add(XOption.FILL_VERTICALLY); xWidgetName = XTextDam.WIDGET_ID; } else if (useMultiLineWidget(attributeType)) { - xWidgetName = XStackedDam.WIDGET_ID; + xWidgetName = XTextDam.WIDGET_ID; defaultData.getXOptionHandler().add(XOption.NOT_EDITABLE); + defaultData.getXOptionHandler().add(XOption.FILL_VERTICALLY); } else if (attributeType.isBranchId()) { xWidgetName = XBranchSelectWidget.WIDGET_ID; } else if (attributeType.isArtifactId()) { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/BranchXViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/BranchXViewer.java index 332ed8c224..ab0065a61f 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/BranchXViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/BranchXViewer.java @@ -18,7 +18,6 @@ import java.util.Collection; import org.eclipse.jface.action.MenuManager; import org.eclipse.nebula.widgets.xviewer.XViewer; import org.eclipse.nebula.widgets.xviewer.XViewerTextFilter; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.enums.PermissionEnum; @@ -30,10 +29,11 @@ import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.util.HelpUtil; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.explorer.ArtifactExplorer; import org.eclipse.osee.framework.ui.skynet.internal.Activator; -import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI; import org.eclipse.osee.framework.ui.skynet.util.PromptChangeUtil; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.XResultDataDialog; import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.XBranchWidget.IBranchWidgetMenuListener; import org.eclipse.osee.framework.ui.skynet.widgets.xmerge.MergeView; import org.eclipse.swt.widgets.Composite; @@ -58,8 +58,8 @@ public class BranchXViewer extends XViewer { ArrayList branches = xBranchViewer.getSelectedBranches(); if (branches != null && !branches.isEmpty()) { for (BranchToken branch : branches) { - boolean hasPermission = AccessControlManager.hasPermission(branch, PermissionEnum.READ); - if (hasPermission) { + OseeApiService.get().getAccessControlService().hasBranchPermission(branch, PermissionEnum.READ, rd); + if (rd.isSuccess()) { if (branch.notEqual(CoreBranches.SYSTEM_ROOT)) { if (!BranchManager.getType(branch).isMergeBranch()) { ArtifactExplorer.exploreBranch(branch); @@ -79,7 +79,7 @@ public class BranchXViewer extends XViewer { } } if (rd.isErrors()) { - XResultDataUI.report(rd, "Branch Access Denied"); + XResultDataDialog.open(rd, "Branch Access Denied", "Branch Access Denied"); } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchContentProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchContentProvider.java index 7176e28d89..64f0f7d91b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchContentProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchContentProvider.java @@ -23,7 +23,6 @@ import java.util.Set; import java.util.logging.Level; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.enums.BranchArchivedState; @@ -32,6 +31,7 @@ import org.eclipse.osee.framework.core.model.cache.BranchFilter; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.change.ChangeUiUtil; /** @@ -99,7 +99,7 @@ public class XBranchContentProvider implements ITreeContentProvider { List branchTypes = new ArrayList<>(4); try { - boolean isAdmin = AccessControlManager.isOseeAdmin(); + boolean isAdmin = OseeApiService.get().getAccessControlService().isOseeAdmin(); if (isAdmin) { branchTypes.add(BranchType.SYSTEM_ROOT); } @@ -119,7 +119,7 @@ public class XBranchContentProvider implements ITreeContentProvider { branchesToReturn.addAll(BranchManager.getBranches(BranchArchivedState.UNARCHIVED, BranchType.WORKING)); } if (!showChildBranchesAtMainLevel) { - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { branchesToReturn.add(SYSTEM_ROOT); } branchTypes.add(BranchType.BASELINE); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchLabelProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchLabelProvider.java index 6cb6f0deb9..f9340eb3be 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchLabelProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchLabelProvider.java @@ -23,14 +23,11 @@ import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.nebula.widgets.xviewer.XViewerCells; import org.eclipse.nebula.widgets.xviewer.XViewerLabelProvider; import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; -import org.eclipse.osee.framework.core.data.AccessContextToken; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionRecord; -import org.eclipse.osee.framework.core.services.CmAccessControl; -import org.eclipse.osee.framework.core.util.OsgiUtil; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.UserManager; @@ -162,24 +159,10 @@ public class XBranchLabelProvider extends XViewerLabelProvider { } } else if (cCol.equals(BranchXViewerFactory.inheritAccessControl)) { return String.valueOf(branch.isInheritAccessControl()); - } else if (cCol.equals(BranchXViewerFactory.branchAccessContextId)) { - return getBranchAccessContextId(branch); } return ""; } - private String getBranchAccessContextId(Branch branch) { - String accessContextId = ""; - try { - CmAccessControl cmAccessControl = OsgiUtil.getService(getClass(), CmAccessControl.class); - Collection ids = cmAccessControl.getContextId(UserManager.getUser(), branch); - accessContextId = ids.toString(); - } catch (Exception ex) { - return String.format("Exception %s", ex.getLocalizedMessage()); - } - return accessContextId; - } - protected String getTransactionText(TransactionRecord transaction, XViewerColumn cCol, int columnIndex) { String columnText = ""; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchWidget.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchWidget.java index e7012bf6cc..11eb302fa3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchWidget.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchWidget.java @@ -25,7 +25,6 @@ import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.TransactionId; @@ -38,6 +37,7 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.PluginUiImage; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.change.BranchTransactionUiData; import org.eclipse.osee.framework.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.widgets.GenericXWidget; @@ -262,7 +262,7 @@ public class XBranchWidget extends GenericXWidget implements IOseeTreeReportProv } }); - if (AccessControlManager.isOseeAdmin()) { + if (OseeApiService.get().getAccessControlService().isOseeAdmin()) { allButton = new ToolItem(toolBar, SWT.CHECK); allButton.setImage(ImageManager.getImage(FrameworkImage.ADD_GREEN)); allButton.setToolTipText("Show All Branches (Admin)"); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java index a42aee09b2..a7abb3c6d4 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java @@ -33,7 +33,6 @@ import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.nebula.widgets.xviewer.customize.XViewerCustomMenu; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; @@ -65,6 +64,7 @@ import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.OpenContributionItem; import org.eclipse.osee.framework.ui.skynet.OseeStatusContributionItemFactory; import org.eclipse.osee.framework.ui.skynet.action.CompareArtifactAction; +import org.eclipse.osee.framework.ui.skynet.access.internal.OseeApiService; import org.eclipse.osee.framework.ui.skynet.action.EditTransactionComment; import org.eclipse.osee.framework.ui.skynet.action.ITransactionRecordSelectionProvider; import org.eclipse.osee.framework.ui.skynet.action.WasIsCompareEditorAction; @@ -243,7 +243,7 @@ public class HistoryView extends GenericViewPart implements IBranchEventListener final MenuItem replaceWithMenu = new MenuItem(popupMenu, SWT.CASCADE); replaceWithMenu.setText("&Replace Attribute with Version"); try { - replaceWithMenu.setEnabled(AccessControlManager.isOseeAdmin()); + replaceWithMenu.setEnabled(OseeApiService.get().getAccessControlService().isOseeAdmin()); } catch (Exception ex) { replaceWithMenu.setEnabled(false); } diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/FontManager.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/FontManager.java index 49e3282b9f..537f648fc4 100644 --- a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/FontManager.java +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/FontManager.java @@ -22,7 +22,7 @@ import org.eclipse.swt.graphics.FontData; /** * Share font resources among OSEE applications - * + * * @author Donald G. Dunne */ public final class FontManager { diff --git a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml deleted file mode 100644 index 0549830ef3..0000000000 --- a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.subscription.ds.xml b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.subscription.ds.xml deleted file mode 100644 index 2ccb565de5..0000000000 --- a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.subscription.ds.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java index 3c4b8c06ec..5332f8b7d5 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java @@ -133,9 +133,9 @@ public class TxDataManagerTest { r2Guid = GUID.create(); r3Guid = GUID.create(); - Long id1 = Lib.generateUuid(); - Long id2 = Lib.generateUuid(); - Long id3 = Lib.generateUuid(); + Long id1 = Lib.generateArtifactIdAsInt(); + Long id2 = Lib.generateArtifactIdAsInt(); + Long id3 = Lib.generateArtifactIdAsInt(); artifactId1 = ArtifactToken.valueOf(id1, r1Guid, "", COMMON, null); artifactId2 = ArtifactToken.valueOf(id2, r2Guid, "", COMMON, null); diff --git a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF index d1f3517cac..dc309f9325 100644 --- a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF @@ -27,11 +27,11 @@ Import-Package: com.fasterxml.jackson.annotation, org.eclipse.osee.console.admin, org.eclipse.osee.framework.core, org.eclipse.osee.framework.core.access, + org.eclipse.osee.framework.core.access.event, + org.eclipse.osee.framework.core.access.object, + org.eclipse.osee.framework.core.access.operation, org.eclipse.osee.framework.core.applicability, org.eclipse.osee.framework.core.data, - org.eclipse.osee.framework.core.dsl, - org.eclipse.osee.framework.core.dsl.oseeDsl, - org.eclipse.osee.framework.core.dsl.oseeDsl.util, org.eclipse.osee.framework.core.enums, org.eclipse.osee.framework.core.enums.token, org.eclipse.osee.framework.core.exception, diff --git a/plugins/org.eclipse.osee.orcs.core/OSGI-INF/access.control.service.xml b/plugins/org.eclipse.osee.orcs.core/OSGI-INF/access.control.service.xml index c161084841..242ca2ff31 100644 --- a/plugins/org.eclipse.osee.orcs.core/OSGI-INF/access.control.service.xml +++ b/plugins/org.eclipse.osee.orcs.core/OSGI-INF/access.control.service.xml @@ -1,5 +1,6 @@ - + + diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateDemoBranches.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateDemoBranches.java index f02856dd6a..3ad5f423f5 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateDemoBranches.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/CreateDemoBranches.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.eclipse.osee.framework.core.applicability.FeatureDefinition; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; +import org.eclipse.osee.framework.core.data.Branch; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.ConfigurationGroupDefinition; @@ -72,8 +73,10 @@ public class CreateDemoBranches { createDemoProgramBranch(CIS_Bld_1, account); branchOps.createBaselineBranch(DemoBranches.SAW_PL, DemoUsers.Joe_Smith, SAW_Bld_1, ArtifactId.SENTINEL); - branchOps.createBaselineBranch(DemoBranches.SAW_PL_Hardening_Branch, DemoUsers.Joe_Smith, SAW_PL, - ArtifactId.SENTINEL); + + Branch hardeningBranch = branchOps.createBaselineBranch(DemoBranches.SAW_PL_Hardening_Branch, DemoUsers.Joe_Smith, + SAW_PL, ArtifactId.SENTINEL); + orcsApi.getAccessControlService().removePermissions(hardeningBranch); createProductLineConfig(DemoBranches.SAW_PL, account); branchOps.createWorkingBranch(DemoBranches.SAW_PL_Working_Branch, DemoUsers.Joe_Smith, SAW_PL, @@ -88,7 +91,7 @@ public class CreateDemoBranches { CoreArtifactTokens.DefaultHierarchyRoot, tx, orcsApi); Artifacts.getOrCreate(CoreArtifactTokens.ProductsFolder, plFolder, tx, orcsApi); ArtifactToken featuresFolder = Artifacts.getOrCreate(CoreArtifactTokens.FeaturesFolder, plFolder, tx, orcsApi); - ArtifactToken cfgFolder = Artifacts.getOrCreate(CoreArtifactTokens.PlCfgGroupsFolder, plFolder, tx, orcsApi); + Artifacts.getOrCreate(CoreArtifactTokens.PlCfgGroupsFolder, plFolder, tx, orcsApi); ArtifactToken productA = tx.createView(branch, "Product A"); ArtifactToken productB = tx.createView(branch, "Product B"); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java index f1c3bae265..0e03b574f8 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java @@ -84,9 +84,9 @@ public class OrcsApiImpl extends OseeApiBase implements OrcsApi { private TxCallableFactory txCallableFactory; private OrcsApplicabilityOps applicability; private UserGroupService userGroupService; - private IAccessControlService accessControlService; private ActivityLog activityLog; private OrcsTypes orcsTypes; + IAccessControlService accessControlService; ExternalArtifactManager proxyManager; @@ -173,7 +173,6 @@ public class OrcsApiImpl extends OseeApiBase implements OrcsApi { indexerModule.start(getSystemSession(), tokenService()); applicability = new OrcsApplicabilityOps(this, logger); - accessControlService = new AccessControlServiceImpl(); } public void stop() { @@ -269,11 +268,6 @@ public class OrcsApiImpl extends OseeApiBase implements OrcsApi { return userGroupService; } - @Override - public IAccessControlService getAccessControlService() { - return accessControlService; - } - @Override public JdbcService getJdbcService() { return dataStore.getJdbcService(); @@ -283,4 +277,14 @@ public class OrcsApiImpl extends OseeApiBase implements OrcsApi { public ActivityLog getActivityLog() { return activityLog; } + + @Override + public IAccessControlService getAccessControlService() { + if (accessControlService == null) { + accessControlService = + new AccessControlServiceImpl(this, dataStore.getJdbcService().getClient(), tokenService()); + } + return accessControlService; + } + } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/AccessControlServiceImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/AccessControlServiceImpl.java index d5c8d6e29f..5b06b1cc38 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/AccessControlServiceImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/AccessControlServiceImpl.java @@ -10,87 +10,180 @@ * Contributors: * Boeing - initial API and implementation **********************************************************************/ - package org.eclipse.osee.orcs.core.internal.access; import java.util.Collection; -import java.util.LinkedList; -import org.eclipse.osee.framework.core.access.AccessDataQuery; -import org.eclipse.osee.framework.core.access.ArtifactCheck; -import org.eclipse.osee.framework.core.access.IAccessControlService; +import java.util.function.Consumer; +import org.eclipse.osee.framework.core.OrcsTokenService; +import org.eclipse.osee.framework.core.access.AbstractAccessControlService; +import org.eclipse.osee.framework.core.access.AccessQueries; +import org.eclipse.osee.framework.core.access.event.AccessTopicEventPayload; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; +import org.eclipse.osee.framework.core.data.ArtifactTypeToken; +import org.eclipse.osee.framework.core.data.Branch; import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.RelationTypeToken; +import org.eclipse.osee.framework.core.data.BranchToken; +import org.eclipse.osee.framework.core.data.IUserGroupService; +import org.eclipse.osee.framework.core.data.TransactionId; +import org.eclipse.osee.framework.core.data.UserId; +import org.eclipse.osee.framework.core.enums.CoreBranches; +import org.eclipse.osee.framework.core.enums.CoreRelationTypes; +import org.eclipse.osee.framework.core.enums.CoreUserGroups; import org.eclipse.osee.framework.core.enums.PermissionEnum; -import org.eclipse.osee.framework.jdk.core.result.XResultData; +import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.framework.jdk.core.type.ResultSet; +import org.eclipse.osee.framework.jdk.core.util.OseeProperties; +import org.eclipse.osee.jdbc.JdbcClient; +import org.eclipse.osee.jdbc.JdbcStatement; +import org.eclipse.osee.orcs.OrcsApi; +import org.eclipse.osee.orcs.data.ArtifactReadable; /** * @author Donald G. Dunne */ -public class AccessControlServiceImpl implements IAccessControlService { +public class AccessControlServiceImpl extends AbstractAccessControlService { - private final static Collection artifactChecks = new LinkedList(); + // for ReviewOsgiXml public void addOseeAccessProvider(IOseeAccessProvider provider) + // for ReviewOsgiXml public void addArtifactCheck(ArtifactCheck artifactCheck) - public void addArtifactCheck(ArtifactCheck artifactCheck) { - artifactChecks.add(artifactCheck); - } + protected JdbcClient jdbcClient; + private OrcsApi orcsApi; public AccessControlServiceImpl() { - // for osgi instantiation + super(null, null); + // for jax-rs } + public AccessControlServiceImpl(OrcsApi orcsApi, JdbcClient jdbcClient, OrcsTokenService tokenService) { + super(tokenService, new AccessStoreOperations(orcsApi, jdbcClient)); + this.orcsApi = orcsApi; + this.jdbcClient = jdbcClient; + } + + // Caches not needed on server, load as needed @Override - public boolean hasPermission(Object object, PermissionEnum permission) { - throw new UnsupportedOperationException("Not available on server yet"); + public synchronized void ensurePopulated() { + cache.initializeCaches(); + populateArtifactAccessControlList(); + populateBranchAccessControlList(); } @Override public void removePermissions(BranchId branch) { - throw new UnsupportedOperationException("Not available on server yet"); + jdbcClient.runPreparedUpdate(AccessQueries.DELETE_ARTIFACT_ACL_FROM_BRANCH, branch); + jdbcClient.runPreparedUpdate(AccessQueries.DELETE_BRANCH_ACL_FROM_BRANCH, branch); + // NOTE: No events are produced, so the IDE clients will not be notified. Fix this when servers talk to clients. } @Override - public AccessDataQuery getAccessData(ArtifactToken userArtifact, Collection itemsToCheck) { - throw new UnsupportedOperationException("Not available on server yet"); + public boolean isReadOnly(ArtifactToken artifact) { + try { + if (artifact instanceof ArtifactReadable) { + boolean deleted = ((ArtifactReadable) artifact).isDeleted(); + boolean historical = ((ArtifactReadable) artifact).isHistorical(); + boolean hasPermission = hasArtifactPermission(artifact, PermissionEnum.WRITE, null).isSuccess(); + return deleted || historical || !hasPermission; + } + return true; + } catch (OseeCoreException ex) { + return true; + } } @Override - public XResultData isDeleteable(Collection artifacts, XResultData results) { - for (ArtifactCheck check : artifactChecks) { - check.isDeleteable(artifacts, results); - } - return results; + public boolean isOseeAdmin() { + return orcsApi.getUserGroupService().getUserGroup(CoreUserGroups.OseeAdmin).isCurrentUserMember(); } @Override - public XResultData isRenamable(Collection artifacts, XResultData results) { - for (ArtifactCheck check : artifactChecks) { - check.isRenamable(artifacts, results); - } - return results; + public ArtifactToken getUserByArtId(ArtifactId subjectArtId) { + return orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).andId(subjectArtId).getArtifactOrNull(); } @Override - public XResultData isDeleteableRelation(ArtifactToken artifact, RelationTypeToken relationType, XResultData results) { - for (ArtifactCheck check : artifactChecks) { - check.isDeleteableRelation(artifact, relationType, results); - } - return results; + public void kickAccessTopicEvent(AccessTopicEventPayload event) { + // do nothing } @Override - public void ensurePopulated() { - throw new UnsupportedOperationException("Not available on server yet"); + public IUserGroupService getUserGroupService() { + return orcsApi.getUserGroupService(); } @Override - public void clearCache() { - // No server caches to clear + public Collection getArtifactListFromType(ArtifactTypeToken artType, BranchToken branch) { + return orcsApi.getQueryFactory().fromBranch(branch).andIsOfType(artType).asArtifactTokens(); } @Override - public boolean isOseeAdmin() { + public boolean isBaselineBranch(BranchToken branch) { + ResultSet branches = orcsApi.getQueryFactory().branchQuery().andId(branch).getResults(); + if (branches.size() == 1) { + return branches.iterator().next().getBranchType().isBaselineBranch(); + } return false; } + @Override + protected boolean isInDbInit() { + return OseeProperties.isInDbInit(); + } + + @Override + public boolean isInDb(ArtifactToken artifact) { + return ((ArtifactReadable) artifact).getTransaction().equals(TransactionId.SENTINEL); + } + + @Override + public ArtifactToken getUser() { + return null; + } + + @Override + public ArtifactToken getArtifactFromId(ArtifactId subjectId, BranchToken branch) { + return orcsApi.getQueryFactory().fromBranch(branch).andId(subjectId).asArtifactTokenOrSentinel(); + } + + @Override + public void populateBranchAccessControlList() { + Consumer consumer = stmt -> { + ArtifactId subjectId = ArtifactId.valueOf(stmt.getLong("privilege_entity_id")); + BranchId branchId = BranchId.valueOf(stmt.getLong("branch_id")); + BranchToken branch = orcsApi.getQueryFactory().branchQuery().andId(branchId).getOneOrSentinel(); + if (branch.isValid()) { + PermissionEnum permission = PermissionEnum.getPermission(stmt.getInt("permission_id")); + ArtifactTypeToken subjectArtifactType = tokenService.getArtifactType(stmt.getLong("art_type_id")); + brchAclOps.populateBranchAccessControlListEntry(subjectId, subjectArtifactType, branch, permission); + } + }; + jdbcClient.runQuery(consumer, AccessQueries.GET_ALL_BRANCH_ACCESS_CONTROL_LIST); + } + + @Override + public void populateArtifactAccessControlList() { + Consumer consumer = stmt -> { + ArtifactId subjectId = UserId.valueOf(stmt.getLong("privilege_entity_id")); + ArtifactId artifactId = ArtifactId.valueOf(stmt.getLong("art_id")); + BranchId branchId = BranchId.valueOf(stmt.getLong("branch_id")); + PermissionEnum permission = PermissionEnum.getPermission(stmt.getInt("permission_id")); + ArtifactTypeToken subjectArtifactType = tokenService.getArtifactType(stmt.getLong("art_type_id")); + + artAclOps.populateArtifactAccessControlListEntry(subjectId, artifactId, branchId, permission, + subjectArtifactType); + }; + + jdbcClient.runQuery(consumer, AccessQueries.GET_ALL_ARTIFACT_ACCESS_CONTROL_LIST); + } + + @Override + public void populateGroupMembers(ArtifactId groupId) { + if (!cache.groupToSubjectsCache.containsKey(groupId.getId())) { + jdbcClient.runQuery(stmt -> { + ArtifactId groupMember = ArtifactId.valueOf(stmt.getLong("b_art_id")); + userGrpOps.populateGroupMembersEntry(groupId, groupMember); + }, AccessQueries.USER_GROUP_MEMBERS, groupId, CoreRelationTypes.Users_User); + } + } + } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/UserGroupImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/UserGroupImpl.java index c4403901eb..6c0c63874c 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/UserGroupImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/UserGroupImpl.java @@ -55,7 +55,7 @@ public class UserGroupImpl extends AbstractUserGroupImpl { } @Override - public boolean addMember(UserId user) { + public boolean addMember(UserId user, boolean persist) { throw new UnsupportedOperationException(); } @@ -88,7 +88,7 @@ public class UserGroupImpl extends AbstractUserGroupImpl { } @Override - public boolean removeMember(UserId user) { + public boolean removeMember(UserId user, boolean persist) { throw new UnsupportedOperationException(); } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/UserGroupService.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/UserGroupService.java index 48af029d5f..00003b70d5 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/UserGroupService.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/access/UserGroupService.java @@ -81,6 +81,11 @@ public class UserGroupService implements IUserGroupService { } } + @Override + public IUserGroup getUserGroup(ArtifactToken userGroupArt) { + return new UserGroupImpl(userGroupArt); + } + @Override public Collection getMyUserGroups() { return UserGroupService.getUserGroupService().getMyUserGroups(); @@ -112,4 +117,9 @@ public class UserGroupService implements IUserGroupService { throw new UnsupportedOperationException(); } + @Override + public boolean isUserMember(IUserGroupArtifactToken userGroup, ArtifactId user) { + return isUserMember(userGroup, user.getId()); + } + } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java index 0dd9c217ad..b057a02555 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/BranchQueryImpl.java @@ -71,4 +71,13 @@ public class BranchQueryImpl extends BranchQueryBuilderImpl impleme public boolean isArchived(BranchId branchId) { return queryEngine.isArchived(branchId); } + + @Override + public BranchToken getOneOrSentinel() { + ResultSet branches = getResults(); + if (branches.size() == 1) { + return branches.iterator().next(); + } + return BranchToken.SENTINEL; + } } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.parent/pom.xml b/plugins/org.eclipse.osee.orcs.parent/pom.xml index 18d3b21418..151525a388 100644 --- a/plugins/org.eclipse.osee.orcs.parent/pom.xml +++ b/plugins/org.eclipse.osee.orcs.parent/pom.xml @@ -28,9 +28,6 @@ ../../plugins/org.eclipse.osee.framework.core ../../plugins/org.eclipse.osee.framework.core.test - ../../plugins/org.eclipse.osee.framework.core.dsl - ../../plugins/org.eclipse.osee.framework.core.dsl.integration - ../../plugins/org.eclipse.osee.framework.core.dsl.integration.test ../../plugins/org.eclipse.osee.framework.core.model ../../plugins/org.eclipse.osee.framework.core.model.test ../../plugins/org.eclipse.osee.framework.resource.management @@ -68,9 +65,6 @@ ../../plugins/org.eclipse.osee.framework.core ../../plugins/org.eclipse.osee.framework.core.test - ../../plugins/org.eclipse.osee.framework.core.dsl - ../../plugins/org.eclipse.osee.framework.core.dsl.integration - ../../plugins/org.eclipse.osee.framework.core.dsl.integration.test ../../plugins/org.eclipse.osee.framework.core.model ../../plugins/org.eclipse.osee.framework.core.model.test ../../plugins/org.eclipse.osee.framework.resource.management diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java index 2d1700dfa5..74080ed848 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java @@ -25,6 +25,7 @@ import org.eclipse.osee.define.api.DefineBranchEndpointApi; import org.eclipse.osee.define.api.ImportEndpoint; import org.eclipse.osee.define.api.RenderEndpoint; import org.eclipse.osee.framework.core.OseeApiBase; +import org.eclipse.osee.framework.core.access.IAccessControlService; import org.eclipse.osee.framework.core.data.ArtifactToken; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; @@ -61,6 +62,9 @@ import org.eclipse.osee.orcs.rest.model.search.artifact.SearchResult; */ public class OseeClientImpl extends OseeApiBase implements OseeClient, QueryExecutor { + // for ReviewOsgiXml public void setJaxRsApi(JaxRsApi jaxRsApi) + // for ReviewOsgiXml public void setOrcsTokenService(OrcsTokenService tokenService) + private PredicateFactory predicateFactory; public void start(Map properties) { @@ -218,4 +222,8 @@ public class OseeClientImpl extends OseeApiBase implements OseeClient, QueryExec return target.request(MediaType.TEXT_PLAIN).get(String.class); } -} \ No newline at end of file + @Override + public IAccessControlService getAccessControlService() { + throw new UnsupportedOperationException("Not supported yet"); + } +} diff --git a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF index 98a58e93b3..2c0fae7899 100644 --- a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF @@ -23,6 +23,7 @@ Import-Package: com.fasterxml.jackson.core, org.eclipse.jdt.core.dom, org.eclipse.osee.activity.api, org.eclipse.osee.framework.core, + org.eclipse.osee.framework.core.access, org.eclipse.osee.framework.core.applicability, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.enums, diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java index 146a975e12..c674453850 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java @@ -15,7 +15,6 @@ package org.eclipse.osee.orcs; import org.eclipse.osee.activity.api.ActivityLog; import org.eclipse.osee.framework.core.OseeApi; -import org.eclipse.osee.framework.core.access.IAccessControlService; import org.eclipse.osee.framework.core.data.IUserGroupService; import org.eclipse.osee.jdbc.JdbcService; import org.eclipse.osee.orcs.search.QueryFactory; @@ -50,8 +49,6 @@ public interface OrcsApi extends OseeApi { IUserGroupService getUserGroupService(); - IAccessControlService getAccessControlService(); - JdbcService getJdbcService(); ActivityLog getActivityLog(); diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java index d59247844d..4ec780aedc 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/BranchQuery.java @@ -36,6 +36,8 @@ public interface BranchQuery extends BranchQueryBuilder, Query { boolean isArchived(BranchId branchId); + BranchToken getOneOrSentinel(); + public static BranchQuery createSentinel() { final class BranchQuerySentinel extends NamedIdBase implements BranchQuery { @@ -158,7 +160,13 @@ public interface BranchQuery extends BranchQueryBuilder, Query { public boolean isArchived(BranchId branchId) { return false; } + + @Override + public BranchToken getOneOrSentinel() { + return null; + } } return new BranchQuerySentinel(); } + } \ No newline at end of file diff --git a/plugins/org.eclipse.osee.ote.ui.define/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.ui.define/META-INF/MANIFEST.MF index 355b0c591c..6b30ebfc8c 100644 --- a/plugins/org.eclipse.osee.ote.ui.define/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ote.ui.define/META-INF/MANIFEST.MF @@ -36,8 +36,8 @@ Import-Package: com.lowagie.text, org.apache.commons.lang, org.eclipse.nebula.widgets.xviewer.core.model, org.eclipse.osee.ats.api.data, - org.eclipse.osee.framework.access, org.eclipse.osee.framework.core, + org.eclipse.osee.framework.core.access, org.eclipse.osee.framework.core.client, org.eclipse.osee.framework.core.client.server, org.eclipse.osee.framework.core.data, @@ -48,9 +48,11 @@ Import-Package: com.lowagie.text, org.eclipse.osee.framework.core.model.type, org.eclipse.osee.framework.core.util, org.eclipse.osee.framework.help.ui, + org.eclipse.osee.framework.jdk.core.result, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, org.eclipse.osee.framework.jdk.core.util.io.xml, org.eclipse.osee.framework.logging, org.eclipse.ui.forms.widgets, org.osgi.service.event +Service-Component: OSGI-INF/*.xml diff --git a/plugins/org.eclipse.osee.ote.ui.define/OSGI/access.user.authenticated.topic.handler.xml b/plugins/org.eclipse.osee.ote.ui.define/OSGI/access.user.authenticated.topic.handler.xml deleted file mode 100644 index 3ae3bd05a7..0000000000 --- a/plugins/org.eclipse.osee.ote.ui.define/OSGI/access.user.authenticated.topic.handler.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/plugins/org.eclipse.osee.ote.ui.define/build.properties b/plugins/org.eclipse.osee.ote.ui.define/build.properties index b39251a31e..ee8a84f8cc 100644 --- a/plugins/org.eclipse.osee.ote.ui.define/build.properties +++ b/plugins/org.eclipse.osee.ote.ui.define/build.properties @@ -4,5 +4,5 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ OSEE-INF/images/,\ - OSGI/,\ + OSGI-INF/,\ OSEE-INF/ diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/EditDispositionAction.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/EditDispositionAction.java index 8bca47f025..0bba60a2c3 100644 --- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/EditDispositionAction.java +++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/EditDispositionAction.java @@ -16,7 +16,6 @@ package org.eclipse.osee.ote.ui.define.viewers.actions; import java.util.logging.Level; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; @@ -26,6 +25,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.ote.define.artifacts.ArtifactTestRunOperator; import org.eclipse.osee.ote.ui.define.internal.Activator; +import org.eclipse.osee.ote.ui.define.internal.OseeApiService; import org.eclipse.osee.ote.ui.define.utilities.SelectionHelper; /** @@ -66,7 +66,8 @@ public class EditDispositionAction extends AbstractActionHandler { } private void checkPermissions(Artifact artifact) { - if (true != AccessControlManager.hasPermission(artifact, PermissionEnum.READ)) { + if (OseeApiService.get().getAccessControlService().hasArtifactPermission(artifact, PermissionEnum.READ, + null).isErrors()) { throw new OseeArgumentException("The user %s does not have read access to %s", UserManager.getUser(), artifact); } diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenInArtifactEditor.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenInArtifactEditor.java index d920401746..8a6417f67e 100644 --- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenInArtifactEditor.java +++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenInArtifactEditor.java @@ -16,7 +16,6 @@ package org.eclipse.osee.ote.ui.define.viewers.actions; import java.util.logging.Level; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.enums.PermissionEnum; import org.eclipse.osee.framework.core.enums.PresentationType; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; @@ -26,6 +25,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.ote.define.artifacts.ArtifactTestRunOperator; import org.eclipse.osee.ote.ui.define.internal.Activator; +import org.eclipse.osee.ote.ui.define.internal.OseeApiService; import org.eclipse.osee.ote.ui.define.utilities.SelectionHelper; /** @@ -66,7 +66,8 @@ public class OpenInArtifactEditor extends AbstractActionHandler { } private void checkPermissions(Artifact artifact) { - if (true != AccessControlManager.hasPermission(artifact, PermissionEnum.READ)) { + if (true != OseeApiService.get().getAccessControlService().hasArtifactPermission(artifact, PermissionEnum.READ, + null).isSuccess()) { throw new OseeArgumentException("The user %s does not have read access to %s", UserManager.getUser(), artifact); } diff --git a/plugins/org.eclipse.osee.support.config/launchConfig/OSEE_IDE_[localhost].launch b/plugins/org.eclipse.osee.support.config/launchConfig/OSEE_IDE_[localhost].launch index 26392035f2..abb13b17e4 100644 --- a/plugins/org.eclipse.osee.support.config/launchConfig/OSEE_IDE_[localhost].launch +++ b/plugins/org.eclipse.osee.support.config/launchConfig/OSEE_IDE_[localhost].launch @@ -29,7 +29,7 @@ - +