Skip to content

Commit

Permalink
Merge pull request #219 from pdowler/master
Browse files Browse the repository at this point in the history
remove hard coded cavern log control access, minor server lib fixes
  • Loading branch information
pdowler authored Feb 13, 2024
2 parents 7ec8735 + 09891c0 commit 8bf22e7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void doAction() throws Exception {
String srcPath = Utils.getPath(srcNode);
String destPath = Utils.getPath(destContainer);
if (destPath.contains(srcPath)) {
throw NodeFault.ContainerNotFound.getStatus(
throw NodeFault.InvalidArgument.getStatus(
"Cannot move container node into its descendants: source "
+ "path " + srcPath + " in resolved path " + destPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
******************* CANADIAN ASTRONOMY DATA CENTRE *******************
************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
*
* (c) 2011. (c) 2011.
* (c) 2024. (c) 2024.
* Government of Canada Gouvernement du Canada
* National Research Council Conseil national de recherches
* Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -69,19 +69,11 @@

package org.opencadc.vospace.server.transfers;

import ca.nrc.cadc.net.TransientException;
import ca.nrc.cadc.uws.Job;
import ca.nrc.cadc.uws.server.JobNotFoundException;
import ca.nrc.cadc.uws.server.JobPersistenceException;
import ca.nrc.cadc.uws.server.JobUpdater;
import java.io.IOException;
import java.net.URISyntaxException;
import org.opencadc.vospace.LinkingException;
import org.opencadc.vospace.NodeNotFoundException;
import org.opencadc.vospace.server.NodePersistence;
import org.opencadc.vospace.transfer.Direction;
import org.opencadc.vospace.transfer.Transfer;
import org.opencadc.vospace.transfer.TransferParsingException;

/**
*
Expand All @@ -93,10 +85,7 @@ public PullToVOSpaceAction(NodePersistence per, JobUpdater ju, Job job, Transfer
super(per, ju, job, transfer);
}

public void doAction()
throws JobPersistenceException, JobNotFoundException,
LinkingException, NodeNotFoundException, TransferParsingException,
IOException, TransientException, URISyntaxException {
public void doAction() throws Exception {
throw new UnsupportedOperationException(Direction.pullToVoSpaceValue + " not implemented");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
******************* CANADIAN ASTRONOMY DATA CENTRE *******************
************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
*
* (c) 2011. (c) 2011.
* (c) 2024. (c) 2024.
* Government of Canada Gouvernement du Canada
* National Research Council Conseil national de recherches
* Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -69,19 +69,11 @@

package org.opencadc.vospace.server.transfers;

import ca.nrc.cadc.net.TransientException;
import ca.nrc.cadc.uws.Job;
import ca.nrc.cadc.uws.server.JobNotFoundException;
import ca.nrc.cadc.uws.server.JobPersistenceException;
import ca.nrc.cadc.uws.server.JobUpdater;
import java.io.IOException;
import java.net.URISyntaxException;
import org.opencadc.vospace.LinkingException;
import org.opencadc.vospace.NodeNotFoundException;
import org.opencadc.vospace.server.NodePersistence;
import org.opencadc.vospace.transfer.Direction;
import org.opencadc.vospace.transfer.Transfer;
import org.opencadc.vospace.transfer.TransferParsingException;

/**
*
Expand All @@ -93,10 +85,7 @@ public PushFromVOSpaceAction(NodePersistence per, JobUpdater ju, Job job, Transf
super(per, ju, job, transfer);
}

public void doAction()
throws JobPersistenceException, JobNotFoundException,
LinkingException, NodeNotFoundException, TransferParsingException,
IOException, TransientException, URISyntaxException {
public void doAction() throws Exception {
throw new UnsupportedOperationException(Direction.pushFromVoSpaceValue + " not implemented");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,69 +164,4 @@ public void doAction()
}
}
}

/*
private Node resolveNodeForWrite(VOSpaceAuthorizer voSpaceAuthorizer,
NodePersistence nodePer, VOSURI uri,
Class<? extends Node> newNodeType, boolean persist, boolean resolveLeafNode, boolean allowWriteToLink)
throws NodeNotFoundException, LinkingException, FileNotFoundException, URISyntaxException, TransientException {
try {
Node result = resolveNodeForRead(voSpaceAuthorizer, nodePer, uri, resolveLeafNode);
try {
result = (Node) voSpaceAuthorizer.getWritePermission(result);
// check to ensure the parent node isn't locked
if (result.getParent() != null && result.getParent().isLocked()) {
throw new NodeLockedException(result.getParent().getUri().toString());
}
return result;
} catch (NodeLockedException e) {
// allow the DuplicateNode exception to happen later if this is a link node
if (!allowWriteToLink && result != null && result instanceof LinkNode) {
return result;
}
throw e;
}
} catch (NodeNotFoundException ex) {
// this could be a new file.
Node pn = resolveNodeForRead(voSpaceAuthorizer, nodePer,
uri.getParentURI(), true);
// parent node exists
if (!(pn instanceof ContainerNode)) {
throw new IllegalArgumentException(
"parent is not a ContainerNode: "
+ pn.getUri().getURI()
.toASCIIString());
}
voSpaceAuthorizer.getWritePermission(pn);
// create the new DataNode
try {
Node newNode = null;
if (newNodeType.equals(DataNode.class)) {
newNode = new DataNode(new VOSURI(pn.getUri()
+ "/" + uri.getName()));
} else if (newNodeType.equals(ContainerNode.class)) {
newNode = new ContainerNode(new VOSURI(pn.getUri()
+ "/" + uri.getName()));
} else {
throw new IllegalArgumentException(
"BUG: Only DataNode and ContainerNode supported");
}
newNode.setParent((ContainerNode) pn);
if (persist) {
nodePer.put(newNode);
}
return newNode;
} catch (NodeNotSupportedException e2) {
throw new IllegalArgumentException(
"node type not supported.", e2);
}
}
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,20 @@ private void doit() {
sendError(job.getExecutionPhase(), ErrorType.FATAL, "NotAuthenticated", HttpURLConnection.HTTP_UNAUTHORIZED, true);
return;
} catch (IllegalArgumentException ex) {
// target node was not a DataNode
String msg = "Invalid Argument (target node is not a DataNode)";
// target not valid for specified operation
String msg = ex.getMessage();
log.debug(msg, ex);
sendError(job.getExecutionPhase(), ErrorType.FATAL, msg, HttpURLConnection.HTTP_BAD_REQUEST, true);
return;
} catch (LinkingException link) {
String msg = "Link Exception: " + link.getMessage();
String msg = link.getMessage();
log.debug(msg, link);
// now set the job to error
sendError(job.getExecutionPhase(), ErrorType.FATAL, msg, HttpURLConnection.HTTP_BAD_REQUEST, true);
return;
} catch (UnsupportedOperationException ex) {
ex.printStackTrace();
String msg = "Unsupported Operation: " + ex.getMessage();
String msg = ex.getMessage();
log.debug(msg, ex);
// now set the job to error
sendError(job.getExecutionPhase(), ErrorType.FATAL, msg, HttpURLConnection.HTTP_NOT_IMPLEMENTED, true);
sendError(job.getExecutionPhase(), ErrorType.FATAL, msg, HttpURLConnection.HTTP_BAD_METHOD, true);
return;
}
} catch (TransientException e) {
Expand Down
8 changes: 0 additions & 8 deletions cavern/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@
ca.nrc.cadc.auth
ca.nrc.cadc.uws
</param-value>
</init-param>
<init-param>
<param-name>logAccessGroup</param-name>
<param-value>ivo://cadc.nrc.ca/gms?CADC</param-value>
</init-param>
<init-param>
<param-name>groupAuthorizer</param-name>
<param-value>ca.nrc.cadc.ac.client.GroupAuthorizer</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Expand Down

0 comments on commit 8bf22e7

Please sign in to comment.