void removeLockHolder(String name) {
   if (children != null) {
     Iterator<CommonResource> it = children.iterator();
     while (it.hasNext()) {
       Resource r = it.next();
       if (r instanceof LockNullResource && r.getName().equals(name)) {
         it.remove();
       }
     }
   }
 }
Example #2
0
  @Override
  public void process(HttpManager manager, Request request, Response response)
      throws NotAuthorizedException, BadRequestException {
    if (!handlerHelper.checkExpects(responseHandler, request, response)) {
      return;
    }

    String host = request.getHostHeader();
    String url = HttpManager.decodeUrl(request.getAbsolutePath());

    // Find a resource if it exists
    Resource r = manager.getResourceFactory().getResource(host, url);
    if (r != null) {
      log.debug("locking existing resource: " + r.getName());
      processExistingResource(manager, request, response, r);
    } else {
      log.debug("lock target doesnt exist, attempting lock null..");
      processNonExistingResource(manager, request, response, host, url);
    }
  }
  @Override
  public Resource child(String childName) throws NotAuthorizedException, BadRequestException {
    if (children == null) {
      // attempt to locate singly, ie without loading entire list of children
      // first check if it has already been loaded singly
      if (singlyLoadedChildItems != null && singlyLoadedChildItems.hasChild(childName)) {
        return singlyLoadedChildItems.get(childName);
      }
      // try to load singly using ChildOf annotation, if present
      // childTriValue can be null, the child source object, or a special value indicating no search
      Object childTriValue = annoFactory.childOfAnnotationHandler.execute(this, childName);
      if (childTriValue == null) {
        // return null; // definitely not found

        // well, actually. ChildOf can just apply to a certain sort of child, so if its not found
        // that doesnt mean that there might not be some othe child
        // so we can't assume in any circumstance that a null means not found. Must always fall
        // through to ChildrenOf
      } else if (childTriValue.equals(ChildOfAnnotationHandler.NOT_ATTEMPTED)) {
        // there is no ChildOf method, so fall through to iterating over all children
      } else {
        // got one!
        AnnoResource r = (AnnoResource) childTriValue;
        if (singlyLoadedChildItems == null) {
          singlyLoadedChildItems = new ResourceList();
        }
        singlyLoadedChildItems.add(r);
        return r;
      }
    }

    for (Resource r : getChildren()) {
      if (r.getName().equals(childName)) {
        return r;
      }
    }
    return null;
  }