Exemplo n.º 1
0
  @Override
  public NodeActionResult performNodeAction(Node clientNode, Node serverNode)
      throws TransientException {
    try {
      if (serverNode instanceof ContainerNode) {
        ContainerNode parent = (ContainerNode) serverNode; // as per doAuthorizationCheck

        nodePersistence.getChild(parent, clientNode.getName()); // slightly better than getChildren
        for (Node n : parent.getNodes()) {
          if (n.getName().equals(clientNode.getName()))
            throw new NodeAlreadyExistsException(vosURI.getURI().toASCIIString());
        }

        clientNode.setParent(parent);
        Node storedNode = nodePersistence.put(clientNode);

        // return the node in xml format
        NodeOutputRepresentation nodeOutputRepresentation =
            new NodeOutputRepresentation(storedNode, getNodeWriter(), getMediaType());
        return new NodeActionResult(nodeOutputRepresentation, Status.SUCCESS_OK);
      }
      log.debug("parent is not a container: " + clientNode.getUri().getPath());
      NodeFault nodeFault = NodeFault.ContainerNotFound;
      nodeFault.setMessage(clientNode.getUri().toString());
      return new NodeActionResult(nodeFault);
    } catch (NodeAlreadyExistsException e) {
      log.debug("Node already exists: " + clientNode.getUri().getPath(), e);
      NodeFault nodeFault = NodeFault.DuplicateNode;
      nodeFault.setMessage(clientNode.getUri().toString());
      return new NodeActionResult(nodeFault);
    } catch (NodeNotSupportedException e) {
      log.debug("Node type not supported: " + clientNode.getUri().getPath(), e);
      NodeFault nodeFault = NodeFault.TypeNotSupported;
      nodeFault.setMessage(clientNode.getUri().toString());
      return new NodeActionResult(nodeFault);
    }
  }
Exemplo n.º 2
0
 @Override
 public String getMessage() {
   if (fault != null) return fault.getStatus().getName() + " " + fault.getMessage();
   return super.getMessage();
 }
Exemplo n.º 3
0
 public TransferException(NodeFault fault) {
   super(fault.getMessage());
   this.fault = fault;
 }