public class FileServiceClient extends Object
| Constructor and Description |
|---|
FileServiceClient(String baseUrl)
Constructs a FileServiceClient
|
FileServiceClient(String baseUrl,
String username,
String password)
Creates instance of FileServiceClient.
|
| Modifier and Type | Method and Description |
|---|---|
void |
deleteFile(String cloudId,
String representationName,
String version,
String fileName)
Deletes existed file.
|
InputStream |
getFile(String fileUrl)
Function returns file content.
|
InputStream |
getFile(String cloudId,
String representationName,
String version,
String fileName)
Function returns file content.
|
InputStream |
getFile(String cloudId,
String representationName,
String version,
String fileName,
String range)
Function returns file content.
|
URI |
getFileUri(String cloudId,
String representationName,
String version,
String fileName)
Retrieve file uri from parameters.
|
URI |
modifyFile(String fileUrl,
InputStream data,
String mediaType) |
URI |
modyfiyFile(String cloudId,
String representationName,
String version,
InputStream data,
String mediaType,
String fileName,
String expectedMd5)
Modifies existed file with checking checksum.
|
static Map<String,String> |
parseFileUri(String uri)
Retrieve parts of file uri.
|
URI |
uploadFile(String versionUrl,
InputStream data,
String mediaType)
Uploads file content without checking checksum.
|
URI |
uploadFile(String cloudId,
String representationName,
String version,
InputStream data,
String mediaType)
Uploads file content without checking checksum.
|
URI |
uploadFile(String cloudId,
String representationName,
String version,
InputStream data,
String mediaType,
String expectedMd5)
Uploads file content with checking checksum.
|
URI |
uploadFile(String cloudId,
String representationName,
String version,
String fileName,
InputStream data,
String mediaType)
Uploads file content without checking checksum.
|
FileServiceClient |
useAuthorizationHeader(String headerValue)
Client will use provided authorization header for all requests;
|
public FileServiceClient(String baseUrl)
baseUrl - url of the MCS Rest Servicepublic FileServiceClient(String baseUrl, String username, String password)
FileServiceClient(String)
but includes username and password to perform authenticated requests.baseUrl - URL of the MCS Rest Servicepublic InputStream getFile(String cloudId, String representationName, String version, String fileName) throws eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.FileNotExistsException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
cloudId - id of returned file.representationName - representation name of returned file.version - version of returned file.fileName - name of file.eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException - when requested representation (or representation version) does not exist.eu.europeana.cloud.service.mcs.exception.FileNotExistsException - when requested file does not exist.DriverException - call to service has not succeeded because of server side error.eu.europeana.cloud.service.mcs.exception.MCSException - on unexpected situations.public InputStream getFile(String cloudId, String representationName, String version, String fileName, String range) throws eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.FileNotExistsException, eu.europeana.cloud.service.mcs.exception.WrongContentRangeException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
cloudId - id of returned file.representationName - representation name of returned file.version - version of returned file.fileName - name of file.range - range of bytes to return. Range header can be found in Hypertext Transfer Protocol HTTP/1.1, section
14.35 Range).eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException - when requested representation (or representation version) does not exist.eu.europeana.cloud.service.mcs.exception.FileNotExistsException - when requested file does not exist.eu.europeana.cloud.service.mcs.exception.WrongContentRangeException - when wrong value in "Range" header.DriverException - call to service has not succeeded because of server side error.eu.europeana.cloud.service.mcs.exception.MCSException - on unexpected situations.public InputStream getFile(String fileUrl) throws eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.FileNotExistsException, eu.europeana.cloud.service.mcs.exception.WrongContentRangeException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException, IOException
eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsExceptioneu.europeana.cloud.service.mcs.exception.FileNotExistsExceptioneu.europeana.cloud.service.mcs.exception.WrongContentRangeExceptionDriverExceptioneu.europeana.cloud.service.mcs.exception.MCSExceptionIOExceptionpublic URI uploadFile(String cloudId, String representationName, String version, InputStream data, String mediaType, String expectedMd5) throws IOException, eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
cloudId - id of uploaded file.representationName - representation name of uploaded file.version - version of uploaded file.data - InputStream (content) of uploaded file.mediaType - mediaType of uploaded file.expectedMd5 - expected MD5 checksum.IOException - when incorrect MD5 checksum.eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException - when representation does not exist in specified version.eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException - when specified representation version is persistent and modifying its files is not allowed.DriverException - call to service has not succeeded because of server side error.eu.europeana.cloud.service.mcs.exception.MCSException - on unexpected situations.public URI uploadFile(String cloudId, String representationName, String version, InputStream data, String mediaType) throws eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
cloudId - id of uploaded file.representationName - representation name of uploaded file.version - version of uploaded file.data - InputStream (content) of uploaded file.mediaType - mediaType of uploaded file.eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException - when representation does not exist in specified version.eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException - when specified representation version is persistent and modifying its files is not allowed.DriverException - call to service has not succeeded because of server side error.eu.europeana.cloud.service.mcs.exception.MCSException - on unexpected situations.public URI uploadFile(String cloudId, String representationName, String version, String fileName, InputStream data, String mediaType) throws eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
cloudId - id of uploaded file.representationName - representation name of uploaded file.version - version of uploaded file.data - InputStream (content) of uploaded file.mediaType - mediaType of uploaded file.fileName - user file nameeu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException - when representation does not exist in specified version.eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException - when specified representation version is persistent and modifying its files is not allowed.DriverException - call to service has not succeeded because of server side error.eu.europeana.cloud.service.mcs.exception.MCSException - on unexpected situations.public URI uploadFile(String versionUrl, InputStream data, String mediaType) throws eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
versionUrl - Path to the version where the file will be uploaded to.
For example:
"http://ecloud.eanadev.org:8080/ecloud-service-mcs/records/L9WSPSMVQ85/representations/edm/versions/b17c4f60-70d0-11e4-8fe1-00163eefc9c8"eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsExceptioneu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationExceptionDriverExceptioneu.europeana.cloud.service.mcs.exception.MCSExceptionpublic URI modyfiyFile(String cloudId, String representationName, String version, InputStream data, String mediaType, String fileName, String expectedMd5) throws IOException, eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
cloudId - id of modifying file.representationName - representation name of modifying file.version - version of modifying file.data - InputStream (content) of modifying file.mediaType - mediaType of modifying file.fileName - name of modifying file.expectedMd5 - expected MD5 checksum.IOException - when checksum is incorrect.eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException - when representation does not exist in specified version.eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException - when specified representation version is persistent and modifying its files is not allowed.DriverException - call to service has not succeeded because of server side error.eu.europeana.cloud.service.mcs.exception.MCSException - on unexpected situations.public URI modifyFile(String fileUrl, InputStream data, String mediaType) throws IOException, eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
IOExceptioneu.europeana.cloud.service.mcs.exception.RepresentationNotExistsExceptioneu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationExceptionDriverExceptioneu.europeana.cloud.service.mcs.exception.MCSExceptionpublic void deleteFile(String cloudId, String representationName, String version, String fileName) throws eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException, eu.europeana.cloud.service.mcs.exception.FileNotExistsException, eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException, DriverException, eu.europeana.cloud.service.mcs.exception.MCSException
cloudId - id of deleting file.representationName - representation name of deleting file.version - version of deleting file.fileName - name of deleting file.eu.europeana.cloud.service.mcs.exception.RepresentationNotExistsException - when representation does not exist in specified version.eu.europeana.cloud.service.mcs.exception.FileNotExistsException - when requested file does not exist.eu.europeana.cloud.service.mcs.exception.CannotModifyPersistentRepresentationException - when specified representation version is persistent and modifying its files is not allowed.DriverException - call to service has not succeeded because of server side error.eu.europeana.cloud.service.mcs.exception.MCSException - on unexpected situations.public URI getFileUri(String cloudId, String representationName, String version, String fileName)
cloudId - id of file.representationName - representation name of file.version - version of file.fileName - name of file.public static Map<String,String> parseFileUri(String uri)
Examples: From this string "http://ecloud.eanadev.org:8080/ecloud-service-mcs/records/L9WSPSMVQ85/representations/edm/versions/b17c4f60-70d0/files" Retrieve: {"CLOUDID": "L9WSPSMVQ85", "REPRESENTATIONNAME": "edm", "VERSION": "b17c4f60-70d0", "FILENAME": null }
From this string "http://ecloud.eanadev.org:8080/ecloud-service-mcs/records/L9WSPSMVQ85/representations/edm/versions/b17c4f60-70d0/files/file1" Retrieve: {"CLOUDID": "L9WSPSMVQ85", "REPRESENTATIONNAME": "edm", "VERSION": "b17c4f60-70d0", "FILENAME": "file1" }uri - Address of file/filespublic FileServiceClient useAuthorizationHeader(String headerValue)
headerValue - authorization header valueCopyright © 2013–2017 Europeana Cloud Development Team. All rights reserved.