示例#1
0
 private boolean isComponentWriteableByUser(AbstractComponent component) {
   Platform p = PlatformAccess.getPlatform();
   PolicyContext policyContext = new PolicyContext();
   policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), component);
   policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
   String inspectionKey = PolicyInfo.CategoryType.OBJECT_INSPECTION_POLICY_CATEGORY.getKey();
   return p.getPolicyManager().execute(inspectionKey, policyContext).getStatus();
 }
示例#2
0
  @BeforeMethod
  public void setup() {
    MockitoAnnotations.initMocks(this);

    policy = new PlotStringPolicy();
    context = new PolicyContext();
    viewInfo = new ViewInfo(PlotViewManifestation.class, "Plot", ViewType.OBJECT);
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), viewInfo);
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), mockProvider);
  }
示例#3
0
  @Override
  public boolean canHandle(ActionContext context) {
    if (context.getSelectedManifestations().isEmpty()) return false;

    AbstractComponent targetComponent =
        context.getSelectedManifestations().iterator().next().getManifestedComponent();
    PolicyContext policyContext = new PolicyContext();
    policyContext.setProperty(
        PolicyContext.PropertyName.TARGET_COMPONENT.getName(), targetComponent);
    policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
    String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();

    return (context.getSelectedManifestations().size() == 1)
        && PlatformAccess.getPlatform()
            .getPolicyManager()
            .execute(compositionKey, policyContext)
            .getStatus();
  }