예제 #1
0
  @Override
  public void applyPolicy(
      CallContext callContext, String policyId, String objectId, ExtensionsData extension) {
    // //////////////////
    // General Exception
    // //////////////////
    exceptionService.invalidArgumentRequiredString("objectId", objectId);
    exceptionService.invalidArgumentRequiredString("policyId", policyId);
    Content content = contentService.getContent(objectId);
    exceptionService.objectNotFound(DomainType.OBJECT, content, objectId);
    exceptionService.permissionDenied(
        callContext, PermissionMapping.CAN_ADD_POLICY_OBJECT, content);
    Policy policy = contentService.getPolicy(policyId);
    exceptionService.objectNotFound(DomainType.OBJECT, policy, policyId);
    exceptionService.permissionDenied(callContext, PermissionMapping.CAN_ADD_POLICY_POLICY, policy);

    // //////////////////
    // Specific Exception
    // //////////////////
    TypeDefinition td = typeManager.getTypeDefinition(content);
    if (!td.isControllablePolicy())
      exceptionService.constraint(
          objectId,
          "appyPolicy cannot be performed on the object whose controllablePolicy = false");

    // //////////////////
    // Body of the method
    // //////////////////
    contentService.applyPolicy(callContext, policyId, objectId, extension);
  }
예제 #2
0
  @Override
  public List<ObjectData> getAppliedPolicies(
      CallContext callContext, String objectId, String filter, ExtensionsData extension) {
    // //////////////////
    // General Exception
    // //////////////////
    exceptionService.invalidArgumentRequiredString("objectId", objectId);
    Content content = contentService.getContent(objectId);
    exceptionService.objectNotFound(DomainType.OBJECT, content, objectId);
    exceptionService.permissionDenied(
        callContext, PermissionMapping.CAN_GET_APPLIED_POLICIES_OBJECT, content);

    // //////////////////
    // Body of the method
    // //////////////////
    List<Policy> policies = contentService.getAppliedPolicies(objectId, extension);
    List<ObjectData> objects = new ArrayList<ObjectData>();
    if (!CollectionUtils.isEmpty(policies)) {
      for (Policy policy : policies) {
        objects.add(
            compileObjectService.compileObjectData(callContext, policy, filter, true, true, null));
      }
    }
    return objects;
  }
예제 #3
0
  @Override
  public void removePolicy(
      CallContext callContext, String policyId, String objectId, ExtensionsData extension) {
    // //////////////////
    // General Exception
    // //////////////////
    exceptionService.invalidArgumentRequiredString("objectId", objectId);
    exceptionService.invalidArgumentRequiredString("policyId", policyId);
    Content content = contentService.getContent(objectId);
    exceptionService.objectNotFound(DomainType.OBJECT, content, objectId);
    exceptionService.permissionDenied(
        callContext, PermissionMapping.CAN_REMOVE_POLICY_OBJECT, content);
    Policy policy = contentService.getPolicy(policyId);
    exceptionService.objectNotFound(DomainType.OBJECT, policy, policyId);
    exceptionService.permissionDenied(
        callContext, PermissionMapping.CAN_REMOVE_POLICY_POLICY, policy);

    // //////////////////
    // Body of the method
    // //////////////////
    contentService.removePolicy(callContext, policyId, objectId, extension);
  }