Skip to content
Snippets Groups Projects
Commit f70c909f authored by Sara Bertocco's avatar Sara Bertocco
Browse files
parents 969406ac f7856c4a
Branches
Tags
No related merge requests found
...@@ -15,7 +15,6 @@ import it.inaf.oats.vospace.exception.*; ...@@ -15,7 +15,6 @@ import it.inaf.oats.vospace.exception.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import net.ivoa.xml.vospace.v2.Property; import net.ivoa.xml.vospace.v2.Property;
import java.util.List;
@RestController @RestController
public class CreateNodeController extends BaseNodeController { public class CreateNodeController extends BaseNodeController {
......
...@@ -11,6 +11,7 @@ import it.inaf.oats.vospace.exception.PermissionDeniedException; ...@@ -11,6 +11,7 @@ import it.inaf.oats.vospace.exception.PermissionDeniedException;
import it.inaf.oats.vospace.persistence.LocationDAO; import it.inaf.oats.vospace.persistence.LocationDAO;
import it.inaf.oats.vospace.persistence.NodeDAO; import it.inaf.oats.vospace.persistence.NodeDAO;
import it.inaf.oats.vospace.persistence.model.Location; import it.inaf.oats.vospace.persistence.model.Location;
import it.inaf.oats.vospace.persistence.model.LocationType;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -78,20 +79,18 @@ public class UriService { ...@@ -78,20 +79,18 @@ public class UriService {
Node node = nodeDao.listNode(relativePath).orElseThrow(() -> new NodeNotFoundException(relativePath)); Node node = nodeDao.listNode(relativePath).orElseThrow(() -> new NodeNotFoundException(relativePath));
Location location = locationDAO.getNodeLocation(relativePath).orElseThrow(() Location location = locationDAO.getNodeLocation(relativePath).orElse(null);
-> new InternalFaultException("No registered location found for vos_path " + relativePath));
String endpoint; String endpoint;
switch (location.getType()) {
case PORTAL: if (location != null && location.getType() == LocationType.PORTAL) {
String fileName = nodeDao.getNodeOsName(relativePath); String fileName = nodeDao.getNodeOsName(relativePath);
endpoint = "http://" + location.getSource().getHostname() + location.getSource().getBasePath(); endpoint = "http://" + location.getSource().getHostname() + location.getSource().getBasePath();
if (!endpoint.endsWith("/")) { if (!endpoint.endsWith("/")) {
endpoint += "/"; endpoint += "/";
} }
endpoint += fileName; endpoint += fileName;
break; } else {
default:
endpoint = fileServiceUrl + urlEncodePath(relativePath); endpoint = fileServiceUrl + urlEncodePath(relativePath);
} }
......
package it.inaf.oats.vospace.exception; package it.inaf.oats.vospace.exception;
import java.nio.charset.StandardCharsets;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -23,7 +24,11 @@ public class ErrorController extends AbstractErrorController { ...@@ -23,7 +24,11 @@ public class ErrorController extends AbstractErrorController {
public void errorText(HttpServletRequest request, HttpServletResponse response) throws Exception { public void errorText(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> errors = super.getErrorAttributes(request, true); Map<String, Object> errors = super.getErrorAttributes(request, true);
response.setContentType("text/plain;charset=UTF-8"); response.setContentType("text/plain;charset=UTF-8");
response.getOutputStream().print((String) errors.get("message")); response.setCharacterEncoding("UTF-8");
String errorMessage = (String) errors.get("message");
if (errorMessage != null) {
response.getOutputStream().write(errorMessage.getBytes(StandardCharsets.UTF_8));
}
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment