Exemplo n.º 1
0
  <T extends Request> T setFlagsOnRequest(T request) {
    if (request != null) {
      Set<String> ids = getCombinedIdSet(request);

      request
          .getProperties()
          .put(
              Constants.LOCAL_DESTINATION_KEY,
              ids.isEmpty()
                  || (sourceOperations.getCatalog() != null
                      && ids.contains(sourceOperations.getCatalog().getId())));
      request
          .getProperties()
          .put(
              Constants.REMOTE_DESTINATION_KEY,
              (Requests.isLocal(request) && ids.size() > 1)
                  || (!Requests.isLocal(request) && !ids.isEmpty()));
    }

    return request;
  }
Exemplo n.º 2
0
 private PolicyResponse getWritePolicy(Metacard input, Map<String, Serializable> properties) {
   HashMap<String, Set<String>> operationPolicy = new HashMap<>();
   if (Requests.isLocal(properties) && input.getTags().contains(RegistryConstants.REGISTRY_TAG)) {
     Attribute attribute = input.getAttribute(RegistryObjectMetacardType.REGISTRY_BASE_URL);
     if (isRegistryDisabled()
         || (attribute != null
             && attribute.getValue() instanceof String
             && ((String) attribute.getValue()).startsWith(SystemBaseUrl.getBaseUrl()))) {
       operationPolicy.putAll(bypassAccessPolicy);
     } else {
       operationPolicy.putAll(writeAccessPolicy);
     }
   }
   return new PolicyResponseImpl(operationPolicy, new HashMap<>());
 }