コード例 #1
0
  /**
   * resolve attribute created-by.
   *
   * @param ctx EvaluationContext
   * @param attributeIdValue whole attribute
   * @param resolvableAttribute resolvable part of attribute
   * @param tail tail after resolvable part
   * @return Object[] result
   * @throws de.escidoc.core.common.exceptions.system.WebserverSystemException
   * @throws de.escidoc.core.common.exceptions.system.SqlDatabaseSystemException
   * @throws de.escidoc.core.common.exceptions.application.notfound.GrantNotFoundException
   * @throws de.escidoc.core.common.exceptions.application.notfound.ResourceNotFoundException
   */
  private Object[] resolveCreatedByAttribute(
      final EvaluationCtx ctx,
      final String attributeIdValue,
      final String resolvableAttribute,
      final String tail)
      throws GrantNotFoundException, SqlDatabaseSystemException, ResourceNotFoundException,
          WebserverSystemException {
    final String userOrGroupId =
        FinderModuleHelper.retrieveSingleResourceAttribute(ctx, Constants.URI_RESOURCE_ID, true);
    final String grantId =
        FinderModuleHelper.retrieveSingleResourceAttribute(ctx, Constants.URI_SUBRESOURCE_ID, true);
    if (grantId == null || grantId.length() == 0) {
      throw new GrantNotFoundException("no grantId found");
    }
    final RoleGrant grant =
        resolvableAttribute.matches(".*" + XmlUtility.NAME_USER_ACCOUNT + ".*")
            ? userAccountDao.retrieveGrant(userOrGroupId, grantId)
            : userGroupDao.retrieveGrant(grantId);
    assertGrant(grantId, grant);
    final String createdBy = grant.getCreatorId();

    final EvaluationResult result =
        CustomEvaluationResultBuilder.createSingleStringValueResult(createdBy);
    return new Object[] {result, resolvableAttribute};
  }
コード例 #2
0
  /**
   * Retrieve user-group grant from the system.
   *
   * @param ctx The evaluation context, which will be used as key for the cache.
   * @param grantId The grant id.
   * @return Returns the {@code RoleGrant} identified by the provided id.
   * @throws WebserverSystemException Thrown in case of an internal error.
   * @throws GrantNotFoundException Thrown if no grant with provided id exists.
   */
  private RoleGrant getUserGroupGrant(final EvaluationCtx ctx, final String grantId)
      throws WebserverSystemException, GrantNotFoundException {
    RoleGrant grant = (RoleGrant) getFromCache(XmlUtility.NAME_ID, null, null, grantId, ctx);
    if (grant == null) {
      try {
        grant = userGroupDao.retrieveGrant(grantId);
      } catch (final Exception e) {
        throw new WebserverSystemException(
            StringUtility.format("Exception during retrieval of the grant", e.getMessage()), e);
      }
    }
    assertGrant(grantId, grant);

    putInCache(XmlUtility.NAME_ID, null, null, grantId, ctx, grant);
    return grant;
  }
コード例 #3
0
  /**
   * Retrieve user-group grant from the system.
   *
   * @param ctx The evaluation context, which will be used as key for the cache.
   * @param grantId The grant id.
   * @return Returns the <code>RoleGrant</code> identified by the provided id.
   * @throws WebserverSystemException Thrown in case of an internal error.
   * @throws GrantNotFoundException Thrown if no grant with provided id exists.
   */
  private RoleGrant getUserGroupGrant(final EvaluationCtx ctx, final String grantId)
      throws WebserverSystemException, GrantNotFoundException {
    final StringBuffer key = StringUtility.concatenateWithColon(XmlUtility.NAME_ID, grantId);
    RoleGrant grant = (RoleGrant) RequestAttributesCache.get(ctx, key.toString());
    if (grant == null) {
      try {
        grant = userGroupDao.retrieveGrant(grantId);
      } catch (final Exception e) {
        throw new WebserverSystemException(
            StringUtility.format("Exception during retrieval of the grant", e.getMessage()), e);
      }
    }
    assertGrant(grantId, grant);

    RequestAttributesCache.put(ctx, key.toString(), grant);
    return grant;
  }