Search in sources :

Example 51 with PermissionRestException

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);
    }
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) FileObject(org.apache.commons.vfs2.FileObject) FileObject(org.apache.commons.vfs2.FileObject) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Aggregations

NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)39 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)39 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)39 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)39 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)37 Path (javax.ws.rs.Path)34 Produces (javax.ws.rs.Produces)32 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)27 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)27 GET (javax.ws.rs.GET)26 GZIP (org.jboss.resteasy.annotations.GZIP)17 ArrayList (java.util.ArrayList)13 JobState (org.ow2.proactive.scheduler.common.job.JobState)13 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)11 FileObject (org.apache.commons.vfs2.FileObject)9 Session (org.ow2.proactive_grid_cloud_portal.common.Session)9 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)7 IOException (java.io.IOException)6 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)6