use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException in project scheduling by ow2-proactive.
the class RestDataspaceImpl method metadata.
/**
* Retrieve metadata of file in the location specified in <i>dataspace</i>.
* The format of the HEAD URI is:
* <p>
* {@code http://<rest-server-path>/data/<dataspace>/<path-name>}
* <p>
* Example:
* {@code http://localhost:8080/rest/rest/data/user/my-files/my-text-file.txt}
*/
@HEAD
@Path("/{dataspace}/{path-name:.*}")
public Response metadata(@HeaderParam("sessionid") String sessionId, @PathParam("dataspace") String dataspacePath, @PathParam("path-name") String pathname) throws NotConnectedRestException, PermissionRestException {
Session session = checkSessionValidity(sessionId);
try {
checkPathParams(dataspacePath, pathname);
FileObject fo = resolveFile(session, dataspacePath, pathname);
if (!fo.exists()) {
return notFoundRes();
}
logger.debug(String.format("Retrieving metadata for %s in %s", pathname, dataspacePath));
MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>(FileSystem.metadata(fo));
return Response.ok().replaceAll(headers).build();
} catch (Throwable error) {
logger.error(String.format("Cannot retrieve metadata for %s in %s.", pathname, dataspacePath), error);
throw rethrow(error);
}
}
Aggregations