コード例 #1
0
    private String getName(ResourcePermissionType type, AclResourceTokenizer tokenizer) {
      String name = null;
      switch (type) {
        case PROJECT:
          name = tokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT);
          break;

        case DATASOURCE:
          name = translations.allTablesLabel();
          break;

        case TABLE:
          name = tokenizer.getToken(AclResourceTokenizer.ResourceTokens.TABLE);
          break;

        case VARIABLE:
          name =
              tokenizer.getToken(AclResourceTokenizer.ResourceTokens.TABLE)
                  + ":"
                  + tokenizer.getToken(AclResourceTokenizer.ResourceTokens.VARIABLE);
          break;

        case REPORT_TEMPLATE:
          name = tokenizer.getToken(AclResourceTokenizer.ResourceTokens.REPORTTEMPLATE);
          break;
      }

      assert name != null;
      return name;
    }
コード例 #2
0
  private String getNodeUri(
      ResourcePermissionType type, String aclResource, String principal, String typeName) {
    AclResourceTokenizer aclTokenizer = new AclResourceTokenizer(aclResource);

    switch (type) {
      case PROJECT:
        return ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_PROJECT
            .create()
            .query(ResourcePermissionRequestPaths.PRINCIPAL_QUERY_PARAM, principal)
            .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, typeName)
            .build(aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT));
      case DATASOURCE:
        return ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_DATASOURCE
            .create()
            .query(ResourcePermissionRequestPaths.PRINCIPAL_QUERY_PARAM, principal)
            .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, typeName)
            .build(aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.DATASOURCE));
      case VARIABLE:
        return ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_TABLE_VARIABLE
            .create()
            .query(ResourcePermissionRequestPaths.PRINCIPAL_QUERY_PARAM, principal)
            .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, typeName)
            .build(
                aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT),
                aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.TABLE),
                aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.VARIABLE));
      case TABLE:
        return ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_TABLE
            .create()
            .query(ResourcePermissionRequestPaths.PRINCIPAL_QUERY_PARAM, principal)
            .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, typeName)
            .build(
                aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT),
                aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.TABLE));
      case REPORT_TEMPLATE:
        return ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_REPORTTEMPLATE
            .create()
            .query(ResourcePermissionRequestPaths.PRINCIPAL_QUERY_PARAM, principal)
            .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, typeName)
            .build(
                aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT),
                aclTokenizer.getToken(AclResourceTokenizer.ResourceTokens.REPORTTEMPLATE));
      default:
        return null;
    }
  }
コード例 #3
0
    private PlaceRequest getPlaceRequest(
        ResourcePermissionType type, AclResourceTokenizer tokenizer) {
      PlaceRequest placeRequest = null;
      switch (type) {
        case PROJECT:
          placeRequest =
              ProjectPlacesHelper.getProjectPlace(
                  tokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT));
          break;
        case DATASOURCE:
          placeRequest =
              ProjectPlacesHelper.getDatasourcePlace(
                  tokenizer.getToken(AclResourceTokenizer.ResourceTokens.DATASOURCE));
          break;
        case TABLE:
          placeRequest =
              ProjectPlacesHelper.getTablePlace(
                  tokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT),
                  tokenizer.getToken(AclResourceTokenizer.ResourceTokens.TABLE));
          break;
        case VARIABLE:
          placeRequest =
              ProjectPlacesHelper.getVariablePlace(
                  tokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT),
                  tokenizer.getToken(AclResourceTokenizer.ResourceTokens.TABLE),
                  tokenizer.getToken(AclResourceTokenizer.ResourceTokens.VARIABLE));
          break;
        case REPORT_TEMPLATE:
          placeRequest =
              ProjectPlacesHelper.getReportsPlace(
                  tokenizer.getToken(AclResourceTokenizer.ResourceTokens.PROJECT));
          break;
      }

      assert placeRequest != null;
      return placeRequest;
    }