@Override public ResourceList getChildren() throws NotAuthorizedException, BadRequestException { if (children == null) { children = new ResourceList(); Set<AnnoResource> set = annoFactory.childrenOfAnnotationHandler.execute(this); for (AnnoResource r : set) { children.add(r); } // Now add any temp lock resources for (LockHolder holder : annoFactory.getTempResourcesForParent(this)) { CommonResource cr = annoFactory.instantiate(holder, this); children.add(cr); } // if there are singly loaded items we must replace their dopple-ganger in children // because there might already be references to those resource objects elsewhere in code // and having two objects representing the same resource causes unpredictable chaos!!! if (singlyLoadedChildItems != null) { for (CommonResource r : singlyLoadedChildItems) { children.remove(r.getName()); children.add(r); } } } return children; }
@Override public Resource createNew( String newName, InputStream inputStream, Long length, String contentType) throws IOException, ConflictException, NotAuthorizedException, BadRequestException { Object newChildSource = annoFactory.putChildAnnotationHandler.execute( source, newName, inputStream, length, contentType); AnnoCollectionResource newRes = new AnnoCollectionResource(annoFactory, newChildSource, this); if (children != null) { CommonResource oldRes = children.get(newName); if (oldRes != null) { children.remove(oldRes); } children.add(newRes); } return newRes; }