예제 #1
0
  @Test
  public void shouldGetVdbMask() throws Exception {
    loadVdbs();

    // get
    Properties settings =
        _uriBuilder.createSettings(
            SettingNames.VDB_NAME, TestUtilities.ALL_ELEMENTS_EXAMPLE_VDB_NAME);
    _uriBuilder.addSetting(settings, SettingNames.DATA_ROLE_ID, "roleOne");
    _uriBuilder.addSetting(settings, SettingNames.PERMISSION_ID, "myTable.T2.col1");
    _uriBuilder.addSetting(settings, SettingNames.PERMISSION_CHILD_TYPE, LinkType.MASKS.uriName());
    _uriBuilder.addSetting(settings, SettingNames.PERMISSION_CHILD_ID, "col2");
    URI uri = _uriBuilder.buildVdbPermissionChildUri(LinkType.SELF, settings);
    this.response = request(uri).get();
    final String entity = this.response.readEntity(String.class);
    assertThat(entity, is(notNullValue()));

    // System.out.println("Response:\n" + entity);

    RestVdbMask mask = KomodoJsonMarshaller.unmarshall(entity, RestVdbMask.class);
    assertNotNull(mask);

    assertEquals("col2", mask.getName());
    assertEquals("1", mask.getOrder());

    Collection<RestLink> links = mask.getLinks();
    assertEquals(3, links.size());
  }
예제 #2
0
  /**
   * Constructor for use when serializing.
   *
   * @param baseUri the base uri of the REST request
   * @param mask the mask
   * @param uow the transaction
   * @throws KException if error occurs
   */
  public RestVdbMask(URI baseUri, Mask mask, UnitOfWork uow) throws KException {
    super(baseUri, mask, uow);

    setName(mask.getName(uow));
    setOrder(mask.getOrder(uow));

    Permission permission = ancestor(mask, Permission.class, uow);
    ArgCheck.isNotNull(permission);
    String permName = permission.getName(uow);

    DataRole dataRole = ancestor(permission, DataRole.class, uow);
    ArgCheck.isNotNull(dataRole);
    String dataRoleName = dataRole.getName(uow);

    Vdb vdb = ancestor(dataRole, Vdb.class, uow);
    ArgCheck.isNotNull(vdb);
    String vdbName = vdb.getName(uow);

    Properties settings = getUriBuilder().createSettings(SettingNames.VDB_NAME, vdbName);
    getUriBuilder().addSetting(settings, SettingNames.DATA_ROLE_ID, dataRoleName);
    getUriBuilder().addSetting(settings, SettingNames.PERMISSION_ID, permName);
    getUriBuilder()
        .addSetting(settings, SettingNames.PERMISSION_CHILD_TYPE, LinkType.MASKS.uriName());
    getUriBuilder().addSetting(settings, SettingNames.PERMISSION_CHILD_ID, getId());

    addLink(
        new RestLink(
            LinkType.SELF, getUriBuilder().buildVdbPermissionChildUri(LinkType.SELF, settings)));
    addLink(
        new RestLink(
            LinkType.PARENT,
            getUriBuilder().buildVdbPermissionChildUri(LinkType.PARENT, settings)));
  }