Loading src/main/java/it/inaf/oats/vospace/JobService.java +6 −4 Original line number Original line Diff line number Diff line Loading @@ -112,14 +112,16 @@ public class JobService { throw new UnsupportedOperationException("Not implemented yet"); throw new UnsupportedOperationException("Not implemented yet"); } } job.setPhase(ExecutionPhase.COMPLETED); } catch (VoSpaceErrorSummarizableException e) { } catch (VoSpaceErrorSummarizableException e) { job.setPhase(ExecutionPhase.ERROR); job.setPhase(ExecutionPhase.ERROR); job.setErrorSummary(ErrorSummaryFactory.newErrorSummary(e)); job.setErrorSummary(ErrorSummaryFactory.newErrorSummary(e)); jobDAO.updateJob(job); } catch (Exception e) { } catch (Exception e) { job.setPhase(ExecutionPhase.ERROR); job.setPhase(ExecutionPhase.ERROR); job.setErrorSummary(ErrorSummaryFactory.newErrorSummary( job.setErrorSummary(ErrorSummaryFactory.newErrorSummary( new InternalFaultException(e))); new InternalFaultException(e))); } finally { jobDAO.updateJob(job); jobDAO.updateJob(job); } } } } Loading src/main/java/it/inaf/oats/vospace/URIUtils.java +24 −14 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,7 @@ */ */ package it.inaf.oats.vospace; package it.inaf.oats.vospace; import it.inaf.oats.vospace.exception.InternalFaultException; import it.inaf.oats.vospace.exception.InvalidURIException; import it.inaf.oats.vospace.exception.InvalidURIException; import java.net.URI; import java.net.URI; import java.net.URISyntaxException; import java.net.URISyntaxException; Loading @@ -18,8 +19,10 @@ public class URIUtils { private static final Pattern FORBIDDEN_CHARS = Pattern.compile("[\\x00\\x08\\x0B\\x0C\\x0E-\\x1F" + Pattern.quote("<>?\":\\|'`*") + "]"); private static final Pattern FORBIDDEN_CHARS = Pattern.compile("[\\x00\\x08\\x0B\\x0C\\x0E-\\x1F" + Pattern.quote("<>?\":\\|'`*") + "]"); private static final String SCHEME = "vos"; private static final String SCHEME = "vos"; public static String returnURIFromVosPath(String vosPath, String authority) public static String returnURIFromVosPath(String vosPath, String authority) { throws URISyntaxException { String result = null; try { URI uri = new URI( URI uri = new URI( SCHEME, SCHEME, authority, authority, Loading @@ -28,7 +31,14 @@ public class URIUtils { null null ); ); return uri.toASCIIString(); result = uri.toASCIIString(); } catch (URISyntaxException e) { throw new InternalFaultException("unable to percent encode URI from authority and path: " + authority + " , " + vosPath); } return result; } } public static String returnVosPathFromNodeURI(Node myNode, String authority) { public static String returnVosPathFromNodeURI(Node myNode, String authority) { Loading src/main/java/it/inaf/oats/vospace/UriService.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -134,7 +134,7 @@ public class UriService { case pushToVoSpace: case pushToVoSpace: case pullToVoSpace: case pullToVoSpace: DataNode newNode = new DataNode(); DataNode newNode = new DataNode(); newNode.setUri("vos://"+ authority +relativePath); newNode.setUri(URIUtils.returnURIFromVosPath(relativePath, authority)); return createNodeService.createNode(newNode, relativePath, user); return createNodeService.createNode(newNode, relativePath, user); default: default: throw new InternalFaultException("No supported job direction specified"); throw new InternalFaultException("No supported job direction specified"); Loading @@ -148,7 +148,7 @@ public class UriService { throw new InvalidArgumentException("Invalid target size: " + transfer.getTarget().size()); throw new InvalidArgumentException("Invalid target size: " + transfer.getTarget().size()); } } String relativePath = transfer.getTarget().get(0).substring("vos://".length() + authority.length()); String relativePath = URIUtils.returnVosPathFromNodeURI(transfer.getTarget().get(0), authority); User user = (User) servletRequest.getUserPrincipal(); User user = (User) servletRequest.getUserPrincipal(); String creator = user.getName(); String creator = user.getName(); Loading Loading @@ -233,7 +233,7 @@ public class UriService { Location location = locationDAO.findPortalLocation(url.getHost()).orElseThrow(() Location location = locationDAO.findPortalLocation(url.getHost()).orElseThrow(() -> new InternalFaultException("No registered location found for host " + url.getHost())); -> new InternalFaultException("No registered location found for host " + url.getHost())); String vosPath = nodeUri.replaceAll("vos://[^/]+", ""); String vosPath = URIUtils.returnVosPathFromNodeURI(nodeUri, authority); String fileName = url.getPath().substring(url.getPath().lastIndexOf("/") + 1); String fileName = url.getPath().substring(url.getPath().lastIndexOf("/") + 1); Loading src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java +1 −11 Original line number Original line Diff line number Diff line Loading @@ -455,17 +455,7 @@ public class NodeDAO { } } private String getUri(String path) { private String getUri(String path) { // Percent encode path return URIUtils.returnURIFromVosPath(path, authority); String result = null; try { result = URIUtils.returnURIFromVosPath(path, authority); } catch (URISyntaxException e) { throw new InternalFaultException("unable to percent encode URI from authority and path: " + authority + " , " + path); } return result; } } private NodePaths getPathsFromResultSet(ResultSet rs) throws SQLException { private NodePaths getPathsFromResultSet(ResultSet rs) throws SQLException { Loading Loading
src/main/java/it/inaf/oats/vospace/JobService.java +6 −4 Original line number Original line Diff line number Diff line Loading @@ -112,14 +112,16 @@ public class JobService { throw new UnsupportedOperationException("Not implemented yet"); throw new UnsupportedOperationException("Not implemented yet"); } } job.setPhase(ExecutionPhase.COMPLETED); } catch (VoSpaceErrorSummarizableException e) { } catch (VoSpaceErrorSummarizableException e) { job.setPhase(ExecutionPhase.ERROR); job.setPhase(ExecutionPhase.ERROR); job.setErrorSummary(ErrorSummaryFactory.newErrorSummary(e)); job.setErrorSummary(ErrorSummaryFactory.newErrorSummary(e)); jobDAO.updateJob(job); } catch (Exception e) { } catch (Exception e) { job.setPhase(ExecutionPhase.ERROR); job.setPhase(ExecutionPhase.ERROR); job.setErrorSummary(ErrorSummaryFactory.newErrorSummary( job.setErrorSummary(ErrorSummaryFactory.newErrorSummary( new InternalFaultException(e))); new InternalFaultException(e))); } finally { jobDAO.updateJob(job); jobDAO.updateJob(job); } } } } Loading
src/main/java/it/inaf/oats/vospace/URIUtils.java +24 −14 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,7 @@ */ */ package it.inaf.oats.vospace; package it.inaf.oats.vospace; import it.inaf.oats.vospace.exception.InternalFaultException; import it.inaf.oats.vospace.exception.InvalidURIException; import it.inaf.oats.vospace.exception.InvalidURIException; import java.net.URI; import java.net.URI; import java.net.URISyntaxException; import java.net.URISyntaxException; Loading @@ -18,8 +19,10 @@ public class URIUtils { private static final Pattern FORBIDDEN_CHARS = Pattern.compile("[\\x00\\x08\\x0B\\x0C\\x0E-\\x1F" + Pattern.quote("<>?\":\\|'`*") + "]"); private static final Pattern FORBIDDEN_CHARS = Pattern.compile("[\\x00\\x08\\x0B\\x0C\\x0E-\\x1F" + Pattern.quote("<>?\":\\|'`*") + "]"); private static final String SCHEME = "vos"; private static final String SCHEME = "vos"; public static String returnURIFromVosPath(String vosPath, String authority) public static String returnURIFromVosPath(String vosPath, String authority) { throws URISyntaxException { String result = null; try { URI uri = new URI( URI uri = new URI( SCHEME, SCHEME, authority, authority, Loading @@ -28,7 +31,14 @@ public class URIUtils { null null ); ); return uri.toASCIIString(); result = uri.toASCIIString(); } catch (URISyntaxException e) { throw new InternalFaultException("unable to percent encode URI from authority and path: " + authority + " , " + vosPath); } return result; } } public static String returnVosPathFromNodeURI(Node myNode, String authority) { public static String returnVosPathFromNodeURI(Node myNode, String authority) { Loading
src/main/java/it/inaf/oats/vospace/UriService.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -134,7 +134,7 @@ public class UriService { case pushToVoSpace: case pushToVoSpace: case pullToVoSpace: case pullToVoSpace: DataNode newNode = new DataNode(); DataNode newNode = new DataNode(); newNode.setUri("vos://"+ authority +relativePath); newNode.setUri(URIUtils.returnURIFromVosPath(relativePath, authority)); return createNodeService.createNode(newNode, relativePath, user); return createNodeService.createNode(newNode, relativePath, user); default: default: throw new InternalFaultException("No supported job direction specified"); throw new InternalFaultException("No supported job direction specified"); Loading @@ -148,7 +148,7 @@ public class UriService { throw new InvalidArgumentException("Invalid target size: " + transfer.getTarget().size()); throw new InvalidArgumentException("Invalid target size: " + transfer.getTarget().size()); } } String relativePath = transfer.getTarget().get(0).substring("vos://".length() + authority.length()); String relativePath = URIUtils.returnVosPathFromNodeURI(transfer.getTarget().get(0), authority); User user = (User) servletRequest.getUserPrincipal(); User user = (User) servletRequest.getUserPrincipal(); String creator = user.getName(); String creator = user.getName(); Loading Loading @@ -233,7 +233,7 @@ public class UriService { Location location = locationDAO.findPortalLocation(url.getHost()).orElseThrow(() Location location = locationDAO.findPortalLocation(url.getHost()).orElseThrow(() -> new InternalFaultException("No registered location found for host " + url.getHost())); -> new InternalFaultException("No registered location found for host " + url.getHost())); String vosPath = nodeUri.replaceAll("vos://[^/]+", ""); String vosPath = URIUtils.returnVosPathFromNodeURI(nodeUri, authority); String fileName = url.getPath().substring(url.getPath().lastIndexOf("/") + 1); String fileName = url.getPath().substring(url.getPath().lastIndexOf("/") + 1); Loading
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java +1 −11 Original line number Original line Diff line number Diff line Loading @@ -455,17 +455,7 @@ public class NodeDAO { } } private String getUri(String path) { private String getUri(String path) { // Percent encode path return URIUtils.returnURIFromVosPath(path, authority); String result = null; try { result = URIUtils.returnURIFromVosPath(path, authority); } catch (URISyntaxException e) { throw new InternalFaultException("unable to percent encode URI from authority and path: " + authority + " , " + path); } return result; } } private NodePaths getPathsFromResultSet(ResultSet rs) throws SQLException { private NodePaths getPathsFromResultSet(ResultSet rs) throws SQLException { Loading