コード例 #1
0
ファイル: RestVdbMask.java プロジェクト: vhalbert/komodo
  /**
   * 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)));
  }
コード例 #2
0
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.komodo.relational.vdb.Permission#removeMask(org.komodo.spi.repository.Repository.UnitOfWork,
   *     java.lang.String)
   */
  @Override
  public void removeMask(final UnitOfWork transaction, final String maskToRemove)
      throws KException {
    ArgCheck.isNotNull(transaction, "transaction"); // $NON-NLS-1$
    ArgCheck.isTrue(
        (transaction.getState() == State.NOT_STARTED),
        "transaction state is not NOT_STARTED"); //$NON-NLS-1$
    ArgCheck.isNotEmpty(maskToRemove, "maskToRemove"); // $NON-NLS-1$

    boolean found = false;
    final Mask[] masks = getMasks(transaction);

    if (masks.length != 0) {
      for (final Mask mask : masks) {
        if (maskToRemove.equals(mask.getName(transaction))) {
          mask.remove(transaction);
          found = true;
          break;
        }
      }
    }

    if (!found) {
      throw new KException(Messages.getString(Relational.MASK_NOT_FOUND_TO_REMOVE, maskToRemove));
    }
  }