Example usage for java.io FileNotFoundException FileNotFoundException

List of usage examples for java.io FileNotFoundException FileNotFoundException

Introduction

In this page you can find the example usage for java.io FileNotFoundException FileNotFoundException.

Prototype

public FileNotFoundException() 

Source Link

Document

Constructs a FileNotFoundException with null as its error detail message.

Usage

From source file:eu.scape_project.resource.connector.Files.java

/**
 * Exposes an HTTP GET end point witch returns a version of the binary
 * content of a {@link File} or if references are used for files a HTTP
 * redirect a from the Connector API implementation
 * //from w  w w  .j  a  v  a 2 s . c o m
 * @param entityId
 *            the {@link IntellectualEntity}'s id
 * @param repId
 *            the {@link Representation}'s id
 * @param fileId
 *            the {@link File}'s id
 * @param versionId
 *            the version's id
 * @return A {@link Response} with the binary content or a HTTP redirect
 * @throws RepositoryException
 *             if an error occurred while fetching the binary content
 */
@GET
@Path("{entity-id}/{rep-id}/{file-id}/{version-id}")
public Response retrieveFile(@PathParam("entity-id") final String entityId,
        @PathParam("rep-id") final String repId, @PathParam("file-id") final String fileId,
        @PathParam("version-id") final String versionId) throws RepositoryException {
    if (connectorService.isReferencedContent()) {
        IntellectualEntity e = connectorService.fetchEntity(session, entityId);
        for (Representation r : e.getRepresentations()) {
            if (r.getIdentifier().getValue().equals(repId)) {
                for (File f : r.getFiles()) {
                    if (f.getIdentifier().getValue().equals(fileId)) {
                        return Response.temporaryRedirect(f.getUri()).build();
                    }
                }
            }
        }
        throw new RepositoryException(new FileNotFoundException());
    } else {
        final ContentTypeInputStream src = connectorService.fetchBinaryFile(this.session, entityId, repId,
                fileId, versionId);
        return Response.ok().entity(src).type(src.getContentType()).build();
    }
}