本文整理汇总了Java中com.exlibris.core.sdk.storage.containers.StoredEntityMetaData类的典型用法代码示例。如果您正苦于以下问题:Java StoredEntityMetaData类的具体用法?Java StoredEntityMetaData怎么用?Java StoredEntityMetaData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StoredEntityMetaData类属于com.exlibris.core.sdk.storage.containers包,在下文中一共展示了StoredEntityMetaData类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: storeEntity
import com.exlibris.core.sdk.storage.containers.StoredEntityMetaData; //导入依赖的package包/类
@Override
public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata) throws Exception {
String errorMessage = null;
String tmpDestinationsFilePath = getTempStorageDirectory(false) + StorageUtil.DEST_PATH_FOLDER;
String filePid = storedEntityMetadata.getEntityPid();
String iePid = storedEntityMetadata.getIePid();
String fileDestination = StorageUtil.readDestPathFromTmpFile(iePid, tmpDestinationsFilePath, filePid);
if (fileDestination == null) {
File fileInRepository = new File(storedEntityMetadata.getCurrentFilePath());
if (Files.isSymbolicLink(fileInRepository.toPath())) {
File fileInDeposit = Files.readSymbolicLink(fileInRepository.toPath()).toFile();
if (Files.isSymbolicLink(fileInDeposit.toPath())) {
Path originalFilePath = Files.readSymbolicLink(fileInDeposit.toPath());
File originalFile = originalFilePath.toFile();
String newFileName = createFileName(storedEntityMetadata);
File newFileDestination = new File(originalFile.getParent() + "/" + newFileName);
originalFile.renameTo(newFileDestination);
StorageUtil.saveDestPathToTmpFile(iePid, tmpDestinationsFilePath, filePid, newFileDestination.getAbsolutePath());
fileDestination = newFileDestination.getAbsolutePath();
} else {
errorMessage = MessageFormat.format(NOT_SOFT_LINK_ERROR_MSG, filePid, fileInDeposit.getAbsolutePath());
}
} else {
errorMessage = MessageFormat.format(NOT_SOFT_LINK_ERROR_MSG, filePid, fileInRepository.getAbsolutePath());
}
}
if (fileDestination != null && !checkFixity(storedEntityMetadata.getFixities(), fileDestination)) {
errorMessage = MessageFormat.format(FAILED_FIXITY_ERROR_MSG, filePid, fileDestination);
}
if (errorMessage != null) {
log.error(errorMessage);
throw new Exception(errorMessage);
}
return fileDestination;
}
示例2: storeEntity
import com.exlibris.core.sdk.storage.containers.StoredEntityMetaData; //导入依赖的package包/类
@Override
public String storeEntity(InputStream is,
StoredEntityMetaData storedEntityMetadata) throws IOException {
CDMIConnector connector = new CDMIConnector();
try {
return connector.putObject(netAppClient, storedEntityMetadata, is);
} catch (Exception e) {
e.printStackTrace();
throw new IOException();
}
}
示例3: putObject
import com.exlibris.core.sdk.storage.containers.StoredEntityMetaData; //导入依赖的package包/类
public String putObject(NetAppClient netAppClient, StoredEntityMetaData storedEntityMetadata, InputStream inputStream) throws Exception{
// Create the request
DefaultHttpClient httpclient = createHttpClient(netAppClient, true);
HttpPost httpPost = new HttpPost(new URI(getContainerURI(netAppClient, true)));
// TODO: support chunks for big files
byte[] encode = Base64.encode(IOUtils.toByteArray(inputStream));
String bytes = new String(encode);
initializeHeaders(httpPost, CDMIHttpHeader.CONTENT_TYPE_CDMI_OBJECT);
String domainURI = "/cdmi_domains/";
DnxDocument fileDnx = storedEntityMetadata.getFileDnx();
String mimetype = fileDnx.getSectionKeyValue(DNXConstants.FILEFORMAT.MIMETYPE);
String string = "{\"domainURI\":\"" + domainURI
+ "\",\"mimetype\":\"" + mimetype + "\",\"metadata\":{\"pid\" : \"" + storedEntityMetadata.getEntityPid()
+ "\"},\"valuetransferencoding\":\"base64\",\"value\":\"" + bytes + "\"}";
httpPost.setEntity(new StringEntity(string));
// 1. Create data object
HttpResponse response = httpclient.execute(httpPost);
// 2. get object id from the response
String identifier = getSpecificJSONValue(response, "objectID");
// 3. update the existing object value in ranges
/*
FIXME
!!! If InputStreamEntity will not work - try sending in ranges manually
long partSize = 4096;
long remainingBytes = storedEntityMetadata.getSizeInBytes();
long currentRange = 0;
long endRange = 0;
boolean isLastPart = (remainingBytes - partSize <= 0);
while (remainingBytes > 0) {
isLastPart = (remainingBytes - partSize <= 0);
if(isLastPart){
partSize = remainingBytes;
}
endRange = currentRange+partSize;
httpput = new HttpPut(getCDMIObjectURI(netAppClient, identifier)+"?value:"+currentRange+":"+endRange);
byte [] stream = new byte[(int) partSize];
inputStream.read(stream);
StringEntity entity = new StringEntity(new String(stream));
httpput.setEntity(entity);
response = httpclient.execute(httpput);
if (!isSuccessfulResponse(response)){
deleteObject(netAppClient, identifier);
return null;
}
remainingBytes = remainingBytes - partSize;
}
*/
return identifier;
}