@Override public Object post(Context context, Request request, Response response, Object payload) throws ResourceException { final String repositoryId = getAttributeAsString(request, REPOSITORY_ID_PARAM); final String alias = getAttributeAsString(request, ALIAS_PARAM); if ((payload == null) || !String.class.isAssignableFrom(payload.getClass())) { throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Please provide a valid artifact version."); } aliasMapper.setAlias(repositoryId, alias, payload.toString()); return new StringRepresentation(payload.toString(), TEXT_PLAIN); }
@Override public Object get(Context context, Request request, Response response, Variant variant) throws ResourceException { final String repositoryId = getAttributeAsString(request, REPOSITORY_ID_PARAM); String alias = getAttributeAsString(request, ALIAS_PARAM); if (alias == null) { throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "Could not find empty alias"); } try { return new StringRepresentation(aliasMapper.getVersion(repositoryId, alias)); } catch (AliasNotFoundException e) { throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND, "Could not find alias " + alias + " for repository " + repositoryId, e); } }