id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,400 | duracloud/duracloud | common-xml/src/main/java/org/duracloud/common/xml/SchemaGenerator.java | SchemaGenerator.generateSchema | public void generateSchema(Class... classes)
throws JAXBException, IOException {
if (!baseDir.exists()) {
baseDir.mkdirs();
}
JAXBContext context = JAXBContext.newInstance(classes);
context.generateSchema(this);
} | java | public void generateSchema(Class... classes)
throws JAXBException, IOException {
if (!baseDir.exists()) {
baseDir.mkdirs();
}
JAXBContext context = JAXBContext.newInstance(classes);
context.generateSchema(this);
} | [
"public",
"void",
"generateSchema",
"(",
"Class",
"...",
"classes",
")",
"throws",
"JAXBException",
",",
"IOException",
"{",
"if",
"(",
"!",
"baseDir",
".",
"exists",
"(",
")",
")",
"{",
"baseDir",
".",
"mkdirs",
"(",
")",
";",
"}",
"JAXBContext",
"context",
"=",
"JAXBContext",
".",
"newInstance",
"(",
"classes",
")",
";",
"context",
".",
"generateSchema",
"(",
"this",
")",
";",
"}"
] | Generates an XML Schema which includes the given classes
@param classes to include in the schema definition
@throws JAXBException
@throws IOException | [
"Generates",
"an",
"XML",
"Schema",
"which",
"includes",
"the",
"given",
"classes"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common-xml/src/main/java/org/duracloud/common/xml/SchemaGenerator.java#L61-L69 |
141,401 | duracloud/duracloud | common-xml/src/main/java/org/duracloud/common/xml/SchemaGenerator.java | SchemaGenerator.createOutput | @Override
public Result createOutput(String namespaceUri, String defaultFileName)
throws IOException {
if (null == fileName) {
fileName = defaultFileName;
}
return new StreamResult(new File(baseDir, fileName));
} | java | @Override
public Result createOutput(String namespaceUri, String defaultFileName)
throws IOException {
if (null == fileName) {
fileName = defaultFileName;
}
return new StreamResult(new File(baseDir, fileName));
} | [
"@",
"Override",
"public",
"Result",
"createOutput",
"(",
"String",
"namespaceUri",
",",
"String",
"defaultFileName",
")",
"throws",
"IOException",
"{",
"if",
"(",
"null",
"==",
"fileName",
")",
"{",
"fileName",
"=",
"defaultFileName",
";",
"}",
"return",
"new",
"StreamResult",
"(",
"new",
"File",
"(",
"baseDir",
",",
"fileName",
")",
")",
";",
"}"
] | Called by the schema generation process. There is no need to call
this method directly. | [
"Called",
"by",
"the",
"schema",
"generation",
"process",
".",
"There",
"is",
"no",
"need",
"to",
"call",
"this",
"method",
"directly",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common-xml/src/main/java/org/duracloud/common/xml/SchemaGenerator.java#L75-L82 |
141,402 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/mgmt/SyncManager.java | SyncManager.handleChangedFile | public synchronized boolean handleChangedFile(ChangedFile changedFile) {
File watchDir = getWatchDir(changedFile.getFile());
SyncWorker worker = new SyncWorker(changedFile, watchDir, endpoint);
try {
addToWorkerList(worker);
workerPool.execute(worker);
return true;
} catch (RejectedExecutionException e) {
workerList.remove(worker);
return false;
}
} | java | public synchronized boolean handleChangedFile(ChangedFile changedFile) {
File watchDir = getWatchDir(changedFile.getFile());
SyncWorker worker = new SyncWorker(changedFile, watchDir, endpoint);
try {
addToWorkerList(worker);
workerPool.execute(worker);
return true;
} catch (RejectedExecutionException e) {
workerList.remove(worker);
return false;
}
} | [
"public",
"synchronized",
"boolean",
"handleChangedFile",
"(",
"ChangedFile",
"changedFile",
")",
"{",
"File",
"watchDir",
"=",
"getWatchDir",
"(",
"changedFile",
".",
"getFile",
"(",
")",
")",
";",
"SyncWorker",
"worker",
"=",
"new",
"SyncWorker",
"(",
"changedFile",
",",
"watchDir",
",",
"endpoint",
")",
";",
"try",
"{",
"addToWorkerList",
"(",
"worker",
")",
";",
"workerPool",
".",
"execute",
"(",
"worker",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"RejectedExecutionException",
"e",
")",
"{",
"workerList",
".",
"remove",
"(",
"worker",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Notifies the SyncManager that a file has changed
@param changedFile the changed file
@returns true if file accepted for processing, false otherwise | [
"Notifies",
"the",
"SyncManager",
"that",
"a",
"file",
"has",
"changed"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/mgmt/SyncManager.java#L106-L118 |
141,403 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/ChunkableContent.java | ChunkableContent.calculateBufferSize | protected int calculateBufferSize(long maxChunkSize) {
final int KB = 1000;
// Ensure maxChunkSize falls on 1-KB boundaries.
if (maxChunkSize % KB != 0) {
String m = "MaxChunkSize must be multiple of " + KB + ": " + maxChunkSize;
log.error(m);
throw new DuraCloudRuntimeException(m);
}
// Find maximum block factor less than or equal to 8-KB.
long size = maxChunkSize;
for (int i = 1; i <= maxChunkSize; i++) {
// MaxChunkSize must be divisible by buffer size
if ((maxChunkSize % i == 0) && ((maxChunkSize / i) <= (8 * KB))) {
size = maxChunkSize / i;
break;
}
}
log.debug("Buf size: " + size + " for maxChunkSize: " + maxChunkSize);
return (int) size;
} | java | protected int calculateBufferSize(long maxChunkSize) {
final int KB = 1000;
// Ensure maxChunkSize falls on 1-KB boundaries.
if (maxChunkSize % KB != 0) {
String m = "MaxChunkSize must be multiple of " + KB + ": " + maxChunkSize;
log.error(m);
throw new DuraCloudRuntimeException(m);
}
// Find maximum block factor less than or equal to 8-KB.
long size = maxChunkSize;
for (int i = 1; i <= maxChunkSize; i++) {
// MaxChunkSize must be divisible by buffer size
if ((maxChunkSize % i == 0) && ((maxChunkSize / i) <= (8 * KB))) {
size = maxChunkSize / i;
break;
}
}
log.debug("Buf size: " + size + " for maxChunkSize: " + maxChunkSize);
return (int) size;
} | [
"protected",
"int",
"calculateBufferSize",
"(",
"long",
"maxChunkSize",
")",
"{",
"final",
"int",
"KB",
"=",
"1000",
";",
"// Ensure maxChunkSize falls on 1-KB boundaries.",
"if",
"(",
"maxChunkSize",
"%",
"KB",
"!=",
"0",
")",
"{",
"String",
"m",
"=",
"\"MaxChunkSize must be multiple of \"",
"+",
"KB",
"+",
"\": \"",
"+",
"maxChunkSize",
";",
"log",
".",
"error",
"(",
"m",
")",
";",
"throw",
"new",
"DuraCloudRuntimeException",
"(",
"m",
")",
";",
"}",
"// Find maximum block factor less than or equal to 8-KB.",
"long",
"size",
"=",
"maxChunkSize",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"maxChunkSize",
";",
"i",
"++",
")",
"{",
"// MaxChunkSize must be divisible by buffer size",
"if",
"(",
"(",
"maxChunkSize",
"%",
"i",
"==",
"0",
")",
"&&",
"(",
"(",
"maxChunkSize",
"/",
"i",
")",
"<=",
"(",
"8",
"*",
"KB",
")",
")",
")",
"{",
"size",
"=",
"maxChunkSize",
"/",
"i",
";",
"break",
";",
"}",
"}",
"log",
".",
"debug",
"(",
"\"Buf size: \"",
"+",
"size",
"+",
"\" for maxChunkSize: \"",
"+",
"maxChunkSize",
")",
";",
"return",
"(",
"int",
")",
"size",
";",
"}"
] | This method finds the maximum 1-KB divisor of arg maxChunkSize that is
less than 8-KB.
It also ensures that arg maxChunkSize is a multiple of 1-KB, otherwise
the stream buffering would lose bytes if the maxChunkSize was not
divisible by the buffer size.
Additionally, by making the buffer multiples of 1-KB ensures efficient
block-writing.
@param maxChunkSize of chunk stream
@return efficient buffer size for given arg chunk-size | [
"This",
"method",
"finds",
"the",
"maximum",
"1",
"-",
"KB",
"divisor",
"of",
"arg",
"maxChunkSize",
"that",
"is",
"less",
"than",
"8",
"-",
"KB",
".",
"It",
"also",
"ensures",
"that",
"arg",
"maxChunkSize",
"is",
"a",
"multiple",
"of",
"1",
"-",
"KB",
"otherwise",
"the",
"stream",
"buffering",
"would",
"lose",
"bytes",
"if",
"the",
"maxChunkSize",
"was",
"not",
"divisible",
"by",
"the",
"buffer",
"size",
".",
"Additionally",
"by",
"making",
"the",
"buffer",
"multiples",
"of",
"1",
"-",
"KB",
"ensures",
"efficient",
"block",
"-",
"writing",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/ChunkableContent.java#L85-L107 |
141,404 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3task/streaminghls/BaseHlsTaskRunner.java | BaseHlsTaskRunner.getExistingDistribution | protected DistributionSummary getExistingDistribution(String bucketName) {
List<DistributionSummary> dists = getAllExistingWebDistributions(bucketName);
if (dists.isEmpty()) {
return null;
} else {
return dists.get(0);
}
} | java | protected DistributionSummary getExistingDistribution(String bucketName) {
List<DistributionSummary> dists = getAllExistingWebDistributions(bucketName);
if (dists.isEmpty()) {
return null;
} else {
return dists.get(0);
}
} | [
"protected",
"DistributionSummary",
"getExistingDistribution",
"(",
"String",
"bucketName",
")",
"{",
"List",
"<",
"DistributionSummary",
">",
"dists",
"=",
"getAllExistingWebDistributions",
"(",
"bucketName",
")",
";",
"if",
"(",
"dists",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"dists",
".",
"get",
"(",
"0",
")",
";",
"}",
"}"
] | Returns the first streaming web distribution associated with a given bucket | [
"Returns",
"the",
"first",
"streaming",
"web",
"distribution",
"associated",
"with",
"a",
"given",
"bucket"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3task/streaminghls/BaseHlsTaskRunner.java#L70-L78 |
141,405 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3task/streaminghls/BaseHlsTaskRunner.java | BaseHlsTaskRunner.getAllExistingWebDistributions | protected List<DistributionSummary> getAllExistingWebDistributions(String bucketName) {
List<DistributionSummary> distListForBucket = new ArrayList<>();
DistributionList distList =
cfClient.listDistributions(new ListDistributionsRequest())
.getDistributionList();
List<DistributionSummary> webDistList = distList.getItems();
while (distList.isTruncated()) {
distList = cfClient.listDistributions(
new ListDistributionsRequest().withMarker(distList.getNextMarker()))
.getDistributionList();
webDistList.addAll(distList.getItems());
}
for (DistributionSummary distSummary : webDistList) {
if (isDistFromBucket(bucketName, distSummary)) {
distListForBucket.add(distSummary);
}
}
return distListForBucket;
} | java | protected List<DistributionSummary> getAllExistingWebDistributions(String bucketName) {
List<DistributionSummary> distListForBucket = new ArrayList<>();
DistributionList distList =
cfClient.listDistributions(new ListDistributionsRequest())
.getDistributionList();
List<DistributionSummary> webDistList = distList.getItems();
while (distList.isTruncated()) {
distList = cfClient.listDistributions(
new ListDistributionsRequest().withMarker(distList.getNextMarker()))
.getDistributionList();
webDistList.addAll(distList.getItems());
}
for (DistributionSummary distSummary : webDistList) {
if (isDistFromBucket(bucketName, distSummary)) {
distListForBucket.add(distSummary);
}
}
return distListForBucket;
} | [
"protected",
"List",
"<",
"DistributionSummary",
">",
"getAllExistingWebDistributions",
"(",
"String",
"bucketName",
")",
"{",
"List",
"<",
"DistributionSummary",
">",
"distListForBucket",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"DistributionList",
"distList",
"=",
"cfClient",
".",
"listDistributions",
"(",
"new",
"ListDistributionsRequest",
"(",
")",
")",
".",
"getDistributionList",
"(",
")",
";",
"List",
"<",
"DistributionSummary",
">",
"webDistList",
"=",
"distList",
".",
"getItems",
"(",
")",
";",
"while",
"(",
"distList",
".",
"isTruncated",
"(",
")",
")",
"{",
"distList",
"=",
"cfClient",
".",
"listDistributions",
"(",
"new",
"ListDistributionsRequest",
"(",
")",
".",
"withMarker",
"(",
"distList",
".",
"getNextMarker",
"(",
")",
")",
")",
".",
"getDistributionList",
"(",
")",
";",
"webDistList",
".",
"addAll",
"(",
"distList",
".",
"getItems",
"(",
")",
")",
";",
"}",
"for",
"(",
"DistributionSummary",
"distSummary",
":",
"webDistList",
")",
"{",
"if",
"(",
"isDistFromBucket",
"(",
"bucketName",
",",
"distSummary",
")",
")",
"{",
"distListForBucket",
".",
"add",
"(",
"distSummary",
")",
";",
"}",
"}",
"return",
"distListForBucket",
";",
"}"
] | Determines if a streaming distribution already exists for a given bucket | [
"Determines",
"if",
"a",
"streaming",
"distribution",
"already",
"exists",
"for",
"a",
"given",
"bucket"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3task/streaminghls/BaseHlsTaskRunner.java#L93-L116 |
141,406 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3task/streaminghls/BaseHlsTaskRunner.java | BaseHlsTaskRunner.checkThatStreamingServiceIsEnabled | protected void checkThatStreamingServiceIsEnabled(String spaceId, String taskName) {
// Verify that streaming is enabled
Map<String, String> spaceProperties = s3Provider.getSpaceProperties(spaceId);
if (!spaceProperties.containsKey(HLS_STREAMING_HOST_PROP)) {
throw new UnsupportedTaskException(
taskName,
"The " + taskName + " task can only be used after a space " +
"has been configured to enable HLS streaming. Use " +
StorageTaskConstants.ENABLE_HLS_TASK_NAME +
" to enable HLS streaming on this space.");
}
} | java | protected void checkThatStreamingServiceIsEnabled(String spaceId, String taskName) {
// Verify that streaming is enabled
Map<String, String> spaceProperties = s3Provider.getSpaceProperties(spaceId);
if (!spaceProperties.containsKey(HLS_STREAMING_HOST_PROP)) {
throw new UnsupportedTaskException(
taskName,
"The " + taskName + " task can only be used after a space " +
"has been configured to enable HLS streaming. Use " +
StorageTaskConstants.ENABLE_HLS_TASK_NAME +
" to enable HLS streaming on this space.");
}
} | [
"protected",
"void",
"checkThatStreamingServiceIsEnabled",
"(",
"String",
"spaceId",
",",
"String",
"taskName",
")",
"{",
"// Verify that streaming is enabled",
"Map",
"<",
"String",
",",
"String",
">",
"spaceProperties",
"=",
"s3Provider",
".",
"getSpaceProperties",
"(",
"spaceId",
")",
";",
"if",
"(",
"!",
"spaceProperties",
".",
"containsKey",
"(",
"HLS_STREAMING_HOST_PROP",
")",
")",
"{",
"throw",
"new",
"UnsupportedTaskException",
"(",
"taskName",
",",
"\"The \"",
"+",
"taskName",
"+",
"\" task can only be used after a space \"",
"+",
"\"has been configured to enable HLS streaming. Use \"",
"+",
"StorageTaskConstants",
".",
"ENABLE_HLS_TASK_NAME",
"+",
"\" to enable HLS streaming on this space.\"",
")",
";",
"}",
"}"
] | Determines if a streaming distribution exists for a given space
@throws UnsupportedTaskException if no distribution exists | [
"Determines",
"if",
"a",
"streaming",
"distribution",
"exists",
"for",
"a",
"given",
"space"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3task/streaminghls/BaseHlsTaskRunner.java#L181-L192 |
141,407 | duracloud/duracloud | irodsstorageprovider/src/main/java/org/duracloud/irodsstorage/IrodsStorageProvider.java | IrodsStorageProvider.getSpaces | @Override
public Iterator<String> getSpaces() {
ConnectOperation co =
new ConnectOperation(host, port, username, password, zone);
log.trace("Listing spaces");
try {
return listDirectories(baseDirectory, co.getConnection());
} catch (IOException e) {
log.error("Could not connect to iRODS", e);
throw new StorageException(e);
}
} | java | @Override
public Iterator<String> getSpaces() {
ConnectOperation co =
new ConnectOperation(host, port, username, password, zone);
log.trace("Listing spaces");
try {
return listDirectories(baseDirectory, co.getConnection());
} catch (IOException e) {
log.error("Could not connect to iRODS", e);
throw new StorageException(e);
}
} | [
"@",
"Override",
"public",
"Iterator",
"<",
"String",
">",
"getSpaces",
"(",
")",
"{",
"ConnectOperation",
"co",
"=",
"new",
"ConnectOperation",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"zone",
")",
";",
"log",
".",
"trace",
"(",
"\"Listing spaces\"",
")",
";",
"try",
"{",
"return",
"listDirectories",
"(",
"baseDirectory",
",",
"co",
".",
"getConnection",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not connect to iRODS\"",
",",
"e",
")",
";",
"throw",
"new",
"StorageException",
"(",
"e",
")",
";",
"}",
"}"
] | Return a list of irods spaces. IRODS spaces are directories under
the baseDirectory of this provider.
@return | [
"Return",
"a",
"list",
"of",
"irods",
"spaces",
".",
"IRODS",
"spaces",
"are",
"directories",
"under",
"the",
"baseDirectory",
"of",
"this",
"provider",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/irodsstorageprovider/src/main/java/org/duracloud/irodsstorage/IrodsStorageProvider.java#L104-L116 |
141,408 | duracloud/duracloud | irodsstorageprovider/src/main/java/org/duracloud/irodsstorage/IrodsStorageProvider.java | IrodsStorageProvider.createSpace | @Override
public void createSpace(String spaceId) {
ConnectOperation co =
new ConnectOperation(host, port, username, password, zone);
try {
IrodsOperations io = new IrodsOperations(co);
io.mkdir(baseDirectory + "/" + spaceId);
log.trace("Created space/directory: " +
baseDirectory + "/" + spaceId);
} catch (IOException e) {
log.error("Could not connect to iRODS", e);
throw new StorageException(e);
}
} | java | @Override
public void createSpace(String spaceId) {
ConnectOperation co =
new ConnectOperation(host, port, username, password, zone);
try {
IrodsOperations io = new IrodsOperations(co);
io.mkdir(baseDirectory + "/" + spaceId);
log.trace("Created space/directory: " +
baseDirectory + "/" + spaceId);
} catch (IOException e) {
log.error("Could not connect to iRODS", e);
throw new StorageException(e);
}
} | [
"@",
"Override",
"public",
"void",
"createSpace",
"(",
"String",
"spaceId",
")",
"{",
"ConnectOperation",
"co",
"=",
"new",
"ConnectOperation",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"zone",
")",
";",
"try",
"{",
"IrodsOperations",
"io",
"=",
"new",
"IrodsOperations",
"(",
"co",
")",
";",
"io",
".",
"mkdir",
"(",
"baseDirectory",
"+",
"\"/\"",
"+",
"spaceId",
")",
";",
"log",
".",
"trace",
"(",
"\"Created space/directory: \"",
"+",
"baseDirectory",
"+",
"\"/\"",
"+",
"spaceId",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not connect to iRODS\"",
",",
"e",
")",
";",
"throw",
"new",
"StorageException",
"(",
"e",
")",
";",
"}",
"}"
] | Create a new directory under the baseDirectory
@param spaceId | [
"Create",
"a",
"new",
"directory",
"under",
"the",
"baseDirectory"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/irodsstorageprovider/src/main/java/org/duracloud/irodsstorage/IrodsStorageProvider.java#L234-L247 |
141,409 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/manifest/xml/ManifestElementReader.java | ManifestElementReader.createManifestFrom | public static ChunksManifest createManifestFrom(ChunksManifestDocument doc) {
ChunksManifestType manifestType = doc.getChunksManifest();
HeaderType headerType = manifestType.getHeader();
ChunksManifest.ManifestHeader header = createHeaderFromElement(
headerType);
ChunksType chunksType = manifestType.getChunks();
List<ChunksManifestBean.ManifestEntry> entries = createEntriesFromElement(
chunksType);
ChunksManifestBean manifestBean = new ChunksManifestBean();
manifestBean.setHeader(header);
manifestBean.setEntries(entries);
return new ChunksManifest(manifestBean);
} | java | public static ChunksManifest createManifestFrom(ChunksManifestDocument doc) {
ChunksManifestType manifestType = doc.getChunksManifest();
HeaderType headerType = manifestType.getHeader();
ChunksManifest.ManifestHeader header = createHeaderFromElement(
headerType);
ChunksType chunksType = manifestType.getChunks();
List<ChunksManifestBean.ManifestEntry> entries = createEntriesFromElement(
chunksType);
ChunksManifestBean manifestBean = new ChunksManifestBean();
manifestBean.setHeader(header);
manifestBean.setEntries(entries);
return new ChunksManifest(manifestBean);
} | [
"public",
"static",
"ChunksManifest",
"createManifestFrom",
"(",
"ChunksManifestDocument",
"doc",
")",
"{",
"ChunksManifestType",
"manifestType",
"=",
"doc",
".",
"getChunksManifest",
"(",
")",
";",
"HeaderType",
"headerType",
"=",
"manifestType",
".",
"getHeader",
"(",
")",
";",
"ChunksManifest",
".",
"ManifestHeader",
"header",
"=",
"createHeaderFromElement",
"(",
"headerType",
")",
";",
"ChunksType",
"chunksType",
"=",
"manifestType",
".",
"getChunks",
"(",
")",
";",
"List",
"<",
"ChunksManifestBean",
".",
"ManifestEntry",
">",
"entries",
"=",
"createEntriesFromElement",
"(",
"chunksType",
")",
";",
"ChunksManifestBean",
"manifestBean",
"=",
"new",
"ChunksManifestBean",
"(",
")",
";",
"manifestBean",
".",
"setHeader",
"(",
"header",
")",
";",
"manifestBean",
".",
"setEntries",
"(",
"entries",
")",
";",
"return",
"new",
"ChunksManifest",
"(",
"manifestBean",
")",
";",
"}"
] | This method binds a ChunksManifest xml document to a ChunksManifest
object
@param doc ChunksManifest xml document
@return ChunksManifest object | [
"This",
"method",
"binds",
"a",
"ChunksManifest",
"xml",
"document",
"to",
"a",
"ChunksManifest",
"object"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/manifest/xml/ManifestElementReader.java#L43-L59 |
141,410 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/backup/ChangedListBackupManager.java | ChangedListBackupManager.loadBackup | public long loadBackup() {
long backupTime = -1;
File[] backupDirFiles = getSortedBackupDirFiles();
if (backupDirFiles.length > 0) {
File latestBackup = backupDirFiles[0];
try {
backupTime = Long.parseLong(latestBackup.getName());
changedList.restore(latestBackup, this.contentDirs);
} catch (NumberFormatException e) {
logger.error("Unable to load changed list backup. File in " +
"changed list backup dir has invalid name: " +
latestBackup.getName());
backupTime = -1;
}
}
return backupTime;
} | java | public long loadBackup() {
long backupTime = -1;
File[] backupDirFiles = getSortedBackupDirFiles();
if (backupDirFiles.length > 0) {
File latestBackup = backupDirFiles[0];
try {
backupTime = Long.parseLong(latestBackup.getName());
changedList.restore(latestBackup, this.contentDirs);
} catch (NumberFormatException e) {
logger.error("Unable to load changed list backup. File in " +
"changed list backup dir has invalid name: " +
latestBackup.getName());
backupTime = -1;
}
}
return backupTime;
} | [
"public",
"long",
"loadBackup",
"(",
")",
"{",
"long",
"backupTime",
"=",
"-",
"1",
";",
"File",
"[",
"]",
"backupDirFiles",
"=",
"getSortedBackupDirFiles",
"(",
")",
";",
"if",
"(",
"backupDirFiles",
".",
"length",
">",
"0",
")",
"{",
"File",
"latestBackup",
"=",
"backupDirFiles",
"[",
"0",
"]",
";",
"try",
"{",
"backupTime",
"=",
"Long",
".",
"parseLong",
"(",
"latestBackup",
".",
"getName",
"(",
")",
")",
";",
"changedList",
".",
"restore",
"(",
"latestBackup",
",",
"this",
".",
"contentDirs",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Unable to load changed list backup. File in \"",
"+",
"\"changed list backup dir has invalid name: \"",
"+",
"latestBackup",
".",
"getName",
"(",
")",
")",
";",
"backupTime",
"=",
"-",
"1",
";",
"}",
"}",
"return",
"backupTime",
";",
"}"
] | Attempts to reload the changed list from a backup file. If there are
no backup files or the backup file cannot be read, returns -1, otherwise
the backup file is loaded and the time the backup file was written is
returned.
@return the write time of the backup file, or -1 if no backup is available | [
"Attempts",
"to",
"reload",
"the",
"changed",
"list",
"from",
"a",
"backup",
"file",
".",
"If",
"there",
"are",
"no",
"backup",
"files",
"or",
"the",
"backup",
"file",
"cannot",
"be",
"read",
"returns",
"-",
"1",
"otherwise",
"the",
"backup",
"file",
"is",
"loaded",
"and",
"the",
"time",
"the",
"backup",
"file",
"was",
"written",
"is",
"returned",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/backup/ChangedListBackupManager.java#L61-L77 |
141,411 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/backup/ChangedListBackupManager.java | ChangedListBackupManager.run | public void run() {
while (continueBackup) {
if (changedListVersion < changedList.getVersion()) {
cleanupBackupDir(SAVED_BACKUPS);
String filename = String.valueOf(System.currentTimeMillis());
File persistFile = new File(backupDir, filename);
backingUp = true;
changedListVersion = changedList.persist(persistFile);
backingUp = false;
}
sleepAndCheck(backupFrequency);
}
} | java | public void run() {
while (continueBackup) {
if (changedListVersion < changedList.getVersion()) {
cleanupBackupDir(SAVED_BACKUPS);
String filename = String.valueOf(System.currentTimeMillis());
File persistFile = new File(backupDir, filename);
backingUp = true;
changedListVersion = changedList.persist(persistFile);
backingUp = false;
}
sleepAndCheck(backupFrequency);
}
} | [
"public",
"void",
"run",
"(",
")",
"{",
"while",
"(",
"continueBackup",
")",
"{",
"if",
"(",
"changedListVersion",
"<",
"changedList",
".",
"getVersion",
"(",
")",
")",
"{",
"cleanupBackupDir",
"(",
"SAVED_BACKUPS",
")",
";",
"String",
"filename",
"=",
"String",
".",
"valueOf",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"File",
"persistFile",
"=",
"new",
"File",
"(",
"backupDir",
",",
"filename",
")",
";",
"backingUp",
"=",
"true",
";",
"changedListVersion",
"=",
"changedList",
".",
"persist",
"(",
"persistFile",
")",
";",
"backingUp",
"=",
"false",
";",
"}",
"sleepAndCheck",
"(",
"backupFrequency",
")",
";",
"}",
"}"
] | Runs the backup manager. Writes out files which are a backups of the
changed list based on the set backup frequency. Retains SAVED_BACKUPS
number of backup files, removes the rest. | [
"Runs",
"the",
"backup",
"manager",
".",
"Writes",
"out",
"files",
"which",
"are",
"a",
"backups",
"of",
"the",
"changed",
"list",
"based",
"on",
"the",
"set",
"backup",
"frequency",
".",
"Retains",
"SAVED_BACKUPS",
"number",
"of",
"backup",
"files",
"removes",
"the",
"rest",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/backup/ChangedListBackupManager.java#L84-L97 |
141,412 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/mgmt/ChangedList.java | ChangedList.reserve | public synchronized ChangedFile reserve() {
if (fileList.isEmpty() || shutdown) {
return null;
}
String key = fileList.keySet().iterator().next();
ChangedFile changedFile = fileList.remove(key);
reservedFiles.put(key, changedFile);
incrementVersion();
fireChangedEventAsync();
return changedFile;
} | java | public synchronized ChangedFile reserve() {
if (fileList.isEmpty() || shutdown) {
return null;
}
String key = fileList.keySet().iterator().next();
ChangedFile changedFile = fileList.remove(key);
reservedFiles.put(key, changedFile);
incrementVersion();
fireChangedEventAsync();
return changedFile;
} | [
"public",
"synchronized",
"ChangedFile",
"reserve",
"(",
")",
"{",
"if",
"(",
"fileList",
".",
"isEmpty",
"(",
")",
"||",
"shutdown",
")",
"{",
"return",
"null",
";",
"}",
"String",
"key",
"=",
"fileList",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"ChangedFile",
"changedFile",
"=",
"fileList",
".",
"remove",
"(",
"key",
")",
";",
"reservedFiles",
".",
"put",
"(",
"key",
",",
"changedFile",
")",
";",
"incrementVersion",
"(",
")",
";",
"fireChangedEventAsync",
"(",
")",
";",
"return",
"changedFile",
";",
"}"
] | Retrieves a changed file for processing and removes it from the list of unreserved files.
Returns null if there are no changed files in the list.
@return a file which has changed on the file system | [
"Retrieves",
"a",
"changed",
"file",
"for",
"processing",
"and",
"removes",
"it",
"from",
"the",
"list",
"of",
"unreserved",
"files",
".",
"Returns",
"null",
"if",
"there",
"are",
"no",
"changed",
"files",
"in",
"the",
"list",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/mgmt/ChangedList.java#L159-L170 |
141,413 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/mgmt/ChangedList.java | ChangedList.persist | public long persist(File persistFile) {
try {
FileOutputStream fileStream = new FileOutputStream(persistFile);
ObjectOutputStream oStream = new ObjectOutputStream((fileStream));
long persistVersion;
Map<String, ChangedFile> fileListCopy;
synchronized (this) {
fileListCopy = (Map<String, ChangedFile>) fileList.clone();
fileListCopy.putAll(reservedFiles);
persistVersion = listVersion;
}
oStream.writeObject(fileListCopy);
oStream.close();
return persistVersion;
} catch (IOException e) {
throw new RuntimeException("Unable to persist File Changed List:" +
e.getMessage(), e);
}
} | java | public long persist(File persistFile) {
try {
FileOutputStream fileStream = new FileOutputStream(persistFile);
ObjectOutputStream oStream = new ObjectOutputStream((fileStream));
long persistVersion;
Map<String, ChangedFile> fileListCopy;
synchronized (this) {
fileListCopy = (Map<String, ChangedFile>) fileList.clone();
fileListCopy.putAll(reservedFiles);
persistVersion = listVersion;
}
oStream.writeObject(fileListCopy);
oStream.close();
return persistVersion;
} catch (IOException e) {
throw new RuntimeException("Unable to persist File Changed List:" +
e.getMessage(), e);
}
} | [
"public",
"long",
"persist",
"(",
"File",
"persistFile",
")",
"{",
"try",
"{",
"FileOutputStream",
"fileStream",
"=",
"new",
"FileOutputStream",
"(",
"persistFile",
")",
";",
"ObjectOutputStream",
"oStream",
"=",
"new",
"ObjectOutputStream",
"(",
"(",
"fileStream",
")",
")",
";",
"long",
"persistVersion",
";",
"Map",
"<",
"String",
",",
"ChangedFile",
">",
"fileListCopy",
";",
"synchronized",
"(",
"this",
")",
"{",
"fileListCopy",
"=",
"(",
"Map",
"<",
"String",
",",
"ChangedFile",
">",
")",
"fileList",
".",
"clone",
"(",
")",
";",
"fileListCopy",
".",
"putAll",
"(",
"reservedFiles",
")",
";",
"persistVersion",
"=",
"listVersion",
";",
"}",
"oStream",
".",
"writeObject",
"(",
"fileListCopy",
")",
";",
"oStream",
".",
"close",
"(",
")",
";",
"return",
"persistVersion",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to persist File Changed List:\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Writes out the current state of the ChangeList to the given file.
@param persistFile file to write state to
@return the version ID of the ChangedList which was persisted | [
"Writes",
"out",
"the",
"current",
"state",
"of",
"the",
"ChangeList",
"to",
"the",
"given",
"file",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/mgmt/ChangedList.java#L190-L210 |
141,414 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/mgmt/ChangedList.java | ChangedList.restore | public synchronized void restore(File persistFile, List<File> contentDirs) {
try {
FileInputStream fileStream = new FileInputStream(persistFile);
ObjectInputStream oStream = new ObjectInputStream(fileStream);
log.info("Restoring changed list from backup: {}", persistFile.getAbsolutePath());
synchronized (this) {
LinkedHashMap<String, ChangedFile> fileListFromDisk =
(LinkedHashMap<String, ChangedFile>) oStream.readObject();
//remove files in change list that are not in the content dir list.
if (contentDirs != null && !contentDirs.isEmpty()) {
Iterator<Entry<String, ChangedFile>> entries =
fileListFromDisk.entrySet().iterator();
while (entries.hasNext()) {
Entry<String, ChangedFile> entry = entries.next();
ChangedFile file = entry.getValue();
boolean watched = false;
for (File contentDir : contentDirs) {
if (file.getFile()
.getAbsolutePath()
.startsWith(contentDir.getAbsolutePath()) &&
!this.fileExclusionManager.isExcluded(file.getFile())) {
watched = true;
break;
}
}
if (!watched) {
entries.remove();
}
}
}
this.fileList = fileListFromDisk;
}
oStream.close();
} catch (Exception e) {
throw new RuntimeException("Unable to restore File Changed List:" +
e.getMessage(), e);
}
} | java | public synchronized void restore(File persistFile, List<File> contentDirs) {
try {
FileInputStream fileStream = new FileInputStream(persistFile);
ObjectInputStream oStream = new ObjectInputStream(fileStream);
log.info("Restoring changed list from backup: {}", persistFile.getAbsolutePath());
synchronized (this) {
LinkedHashMap<String, ChangedFile> fileListFromDisk =
(LinkedHashMap<String, ChangedFile>) oStream.readObject();
//remove files in change list that are not in the content dir list.
if (contentDirs != null && !contentDirs.isEmpty()) {
Iterator<Entry<String, ChangedFile>> entries =
fileListFromDisk.entrySet().iterator();
while (entries.hasNext()) {
Entry<String, ChangedFile> entry = entries.next();
ChangedFile file = entry.getValue();
boolean watched = false;
for (File contentDir : contentDirs) {
if (file.getFile()
.getAbsolutePath()
.startsWith(contentDir.getAbsolutePath()) &&
!this.fileExclusionManager.isExcluded(file.getFile())) {
watched = true;
break;
}
}
if (!watched) {
entries.remove();
}
}
}
this.fileList = fileListFromDisk;
}
oStream.close();
} catch (Exception e) {
throw new RuntimeException("Unable to restore File Changed List:" +
e.getMessage(), e);
}
} | [
"public",
"synchronized",
"void",
"restore",
"(",
"File",
"persistFile",
",",
"List",
"<",
"File",
">",
"contentDirs",
")",
"{",
"try",
"{",
"FileInputStream",
"fileStream",
"=",
"new",
"FileInputStream",
"(",
"persistFile",
")",
";",
"ObjectInputStream",
"oStream",
"=",
"new",
"ObjectInputStream",
"(",
"fileStream",
")",
";",
"log",
".",
"info",
"(",
"\"Restoring changed list from backup: {}\"",
",",
"persistFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"LinkedHashMap",
"<",
"String",
",",
"ChangedFile",
">",
"fileListFromDisk",
"=",
"(",
"LinkedHashMap",
"<",
"String",
",",
"ChangedFile",
">",
")",
"oStream",
".",
"readObject",
"(",
")",
";",
"//remove files in change list that are not in the content dir list.",
"if",
"(",
"contentDirs",
"!=",
"null",
"&&",
"!",
"contentDirs",
".",
"isEmpty",
"(",
")",
")",
"{",
"Iterator",
"<",
"Entry",
"<",
"String",
",",
"ChangedFile",
">",
">",
"entries",
"=",
"fileListFromDisk",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasNext",
"(",
")",
")",
"{",
"Entry",
"<",
"String",
",",
"ChangedFile",
">",
"entry",
"=",
"entries",
".",
"next",
"(",
")",
";",
"ChangedFile",
"file",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"boolean",
"watched",
"=",
"false",
";",
"for",
"(",
"File",
"contentDir",
":",
"contentDirs",
")",
"{",
"if",
"(",
"file",
".",
"getFile",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
".",
"startsWith",
"(",
"contentDir",
".",
"getAbsolutePath",
"(",
")",
")",
"&&",
"!",
"this",
".",
"fileExclusionManager",
".",
"isExcluded",
"(",
"file",
".",
"getFile",
"(",
")",
")",
")",
"{",
"watched",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"watched",
")",
"{",
"entries",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}",
"this",
".",
"fileList",
"=",
"fileListFromDisk",
";",
"}",
"oStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to restore File Changed List:\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Restores the state of the ChangedList using the given backup file
@param persistFile file containing previous state
@param contentDirs content directories currently configured. | [
"Restores",
"the",
"state",
"of",
"the",
"ChangedList",
"using",
"the",
"given",
"backup",
"file"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/mgmt/ChangedList.java#L218-L259 |
141,415 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/SpaceRest.java | SpaceRest.addSpacePropertiesToResponse | private Response addSpacePropertiesToResponse(ResponseBuilder response,
String spaceID,
String storeID)
throws ResourceException {
Map<String, String> properties =
spaceResource.getSpaceProperties(spaceID, storeID);
return addPropertiesToResponse(response, properties);
} | java | private Response addSpacePropertiesToResponse(ResponseBuilder response,
String spaceID,
String storeID)
throws ResourceException {
Map<String, String> properties =
spaceResource.getSpaceProperties(spaceID, storeID);
return addPropertiesToResponse(response, properties);
} | [
"private",
"Response",
"addSpacePropertiesToResponse",
"(",
"ResponseBuilder",
"response",
",",
"String",
"spaceID",
",",
"String",
"storeID",
")",
"throws",
"ResourceException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"spaceResource",
".",
"getSpaceProperties",
"(",
"spaceID",
",",
"storeID",
")",
";",
"return",
"addPropertiesToResponse",
"(",
"response",
",",
"properties",
")",
";",
"}"
] | Adds the properties of a space as header values to the response | [
"Adds",
"the",
"properties",
"of",
"a",
"space",
"as",
"header",
"values",
"to",
"the",
"response"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceRest.java#L171-L179 |
141,416 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/SpaceRest.java | SpaceRest.addSpaceACLsToResponse | private Response addSpaceACLsToResponse(ResponseBuilder response,
String spaceID,
String storeID)
throws ResourceException {
Map<String, String> aclProps = new HashMap<String, String>();
Map<String, AclType> acls = spaceResource.getSpaceACLs(spaceID,
storeID);
for (String key : acls.keySet()) {
aclProps.put(key, acls.get(key).name());
}
return addPropertiesToResponse(response, aclProps);
} | java | private Response addSpaceACLsToResponse(ResponseBuilder response,
String spaceID,
String storeID)
throws ResourceException {
Map<String, String> aclProps = new HashMap<String, String>();
Map<String, AclType> acls = spaceResource.getSpaceACLs(spaceID,
storeID);
for (String key : acls.keySet()) {
aclProps.put(key, acls.get(key).name());
}
return addPropertiesToResponse(response, aclProps);
} | [
"private",
"Response",
"addSpaceACLsToResponse",
"(",
"ResponseBuilder",
"response",
",",
"String",
"spaceID",
",",
"String",
"storeID",
")",
"throws",
"ResourceException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"aclProps",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"Map",
"<",
"String",
",",
"AclType",
">",
"acls",
"=",
"spaceResource",
".",
"getSpaceACLs",
"(",
"spaceID",
",",
"storeID",
")",
";",
"for",
"(",
"String",
"key",
":",
"acls",
".",
"keySet",
"(",
")",
")",
"{",
"aclProps",
".",
"put",
"(",
"key",
",",
"acls",
".",
"get",
"(",
"key",
")",
".",
"name",
"(",
")",
")",
";",
"}",
"return",
"addPropertiesToResponse",
"(",
"response",
",",
"aclProps",
")",
";",
"}"
] | Adds the ACLs of a space as header values to the response. | [
"Adds",
"the",
"ACLs",
"of",
"a",
"space",
"as",
"header",
"values",
"to",
"the",
"response",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceRest.java#L218-L229 |
141,417 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/SpaceRest.java | SpaceRest.updateSpaceACLs | @Path("/acl/{spaceID}")
@POST
public Response updateSpaceACLs(@PathParam("spaceID") String spaceID,
@QueryParam("storeID") String storeID) {
String msg = "update space ACLs(" + spaceID + ", " + storeID + ")";
try {
log.debug(msg);
return doUpdateSpaceACLs(spaceID, storeID);
} catch (ResourceNotFoundException e) {
return responseNotFound(msg, e, NOT_FOUND);
} catch (ResourceException e) {
return responseBad(msg, e, INTERNAL_SERVER_ERROR);
} catch (Exception e) {
return responseBad(msg, e, INTERNAL_SERVER_ERROR);
}
} | java | @Path("/acl/{spaceID}")
@POST
public Response updateSpaceACLs(@PathParam("spaceID") String spaceID,
@QueryParam("storeID") String storeID) {
String msg = "update space ACLs(" + spaceID + ", " + storeID + ")";
try {
log.debug(msg);
return doUpdateSpaceACLs(spaceID, storeID);
} catch (ResourceNotFoundException e) {
return responseNotFound(msg, e, NOT_FOUND);
} catch (ResourceException e) {
return responseBad(msg, e, INTERNAL_SERVER_ERROR);
} catch (Exception e) {
return responseBad(msg, e, INTERNAL_SERVER_ERROR);
}
} | [
"@",
"Path",
"(",
"\"/acl/{spaceID}\"",
")",
"@",
"POST",
"public",
"Response",
"updateSpaceACLs",
"(",
"@",
"PathParam",
"(",
"\"spaceID\"",
")",
"String",
"spaceID",
",",
"@",
"QueryParam",
"(",
"\"storeID\"",
")",
"String",
"storeID",
")",
"{",
"String",
"msg",
"=",
"\"update space ACLs(\"",
"+",
"spaceID",
"+",
"\", \"",
"+",
"storeID",
"+",
"\")\"",
";",
"try",
"{",
"log",
".",
"debug",
"(",
"msg",
")",
";",
"return",
"doUpdateSpaceACLs",
"(",
"spaceID",
",",
"storeID",
")",
";",
"}",
"catch",
"(",
"ResourceNotFoundException",
"e",
")",
"{",
"return",
"responseNotFound",
"(",
"msg",
",",
"e",
",",
"NOT_FOUND",
")",
";",
"}",
"catch",
"(",
"ResourceException",
"e",
")",
"{",
"return",
"responseBad",
"(",
"msg",
",",
"e",
",",
"INTERNAL_SERVER_ERROR",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"responseBad",
"(",
"msg",
",",
"e",
",",
"INTERNAL_SERVER_ERROR",
")",
";",
"}",
"}"
] | This method sets the ACLs associated with a space.
Only values included in the ACLs headers will be updated, others will
be removed.
@return 200 response | [
"This",
"method",
"sets",
"the",
"ACLs",
"associated",
"with",
"a",
"space",
".",
"Only",
"values",
"included",
"in",
"the",
"ACLs",
"headers",
"will",
"be",
"updated",
"others",
"will",
"be",
"removed",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceRest.java#L288-L307 |
141,418 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/writer/DuracloudContentWriter.java | DuracloudContentWriter.write | @Override
public ChunksManifest write(String spaceId,
ChunkableContent chunkable,
Map<String, String> contentProperties)
throws NotFoundException {
return write(spaceId, chunkable, contentProperties, true);
} | java | @Override
public ChunksManifest write(String spaceId,
ChunkableContent chunkable,
Map<String, String> contentProperties)
throws NotFoundException {
return write(spaceId, chunkable, contentProperties, true);
} | [
"@",
"Override",
"public",
"ChunksManifest",
"write",
"(",
"String",
"spaceId",
",",
"ChunkableContent",
"chunkable",
",",
"Map",
"<",
"String",
",",
"String",
">",
"contentProperties",
")",
"throws",
"NotFoundException",
"{",
"return",
"write",
"(",
"spaceId",
",",
"chunkable",
",",
"contentProperties",
",",
"true",
")",
";",
"}"
] | This method implements the ContentWriter interface for writing content
to a DataStore. In this case, the DataStore is durastore.
@param spaceId destination space of arg chunkable content
@param chunkable content to be written
@throws NotFoundException if space is not found | [
"This",
"method",
"implements",
"the",
"ContentWriter",
"interface",
"for",
"writing",
"content",
"to",
"a",
"DataStore",
".",
"In",
"this",
"case",
"the",
"DataStore",
"is",
"durastore",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/writer/DuracloudContentWriter.java#L135-L141 |
141,419 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/writer/DuracloudContentWriter.java | DuracloudContentWriter.writeSingle | @Override
public String writeSingle(String spaceId,
String chunkChecksum,
ChunkInputStream chunk,
Map<String, String> properties)
throws NotFoundException {
log.debug("writeSingle: " + spaceId + ", " + chunk.getChunkId());
createSpaceIfNotExist(spaceId);
addChunk(spaceId, chunkChecksum, chunk, properties, true);
log.debug("written: " + spaceId + ", " + chunk.getChunkId());
return chunk.getMD5();
} | java | @Override
public String writeSingle(String spaceId,
String chunkChecksum,
ChunkInputStream chunk,
Map<String, String> properties)
throws NotFoundException {
log.debug("writeSingle: " + spaceId + ", " + chunk.getChunkId());
createSpaceIfNotExist(spaceId);
addChunk(spaceId, chunkChecksum, chunk, properties, true);
log.debug("written: " + spaceId + ", " + chunk.getChunkId());
return chunk.getMD5();
} | [
"@",
"Override",
"public",
"String",
"writeSingle",
"(",
"String",
"spaceId",
",",
"String",
"chunkChecksum",
",",
"ChunkInputStream",
"chunk",
",",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
")",
"throws",
"NotFoundException",
"{",
"log",
".",
"debug",
"(",
"\"writeSingle: \"",
"+",
"spaceId",
"+",
"\", \"",
"+",
"chunk",
".",
"getChunkId",
"(",
")",
")",
";",
"createSpaceIfNotExist",
"(",
"spaceId",
")",
";",
"addChunk",
"(",
"spaceId",
",",
"chunkChecksum",
",",
"chunk",
",",
"properties",
",",
"true",
")",
";",
"log",
".",
"debug",
"(",
"\"written: \"",
"+",
"spaceId",
"+",
"\", \"",
"+",
"chunk",
".",
"getChunkId",
"(",
")",
")",
";",
"return",
"chunk",
".",
"getMD5",
"(",
")",
";",
"}"
] | This method writes a single chunk to the DataStore.
@param spaceId destination where arg chunk content will be written
@param chunkChecksum md5 checksum of the chunk if known, null otherwise
@param chunk content to be written
@param properties user-defined properties for the content
@return MD5 of written content
@throws NotFoundException if space is not found | [
"This",
"method",
"writes",
"a",
"single",
"chunk",
"to",
"the",
"DataStore",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/writer/DuracloudContentWriter.java#L296-L310 |
141,420 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java | SpaceResource.getSpaces | public String getSpaces(String storeID) throws ResourceException {
Element spacesElem = new Element("spaces");
try {
StorageProvider storage =
storageProviderFactory.getStorageProvider(storeID);
Iterator<String> spaces = storage.getSpaces();
while (spaces.hasNext()) {
String spaceID = spaces.next();
Element spaceElem = new Element("space");
spaceElem.setAttribute("id", spaceID);
spacesElem.addContent(spaceElem);
}
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("Error attempting to build spaces XML",
e);
}
Document doc = new Document(spacesElem);
XMLOutputter xmlConverter = new XMLOutputter();
return xmlConverter.outputString(doc);
} | java | public String getSpaces(String storeID) throws ResourceException {
Element spacesElem = new Element("spaces");
try {
StorageProvider storage =
storageProviderFactory.getStorageProvider(storeID);
Iterator<String> spaces = storage.getSpaces();
while (spaces.hasNext()) {
String spaceID = spaces.next();
Element spaceElem = new Element("space");
spaceElem.setAttribute("id", spaceID);
spacesElem.addContent(spaceElem);
}
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("Error attempting to build spaces XML",
e);
}
Document doc = new Document(spacesElem);
XMLOutputter xmlConverter = new XMLOutputter();
return xmlConverter.outputString(doc);
} | [
"public",
"String",
"getSpaces",
"(",
"String",
"storeID",
")",
"throws",
"ResourceException",
"{",
"Element",
"spacesElem",
"=",
"new",
"Element",
"(",
"\"spaces\"",
")",
";",
"try",
"{",
"StorageProvider",
"storage",
"=",
"storageProviderFactory",
".",
"getStorageProvider",
"(",
"storeID",
")",
";",
"Iterator",
"<",
"String",
">",
"spaces",
"=",
"storage",
".",
"getSpaces",
"(",
")",
";",
"while",
"(",
"spaces",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"spaceID",
"=",
"spaces",
".",
"next",
"(",
")",
";",
"Element",
"spaceElem",
"=",
"new",
"Element",
"(",
"\"space\"",
")",
";",
"spaceElem",
".",
"setAttribute",
"(",
"\"id\"",
",",
"spaceID",
")",
";",
"spacesElem",
".",
"addContent",
"(",
"spaceElem",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"storageProviderFactory",
".",
"expireStorageProvider",
"(",
"storeID",
")",
";",
"throw",
"new",
"ResourceException",
"(",
"\"Error attempting to build spaces XML\"",
",",
"e",
")",
";",
"}",
"Document",
"doc",
"=",
"new",
"Document",
"(",
"spacesElem",
")",
";",
"XMLOutputter",
"xmlConverter",
"=",
"new",
"XMLOutputter",
"(",
")",
";",
"return",
"xmlConverter",
".",
"outputString",
"(",
"doc",
")",
";",
"}"
] | Provides a listing of all spaces for a customer. Open spaces are
always included in the list, closed spaces are included based
on user authorization.
@param storeID
@return XML listing of spaces | [
"Provides",
"a",
"listing",
"of",
"all",
"spaces",
"for",
"a",
"customer",
".",
"Open",
"spaces",
"are",
"always",
"included",
"in",
"the",
"list",
"closed",
"spaces",
"are",
"included",
"based",
"on",
"user",
"authorization",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java#L52-L76 |
141,421 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java | SpaceResource.getSpaceContents | public String getSpaceContents(String spaceID,
String storeID,
String prefix,
long maxResults,
String marker) throws ResourceException {
Element spaceElem = new Element("space");
spaceElem.setAttribute("id", spaceID);
try {
StorageProvider storage = storageProviderFactory.getStorageProvider(storeID);
List<String> contents = storage.getSpaceContentsChunked(spaceID,
prefix,
maxResults,
marker);
if (contents != null) {
for (String contentItem : contents) {
Element contentElem = new Element("item");
contentElem.setText(contentItem);
spaceElem.addContent(contentElem);
}
}
} catch (NotFoundException e) {
throw new ResourceNotFoundException("build space XML for", spaceID, e);
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("build space XML for", spaceID, e);
}
Document doc = new Document(spaceElem);
XMLOutputter xmlConverter = new XMLOutputter();
return xmlConverter.outputString(doc);
} | java | public String getSpaceContents(String spaceID,
String storeID,
String prefix,
long maxResults,
String marker) throws ResourceException {
Element spaceElem = new Element("space");
spaceElem.setAttribute("id", spaceID);
try {
StorageProvider storage = storageProviderFactory.getStorageProvider(storeID);
List<String> contents = storage.getSpaceContentsChunked(spaceID,
prefix,
maxResults,
marker);
if (contents != null) {
for (String contentItem : contents) {
Element contentElem = new Element("item");
contentElem.setText(contentItem);
spaceElem.addContent(contentElem);
}
}
} catch (NotFoundException e) {
throw new ResourceNotFoundException("build space XML for", spaceID, e);
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("build space XML for", spaceID, e);
}
Document doc = new Document(spaceElem);
XMLOutputter xmlConverter = new XMLOutputter();
return xmlConverter.outputString(doc);
} | [
"public",
"String",
"getSpaceContents",
"(",
"String",
"spaceID",
",",
"String",
"storeID",
",",
"String",
"prefix",
",",
"long",
"maxResults",
",",
"String",
"marker",
")",
"throws",
"ResourceException",
"{",
"Element",
"spaceElem",
"=",
"new",
"Element",
"(",
"\"space\"",
")",
";",
"spaceElem",
".",
"setAttribute",
"(",
"\"id\"",
",",
"spaceID",
")",
";",
"try",
"{",
"StorageProvider",
"storage",
"=",
"storageProviderFactory",
".",
"getStorageProvider",
"(",
"storeID",
")",
";",
"List",
"<",
"String",
">",
"contents",
"=",
"storage",
".",
"getSpaceContentsChunked",
"(",
"spaceID",
",",
"prefix",
",",
"maxResults",
",",
"marker",
")",
";",
"if",
"(",
"contents",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"contentItem",
":",
"contents",
")",
"{",
"Element",
"contentElem",
"=",
"new",
"Element",
"(",
"\"item\"",
")",
";",
"contentElem",
".",
"setText",
"(",
"contentItem",
")",
";",
"spaceElem",
".",
"addContent",
"(",
"contentElem",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"\"build space XML for\"",
",",
"spaceID",
",",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"storageProviderFactory",
".",
"expireStorageProvider",
"(",
"storeID",
")",
";",
"throw",
"new",
"ResourceException",
"(",
"\"build space XML for\"",
",",
"spaceID",
",",
"e",
")",
";",
"}",
"Document",
"doc",
"=",
"new",
"Document",
"(",
"spaceElem",
")",
";",
"XMLOutputter",
"xmlConverter",
"=",
"new",
"XMLOutputter",
"(",
")",
";",
"return",
"xmlConverter",
".",
"outputString",
"(",
"doc",
")",
";",
"}"
] | Gets a listing of the contents of a space.
@param spaceID
@param storeID
@param prefix
@param maxResults
@param marker
@return XML listing of space contents | [
"Gets",
"a",
"listing",
"of",
"the",
"contents",
"of",
"a",
"space",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java#L126-L158 |
141,422 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java | SpaceResource.addSpace | public void addSpace(String spaceID, Map<String, AclType> userACLs, String storeID)
throws ResourceException, InvalidIdException {
IdUtil.validateSpaceId(spaceID);
try {
StorageProvider storage = storageProviderFactory.getStorageProvider(storeID);
storage.createSpace(spaceID);
waitForSpaceCreation(storage, spaceID);
updateSpaceACLs(spaceID, userACLs, storeID);
} catch (NotFoundException e) {
throw new InvalidIdException(e.getMessage());
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("add space", spaceID, e);
}
} | java | public void addSpace(String spaceID, Map<String, AclType> userACLs, String storeID)
throws ResourceException, InvalidIdException {
IdUtil.validateSpaceId(spaceID);
try {
StorageProvider storage = storageProviderFactory.getStorageProvider(storeID);
storage.createSpace(spaceID);
waitForSpaceCreation(storage, spaceID);
updateSpaceACLs(spaceID, userACLs, storeID);
} catch (NotFoundException e) {
throw new InvalidIdException(e.getMessage());
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("add space", spaceID, e);
}
} | [
"public",
"void",
"addSpace",
"(",
"String",
"spaceID",
",",
"Map",
"<",
"String",
",",
"AclType",
">",
"userACLs",
",",
"String",
"storeID",
")",
"throws",
"ResourceException",
",",
"InvalidIdException",
"{",
"IdUtil",
".",
"validateSpaceId",
"(",
"spaceID",
")",
";",
"try",
"{",
"StorageProvider",
"storage",
"=",
"storageProviderFactory",
".",
"getStorageProvider",
"(",
"storeID",
")",
";",
"storage",
".",
"createSpace",
"(",
"spaceID",
")",
";",
"waitForSpaceCreation",
"(",
"storage",
",",
"spaceID",
")",
";",
"updateSpaceACLs",
"(",
"spaceID",
",",
"userACLs",
",",
"storeID",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"throw",
"new",
"InvalidIdException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"storageProviderFactory",
".",
"expireStorageProvider",
"(",
"storeID",
")",
";",
"throw",
"new",
"ResourceException",
"(",
"\"add space\"",
",",
"spaceID",
",",
"e",
")",
";",
"}",
"}"
] | Adds a space.
@param spaceID
@param storeID | [
"Adds",
"a",
"space",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java#L166-L182 |
141,423 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java | SpaceResource.updateSpaceACLs | public void updateSpaceACLs(String spaceID,
Map<String, AclType> spaceACLs,
String storeID) throws ResourceException {
try {
StorageProvider storage = storageProviderFactory.getStorageProvider(
storeID);
if (null != spaceACLs) {
storage.setSpaceACLs(spaceID, spaceACLs);
}
} catch (NotFoundException e) {
throw new ResourceNotFoundException("update space ACLs for", spaceID, e);
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("update space ACLs for", spaceID, e);
}
} | java | public void updateSpaceACLs(String spaceID,
Map<String, AclType> spaceACLs,
String storeID) throws ResourceException {
try {
StorageProvider storage = storageProviderFactory.getStorageProvider(
storeID);
if (null != spaceACLs) {
storage.setSpaceACLs(spaceID, spaceACLs);
}
} catch (NotFoundException e) {
throw new ResourceNotFoundException("update space ACLs for", spaceID, e);
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("update space ACLs for", spaceID, e);
}
} | [
"public",
"void",
"updateSpaceACLs",
"(",
"String",
"spaceID",
",",
"Map",
"<",
"String",
",",
"AclType",
">",
"spaceACLs",
",",
"String",
"storeID",
")",
"throws",
"ResourceException",
"{",
"try",
"{",
"StorageProvider",
"storage",
"=",
"storageProviderFactory",
".",
"getStorageProvider",
"(",
"storeID",
")",
";",
"if",
"(",
"null",
"!=",
"spaceACLs",
")",
"{",
"storage",
".",
"setSpaceACLs",
"(",
"spaceID",
",",
"spaceACLs",
")",
";",
"}",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"\"update space ACLs for\"",
",",
"spaceID",
",",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"storageProviderFactory",
".",
"expireStorageProvider",
"(",
"storeID",
")",
";",
"throw",
"new",
"ResourceException",
"(",
"\"update space ACLs for\"",
",",
"spaceID",
",",
"e",
")",
";",
"}",
"}"
] | Updates the ACLs of a space.
@param spaceID
@param spaceACLs
@param storeID | [
"Updates",
"the",
"ACLs",
"of",
"a",
"space",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java#L221-L237 |
141,424 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java | SpaceResource.deleteSpace | public void deleteSpace(String spaceID, String storeID) throws ResourceException {
try {
StorageProvider storage = storageProviderFactory.getStorageProvider(storeID);
storage.deleteSpace(spaceID);
} catch (NotFoundException e) {
throw new ResourceNotFoundException("delete space", spaceID, e);
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("delete space", spaceID, e);
}
} | java | public void deleteSpace(String spaceID, String storeID) throws ResourceException {
try {
StorageProvider storage = storageProviderFactory.getStorageProvider(storeID);
storage.deleteSpace(spaceID);
} catch (NotFoundException e) {
throw new ResourceNotFoundException("delete space", spaceID, e);
} catch (Exception e) {
storageProviderFactory.expireStorageProvider(storeID);
throw new ResourceException("delete space", spaceID, e);
}
} | [
"public",
"void",
"deleteSpace",
"(",
"String",
"spaceID",
",",
"String",
"storeID",
")",
"throws",
"ResourceException",
"{",
"try",
"{",
"StorageProvider",
"storage",
"=",
"storageProviderFactory",
".",
"getStorageProvider",
"(",
"storeID",
")",
";",
"storage",
".",
"deleteSpace",
"(",
"spaceID",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"throw",
"new",
"ResourceNotFoundException",
"(",
"\"delete space\"",
",",
"spaceID",
",",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"storageProviderFactory",
".",
"expireStorageProvider",
"(",
"storeID",
")",
";",
"throw",
"new",
"ResourceException",
"(",
"\"delete space\"",
",",
"spaceID",
",",
"e",
")",
";",
"}",
"}"
] | Deletes a space, removing all included content.
@param spaceID
@param storeID | [
"Deletes",
"a",
"space",
"removing",
"all",
"included",
"content",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/SpaceResource.java#L245-L255 |
141,425 | duracloud/duracloud | security/src/main/java/org/duracloud/security/impl/UserDetailsServiceImpl.java | UserDetailsServiceImpl.loadUserByUsername | public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException {
UserDetails userDetails = usersTable.get(username);
if (null == userDetails) {
throw new UsernameNotFoundException(username);
}
return userDetails;
} | java | public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException {
UserDetails userDetails = usersTable.get(username);
if (null == userDetails) {
throw new UsernameNotFoundException(username);
}
return userDetails;
} | [
"public",
"UserDetails",
"loadUserByUsername",
"(",
"String",
"username",
")",
"throws",
"UsernameNotFoundException",
"{",
"UserDetails",
"userDetails",
"=",
"usersTable",
".",
"get",
"(",
"username",
")",
";",
"if",
"(",
"null",
"==",
"userDetails",
")",
"{",
"throw",
"new",
"UsernameNotFoundException",
"(",
"username",
")",
";",
"}",
"return",
"userDetails",
";",
"}"
] | This method retrieves UserDetails for all users from a flat file in
DuraCloud.
@param username of principal for whom details are sought
@return UserDetails for arg username
@throws UsernameNotFoundException if username not found | [
"This",
"method",
"retrieves",
"UserDetails",
"for",
"all",
"users",
"from",
"a",
"flat",
"file",
"in",
"DuraCloud",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/security/src/main/java/org/duracloud/security/impl/UserDetailsServiceImpl.java#L49-L56 |
141,426 | duracloud/duracloud | security/src/main/java/org/duracloud/security/impl/UserDetailsServiceImpl.java | UserDetailsServiceImpl.getUsers | public List<SecurityUserBean> getUsers() {
List<SecurityUserBean> users = new ArrayList<SecurityUserBean>();
for (DuracloudUserDetails user : this.usersTable.values()) {
SecurityUserBean bean = createUserBean(user);
users.add(bean);
}
return users;
} | java | public List<SecurityUserBean> getUsers() {
List<SecurityUserBean> users = new ArrayList<SecurityUserBean>();
for (DuracloudUserDetails user : this.usersTable.values()) {
SecurityUserBean bean = createUserBean(user);
users.add(bean);
}
return users;
} | [
"public",
"List",
"<",
"SecurityUserBean",
">",
"getUsers",
"(",
")",
"{",
"List",
"<",
"SecurityUserBean",
">",
"users",
"=",
"new",
"ArrayList",
"<",
"SecurityUserBean",
">",
"(",
")",
";",
"for",
"(",
"DuracloudUserDetails",
"user",
":",
"this",
".",
"usersTable",
".",
"values",
"(",
")",
")",
"{",
"SecurityUserBean",
"bean",
"=",
"createUserBean",
"(",
"user",
")",
";",
"users",
".",
"add",
"(",
"bean",
")",
";",
"}",
"return",
"users",
";",
"}"
] | This method returns all of the non-system-defined users.
@return | [
"This",
"method",
"returns",
"all",
"of",
"the",
"non",
"-",
"system",
"-",
"defined",
"users",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/security/src/main/java/org/duracloud/security/impl/UserDetailsServiceImpl.java#L96-L103 |
141,427 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java | StorageProviderUtil.storeProperties | public static ByteArrayInputStream storeProperties(
Map<String, String> propertiesMap)
throws StorageException {
// Pull out known computed values
propertiesMap.remove(StorageProvider.PROPERTIES_SPACE_COUNT);
// Serialize Map
byte[] properties = null;
try {
String serializedProperties = serializeMap(propertiesMap);
properties = serializedProperties.getBytes("UTF-8");
} catch (Exception e) {
String err = "Could not store properties" +
" due to error: " + e.getMessage();
throw new StorageException(err);
}
ByteArrayInputStream is = new ByteArrayInputStream(properties);
return is;
} | java | public static ByteArrayInputStream storeProperties(
Map<String, String> propertiesMap)
throws StorageException {
// Pull out known computed values
propertiesMap.remove(StorageProvider.PROPERTIES_SPACE_COUNT);
// Serialize Map
byte[] properties = null;
try {
String serializedProperties = serializeMap(propertiesMap);
properties = serializedProperties.getBytes("UTF-8");
} catch (Exception e) {
String err = "Could not store properties" +
" due to error: " + e.getMessage();
throw new StorageException(err);
}
ByteArrayInputStream is = new ByteArrayInputStream(properties);
return is;
} | [
"public",
"static",
"ByteArrayInputStream",
"storeProperties",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"propertiesMap",
")",
"throws",
"StorageException",
"{",
"// Pull out known computed values",
"propertiesMap",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_SPACE_COUNT",
")",
";",
"// Serialize Map",
"byte",
"[",
"]",
"properties",
"=",
"null",
";",
"try",
"{",
"String",
"serializedProperties",
"=",
"serializeMap",
"(",
"propertiesMap",
")",
";",
"properties",
"=",
"serializedProperties",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"err",
"=",
"\"Could not store properties\"",
"+",
"\" due to error: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"StorageException",
"(",
"err",
")",
";",
"}",
"ByteArrayInputStream",
"is",
"=",
"new",
"ByteArrayInputStream",
"(",
"properties",
")",
";",
"return",
"is",
";",
"}"
] | Converts properties stored in a Map into a stream for storage purposes.
@param propertiesMap
@return
@throws StorageException | [
"Converts",
"properties",
"stored",
"in",
"a",
"Map",
"into",
"a",
"stream",
"for",
"storage",
"purposes",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java#L84-L103 |
141,428 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java | StorageProviderUtil.compareChecksum | public static String compareChecksum(StorageProvider provider,
String spaceId,
String contentId,
String checksum)
throws StorageException {
String providerChecksum =
provider.getContentProperties(spaceId, contentId).
get(StorageProvider.PROPERTIES_CONTENT_CHECKSUM);
return compareChecksum(providerChecksum, spaceId, contentId, checksum);
} | java | public static String compareChecksum(StorageProvider provider,
String spaceId,
String contentId,
String checksum)
throws StorageException {
String providerChecksum =
provider.getContentProperties(spaceId, contentId).
get(StorageProvider.PROPERTIES_CONTENT_CHECKSUM);
return compareChecksum(providerChecksum, spaceId, contentId, checksum);
} | [
"public",
"static",
"String",
"compareChecksum",
"(",
"StorageProvider",
"provider",
",",
"String",
"spaceId",
",",
"String",
"contentId",
",",
"String",
"checksum",
")",
"throws",
"StorageException",
"{",
"String",
"providerChecksum",
"=",
"provider",
".",
"getContentProperties",
"(",
"spaceId",
",",
"contentId",
")",
".",
"get",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_CHECKSUM",
")",
";",
"return",
"compareChecksum",
"(",
"providerChecksum",
",",
"spaceId",
",",
"contentId",
",",
"checksum",
")",
";",
"}"
] | Determines if the checksum for a particular piece of content
stored in a StorageProvider matches the expected checksum value.
@param provider The StorageProvider where the content was stored
@param spaceId The Space in which the content was stored
@param contentId The Id of the content
@param checksum The content checksum, either provided or computed
@throws StorageException if the included checksum does not match
the storage provider generated checksum
@returns the validated checksum value from the provider | [
"Determines",
"if",
"the",
"checksum",
"for",
"a",
"particular",
"piece",
"of",
"content",
"stored",
"in",
"a",
"StorageProvider",
"matches",
"the",
"expected",
"checksum",
"value",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java#L117-L126 |
141,429 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java | StorageProviderUtil.compareChecksum | public static String compareChecksum(String providerChecksum,
String spaceId,
String contentId,
String checksum)
throws ChecksumMismatchException {
if (!providerChecksum.equals(checksum)) {
String err = "Content " + contentId + " was added to space " +
spaceId + " but the checksum, either provided or computed " +
"enroute, (" + checksum + ") does not match the checksum " +
"computed by the storage provider (" + providerChecksum +
"). This content should be retransmitted.";
log.warn(err);
throw new ChecksumMismatchException(err, NO_RETRY);
}
return providerChecksum;
} | java | public static String compareChecksum(String providerChecksum,
String spaceId,
String contentId,
String checksum)
throws ChecksumMismatchException {
if (!providerChecksum.equals(checksum)) {
String err = "Content " + contentId + " was added to space " +
spaceId + " but the checksum, either provided or computed " +
"enroute, (" + checksum + ") does not match the checksum " +
"computed by the storage provider (" + providerChecksum +
"). This content should be retransmitted.";
log.warn(err);
throw new ChecksumMismatchException(err, NO_RETRY);
}
return providerChecksum;
} | [
"public",
"static",
"String",
"compareChecksum",
"(",
"String",
"providerChecksum",
",",
"String",
"spaceId",
",",
"String",
"contentId",
",",
"String",
"checksum",
")",
"throws",
"ChecksumMismatchException",
"{",
"if",
"(",
"!",
"providerChecksum",
".",
"equals",
"(",
"checksum",
")",
")",
"{",
"String",
"err",
"=",
"\"Content \"",
"+",
"contentId",
"+",
"\" was added to space \"",
"+",
"spaceId",
"+",
"\" but the checksum, either provided or computed \"",
"+",
"\"enroute, (\"",
"+",
"checksum",
"+",
"\") does not match the checksum \"",
"+",
"\"computed by the storage provider (\"",
"+",
"providerChecksum",
"+",
"\"). This content should be retransmitted.\"",
";",
"log",
".",
"warn",
"(",
"err",
")",
";",
"throw",
"new",
"ChecksumMismatchException",
"(",
"err",
",",
"NO_RETRY",
")",
";",
"}",
"return",
"providerChecksum",
";",
"}"
] | Determines if two checksum values are equal
@param providerChecksum The checksum provided by the StorageProvider
@param spaceId The Space in which the content was stored
@param contentId The Id of the content
@param checksum The content checksum, either provided or computed
@throws ChecksumMismatchException if the included checksum does not match
the storage provider generated checksum
@returns the validated checksum value from the provider | [
"Determines",
"if",
"two",
"checksum",
"values",
"are",
"equal"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java#L139-L154 |
141,430 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java | StorageProviderUtil.contains | public static boolean contains(Iterator<String> iterator, String value) {
if (iterator == null || value == null) {
return false;
}
while (iterator.hasNext()) {
if (value.equals(iterator.next())) {
return true;
}
}
return false;
} | java | public static boolean contains(Iterator<String> iterator, String value) {
if (iterator == null || value == null) {
return false;
}
while (iterator.hasNext()) {
if (value.equals(iterator.next())) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"contains",
"(",
"Iterator",
"<",
"String",
">",
"iterator",
",",
"String",
"value",
")",
"{",
"if",
"(",
"iterator",
"==",
"null",
"||",
"value",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"value",
".",
"equals",
"(",
"iterator",
".",
"next",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Determines if a String value is included in a Iterated list.
The iteration is only run as far as necessary to determine
if the value is included in the underlying list.
@param iterator
@param value
@return | [
"Determines",
"if",
"a",
"String",
"value",
"is",
"included",
"in",
"a",
"Iterated",
"list",
".",
"The",
"iteration",
"is",
"only",
"run",
"as",
"far",
"as",
"necessary",
"to",
"determine",
"if",
"the",
"value",
"is",
"included",
"in",
"the",
"underlying",
"list",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java#L165-L175 |
141,431 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java | StorageProviderUtil.count | public static long count(Iterator<String> iterator) {
if (iterator == null) {
return 0;
}
long count = 0;
while (iterator.hasNext()) {
++count;
iterator.next();
}
return count;
} | java | public static long count(Iterator<String> iterator) {
if (iterator == null) {
return 0;
}
long count = 0;
while (iterator.hasNext()) {
++count;
iterator.next();
}
return count;
} | [
"public",
"static",
"long",
"count",
"(",
"Iterator",
"<",
"String",
">",
"iterator",
")",
"{",
"if",
"(",
"iterator",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"long",
"count",
"=",
"0",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"++",
"count",
";",
"iterator",
".",
"next",
"(",
")",
";",
"}",
"return",
"count",
";",
"}"
] | Determines the number of elements in an iteration.
@param iterator
@return | [
"Determines",
"the",
"number",
"of",
"elements",
"in",
"an",
"iteration",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java#L183-L193 |
141,432 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java | StorageProviderUtil.getList | public static List<String> getList(Iterator<String> iterator) {
List<String> contents = new ArrayList<String>();
while (iterator.hasNext()) {
contents.add(iterator.next());
}
return contents;
} | java | public static List<String> getList(Iterator<String> iterator) {
List<String> contents = new ArrayList<String>();
while (iterator.hasNext()) {
contents.add(iterator.next());
}
return contents;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getList",
"(",
"Iterator",
"<",
"String",
">",
"iterator",
")",
"{",
"List",
"<",
"String",
">",
"contents",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"contents",
".",
"add",
"(",
"iterator",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"contents",
";",
"}"
] | Creates a list of all of the items in an iteration.
Be wary of using this for Iterations of very long lists.
@param iterator
@return | [
"Creates",
"a",
"list",
"of",
"all",
"of",
"the",
"items",
"in",
"an",
"iteration",
".",
"Be",
"wary",
"of",
"using",
"this",
"for",
"Iterations",
"of",
"very",
"long",
"lists",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java#L202-L208 |
141,433 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java | StorageProviderUtil.createContentProperties | public static Map<String, String> createContentProperties(String absolutePath,
String creator) {
Map<String, String> props = new HashMap<String, String>();
if (creator != null && creator.trim().length() > 0) {
props.put(StorageProvider.PROPERTIES_CONTENT_CREATOR, creator);
}
props.put(StorageProvider.PROPERTIES_CONTENT_FILE_PATH, absolutePath);
try {
Path path = FileSystems.getDefault().getPath(absolutePath);
BasicFileAttributes bfa =
Files.readAttributes(path, BasicFileAttributes.class);
String creationDate =
DateUtil.convertToStringLong(bfa.creationTime().toMillis());
props.put(StorageProvider.PROPERTIES_CONTENT_FILE_CREATED, creationDate);
String lastAccessed =
DateUtil.convertToStringLong(bfa.lastAccessTime().toMillis());
props.put(StorageProvider.PROPERTIES_CONTENT_FILE_LAST_ACCESSED, lastAccessed);
String modified =
DateUtil.convertToStringLong(bfa.lastModifiedTime().toMillis());
props.put(StorageProvider.PROPERTIES_CONTENT_FILE_MODIFIED, modified);
} catch (IOException ex) {
log.error("Failed to read basic file attributes from "
+ absolutePath + ": " + ex.getMessage(), ex);
}
return props;
} | java | public static Map<String, String> createContentProperties(String absolutePath,
String creator) {
Map<String, String> props = new HashMap<String, String>();
if (creator != null && creator.trim().length() > 0) {
props.put(StorageProvider.PROPERTIES_CONTENT_CREATOR, creator);
}
props.put(StorageProvider.PROPERTIES_CONTENT_FILE_PATH, absolutePath);
try {
Path path = FileSystems.getDefault().getPath(absolutePath);
BasicFileAttributes bfa =
Files.readAttributes(path, BasicFileAttributes.class);
String creationDate =
DateUtil.convertToStringLong(bfa.creationTime().toMillis());
props.put(StorageProvider.PROPERTIES_CONTENT_FILE_CREATED, creationDate);
String lastAccessed =
DateUtil.convertToStringLong(bfa.lastAccessTime().toMillis());
props.put(StorageProvider.PROPERTIES_CONTENT_FILE_LAST_ACCESSED, lastAccessed);
String modified =
DateUtil.convertToStringLong(bfa.lastModifiedTime().toMillis());
props.put(StorageProvider.PROPERTIES_CONTENT_FILE_MODIFIED, modified);
} catch (IOException ex) {
log.error("Failed to read basic file attributes from "
+ absolutePath + ": " + ex.getMessage(), ex);
}
return props;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"createContentProperties",
"(",
"String",
"absolutePath",
",",
"String",
"creator",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"props",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"creator",
"!=",
"null",
"&&",
"creator",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"props",
".",
"put",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_CREATOR",
",",
"creator",
")",
";",
"}",
"props",
".",
"put",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_FILE_PATH",
",",
"absolutePath",
")",
";",
"try",
"{",
"Path",
"path",
"=",
"FileSystems",
".",
"getDefault",
"(",
")",
".",
"getPath",
"(",
"absolutePath",
")",
";",
"BasicFileAttributes",
"bfa",
"=",
"Files",
".",
"readAttributes",
"(",
"path",
",",
"BasicFileAttributes",
".",
"class",
")",
";",
"String",
"creationDate",
"=",
"DateUtil",
".",
"convertToStringLong",
"(",
"bfa",
".",
"creationTime",
"(",
")",
".",
"toMillis",
"(",
")",
")",
";",
"props",
".",
"put",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_FILE_CREATED",
",",
"creationDate",
")",
";",
"String",
"lastAccessed",
"=",
"DateUtil",
".",
"convertToStringLong",
"(",
"bfa",
".",
"lastAccessTime",
"(",
")",
".",
"toMillis",
"(",
")",
")",
";",
"props",
".",
"put",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_FILE_LAST_ACCESSED",
",",
"lastAccessed",
")",
";",
"String",
"modified",
"=",
"DateUtil",
".",
"convertToStringLong",
"(",
"bfa",
".",
"lastModifiedTime",
"(",
")",
".",
"toMillis",
"(",
")",
")",
";",
"props",
".",
"put",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_FILE_MODIFIED",
",",
"modified",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"log",
".",
"error",
"(",
"\"Failed to read basic file attributes from \"",
"+",
"absolutePath",
"+",
"\": \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"return",
"props",
";",
"}"
] | Generates a map of all client-side default content properties to be
added with new content.
@param absolutePath
@param creator
@return | [
"Generates",
"a",
"map",
"of",
"all",
"client",
"-",
"side",
"default",
"content",
"properties",
"to",
"be",
"added",
"with",
"new",
"content",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java#L218-L252 |
141,434 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java | StorageProviderUtil.removeCalculatedProperties | public static Map<String, String> removeCalculatedProperties(Map<String, String> contentProperties) {
if (contentProperties != null) {
contentProperties = new HashMap<>(contentProperties);
// Remove calculated properties
contentProperties.remove(StorageProvider.PROPERTIES_CONTENT_MD5);
contentProperties.remove(StorageProvider.PROPERTIES_CONTENT_CHECKSUM);
contentProperties.remove(StorageProvider.PROPERTIES_CONTENT_MODIFIED);
contentProperties.remove(StorageProvider.PROPERTIES_CONTENT_SIZE);
}
return contentProperties;
} | java | public static Map<String, String> removeCalculatedProperties(Map<String, String> contentProperties) {
if (contentProperties != null) {
contentProperties = new HashMap<>(contentProperties);
// Remove calculated properties
contentProperties.remove(StorageProvider.PROPERTIES_CONTENT_MD5);
contentProperties.remove(StorageProvider.PROPERTIES_CONTENT_CHECKSUM);
contentProperties.remove(StorageProvider.PROPERTIES_CONTENT_MODIFIED);
contentProperties.remove(StorageProvider.PROPERTIES_CONTENT_SIZE);
}
return contentProperties;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"removeCalculatedProperties",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"contentProperties",
")",
"{",
"if",
"(",
"contentProperties",
"!=",
"null",
")",
"{",
"contentProperties",
"=",
"new",
"HashMap",
"<>",
"(",
"contentProperties",
")",
";",
"// Remove calculated properties",
"contentProperties",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_MD5",
")",
";",
"contentProperties",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_CHECKSUM",
")",
";",
"contentProperties",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_MODIFIED",
")",
";",
"contentProperties",
".",
"remove",
"(",
"StorageProvider",
".",
"PROPERTIES_CONTENT_SIZE",
")",
";",
"}",
"return",
"contentProperties",
";",
"}"
] | Returns a new map with the calculated properties removed. If null, null
is returned.
@param contentProperties
@return | [
"Returns",
"a",
"new",
"map",
"with",
"the",
"calculated",
"properties",
"removed",
".",
"If",
"null",
"null",
"is",
"returned",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/StorageProviderUtil.java#L261-L272 |
141,435 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java | S3StorageProvider.setSpaceLifecycle | public void setSpaceLifecycle(String bucketName,
BucketLifecycleConfiguration config) {
boolean success = false;
int maxLoops = 6;
for (int loops = 0; !success && loops < maxLoops; loops++) {
try {
s3Client.deleteBucketLifecycleConfiguration(bucketName);
s3Client.setBucketLifecycleConfiguration(bucketName, config);
success = true;
} catch (NotFoundException e) {
success = false;
wait(loops);
}
}
if (!success) {
throw new StorageException(
"Lifecycle policy for bucket " + bucketName +
" could not be applied. The space cannot be found.");
}
} | java | public void setSpaceLifecycle(String bucketName,
BucketLifecycleConfiguration config) {
boolean success = false;
int maxLoops = 6;
for (int loops = 0; !success && loops < maxLoops; loops++) {
try {
s3Client.deleteBucketLifecycleConfiguration(bucketName);
s3Client.setBucketLifecycleConfiguration(bucketName, config);
success = true;
} catch (NotFoundException e) {
success = false;
wait(loops);
}
}
if (!success) {
throw new StorageException(
"Lifecycle policy for bucket " + bucketName +
" could not be applied. The space cannot be found.");
}
} | [
"public",
"void",
"setSpaceLifecycle",
"(",
"String",
"bucketName",
",",
"BucketLifecycleConfiguration",
"config",
")",
"{",
"boolean",
"success",
"=",
"false",
";",
"int",
"maxLoops",
"=",
"6",
";",
"for",
"(",
"int",
"loops",
"=",
"0",
";",
"!",
"success",
"&&",
"loops",
"<",
"maxLoops",
";",
"loops",
"++",
")",
"{",
"try",
"{",
"s3Client",
".",
"deleteBucketLifecycleConfiguration",
"(",
"bucketName",
")",
";",
"s3Client",
".",
"setBucketLifecycleConfiguration",
"(",
"bucketName",
",",
"config",
")",
";",
"success",
"=",
"true",
";",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"success",
"=",
"false",
";",
"wait",
"(",
"loops",
")",
";",
"}",
"}",
"if",
"(",
"!",
"success",
")",
"{",
"throw",
"new",
"StorageException",
"(",
"\"Lifecycle policy for bucket \"",
"+",
"bucketName",
"+",
"\" could not be applied. The space cannot be found.\"",
")",
";",
"}",
"}"
] | Sets a lifecycle policy on an S3 bucket based on the given configuration
@param bucketName name of the bucket to update
@param config bucket lifecycle configuration | [
"Sets",
"a",
"lifecycle",
"policy",
"on",
"an",
"S3",
"bucket",
"based",
"on",
"the",
"given",
"configuration"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java#L325-L345 |
141,436 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java | S3StorageProvider.addHiddenContent | public String addHiddenContent(String spaceId,
String contentId,
String contentMimeType,
InputStream content) {
log.debug("addHiddenContent(" + spaceId + ", " + contentId + ", " +
contentMimeType + ")");
// Will throw if bucket does not exist
String bucketName = getBucketName(spaceId);
// Wrap the content in order to be able to retrieve a checksum
if (contentMimeType == null || contentMimeType.equals("")) {
contentMimeType = DEFAULT_MIMETYPE;
}
ObjectMetadata objMetadata = new ObjectMetadata();
objMetadata.setContentType(contentMimeType);
PutObjectRequest putRequest = new PutObjectRequest(bucketName,
contentId,
content,
objMetadata);
putRequest.setStorageClass(DEFAULT_STORAGE_CLASS);
putRequest.setCannedAcl(CannedAccessControlList.Private);
try {
PutObjectResult putResult = s3Client.putObject(putRequest);
return putResult.getETag();
} catch (AmazonClientException e) {
String err = "Could not add content " + contentId +
" with type " + contentMimeType +
" to S3 bucket " + bucketName + " due to error: " +
e.getMessage();
throw new StorageException(err, e, NO_RETRY);
}
} | java | public String addHiddenContent(String spaceId,
String contentId,
String contentMimeType,
InputStream content) {
log.debug("addHiddenContent(" + spaceId + ", " + contentId + ", " +
contentMimeType + ")");
// Will throw if bucket does not exist
String bucketName = getBucketName(spaceId);
// Wrap the content in order to be able to retrieve a checksum
if (contentMimeType == null || contentMimeType.equals("")) {
contentMimeType = DEFAULT_MIMETYPE;
}
ObjectMetadata objMetadata = new ObjectMetadata();
objMetadata.setContentType(contentMimeType);
PutObjectRequest putRequest = new PutObjectRequest(bucketName,
contentId,
content,
objMetadata);
putRequest.setStorageClass(DEFAULT_STORAGE_CLASS);
putRequest.setCannedAcl(CannedAccessControlList.Private);
try {
PutObjectResult putResult = s3Client.putObject(putRequest);
return putResult.getETag();
} catch (AmazonClientException e) {
String err = "Could not add content " + contentId +
" with type " + contentMimeType +
" to S3 bucket " + bucketName + " due to error: " +
e.getMessage();
throw new StorageException(err, e, NO_RETRY);
}
} | [
"public",
"String",
"addHiddenContent",
"(",
"String",
"spaceId",
",",
"String",
"contentId",
",",
"String",
"contentMimeType",
",",
"InputStream",
"content",
")",
"{",
"log",
".",
"debug",
"(",
"\"addHiddenContent(\"",
"+",
"spaceId",
"+",
"\", \"",
"+",
"contentId",
"+",
"\", \"",
"+",
"contentMimeType",
"+",
"\")\"",
")",
";",
"// Will throw if bucket does not exist",
"String",
"bucketName",
"=",
"getBucketName",
"(",
"spaceId",
")",
";",
"// Wrap the content in order to be able to retrieve a checksum",
"if",
"(",
"contentMimeType",
"==",
"null",
"||",
"contentMimeType",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"contentMimeType",
"=",
"DEFAULT_MIMETYPE",
";",
"}",
"ObjectMetadata",
"objMetadata",
"=",
"new",
"ObjectMetadata",
"(",
")",
";",
"objMetadata",
".",
"setContentType",
"(",
"contentMimeType",
")",
";",
"PutObjectRequest",
"putRequest",
"=",
"new",
"PutObjectRequest",
"(",
"bucketName",
",",
"contentId",
",",
"content",
",",
"objMetadata",
")",
";",
"putRequest",
".",
"setStorageClass",
"(",
"DEFAULT_STORAGE_CLASS",
")",
";",
"putRequest",
".",
"setCannedAcl",
"(",
"CannedAccessControlList",
".",
"Private",
")",
";",
"try",
"{",
"PutObjectResult",
"putResult",
"=",
"s3Client",
".",
"putObject",
"(",
"putRequest",
")",
";",
"return",
"putResult",
".",
"getETag",
"(",
")",
";",
"}",
"catch",
"(",
"AmazonClientException",
"e",
")",
"{",
"String",
"err",
"=",
"\"Could not add content \"",
"+",
"contentId",
"+",
"\" with type \"",
"+",
"contentMimeType",
"+",
"\" to S3 bucket \"",
"+",
"bucketName",
"+",
"\" due to error: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"StorageException",
"(",
"err",
",",
"e",
",",
"NO_RETRY",
")",
";",
"}",
"}"
] | Adds content to a hidden space.
@param spaceId hidden spaceId
@param contentId
@param contentMimeType
@param content
@return | [
"Adds",
"content",
"to",
"a",
"hidden",
"space",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java#L519-L556 |
141,437 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java | S3StorageProvider.getBucketName | public String getBucketName(String spaceId) {
// Determine if there is an existing bucket that matches this space ID.
// The bucket name may use any access key ID as the prefix, so there is
// no way to know the exact bucket name up front.
List<Bucket> buckets = listAllBuckets();
for (Bucket bucket : buckets) {
String bucketName = bucket.getName();
spaceId = spaceId.replace(".", "[.]");
if (bucketName.matches("(" + HIDDEN_SPACE_PREFIX + ")?[\\w]{20}[.]" + spaceId)) {
return bucketName;
}
}
throw new NotFoundException("No S3 bucket found matching spaceID: " + spaceId);
} | java | public String getBucketName(String spaceId) {
// Determine if there is an existing bucket that matches this space ID.
// The bucket name may use any access key ID as the prefix, so there is
// no way to know the exact bucket name up front.
List<Bucket> buckets = listAllBuckets();
for (Bucket bucket : buckets) {
String bucketName = bucket.getName();
spaceId = spaceId.replace(".", "[.]");
if (bucketName.matches("(" + HIDDEN_SPACE_PREFIX + ")?[\\w]{20}[.]" + spaceId)) {
return bucketName;
}
}
throw new NotFoundException("No S3 bucket found matching spaceID: " + spaceId);
} | [
"public",
"String",
"getBucketName",
"(",
"String",
"spaceId",
")",
"{",
"// Determine if there is an existing bucket that matches this space ID.",
"// The bucket name may use any access key ID as the prefix, so there is",
"// no way to know the exact bucket name up front.",
"List",
"<",
"Bucket",
">",
"buckets",
"=",
"listAllBuckets",
"(",
")",
";",
"for",
"(",
"Bucket",
"bucket",
":",
"buckets",
")",
"{",
"String",
"bucketName",
"=",
"bucket",
".",
"getName",
"(",
")",
";",
"spaceId",
"=",
"spaceId",
".",
"replace",
"(",
"\".\"",
",",
"\"[.]\"",
")",
";",
"if",
"(",
"bucketName",
".",
"matches",
"(",
"\"(\"",
"+",
"HIDDEN_SPACE_PREFIX",
"+",
"\")?[\\\\w]{20}[.]\"",
"+",
"spaceId",
")",
")",
"{",
"return",
"bucketName",
";",
"}",
"}",
"throw",
"new",
"NotFoundException",
"(",
"\"No S3 bucket found matching spaceID: \"",
"+",
"spaceId",
")",
";",
"}"
] | Gets the name of an existing bucket based on a space ID. If no bucket
with this spaceId exists, throws a NotFoundException
@param spaceId the space Id to convert into an S3 bucket name
@return S3 bucket name of a given DuraCloud space
@throws NotFoundException if no bucket matches this spaceID | [
"Gets",
"the",
"name",
"of",
"an",
"existing",
"bucket",
"based",
"on",
"a",
"space",
"ID",
".",
"If",
"no",
"bucket",
"with",
"this",
"spaceId",
"exists",
"throws",
"a",
"NotFoundException"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java#L1107-L1120 |
141,438 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java | S3StorageProvider.getSpaceId | protected String getSpaceId(String bucketName) {
String spaceId = bucketName;
if (isSpace(bucketName)) {
spaceId = spaceId.substring(accessKeyId.length() + 1);
}
return spaceId;
} | java | protected String getSpaceId(String bucketName) {
String spaceId = bucketName;
if (isSpace(bucketName)) {
spaceId = spaceId.substring(accessKeyId.length() + 1);
}
return spaceId;
} | [
"protected",
"String",
"getSpaceId",
"(",
"String",
"bucketName",
")",
"{",
"String",
"spaceId",
"=",
"bucketName",
";",
"if",
"(",
"isSpace",
"(",
"bucketName",
")",
")",
"{",
"spaceId",
"=",
"spaceId",
".",
"substring",
"(",
"accessKeyId",
".",
"length",
"(",
")",
"+",
"1",
")",
";",
"}",
"return",
"spaceId",
";",
"}"
] | Converts a bucket name into what could be passed in as a space ID.
@param bucketName name of the S3 bucket
@return the DuraCloud space name equivalent to a given S3 bucket Id | [
"Converts",
"a",
"bucket",
"name",
"into",
"what",
"could",
"be",
"passed",
"in",
"as",
"a",
"space",
"ID",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java#L1128-L1134 |
141,439 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java | S3StorageProvider.isSpace | protected boolean isSpace(String bucketName) {
boolean isSpace = false;
// According to AWS docs, the access key (used in DuraCloud as a
// prefix for uniqueness) is a 20 character alphanumeric sequence.
if (bucketName.matches("[\\w]{20}[.].*")) {
isSpace = true;
}
return isSpace;
} | java | protected boolean isSpace(String bucketName) {
boolean isSpace = false;
// According to AWS docs, the access key (used in DuraCloud as a
// prefix for uniqueness) is a 20 character alphanumeric sequence.
if (bucketName.matches("[\\w]{20}[.].*")) {
isSpace = true;
}
return isSpace;
} | [
"protected",
"boolean",
"isSpace",
"(",
"String",
"bucketName",
")",
"{",
"boolean",
"isSpace",
"=",
"false",
";",
"// According to AWS docs, the access key (used in DuraCloud as a",
"// prefix for uniqueness) is a 20 character alphanumeric sequence.",
"if",
"(",
"bucketName",
".",
"matches",
"(",
"\"[\\\\w]{20}[.].*\"",
")",
")",
"{",
"isSpace",
"=",
"true",
";",
"}",
"return",
"isSpace",
";",
"}"
] | Determines if an S3 bucket is a DuraCloud space
@param bucketName name of the S3 bucket
@return true if the given S3 bucket name is named according to the
DuraCloud space naming conventions, false otherwise | [
"Determines",
"if",
"an",
"S3",
"bucket",
"is",
"a",
"DuraCloud",
"space"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3storage/S3StorageProvider.java#L1143-L1151 |
141,440 | duracloud/duracloud | storeclient/src/main/java/org/duracloud/client/util/DuracloudFileWriter.java | DuracloudFileWriter.flush | @Override
public void flush() throws IOException {
checkWriter();
writer.flush();
try {
contentStoreUtil.storeContentStream(tempFile,
spaceId,
contentId,
mimetype);
} catch (DuraCloudRuntimeException ex) {
throw new IOException("flush failed: " + ex.getMessage(), ex);
}
} | java | @Override
public void flush() throws IOException {
checkWriter();
writer.flush();
try {
contentStoreUtil.storeContentStream(tempFile,
spaceId,
contentId,
mimetype);
} catch (DuraCloudRuntimeException ex) {
throw new IOException("flush failed: " + ex.getMessage(), ex);
}
} | [
"@",
"Override",
"public",
"void",
"flush",
"(",
")",
"throws",
"IOException",
"{",
"checkWriter",
"(",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"try",
"{",
"contentStoreUtil",
".",
"storeContentStream",
"(",
"tempFile",
",",
"spaceId",
",",
"contentId",
",",
"mimetype",
")",
";",
"}",
"catch",
"(",
"DuraCloudRuntimeException",
"ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"flush failed: \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"}"
] | Writes the tempfile to durastore. | [
"Writes",
"the",
"tempfile",
"to",
"durastore",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storeclient/src/main/java/org/duracloud/client/util/DuracloudFileWriter.java#L78-L90 |
141,441 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/FileChunker.java | FileChunker.addContentFrom | protected void addContentFrom(File baseDir, String destSpaceId) {
Collection<File> files = listFiles(baseDir,
options.getFileFilter(),
options.getDirFilter());
for (File file : files) {
try {
doAddContent(baseDir, destSpaceId, file);
} catch (Exception e) {
StringBuilder sb = new StringBuilder("Error: ");
sb.append("Unable to addContentFrom [");
sb.append(baseDir);
sb.append(", ");
sb.append(destSpaceId);
sb.append("] : ");
sb.append(e.getMessage());
sb.append("\n");
sb.append(ExceptionUtil.getStackTraceAsString(e));
log.error(sb.toString());
}
}
} | java | protected void addContentFrom(File baseDir, String destSpaceId) {
Collection<File> files = listFiles(baseDir,
options.getFileFilter(),
options.getDirFilter());
for (File file : files) {
try {
doAddContent(baseDir, destSpaceId, file);
} catch (Exception e) {
StringBuilder sb = new StringBuilder("Error: ");
sb.append("Unable to addContentFrom [");
sb.append(baseDir);
sb.append(", ");
sb.append(destSpaceId);
sb.append("] : ");
sb.append(e.getMessage());
sb.append("\n");
sb.append(ExceptionUtil.getStackTraceAsString(e));
log.error(sb.toString());
}
}
} | [
"protected",
"void",
"addContentFrom",
"(",
"File",
"baseDir",
",",
"String",
"destSpaceId",
")",
"{",
"Collection",
"<",
"File",
">",
"files",
"=",
"listFiles",
"(",
"baseDir",
",",
"options",
".",
"getFileFilter",
"(",
")",
",",
"options",
".",
"getDirFilter",
"(",
")",
")",
";",
"for",
"(",
"File",
"file",
":",
"files",
")",
"{",
"try",
"{",
"doAddContent",
"(",
"baseDir",
",",
"destSpaceId",
",",
"file",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\"Error: \"",
")",
";",
"sb",
".",
"append",
"(",
"\"Unable to addContentFrom [\"",
")",
";",
"sb",
".",
"append",
"(",
"baseDir",
")",
";",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"sb",
".",
"append",
"(",
"destSpaceId",
")",
";",
"sb",
".",
"append",
"(",
"\"] : \"",
")",
";",
"sb",
".",
"append",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"ExceptionUtil",
".",
"getStackTraceAsString",
"(",
"e",
")",
")",
";",
"log",
".",
"error",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}"
] | This method loops the arg baseDir and pushes the found content to the
arg destSpace.
@param baseDir of content to push to DataStore
@param destSpaceId of content destination | [
"This",
"method",
"loops",
"the",
"arg",
"baseDir",
"and",
"pushes",
"the",
"found",
"content",
"to",
"the",
"arg",
"destSpace",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/FileChunker.java#L167-L189 |
141,442 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/FileChunker.java | FileChunker.getContentId | private String getContentId(File baseDir, File file) {
String filePath = file.getPath();
String basePath = baseDir.getPath();
int index = filePath.indexOf(basePath);
if (index == -1) {
StringBuilder sb = new StringBuilder("Invalid basePath for file: ");
sb.append("b: '" + basePath + "', ");
sb.append("f: '" + filePath + "'");
throw new DuraCloudRuntimeException(sb.toString());
}
String contentId = filePath.substring(index + basePath.length());
if (contentId.startsWith(File.separator)) {
contentId = contentId.substring(1, contentId.length());
}
// Replace backslash (\) with forward slash (/) for all content IDs
contentId = contentId.replaceAll("\\\\", "/");
return contentId;
} | java | private String getContentId(File baseDir, File file) {
String filePath = file.getPath();
String basePath = baseDir.getPath();
int index = filePath.indexOf(basePath);
if (index == -1) {
StringBuilder sb = new StringBuilder("Invalid basePath for file: ");
sb.append("b: '" + basePath + "', ");
sb.append("f: '" + filePath + "'");
throw new DuraCloudRuntimeException(sb.toString());
}
String contentId = filePath.substring(index + basePath.length());
if (contentId.startsWith(File.separator)) {
contentId = contentId.substring(1, contentId.length());
}
// Replace backslash (\) with forward slash (/) for all content IDs
contentId = contentId.replaceAll("\\\\", "/");
return contentId;
} | [
"private",
"String",
"getContentId",
"(",
"File",
"baseDir",
",",
"File",
"file",
")",
"{",
"String",
"filePath",
"=",
"file",
".",
"getPath",
"(",
")",
";",
"String",
"basePath",
"=",
"baseDir",
".",
"getPath",
"(",
")",
";",
"int",
"index",
"=",
"filePath",
".",
"indexOf",
"(",
"basePath",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\"Invalid basePath for file: \"",
")",
";",
"sb",
".",
"append",
"(",
"\"b: '\"",
"+",
"basePath",
"+",
"\"', \"",
")",
";",
"sb",
".",
"append",
"(",
"\"f: '\"",
"+",
"filePath",
"+",
"\"'\"",
")",
";",
"throw",
"new",
"DuraCloudRuntimeException",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"String",
"contentId",
"=",
"filePath",
".",
"substring",
"(",
"index",
"+",
"basePath",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"contentId",
".",
"startsWith",
"(",
"File",
".",
"separator",
")",
")",
"{",
"contentId",
"=",
"contentId",
".",
"substring",
"(",
"1",
",",
"contentId",
".",
"length",
"(",
")",
")",
";",
"}",
"// Replace backslash (\\) with forward slash (/) for all content IDs",
"contentId",
"=",
"contentId",
".",
"replaceAll",
"(",
"\"\\\\\\\\\"",
",",
"\"/\"",
")",
";",
"return",
"contentId",
";",
"}"
] | This method defines the returned contentId as the path of the arg file
minus the path of the arg baseDir, in which the file was found.
@param baseDir dir that contained the arg file or one of its parents
@param file for which contentId is to be found
@return contentId of arg file | [
"This",
"method",
"defines",
"the",
"returned",
"contentId",
"as",
"the",
"path",
"of",
"the",
"arg",
"file",
"minus",
"the",
"path",
"of",
"the",
"arg",
"baseDir",
"in",
"which",
"the",
"file",
"was",
"found",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/FileChunker.java#L275-L294 |
141,443 | duracloud/duracloud | durastore/src/main/java/org/duracloud/durastore/rest/StoreRest.java | StoreRest.getStores | @GET
public Response getStores() {
String msg = "getting stores.";
try {
return doGetStores(msg);
} catch (StorageException se) {
return responseBad(msg, se);
} catch (Exception e) {
return responseBad(msg, e);
}
} | java | @GET
public Response getStores() {
String msg = "getting stores.";
try {
return doGetStores(msg);
} catch (StorageException se) {
return responseBad(msg, se);
} catch (Exception e) {
return responseBad(msg, e);
}
} | [
"@",
"GET",
"public",
"Response",
"getStores",
"(",
")",
"{",
"String",
"msg",
"=",
"\"getting stores.\"",
";",
"try",
"{",
"return",
"doGetStores",
"(",
"msg",
")",
";",
"}",
"catch",
"(",
"StorageException",
"se",
")",
"{",
"return",
"responseBad",
"(",
"msg",
",",
"se",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"responseBad",
"(",
"msg",
",",
"e",
")",
";",
"}",
"}"
] | Provides a listing of all available storage provider accounts
@return 200 response with XML file listing stores | [
"Provides",
"a",
"listing",
"of",
"all",
"available",
"storage",
"provider",
"accounts"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/durastore/src/main/java/org/duracloud/durastore/rest/StoreRest.java#L49-L61 |
141,444 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/IdUtil.java | IdUtil.validateSpaceId | public static void validateSpaceId(String spaceID)
throws InvalidIdException {
if (spaceID == null ||
spaceID.trim().length() < 3 ||
spaceID.trim().length() > 42) {
String err = "Space ID must be between 3 and 42 characters long";
throw new InvalidIdException(err);
}
if (!spaceID.matches("[a-z0-9.-]*")) {
String err = "Only lowercase letters, numbers, periods, " +
"and dashes may be used in a Space ID";
throw new InvalidIdException(err);
}
if (spaceID.startsWith(".") || spaceID.startsWith("-")) {
String err = "A Space ID must begin with a lowercase letter.";
throw new InvalidIdException(err);
}
if (spaceID.matches("[0-9]+[a-z0-9.-]*")) {
String err = "A Space ID must begin with a lowercase letter.";
throw new InvalidIdException(err);
}
// This rule is required to conform with the spec for a URI host name,
// see RFC 2396.
if (spaceID.matches("[a-z0-9.-]*[.][0-9]+[a-z0-9-]*")) {
String err = "The last period in a Space ID may not be " +
"immediately followed by a number.";
throw new InvalidIdException(err);
}
if (spaceID.endsWith("-")) {
String err = "A Space ID must end with a lowercase letter, " +
"number, or period";
throw new InvalidIdException(err);
}
if (spaceID.contains("..") ||
spaceID.contains("-.") ||
spaceID.contains(".-")) {
String err = "A Space ID must not contain '..' '-.' or '.-'";
throw new InvalidIdException(err);
}
if (spaceID.matches("[0-9]+.[0-9]+.[0-9]+.[0-9]+")) {
String err = "A Space ID must not be formatted as an IP address";
throw new InvalidIdException(err);
}
} | java | public static void validateSpaceId(String spaceID)
throws InvalidIdException {
if (spaceID == null ||
spaceID.trim().length() < 3 ||
spaceID.trim().length() > 42) {
String err = "Space ID must be between 3 and 42 characters long";
throw new InvalidIdException(err);
}
if (!spaceID.matches("[a-z0-9.-]*")) {
String err = "Only lowercase letters, numbers, periods, " +
"and dashes may be used in a Space ID";
throw new InvalidIdException(err);
}
if (spaceID.startsWith(".") || spaceID.startsWith("-")) {
String err = "A Space ID must begin with a lowercase letter.";
throw new InvalidIdException(err);
}
if (spaceID.matches("[0-9]+[a-z0-9.-]*")) {
String err = "A Space ID must begin with a lowercase letter.";
throw new InvalidIdException(err);
}
// This rule is required to conform with the spec for a URI host name,
// see RFC 2396.
if (spaceID.matches("[a-z0-9.-]*[.][0-9]+[a-z0-9-]*")) {
String err = "The last period in a Space ID may not be " +
"immediately followed by a number.";
throw new InvalidIdException(err);
}
if (spaceID.endsWith("-")) {
String err = "A Space ID must end with a lowercase letter, " +
"number, or period";
throw new InvalidIdException(err);
}
if (spaceID.contains("..") ||
spaceID.contains("-.") ||
spaceID.contains(".-")) {
String err = "A Space ID must not contain '..' '-.' or '.-'";
throw new InvalidIdException(err);
}
if (spaceID.matches("[0-9]+.[0-9]+.[0-9]+.[0-9]+")) {
String err = "A Space ID must not be formatted as an IP address";
throw new InvalidIdException(err);
}
} | [
"public",
"static",
"void",
"validateSpaceId",
"(",
"String",
"spaceID",
")",
"throws",
"InvalidIdException",
"{",
"if",
"(",
"spaceID",
"==",
"null",
"||",
"spaceID",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"<",
"3",
"||",
"spaceID",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
">",
"42",
")",
"{",
"String",
"err",
"=",
"\"Space ID must be between 3 and 42 characters long\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"if",
"(",
"!",
"spaceID",
".",
"matches",
"(",
"\"[a-z0-9.-]*\"",
")",
")",
"{",
"String",
"err",
"=",
"\"Only lowercase letters, numbers, periods, \"",
"+",
"\"and dashes may be used in a Space ID\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"if",
"(",
"spaceID",
".",
"startsWith",
"(",
"\".\"",
")",
"||",
"spaceID",
".",
"startsWith",
"(",
"\"-\"",
")",
")",
"{",
"String",
"err",
"=",
"\"A Space ID must begin with a lowercase letter.\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"if",
"(",
"spaceID",
".",
"matches",
"(",
"\"[0-9]+[a-z0-9.-]*\"",
")",
")",
"{",
"String",
"err",
"=",
"\"A Space ID must begin with a lowercase letter.\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"// This rule is required to conform with the spec for a URI host name,",
"// see RFC 2396.",
"if",
"(",
"spaceID",
".",
"matches",
"(",
"\"[a-z0-9.-]*[.][0-9]+[a-z0-9-]*\"",
")",
")",
"{",
"String",
"err",
"=",
"\"The last period in a Space ID may not be \"",
"+",
"\"immediately followed by a number.\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"if",
"(",
"spaceID",
".",
"endsWith",
"(",
"\"-\"",
")",
")",
"{",
"String",
"err",
"=",
"\"A Space ID must end with a lowercase letter, \"",
"+",
"\"number, or period\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"if",
"(",
"spaceID",
".",
"contains",
"(",
"\"..\"",
")",
"||",
"spaceID",
".",
"contains",
"(",
"\"-.\"",
")",
"||",
"spaceID",
".",
"contains",
"(",
"\".-\"",
")",
")",
"{",
"String",
"err",
"=",
"\"A Space ID must not contain '..' '-.' or '.-'\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"if",
"(",
"spaceID",
".",
"matches",
"(",
"\"[0-9]+.[0-9]+.[0-9]+.[0-9]+\"",
")",
")",
"{",
"String",
"err",
"=",
"\"A Space ID must not be formatted as an IP address\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"}"
] | Determines if the ID of the space to be added is valid
@throws InvalidIdException if not valid | [
"Determines",
"if",
"the",
"ID",
"of",
"the",
"space",
"to",
"be",
"added",
"is",
"valid"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/IdUtil.java#L30-L80 |
141,445 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/util/IdUtil.java | IdUtil.validateContentId | public static void validateContentId(String contentID)
throws InvalidIdException {
if (contentID == null) {
String err = "Content ID must be at least 1 character long";
throw new InvalidIdException(err);
}
if (contentID.contains("?")) {
String err = "Content ID may not include the '?' character";
throw new InvalidIdException(err);
}
if (contentID.contains("\\")) {
String err = "Content ID may not include the '\\' character";
throw new InvalidIdException(err);
}
int utfLength;
int urlLength;
try {
utfLength = contentID.getBytes("UTF-8").length;
String urlEncoded = URLEncoder.encode(contentID, "UTF-8");
urlLength = urlEncoded.getBytes("UTF-8").length;
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
if (utfLength > 1024 || urlLength > 1024) {
String err =
"Content ID must <= 1024 bytes after URL and UTF-8 encoding";
throw new InvalidIdException(err);
}
} | java | public static void validateContentId(String contentID)
throws InvalidIdException {
if (contentID == null) {
String err = "Content ID must be at least 1 character long";
throw new InvalidIdException(err);
}
if (contentID.contains("?")) {
String err = "Content ID may not include the '?' character";
throw new InvalidIdException(err);
}
if (contentID.contains("\\")) {
String err = "Content ID may not include the '\\' character";
throw new InvalidIdException(err);
}
int utfLength;
int urlLength;
try {
utfLength = contentID.getBytes("UTF-8").length;
String urlEncoded = URLEncoder.encode(contentID, "UTF-8");
urlLength = urlEncoded.getBytes("UTF-8").length;
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
if (utfLength > 1024 || urlLength > 1024) {
String err =
"Content ID must <= 1024 bytes after URL and UTF-8 encoding";
throw new InvalidIdException(err);
}
} | [
"public",
"static",
"void",
"validateContentId",
"(",
"String",
"contentID",
")",
"throws",
"InvalidIdException",
"{",
"if",
"(",
"contentID",
"==",
"null",
")",
"{",
"String",
"err",
"=",
"\"Content ID must be at least 1 character long\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"if",
"(",
"contentID",
".",
"contains",
"(",
"\"?\"",
")",
")",
"{",
"String",
"err",
"=",
"\"Content ID may not include the '?' character\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"if",
"(",
"contentID",
".",
"contains",
"(",
"\"\\\\\"",
")",
")",
"{",
"String",
"err",
"=",
"\"Content ID may not include the '\\\\' character\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"int",
"utfLength",
";",
"int",
"urlLength",
";",
"try",
"{",
"utfLength",
"=",
"contentID",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
".",
"length",
";",
"String",
"urlEncoded",
"=",
"URLEncoder",
".",
"encode",
"(",
"contentID",
",",
"\"UTF-8\"",
")",
";",
"urlLength",
"=",
"urlEncoded",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
".",
"length",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"if",
"(",
"utfLength",
">",
"1024",
"||",
"urlLength",
">",
"1024",
")",
"{",
"String",
"err",
"=",
"\"Content ID must <= 1024 bytes after URL and UTF-8 encoding\"",
";",
"throw",
"new",
"InvalidIdException",
"(",
"err",
")",
";",
"}",
"}"
] | Determines if the ID of the content to be added is valid
@throws InvalidIdException if not valid | [
"Determines",
"if",
"the",
"ID",
"of",
"the",
"content",
"to",
"be",
"added",
"is",
"valid"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/util/IdUtil.java#L87-L119 |
141,446 | duracloud/duracloud | snapshotdata/src/main/java/org/duracloud/snapshot/dto/bridge/CompleteRestoreBridgeResult.java | CompleteRestoreBridgeResult.deserialize | public static CompleteRestoreBridgeResult deserialize(String json) {
JaxbJsonSerializer<CompleteRestoreBridgeResult> serializer =
new JaxbJsonSerializer<>(CompleteRestoreBridgeResult.class);
try {
return serializer.deserialize(json);
} catch (IOException e) {
throw new SnapshotDataException(
"Unable to create result due to: " + e.getMessage());
}
} | java | public static CompleteRestoreBridgeResult deserialize(String json) {
JaxbJsonSerializer<CompleteRestoreBridgeResult> serializer =
new JaxbJsonSerializer<>(CompleteRestoreBridgeResult.class);
try {
return serializer.deserialize(json);
} catch (IOException e) {
throw new SnapshotDataException(
"Unable to create result due to: " + e.getMessage());
}
} | [
"public",
"static",
"CompleteRestoreBridgeResult",
"deserialize",
"(",
"String",
"json",
")",
"{",
"JaxbJsonSerializer",
"<",
"CompleteRestoreBridgeResult",
">",
"serializer",
"=",
"new",
"JaxbJsonSerializer",
"<>",
"(",
"CompleteRestoreBridgeResult",
".",
"class",
")",
";",
"try",
"{",
"return",
"serializer",
".",
"deserialize",
"(",
"json",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SnapshotDataException",
"(",
"\"Unable to create result due to: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Creates a deserialized version of bridge parameters
@return JSON formatted bridge info | [
"Creates",
"a",
"deserialized",
"version",
"of",
"bridge",
"parameters"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/snapshotdata/src/main/java/org/duracloud/snapshot/dto/bridge/CompleteRestoreBridgeResult.java#L66-L75 |
141,447 | duracloud/duracloud | duradmin/src/main/java/org/duracloud/duradmin/util/MessageUtils.java | MessageUtils.appendRedirectMessage | public static String appendRedirectMessage(String outcomeUrl,
Message message,
HttpServletRequest request) {
String key = addMessageToRedirect(message, request);
if (!outcomeUrl.contains("?")) {
outcomeUrl += "?";
} else {
outcomeUrl += "&";
}
int index = outcomeUrl.indexOf(REDIRECT_KEY);
if (index > 0) {
int start = index + REDIRECT_KEY.length() + 1;
int end = outcomeUrl.indexOf("=", start);
if (end < 0) {
end = outcomeUrl.length();
}
String value = outcomeUrl.substring(start, end);
outcomeUrl = outcomeUrl.replace(REDIRECT_KEY + "=" + value,
REDIRECT_KEY + "=" + key);
} else {
outcomeUrl += REDIRECT_KEY + "=" + key;
}
return outcomeUrl;
} | java | public static String appendRedirectMessage(String outcomeUrl,
Message message,
HttpServletRequest request) {
String key = addMessageToRedirect(message, request);
if (!outcomeUrl.contains("?")) {
outcomeUrl += "?";
} else {
outcomeUrl += "&";
}
int index = outcomeUrl.indexOf(REDIRECT_KEY);
if (index > 0) {
int start = index + REDIRECT_KEY.length() + 1;
int end = outcomeUrl.indexOf("=", start);
if (end < 0) {
end = outcomeUrl.length();
}
String value = outcomeUrl.substring(start, end);
outcomeUrl = outcomeUrl.replace(REDIRECT_KEY + "=" + value,
REDIRECT_KEY + "=" + key);
} else {
outcomeUrl += REDIRECT_KEY + "=" + key;
}
return outcomeUrl;
} | [
"public",
"static",
"String",
"appendRedirectMessage",
"(",
"String",
"outcomeUrl",
",",
"Message",
"message",
",",
"HttpServletRequest",
"request",
")",
"{",
"String",
"key",
"=",
"addMessageToRedirect",
"(",
"message",
",",
"request",
")",
";",
"if",
"(",
"!",
"outcomeUrl",
".",
"contains",
"(",
"\"?\"",
")",
")",
"{",
"outcomeUrl",
"+=",
"\"?\"",
";",
"}",
"else",
"{",
"outcomeUrl",
"+=",
"\"&\"",
";",
"}",
"int",
"index",
"=",
"outcomeUrl",
".",
"indexOf",
"(",
"REDIRECT_KEY",
")",
";",
"if",
"(",
"index",
">",
"0",
")",
"{",
"int",
"start",
"=",
"index",
"+",
"REDIRECT_KEY",
".",
"length",
"(",
")",
"+",
"1",
";",
"int",
"end",
"=",
"outcomeUrl",
".",
"indexOf",
"(",
"\"=\"",
",",
"start",
")",
";",
"if",
"(",
"end",
"<",
"0",
")",
"{",
"end",
"=",
"outcomeUrl",
".",
"length",
"(",
")",
";",
"}",
"String",
"value",
"=",
"outcomeUrl",
".",
"substring",
"(",
"start",
",",
"end",
")",
";",
"outcomeUrl",
"=",
"outcomeUrl",
".",
"replace",
"(",
"REDIRECT_KEY",
"+",
"\"=\"",
"+",
"value",
",",
"REDIRECT_KEY",
"+",
"\"=\"",
"+",
"key",
")",
";",
"}",
"else",
"{",
"outcomeUrl",
"+=",
"REDIRECT_KEY",
"+",
"\"=\"",
"+",
"key",
";",
"}",
"return",
"outcomeUrl",
";",
"}"
] | adds a redirect message and appends the redirect key to the outcomeUrl.
If a redirect key already exists, it is replaced. replace redirect key if
it exists in the outcomeUrl.
@param outcomeUrl
@param message
@param request
@return | [
"adds",
"a",
"redirect",
"message",
"and",
"appends",
"the",
"redirect",
"key",
"to",
"the",
"outcomeUrl",
".",
"If",
"a",
"redirect",
"key",
"already",
"exists",
"it",
"is",
"replaced",
".",
"replace",
"redirect",
"key",
"if",
"it",
"exists",
"in",
"the",
"outcomeUrl",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/duradmin/src/main/java/org/duracloud/duradmin/util/MessageUtils.java#L59-L85 |
141,448 | duracloud/duracloud | storageproviderdata/src/main/java/org/duracloud/s3storageprovider/dto/SetStoragePolicyTaskParameters.java | SetStoragePolicyTaskParameters.serialize | public String serialize() {
JaxbJsonSerializer<SetStoragePolicyTaskParameters> serializer =
new JaxbJsonSerializer<>(SetStoragePolicyTaskParameters.class);
try {
return serializer.serialize(this);
} catch (IOException e) {
throw new TaskDataException(
"Unable to create task parameters due to: " + e.getMessage());
}
} | java | public String serialize() {
JaxbJsonSerializer<SetStoragePolicyTaskParameters> serializer =
new JaxbJsonSerializer<>(SetStoragePolicyTaskParameters.class);
try {
return serializer.serialize(this);
} catch (IOException e) {
throw new TaskDataException(
"Unable to create task parameters due to: " + e.getMessage());
}
} | [
"public",
"String",
"serialize",
"(",
")",
"{",
"JaxbJsonSerializer",
"<",
"SetStoragePolicyTaskParameters",
">",
"serializer",
"=",
"new",
"JaxbJsonSerializer",
"<>",
"(",
"SetStoragePolicyTaskParameters",
".",
"class",
")",
";",
"try",
"{",
"return",
"serializer",
".",
"serialize",
"(",
"this",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"TaskDataException",
"(",
"\"Unable to create task parameters due to: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Creates a serialized version of task parameters
@return JSON formatted task result info | [
"Creates",
"a",
"serialized",
"version",
"of",
"task",
"parameters"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageproviderdata/src/main/java/org/duracloud/s3storageprovider/dto/SetStoragePolicyTaskParameters.java#L64-L73 |
141,449 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/monitor/DirectoryUpdateMonitor.java | DirectoryUpdateMonitor.startMonitor | public void startMonitor() {
logger.info("Starting Directory Update Monitor");
try {
monitor.start();
} catch (IllegalStateException e) {
logger.info("File alteration monitor is already started: " + e.getMessage());
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
} | java | public void startMonitor() {
logger.info("Starting Directory Update Monitor");
try {
monitor.start();
} catch (IllegalStateException e) {
logger.info("File alteration monitor is already started: " + e.getMessage());
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
} | [
"public",
"void",
"startMonitor",
"(",
")",
"{",
"logger",
".",
"info",
"(",
"\"Starting Directory Update Monitor\"",
")",
";",
"try",
"{",
"monitor",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"logger",
".",
"info",
"(",
"\"File alteration monitor is already started: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Starts the monitor watching for updates. | [
"Starts",
"the",
"monitor",
"watching",
"for",
"updates",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/monitor/DirectoryUpdateMonitor.java#L73-L82 |
141,450 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/monitor/DirectoryUpdateMonitor.java | DirectoryUpdateMonitor.stopMonitor | public void stopMonitor() {
logger.info("Stopping Directory Update Monitor");
try {
monitor.stop();
} catch (IllegalStateException e) {
logger.info("File alteration monitor is already stopped: " + e.getMessage());
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
} | java | public void stopMonitor() {
logger.info("Stopping Directory Update Monitor");
try {
monitor.stop();
} catch (IllegalStateException e) {
logger.info("File alteration monitor is already stopped: " + e.getMessage());
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
} | [
"public",
"void",
"stopMonitor",
"(",
")",
"{",
"logger",
".",
"info",
"(",
"\"Stopping Directory Update Monitor\"",
")",
";",
"try",
"{",
"monitor",
".",
"stop",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"logger",
".",
"info",
"(",
"\"File alteration monitor is already stopped: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Stops the monitor, no further updates will be reported. | [
"Stops",
"the",
"monitor",
"no",
"further",
"updates",
"will",
"be",
"reported",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/monitor/DirectoryUpdateMonitor.java#L87-L96 |
141,451 | duracloud/duracloud | security/src/main/java/org/duracloud/security/vote/SpaceAccessVoter.java | SpaceAccessVoter.getSpaceACLs | protected Map<String, AclType> getSpaceACLs(HttpServletRequest request) {
String storeId = getStoreId(request);
String spaceId = getSpaceId(request);
return getSpaceACLs(storeId, spaceId);
} | java | protected Map<String, AclType> getSpaceACLs(HttpServletRequest request) {
String storeId = getStoreId(request);
String spaceId = getSpaceId(request);
return getSpaceACLs(storeId, spaceId);
} | [
"protected",
"Map",
"<",
"String",
",",
"AclType",
">",
"getSpaceACLs",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"storeId",
"=",
"getStoreId",
"(",
"request",
")",
";",
"String",
"spaceId",
"=",
"getSpaceId",
"(",
"request",
")",
";",
"return",
"getSpaceACLs",
"(",
"storeId",
",",
"spaceId",
")",
";",
"}"
] | This method returns the ACLs of the requested space, or an empty-map if
there is an error or for certain 'keyword' spaces, or null if the space
does not exist.
@param request containing spaceId and storeId
@return ACLs, empty-map, or null | [
"This",
"method",
"returns",
"the",
"ACLs",
"of",
"the",
"requested",
"space",
"or",
"an",
"empty",
"-",
"map",
"if",
"there",
"is",
"an",
"error",
"or",
"for",
"certain",
"keyword",
"spaces",
"or",
"null",
"if",
"the",
"space",
"does",
"not",
"exist",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/security/src/main/java/org/duracloud/security/vote/SpaceAccessVoter.java#L140-L144 |
141,452 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/EncryptionUtil.java | EncryptionUtil.encrypt | public String encrypt(String toEncrypt) throws DuraCloudRuntimeException {
try {
byte[] input = toEncrypt.getBytes("UTF-8");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] cipherText = cipher.doFinal(input);
return encodeBytes(cipherText);
} catch (Exception e) {
throw new DuraCloudRuntimeException(e);
}
} | java | public String encrypt(String toEncrypt) throws DuraCloudRuntimeException {
try {
byte[] input = toEncrypt.getBytes("UTF-8");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] cipherText = cipher.doFinal(input);
return encodeBytes(cipherText);
} catch (Exception e) {
throw new DuraCloudRuntimeException(e);
}
} | [
"public",
"String",
"encrypt",
"(",
"String",
"toEncrypt",
")",
"throws",
"DuraCloudRuntimeException",
"{",
"try",
"{",
"byte",
"[",
"]",
"input",
"=",
"toEncrypt",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"ENCRYPT_MODE",
",",
"key",
")",
";",
"byte",
"[",
"]",
"cipherText",
"=",
"cipher",
".",
"doFinal",
"(",
"input",
")",
";",
"return",
"encodeBytes",
"(",
"cipherText",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"DuraCloudRuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Provides basic encryption on a String. | [
"Provides",
"basic",
"encryption",
"on",
"a",
"String",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/EncryptionUtil.java#L69-L78 |
141,453 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/EncryptionUtil.java | EncryptionUtil.encodeBytes | private String encodeBytes(byte[] cipherText) {
StringBuffer cipherStringBuffer = new StringBuffer();
for (int i = 0; i < cipherText.length; i++) {
byte b = cipherText[i];
cipherStringBuffer.append(Byte.toString(b) + ":");
}
return cipherStringBuffer.toString();
} | java | private String encodeBytes(byte[] cipherText) {
StringBuffer cipherStringBuffer = new StringBuffer();
for (int i = 0; i < cipherText.length; i++) {
byte b = cipherText[i];
cipherStringBuffer.append(Byte.toString(b) + ":");
}
return cipherStringBuffer.toString();
} | [
"private",
"String",
"encodeBytes",
"(",
"byte",
"[",
"]",
"cipherText",
")",
"{",
"StringBuffer",
"cipherStringBuffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cipherText",
".",
"length",
";",
"i",
"++",
")",
"{",
"byte",
"b",
"=",
"cipherText",
"[",
"i",
"]",
";",
"cipherStringBuffer",
".",
"append",
"(",
"Byte",
".",
"toString",
"(",
"b",
")",
"+",
"\":\"",
")",
";",
"}",
"return",
"cipherStringBuffer",
".",
"toString",
"(",
")",
";",
"}"
] | Encodes a byte array as a String without using a charset
to ensure that the exact bytes can be retrieved on decode. | [
"Encodes",
"a",
"byte",
"array",
"as",
"a",
"String",
"without",
"using",
"a",
"charset",
"to",
"ensure",
"that",
"the",
"exact",
"bytes",
"can",
"be",
"retrieved",
"on",
"decode",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/EncryptionUtil.java#L98-L105 |
141,454 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/EncryptionUtil.java | EncryptionUtil.decodeBytes | private byte[] decodeBytes(String cipherString) {
String[] cipherStringBytes = cipherString.split(":");
byte[] cipherBytes = new byte[cipherStringBytes.length];
for (int i = 0; i < cipherStringBytes.length; i++) {
cipherBytes[i] = Byte.parseByte(cipherStringBytes[i]);
}
return cipherBytes;
} | java | private byte[] decodeBytes(String cipherString) {
String[] cipherStringBytes = cipherString.split(":");
byte[] cipherBytes = new byte[cipherStringBytes.length];
for (int i = 0; i < cipherStringBytes.length; i++) {
cipherBytes[i] = Byte.parseByte(cipherStringBytes[i]);
}
return cipherBytes;
} | [
"private",
"byte",
"[",
"]",
"decodeBytes",
"(",
"String",
"cipherString",
")",
"{",
"String",
"[",
"]",
"cipherStringBytes",
"=",
"cipherString",
".",
"split",
"(",
"\":\"",
")",
";",
"byte",
"[",
"]",
"cipherBytes",
"=",
"new",
"byte",
"[",
"cipherStringBytes",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cipherStringBytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"cipherBytes",
"[",
"i",
"]",
"=",
"Byte",
".",
"parseByte",
"(",
"cipherStringBytes",
"[",
"i",
"]",
")",
";",
"}",
"return",
"cipherBytes",
";",
"}"
] | Decodes a String back into a byte array. | [
"Decodes",
"a",
"String",
"back",
"into",
"a",
"byte",
"array",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/EncryptionUtil.java#L110-L117 |
141,455 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/EncryptionUtil.java | EncryptionUtil.main | public static void main(String[] args) throws Exception {
EncryptionUtil util = new EncryptionUtil();
System.out.println("Enter text to encrypt: ");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = reader.readLine();
if (null != input && !"".equals(input)) {
System.out.println("'" + util.encrypt(input) + "'");
}
} | java | public static void main(String[] args) throws Exception {
EncryptionUtil util = new EncryptionUtil();
System.out.println("Enter text to encrypt: ");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = reader.readLine();
if (null != input && !"".equals(input)) {
System.out.println("'" + util.encrypt(input) + "'");
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"EncryptionUtil",
"util",
"=",
"new",
"EncryptionUtil",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Enter text to encrypt: \"",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"System",
".",
"in",
")",
")",
";",
"String",
"input",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"input",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"input",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"'\"",
"+",
"util",
".",
"encrypt",
"(",
"input",
")",
"+",
"\"'\"",
")",
";",
"}",
"}"
] | This main prompts the user to input a string to be encrypted.
@param args none
@throws Exception on error | [
"This",
"main",
"prompts",
"the",
"user",
"to",
"input",
"a",
"string",
"to",
"be",
"encrypted",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/EncryptionUtil.java#L125-L134 |
141,456 | duracloud/duracloud | security/src/main/java/org/duracloud/security/vote/UserIpLimitsAccessVoter.java | UserIpLimitsAccessVoter.vote | public int vote(Authentication auth,
Object resource,
Collection config) {
String label = "UserIpLimitsAccessVoter";
if (resource != null && !supports(resource.getClass())) {
log.debug(debugText(label, auth, config, resource, ACCESS_ABSTAIN));
return ACCESS_ABSTAIN;
}
FilterInvocation invocation = (FilterInvocation) resource;
HttpServletRequest httpRequest = invocation.getHttpRequest();
if (null == httpRequest) {
log.debug(debugText(label, auth, config, resource, ACCESS_DENIED));
return ACCESS_DENIED;
}
String userIpLimits = getUserIpLimits(auth);
// if user IP limits are set, check request IP
if (null != userIpLimits && !userIpLimits.equals("")) {
String requestIp = httpRequest.getRemoteAddr();
String[] ipLimits = userIpLimits.split(";");
for (String ipLimit : ipLimits) {
if (ipInRange(requestIp, ipLimit)) {
// User's IP is within this range, grant access
log.debug(debugText(label, auth, config, resource, ACCESS_GRANTED));
return ACCESS_GRANTED;
}
}
// There are IP limits, and none of them match the user's IP, deny
log.debug(debugText(label, auth, config, resource, ACCESS_DENIED));
return ACCESS_DENIED;
} else { // No user IP limits, abstain
log.debug(debugText(label, auth, config, resource, ACCESS_ABSTAIN));
return ACCESS_ABSTAIN;
}
} | java | public int vote(Authentication auth,
Object resource,
Collection config) {
String label = "UserIpLimitsAccessVoter";
if (resource != null && !supports(resource.getClass())) {
log.debug(debugText(label, auth, config, resource, ACCESS_ABSTAIN));
return ACCESS_ABSTAIN;
}
FilterInvocation invocation = (FilterInvocation) resource;
HttpServletRequest httpRequest = invocation.getHttpRequest();
if (null == httpRequest) {
log.debug(debugText(label, auth, config, resource, ACCESS_DENIED));
return ACCESS_DENIED;
}
String userIpLimits = getUserIpLimits(auth);
// if user IP limits are set, check request IP
if (null != userIpLimits && !userIpLimits.equals("")) {
String requestIp = httpRequest.getRemoteAddr();
String[] ipLimits = userIpLimits.split(";");
for (String ipLimit : ipLimits) {
if (ipInRange(requestIp, ipLimit)) {
// User's IP is within this range, grant access
log.debug(debugText(label, auth, config, resource, ACCESS_GRANTED));
return ACCESS_GRANTED;
}
}
// There are IP limits, and none of them match the user's IP, deny
log.debug(debugText(label, auth, config, resource, ACCESS_DENIED));
return ACCESS_DENIED;
} else { // No user IP limits, abstain
log.debug(debugText(label, auth, config, resource, ACCESS_ABSTAIN));
return ACCESS_ABSTAIN;
}
} | [
"public",
"int",
"vote",
"(",
"Authentication",
"auth",
",",
"Object",
"resource",
",",
"Collection",
"config",
")",
"{",
"String",
"label",
"=",
"\"UserIpLimitsAccessVoter\"",
";",
"if",
"(",
"resource",
"!=",
"null",
"&&",
"!",
"supports",
"(",
"resource",
".",
"getClass",
"(",
")",
")",
")",
"{",
"log",
".",
"debug",
"(",
"debugText",
"(",
"label",
",",
"auth",
",",
"config",
",",
"resource",
",",
"ACCESS_ABSTAIN",
")",
")",
";",
"return",
"ACCESS_ABSTAIN",
";",
"}",
"FilterInvocation",
"invocation",
"=",
"(",
"FilterInvocation",
")",
"resource",
";",
"HttpServletRequest",
"httpRequest",
"=",
"invocation",
".",
"getHttpRequest",
"(",
")",
";",
"if",
"(",
"null",
"==",
"httpRequest",
")",
"{",
"log",
".",
"debug",
"(",
"debugText",
"(",
"label",
",",
"auth",
",",
"config",
",",
"resource",
",",
"ACCESS_DENIED",
")",
")",
";",
"return",
"ACCESS_DENIED",
";",
"}",
"String",
"userIpLimits",
"=",
"getUserIpLimits",
"(",
"auth",
")",
";",
"// if user IP limits are set, check request IP",
"if",
"(",
"null",
"!=",
"userIpLimits",
"&&",
"!",
"userIpLimits",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"String",
"requestIp",
"=",
"httpRequest",
".",
"getRemoteAddr",
"(",
")",
";",
"String",
"[",
"]",
"ipLimits",
"=",
"userIpLimits",
".",
"split",
"(",
"\";\"",
")",
";",
"for",
"(",
"String",
"ipLimit",
":",
"ipLimits",
")",
"{",
"if",
"(",
"ipInRange",
"(",
"requestIp",
",",
"ipLimit",
")",
")",
"{",
"// User's IP is within this range, grant access",
"log",
".",
"debug",
"(",
"debugText",
"(",
"label",
",",
"auth",
",",
"config",
",",
"resource",
",",
"ACCESS_GRANTED",
")",
")",
";",
"return",
"ACCESS_GRANTED",
";",
"}",
"}",
"// There are IP limits, and none of them match the user's IP, deny",
"log",
".",
"debug",
"(",
"debugText",
"(",
"label",
",",
"auth",
",",
"config",
",",
"resource",
",",
"ACCESS_DENIED",
")",
")",
";",
"return",
"ACCESS_DENIED",
";",
"}",
"else",
"{",
"// No user IP limits, abstain",
"log",
".",
"debug",
"(",
"debugText",
"(",
"label",
",",
"auth",
",",
"config",
",",
"resource",
",",
"ACCESS_ABSTAIN",
")",
")",
";",
"return",
"ACCESS_ABSTAIN",
";",
"}",
"}"
] | This method checks the IP limits of the principal and denys access if
those limits exist and the request is coming from outside the specified
range.
@param auth principal seeking AuthZ
@param resource that is under protection
@param config access-attributes defined on resource
@return vote (AccessDecisionVoter.ACCESS_GRANTED, ACCESS_DENIED, ACCESS_ABSTAIN) | [
"This",
"method",
"checks",
"the",
"IP",
"limits",
"of",
"the",
"principal",
"and",
"denys",
"access",
"if",
"those",
"limits",
"exist",
"and",
"the",
"request",
"is",
"coming",
"from",
"outside",
"the",
"specified",
"range",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/security/src/main/java/org/duracloud/security/vote/UserIpLimitsAccessVoter.java#L75-L112 |
141,457 | duracloud/duracloud | security/src/main/java/org/duracloud/security/vote/UserIpLimitsAccessVoter.java | UserIpLimitsAccessVoter.getUserIpLimits | protected String getUserIpLimits(Authentication auth) {
Object principal = auth.getPrincipal();
if (principal instanceof DuracloudUserDetails) {
DuracloudUserDetails userDetails = (DuracloudUserDetails) principal;
return userDetails.getIpLimits();
} else {
return null;
}
} | java | protected String getUserIpLimits(Authentication auth) {
Object principal = auth.getPrincipal();
if (principal instanceof DuracloudUserDetails) {
DuracloudUserDetails userDetails = (DuracloudUserDetails) principal;
return userDetails.getIpLimits();
} else {
return null;
}
} | [
"protected",
"String",
"getUserIpLimits",
"(",
"Authentication",
"auth",
")",
"{",
"Object",
"principal",
"=",
"auth",
".",
"getPrincipal",
"(",
")",
";",
"if",
"(",
"principal",
"instanceof",
"DuracloudUserDetails",
")",
"{",
"DuracloudUserDetails",
"userDetails",
"=",
"(",
"DuracloudUserDetails",
")",
"principal",
";",
"return",
"userDetails",
".",
"getIpLimits",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Retrieves the ip limits defined for a given user
@param auth Authentication where user details can be found
@return user ip limits, or null if no limits are set | [
"Retrieves",
"the",
"ip",
"limits",
"defined",
"for",
"a",
"given",
"user"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/security/src/main/java/org/duracloud/security/vote/UserIpLimitsAccessVoter.java#L120-L129 |
141,458 | duracloud/duracloud | security/src/main/java/org/duracloud/security/vote/UserIpLimitsAccessVoter.java | UserIpLimitsAccessVoter.ipInRange | protected boolean ipInRange(String ipAddress, String range) {
IpAddressMatcher addressMatcher = new IpAddressMatcher(range);
return addressMatcher.matches(ipAddress);
} | java | protected boolean ipInRange(String ipAddress, String range) {
IpAddressMatcher addressMatcher = new IpAddressMatcher(range);
return addressMatcher.matches(ipAddress);
} | [
"protected",
"boolean",
"ipInRange",
"(",
"String",
"ipAddress",
",",
"String",
"range",
")",
"{",
"IpAddressMatcher",
"addressMatcher",
"=",
"new",
"IpAddressMatcher",
"(",
"range",
")",
";",
"return",
"addressMatcher",
".",
"matches",
"(",
"ipAddress",
")",
";",
"}"
] | Determines if a given IP address is in the given IP range.
@param ipAddress single IP address
@param range IP address range using CIDR notation
@return true if the address is in the range, false otherwise | [
"Determines",
"if",
"a",
"given",
"IP",
"address",
"is",
"in",
"the",
"given",
"IP",
"range",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/security/src/main/java/org/duracloud/security/vote/UserIpLimitsAccessVoter.java#L138-L141 |
141,459 | duracloud/duracloud | common-queue/src/main/java/org/duracloud/common/queue/task/SpaceCentricTypedTask.java | SpaceCentricTypedTask.readTask | public void readTask(Task task) {
Map<String, String> props = task.getProperties();
setAccount(props.get(ACCOUNT_PROP));
setStoreId(props.get(STORE_ID_PROP));
setSpaceId(props.get(SPACE_ID_PROP));
this.attempts = task.getAttempts();
} | java | public void readTask(Task task) {
Map<String, String> props = task.getProperties();
setAccount(props.get(ACCOUNT_PROP));
setStoreId(props.get(STORE_ID_PROP));
setSpaceId(props.get(SPACE_ID_PROP));
this.attempts = task.getAttempts();
} | [
"public",
"void",
"readTask",
"(",
"Task",
"task",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"props",
"=",
"task",
".",
"getProperties",
"(",
")",
";",
"setAccount",
"(",
"props",
".",
"get",
"(",
"ACCOUNT_PROP",
")",
")",
";",
"setStoreId",
"(",
"props",
".",
"get",
"(",
"STORE_ID_PROP",
")",
")",
";",
"setSpaceId",
"(",
"props",
".",
"get",
"(",
"SPACE_ID_PROP",
")",
")",
";",
"this",
".",
"attempts",
"=",
"task",
".",
"getAttempts",
"(",
")",
";",
"}"
] | Reads the information stored in a Task and sets data in the SpaceCentricTypedTask
@param task | [
"Reads",
"the",
"information",
"stored",
"in",
"a",
"Task",
"and",
"sets",
"data",
"in",
"the",
"SpaceCentricTypedTask"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common-queue/src/main/java/org/duracloud/common/queue/task/SpaceCentricTypedTask.java#L79-L85 |
141,460 | duracloud/duracloud | common-queue/src/main/java/org/duracloud/common/queue/task/SpaceCentricTypedTask.java | SpaceCentricTypedTask.writeTask | public Task writeTask() {
Task task = new Task();
addProperty(task, ACCOUNT_PROP, getAccount());
addProperty(task, STORE_ID_PROP, getStoreId());
addProperty(task, SPACE_ID_PROP, getSpaceId());
return task;
} | java | public Task writeTask() {
Task task = new Task();
addProperty(task, ACCOUNT_PROP, getAccount());
addProperty(task, STORE_ID_PROP, getStoreId());
addProperty(task, SPACE_ID_PROP, getSpaceId());
return task;
} | [
"public",
"Task",
"writeTask",
"(",
")",
"{",
"Task",
"task",
"=",
"new",
"Task",
"(",
")",
";",
"addProperty",
"(",
"task",
",",
"ACCOUNT_PROP",
",",
"getAccount",
"(",
")",
")",
";",
"addProperty",
"(",
"task",
",",
"STORE_ID_PROP",
",",
"getStoreId",
"(",
")",
")",
";",
"addProperty",
"(",
"task",
",",
"SPACE_ID_PROP",
",",
"getSpaceId",
"(",
")",
")",
";",
"return",
"task",
";",
"}"
] | Writes all of the information in the SpaceCentricTypedTask into a Task
@return a Task based on the information stored in this SpaceCentricTypedTask | [
"Writes",
"all",
"of",
"the",
"information",
"in",
"the",
"SpaceCentricTypedTask",
"into",
"a",
"Task"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common-queue/src/main/java/org/duracloud/common/queue/task/SpaceCentricTypedTask.java#L92-L98 |
141,461 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3task/streaming/GetSignedUrlTaskRunner.java | GetSignedUrlTaskRunner.performTask | public String performTask(String taskParameters) {
GetSignedUrlTaskParameters taskParams =
GetSignedUrlTaskParameters.deserialize(taskParameters);
String spaceId = taskParams.getSpaceId();
String contentId = taskParams.getContentId();
String resourcePrefix = taskParams.getResourcePrefix();
String ipAddress = taskParams.getIpAddress();
int minutesToExpire = taskParams.getMinutesToExpire();
if (minutesToExpire <= 0) {
minutesToExpire = DEFAULT_MINUTES_TO_EXPIRE;
}
log.info("Performing " + TASK_NAME + " task with parameters: spaceId=" + spaceId +
", contentId=" + contentId + ", resourcePrefix=" + resourcePrefix +
", minutesToExpire=" + minutesToExpire + ", ipAddress=" + ipAddress);
// Will throw if bucket does not exist
String bucketName = unwrappedS3Provider.getBucketName(spaceId);
GetSignedUrlTaskResult taskResult = new GetSignedUrlTaskResult();
// Ensure that streaming service is on
checkThatStreamingServiceIsEnabled(spaceId, TASK_NAME);
// Retrieve the existing distribution for the given space
StreamingDistributionSummary existingDist =
getExistingDistribution(bucketName);
if (null == existingDist) {
throw new UnsupportedTaskException(TASK_NAME,
"The " + TASK_NAME + " task can only be used after a space " +
"has been configured to enable secure streaming. Use " +
StorageTaskConstants.ENABLE_STREAMING_TASK_NAME +
" to enable secure streaming on this space.");
}
String domainName = existingDist.getDomainName();
// Verify that this is a secure distribution
if (existingDist.getTrustedSigners().getItems().isEmpty()) {
throw new UnsupportedTaskException(TASK_NAME,
"The " + TASK_NAME + " task cannot be used to request a " +
"stream from an open distribution. Use " +
StorageTaskConstants.GET_URL_TASK_NAME + " instead.");
}
// Make sure resourcePrefix is a valid string
if (null == resourcePrefix) {
resourcePrefix = "";
}
// Define expiration date/time
Calendar expireCalendar = Calendar.getInstance();
expireCalendar.add(Calendar.MINUTE, minutesToExpire);
try {
File cfKeyPathFile = getCfKeyPathFile(this.cfKeyPath);
String signedUrl =
CloudFrontUrlSigner.getSignedURLWithCustomPolicy(
SignerUtils.Protocol.rtmp,
domainName,
cfKeyPathFile,
contentId,
cfKeyId,
expireCalendar.getTime(),
null,
ipAddress);
taskResult.setSignedUrl("rtmp://" + domainName + "/cfx/st/" +
resourcePrefix + signedUrl);
} catch (InvalidKeySpecException | IOException e) {
throw new RuntimeException("Error encountered attempting to sign URL for" +
" task " + TASK_NAME + ": " + e.getMessage(), e);
}
String toReturn = taskResult.serialize();
log.info("Result of " + TASK_NAME + " task: " + toReturn);
return toReturn;
} | java | public String performTask(String taskParameters) {
GetSignedUrlTaskParameters taskParams =
GetSignedUrlTaskParameters.deserialize(taskParameters);
String spaceId = taskParams.getSpaceId();
String contentId = taskParams.getContentId();
String resourcePrefix = taskParams.getResourcePrefix();
String ipAddress = taskParams.getIpAddress();
int minutesToExpire = taskParams.getMinutesToExpire();
if (minutesToExpire <= 0) {
minutesToExpire = DEFAULT_MINUTES_TO_EXPIRE;
}
log.info("Performing " + TASK_NAME + " task with parameters: spaceId=" + spaceId +
", contentId=" + contentId + ", resourcePrefix=" + resourcePrefix +
", minutesToExpire=" + minutesToExpire + ", ipAddress=" + ipAddress);
// Will throw if bucket does not exist
String bucketName = unwrappedS3Provider.getBucketName(spaceId);
GetSignedUrlTaskResult taskResult = new GetSignedUrlTaskResult();
// Ensure that streaming service is on
checkThatStreamingServiceIsEnabled(spaceId, TASK_NAME);
// Retrieve the existing distribution for the given space
StreamingDistributionSummary existingDist =
getExistingDistribution(bucketName);
if (null == existingDist) {
throw new UnsupportedTaskException(TASK_NAME,
"The " + TASK_NAME + " task can only be used after a space " +
"has been configured to enable secure streaming. Use " +
StorageTaskConstants.ENABLE_STREAMING_TASK_NAME +
" to enable secure streaming on this space.");
}
String domainName = existingDist.getDomainName();
// Verify that this is a secure distribution
if (existingDist.getTrustedSigners().getItems().isEmpty()) {
throw new UnsupportedTaskException(TASK_NAME,
"The " + TASK_NAME + " task cannot be used to request a " +
"stream from an open distribution. Use " +
StorageTaskConstants.GET_URL_TASK_NAME + " instead.");
}
// Make sure resourcePrefix is a valid string
if (null == resourcePrefix) {
resourcePrefix = "";
}
// Define expiration date/time
Calendar expireCalendar = Calendar.getInstance();
expireCalendar.add(Calendar.MINUTE, minutesToExpire);
try {
File cfKeyPathFile = getCfKeyPathFile(this.cfKeyPath);
String signedUrl =
CloudFrontUrlSigner.getSignedURLWithCustomPolicy(
SignerUtils.Protocol.rtmp,
domainName,
cfKeyPathFile,
contentId,
cfKeyId,
expireCalendar.getTime(),
null,
ipAddress);
taskResult.setSignedUrl("rtmp://" + domainName + "/cfx/st/" +
resourcePrefix + signedUrl);
} catch (InvalidKeySpecException | IOException e) {
throw new RuntimeException("Error encountered attempting to sign URL for" +
" task " + TASK_NAME + ": " + e.getMessage(), e);
}
String toReturn = taskResult.serialize();
log.info("Result of " + TASK_NAME + " task: " + toReturn);
return toReturn;
} | [
"public",
"String",
"performTask",
"(",
"String",
"taskParameters",
")",
"{",
"GetSignedUrlTaskParameters",
"taskParams",
"=",
"GetSignedUrlTaskParameters",
".",
"deserialize",
"(",
"taskParameters",
")",
";",
"String",
"spaceId",
"=",
"taskParams",
".",
"getSpaceId",
"(",
")",
";",
"String",
"contentId",
"=",
"taskParams",
".",
"getContentId",
"(",
")",
";",
"String",
"resourcePrefix",
"=",
"taskParams",
".",
"getResourcePrefix",
"(",
")",
";",
"String",
"ipAddress",
"=",
"taskParams",
".",
"getIpAddress",
"(",
")",
";",
"int",
"minutesToExpire",
"=",
"taskParams",
".",
"getMinutesToExpire",
"(",
")",
";",
"if",
"(",
"minutesToExpire",
"<=",
"0",
")",
"{",
"minutesToExpire",
"=",
"DEFAULT_MINUTES_TO_EXPIRE",
";",
"}",
"log",
".",
"info",
"(",
"\"Performing \"",
"+",
"TASK_NAME",
"+",
"\" task with parameters: spaceId=\"",
"+",
"spaceId",
"+",
"\", contentId=\"",
"+",
"contentId",
"+",
"\", resourcePrefix=\"",
"+",
"resourcePrefix",
"+",
"\", minutesToExpire=\"",
"+",
"minutesToExpire",
"+",
"\", ipAddress=\"",
"+",
"ipAddress",
")",
";",
"// Will throw if bucket does not exist",
"String",
"bucketName",
"=",
"unwrappedS3Provider",
".",
"getBucketName",
"(",
"spaceId",
")",
";",
"GetSignedUrlTaskResult",
"taskResult",
"=",
"new",
"GetSignedUrlTaskResult",
"(",
")",
";",
"// Ensure that streaming service is on",
"checkThatStreamingServiceIsEnabled",
"(",
"spaceId",
",",
"TASK_NAME",
")",
";",
"// Retrieve the existing distribution for the given space",
"StreamingDistributionSummary",
"existingDist",
"=",
"getExistingDistribution",
"(",
"bucketName",
")",
";",
"if",
"(",
"null",
"==",
"existingDist",
")",
"{",
"throw",
"new",
"UnsupportedTaskException",
"(",
"TASK_NAME",
",",
"\"The \"",
"+",
"TASK_NAME",
"+",
"\" task can only be used after a space \"",
"+",
"\"has been configured to enable secure streaming. Use \"",
"+",
"StorageTaskConstants",
".",
"ENABLE_STREAMING_TASK_NAME",
"+",
"\" to enable secure streaming on this space.\"",
")",
";",
"}",
"String",
"domainName",
"=",
"existingDist",
".",
"getDomainName",
"(",
")",
";",
"// Verify that this is a secure distribution",
"if",
"(",
"existingDist",
".",
"getTrustedSigners",
"(",
")",
".",
"getItems",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"UnsupportedTaskException",
"(",
"TASK_NAME",
",",
"\"The \"",
"+",
"TASK_NAME",
"+",
"\" task cannot be used to request a \"",
"+",
"\"stream from an open distribution. Use \"",
"+",
"StorageTaskConstants",
".",
"GET_URL_TASK_NAME",
"+",
"\" instead.\"",
")",
";",
"}",
"// Make sure resourcePrefix is a valid string",
"if",
"(",
"null",
"==",
"resourcePrefix",
")",
"{",
"resourcePrefix",
"=",
"\"\"",
";",
"}",
"// Define expiration date/time",
"Calendar",
"expireCalendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"expireCalendar",
".",
"add",
"(",
"Calendar",
".",
"MINUTE",
",",
"minutesToExpire",
")",
";",
"try",
"{",
"File",
"cfKeyPathFile",
"=",
"getCfKeyPathFile",
"(",
"this",
".",
"cfKeyPath",
")",
";",
"String",
"signedUrl",
"=",
"CloudFrontUrlSigner",
".",
"getSignedURLWithCustomPolicy",
"(",
"SignerUtils",
".",
"Protocol",
".",
"rtmp",
",",
"domainName",
",",
"cfKeyPathFile",
",",
"contentId",
",",
"cfKeyId",
",",
"expireCalendar",
".",
"getTime",
"(",
")",
",",
"null",
",",
"ipAddress",
")",
";",
"taskResult",
".",
"setSignedUrl",
"(",
"\"rtmp://\"",
"+",
"domainName",
"+",
"\"/cfx/st/\"",
"+",
"resourcePrefix",
"+",
"signedUrl",
")",
";",
"}",
"catch",
"(",
"InvalidKeySpecException",
"|",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error encountered attempting to sign URL for\"",
"+",
"\" task \"",
"+",
"TASK_NAME",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"String",
"toReturn",
"=",
"taskResult",
".",
"serialize",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"Result of \"",
"+",
"TASK_NAME",
"+",
"\" task: \"",
"+",
"toReturn",
")",
";",
"return",
"toReturn",
";",
"}"
] | Build secure URL | [
"Build",
"secure",
"URL"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3task/streaming/GetSignedUrlTaskRunner.java#L67-L143 |
141,462 | duracloud/duracloud | snapshotdata/src/main/java/org/duracloud/snapshot/dto/bridge/CreateSnapshotBridgeParameters.java | CreateSnapshotBridgeParameters.serialize | public String serialize() {
JaxbJsonSerializer<CreateSnapshotBridgeParameters> serializer =
new JaxbJsonSerializer<>(CreateSnapshotBridgeParameters.class);
try {
return serializer.serialize(this);
} catch (IOException e) {
throw new SnapshotDataException(
"Unable to create task result due to: " + e.getMessage());
}
} | java | public String serialize() {
JaxbJsonSerializer<CreateSnapshotBridgeParameters> serializer =
new JaxbJsonSerializer<>(CreateSnapshotBridgeParameters.class);
try {
return serializer.serialize(this);
} catch (IOException e) {
throw new SnapshotDataException(
"Unable to create task result due to: " + e.getMessage());
}
} | [
"public",
"String",
"serialize",
"(",
")",
"{",
"JaxbJsonSerializer",
"<",
"CreateSnapshotBridgeParameters",
">",
"serializer",
"=",
"new",
"JaxbJsonSerializer",
"<>",
"(",
"CreateSnapshotBridgeParameters",
".",
"class",
")",
";",
"try",
"{",
"return",
"serializer",
".",
"serialize",
"(",
"this",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SnapshotDataException",
"(",
"\"Unable to create task result due to: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Creates a serialized version of bridge parameters
@return JSON formatted bridge info | [
"Creates",
"a",
"serialized",
"version",
"of",
"bridge",
"parameters"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/snapshotdata/src/main/java/org/duracloud/snapshot/dto/bridge/CreateSnapshotBridgeParameters.java#L145-L154 |
141,463 | duracloud/duracloud | common-queue/src/main/java/org/duracloud/common/queue/aws/SQSTaskQueue.java | SQSTaskQueue.put | @Override
public void put(Set<Task> tasks) {
String msgBody = null;
SendMessageBatchRequestEntry msgEntry = null;
Set<SendMessageBatchRequestEntry> msgEntries = new HashSet<>();
for (Task task : tasks) {
msgBody = unmarshallTask(task);
msgEntry = new SendMessageBatchRequestEntry()
.withMessageBody(msgBody)
.withId(msgEntries.size() + ""); // must set unique ID for each msg in the batch request
msgEntries.add(msgEntry);
// Can only send batch of max 10 messages in a SQS queue request
if (msgEntries.size() == 10) {
this.sendBatchMessages(msgEntries);
msgEntries.clear(); // clear the already sent messages
}
}
// After for loop check to see if there are msgs in msgEntries that
// haven't been sent yet because the size never reached 10.
if (!msgEntries.isEmpty()) {
this.sendBatchMessages(msgEntries);
}
} | java | @Override
public void put(Set<Task> tasks) {
String msgBody = null;
SendMessageBatchRequestEntry msgEntry = null;
Set<SendMessageBatchRequestEntry> msgEntries = new HashSet<>();
for (Task task : tasks) {
msgBody = unmarshallTask(task);
msgEntry = new SendMessageBatchRequestEntry()
.withMessageBody(msgBody)
.withId(msgEntries.size() + ""); // must set unique ID for each msg in the batch request
msgEntries.add(msgEntry);
// Can only send batch of max 10 messages in a SQS queue request
if (msgEntries.size() == 10) {
this.sendBatchMessages(msgEntries);
msgEntries.clear(); // clear the already sent messages
}
}
// After for loop check to see if there are msgs in msgEntries that
// haven't been sent yet because the size never reached 10.
if (!msgEntries.isEmpty()) {
this.sendBatchMessages(msgEntries);
}
} | [
"@",
"Override",
"public",
"void",
"put",
"(",
"Set",
"<",
"Task",
">",
"tasks",
")",
"{",
"String",
"msgBody",
"=",
"null",
";",
"SendMessageBatchRequestEntry",
"msgEntry",
"=",
"null",
";",
"Set",
"<",
"SendMessageBatchRequestEntry",
">",
"msgEntries",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"Task",
"task",
":",
"tasks",
")",
"{",
"msgBody",
"=",
"unmarshallTask",
"(",
"task",
")",
";",
"msgEntry",
"=",
"new",
"SendMessageBatchRequestEntry",
"(",
")",
".",
"withMessageBody",
"(",
"msgBody",
")",
".",
"withId",
"(",
"msgEntries",
".",
"size",
"(",
")",
"+",
"\"\"",
")",
";",
"// must set unique ID for each msg in the batch request",
"msgEntries",
".",
"add",
"(",
"msgEntry",
")",
";",
"// Can only send batch of max 10 messages in a SQS queue request",
"if",
"(",
"msgEntries",
".",
"size",
"(",
")",
"==",
"10",
")",
"{",
"this",
".",
"sendBatchMessages",
"(",
"msgEntries",
")",
";",
"msgEntries",
".",
"clear",
"(",
")",
";",
"// clear the already sent messages",
"}",
"}",
"// After for loop check to see if there are msgs in msgEntries that",
"// haven't been sent yet because the size never reached 10.",
"if",
"(",
"!",
"msgEntries",
".",
"isEmpty",
"(",
")",
")",
"{",
"this",
".",
"sendBatchMessages",
"(",
"msgEntries",
")",
";",
"}",
"}"
] | Puts multiple tasks on the queue using batch puts. The tasks argument
can contain more than 10 Tasks, in that case there will be multiple SQS
batch send requests made each containing up to 10 messages.
@param tasks | [
"Puts",
"multiple",
"tasks",
"on",
"the",
"queue",
"using",
"batch",
"puts",
".",
"The",
"tasks",
"argument",
"can",
"contain",
"more",
"than",
"10",
"Tasks",
"in",
"that",
"case",
"there",
"will",
"be",
"multiple",
"SQS",
"batch",
"send",
"requests",
"made",
"each",
"containing",
"up",
"to",
"10",
"messages",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common-queue/src/main/java/org/duracloud/common/queue/aws/SQSTaskQueue.java#L192-L216 |
141,464 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/config/SyncToolConfigParser.java | SyncToolConfigParser.retrievePrevConfig | public SyncToolConfig retrievePrevConfig(File backupDir) {
File prevConfigBackupFile =
new File(backupDir, PREV_BACKUP_FILE_NAME);
if (prevConfigBackupFile.exists()) {
String[] prevConfigArgs = retrieveConfig(prevConfigBackupFile);
try {
return processStandardOptions(prevConfigArgs, false);
} catch (ParseException e) {
return null;
}
} else {
return null;
}
} | java | public SyncToolConfig retrievePrevConfig(File backupDir) {
File prevConfigBackupFile =
new File(backupDir, PREV_BACKUP_FILE_NAME);
if (prevConfigBackupFile.exists()) {
String[] prevConfigArgs = retrieveConfig(prevConfigBackupFile);
try {
return processStandardOptions(prevConfigArgs, false);
} catch (ParseException e) {
return null;
}
} else {
return null;
}
} | [
"public",
"SyncToolConfig",
"retrievePrevConfig",
"(",
"File",
"backupDir",
")",
"{",
"File",
"prevConfigBackupFile",
"=",
"new",
"File",
"(",
"backupDir",
",",
"PREV_BACKUP_FILE_NAME",
")",
";",
"if",
"(",
"prevConfigBackupFile",
".",
"exists",
"(",
")",
")",
"{",
"String",
"[",
"]",
"prevConfigArgs",
"=",
"retrieveConfig",
"(",
"prevConfigBackupFile",
")",
";",
"try",
"{",
"return",
"processStandardOptions",
"(",
"prevConfigArgs",
",",
"false",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Retrieves the configuration of the previous run of the Sync Tool.
If there was no previous run, the backup file cannot be found, or
the backup file cannot be read, returns null, otherwise returns the
parsed configuration
@param backupDir the current backup directory
@return config for previous sync tool run, or null | [
"Retrieves",
"the",
"configuration",
"of",
"the",
"previous",
"run",
"of",
"the",
"Sync",
"Tool",
".",
"If",
"there",
"was",
"no",
"previous",
"run",
"the",
"backup",
"file",
"cannot",
"be",
"found",
"or",
"the",
"backup",
"file",
"cannot",
"be",
"read",
"returns",
"null",
"otherwise",
"returns",
"the",
"parsed",
"configuration"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/config/SyncToolConfigParser.java#L547-L560 |
141,465 | duracloud/duracloud | s3storageprovider/src/main/java/org/duracloud/s3storage/S3ProviderUtil.java | S3ProviderUtil.createNewBucketName | public static String createNewBucketName(String accessKeyId,
String spaceId) {
String bucketName = accessKeyId + "." + spaceId;
bucketName = bucketName.toLowerCase();
bucketName = bucketName.replaceAll("[^a-z0-9-.]", "-");
// Remove duplicate separators (. and -)
while (bucketName.contains("--") || bucketName.contains("..")
|| bucketName.contains("-.") || bucketName.contains(".-")) {
bucketName = bucketName.replaceAll("[-]+", "-");
bucketName = bucketName.replaceAll("[.]+", ".");
bucketName = bucketName.replaceAll("-[.]", "-");
bucketName = bucketName.replaceAll("[.]-", ".");
}
if (bucketName.length() > 63) {
bucketName = bucketName.substring(0, 63);
}
while (bucketName.endsWith("-") || bucketName.endsWith(".")) {
bucketName = bucketName.substring(0, bucketName.length() - 1);
}
return bucketName;
} | java | public static String createNewBucketName(String accessKeyId,
String spaceId) {
String bucketName = accessKeyId + "." + spaceId;
bucketName = bucketName.toLowerCase();
bucketName = bucketName.replaceAll("[^a-z0-9-.]", "-");
// Remove duplicate separators (. and -)
while (bucketName.contains("--") || bucketName.contains("..")
|| bucketName.contains("-.") || bucketName.contains(".-")) {
bucketName = bucketName.replaceAll("[-]+", "-");
bucketName = bucketName.replaceAll("[.]+", ".");
bucketName = bucketName.replaceAll("-[.]", "-");
bucketName = bucketName.replaceAll("[.]-", ".");
}
if (bucketName.length() > 63) {
bucketName = bucketName.substring(0, 63);
}
while (bucketName.endsWith("-") || bucketName.endsWith(".")) {
bucketName = bucketName.substring(0, bucketName.length() - 1);
}
return bucketName;
} | [
"public",
"static",
"String",
"createNewBucketName",
"(",
"String",
"accessKeyId",
",",
"String",
"spaceId",
")",
"{",
"String",
"bucketName",
"=",
"accessKeyId",
"+",
"\".\"",
"+",
"spaceId",
";",
"bucketName",
"=",
"bucketName",
".",
"toLowerCase",
"(",
")",
";",
"bucketName",
"=",
"bucketName",
".",
"replaceAll",
"(",
"\"[^a-z0-9-.]\"",
",",
"\"-\"",
")",
";",
"// Remove duplicate separators (. and -)",
"while",
"(",
"bucketName",
".",
"contains",
"(",
"\"--\"",
")",
"||",
"bucketName",
".",
"contains",
"(",
"\"..\"",
")",
"||",
"bucketName",
".",
"contains",
"(",
"\"-.\"",
")",
"||",
"bucketName",
".",
"contains",
"(",
"\".-\"",
")",
")",
"{",
"bucketName",
"=",
"bucketName",
".",
"replaceAll",
"(",
"\"[-]+\"",
",",
"\"-\"",
")",
";",
"bucketName",
"=",
"bucketName",
".",
"replaceAll",
"(",
"\"[.]+\"",
",",
"\".\"",
")",
";",
"bucketName",
"=",
"bucketName",
".",
"replaceAll",
"(",
"\"-[.]\"",
",",
"\"-\"",
")",
";",
"bucketName",
"=",
"bucketName",
".",
"replaceAll",
"(",
"\"[.]-\"",
",",
"\".\"",
")",
";",
"}",
"if",
"(",
"bucketName",
".",
"length",
"(",
")",
">",
"63",
")",
"{",
"bucketName",
"=",
"bucketName",
".",
"substring",
"(",
"0",
",",
"63",
")",
";",
"}",
"while",
"(",
"bucketName",
".",
"endsWith",
"(",
"\"-\"",
")",
"||",
"bucketName",
".",
"endsWith",
"(",
"\".\"",
")",
")",
"{",
"bucketName",
"=",
"bucketName",
".",
"substring",
"(",
"0",
",",
"bucketName",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"bucketName",
";",
"}"
] | Converts a provided space ID into a valid and unique S3 bucket name.
@param spaceId
@return | [
"Converts",
"a",
"provided",
"space",
"ID",
"into",
"a",
"valid",
"and",
"unique",
"S3",
"bucket",
"name",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/s3storageprovider/src/main/java/org/duracloud/s3storage/S3ProviderUtil.java#L122-L144 |
141,466 | duracloud/duracloud | security/src/main/java/org/duracloud/security/vote/RoleVoterImpl.java | RoleVoterImpl.vote | @Override
public int vote(Authentication authentication,
Object resource,
Collection<ConfigAttribute> config) {
int decision = super.vote(authentication, resource, config);
log.debug(VoterUtil.debugText("RoleVoterImpl",
authentication,
config,
resource,
decision));
return decision;
} | java | @Override
public int vote(Authentication authentication,
Object resource,
Collection<ConfigAttribute> config) {
int decision = super.vote(authentication, resource, config);
log.debug(VoterUtil.debugText("RoleVoterImpl",
authentication,
config,
resource,
decision));
return decision;
} | [
"@",
"Override",
"public",
"int",
"vote",
"(",
"Authentication",
"authentication",
",",
"Object",
"resource",
",",
"Collection",
"<",
"ConfigAttribute",
">",
"config",
")",
"{",
"int",
"decision",
"=",
"super",
".",
"vote",
"(",
"authentication",
",",
"resource",
",",
"config",
")",
";",
"log",
".",
"debug",
"(",
"VoterUtil",
".",
"debugText",
"(",
"\"RoleVoterImpl\"",
",",
"authentication",
",",
"config",
",",
"resource",
",",
"decision",
")",
")",
";",
"return",
"decision",
";",
"}"
] | This method is a pass-through for Spring-RoleVoter.
@param authentication principal seeking AuthZ
@param resource that is under protection
@param config access-attributes defined on resource
@return vote (AccessDecisionVoter.ACCESS_GRANTED, ACCESS_DENIED, ACCESS_ABSTAIN) | [
"This",
"method",
"is",
"a",
"pass",
"-",
"through",
"for",
"Spring",
"-",
"RoleVoter",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/security/src/main/java/org/duracloud/security/vote/RoleVoterImpl.java#L35-L46 |
141,467 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/domain/StorageAccountManager.java | StorageAccountManager.initialize | public void initialize(List<StorageAccount> accts)
throws StorageException {
storageAccounts = new HashMap<>();
for (StorageAccount acct : accts) {
storageAccounts.put(acct.getId(), acct);
if (acct.isPrimary()) {
primaryStorageProviderId = acct.getId();
}
}
// Make sure a primary provider is set
if (primaryStorageProviderId == null) {
primaryStorageProviderId = accts.get(0).getId();
}
} | java | public void initialize(List<StorageAccount> accts)
throws StorageException {
storageAccounts = new HashMap<>();
for (StorageAccount acct : accts) {
storageAccounts.put(acct.getId(), acct);
if (acct.isPrimary()) {
primaryStorageProviderId = acct.getId();
}
}
// Make sure a primary provider is set
if (primaryStorageProviderId == null) {
primaryStorageProviderId = accts.get(0).getId();
}
} | [
"public",
"void",
"initialize",
"(",
"List",
"<",
"StorageAccount",
">",
"accts",
")",
"throws",
"StorageException",
"{",
"storageAccounts",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"StorageAccount",
"acct",
":",
"accts",
")",
"{",
"storageAccounts",
".",
"put",
"(",
"acct",
".",
"getId",
"(",
")",
",",
"acct",
")",
";",
"if",
"(",
"acct",
".",
"isPrimary",
"(",
")",
")",
"{",
"primaryStorageProviderId",
"=",
"acct",
".",
"getId",
"(",
")",
";",
"}",
"}",
"// Make sure a primary provider is set",
"if",
"(",
"primaryStorageProviderId",
"==",
"null",
")",
"{",
"primaryStorageProviderId",
"=",
"accts",
".",
"get",
"(",
"0",
")",
".",
"getId",
"(",
")",
";",
"}",
"}"
] | Initializes the account manager based on provided accounts
@param accts
@throws StorageException | [
"Initializes",
"the",
"account",
"manager",
"based",
"on",
"provided",
"accounts"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/domain/StorageAccountManager.java#L41-L56 |
141,468 | duracloud/duracloud | duradmin/src/main/java/org/duracloud/duradmin/spaces/controller/SnapshotController.java | SnapshotController.restoreSpaceId | @RequestMapping(value = "/spaces/snapshots/{storeId}/{snapshotId}/restore-space-id", method = RequestMethod.GET)
@ResponseBody
public String restoreSpaceId(HttpServletRequest request,
@PathVariable("storeId") String storeId,
@PathVariable("snapshotId") String snapshotId) throws Exception {
ContentStore contentStore = getContentStore(storeId);
String spaceId = SnapshotIdentifier.parseSnapshotId(snapshotId).getRestoreSpaceId();
if (contentStore.spaceExists(spaceId)) {
return "{ \"spaceId\": \"" + spaceId + "\"," + "\"storeId\": \"" + storeId + "\"}";
} else {
return "{}";
}
} | java | @RequestMapping(value = "/spaces/snapshots/{storeId}/{snapshotId}/restore-space-id", method = RequestMethod.GET)
@ResponseBody
public String restoreSpaceId(HttpServletRequest request,
@PathVariable("storeId") String storeId,
@PathVariable("snapshotId") String snapshotId) throws Exception {
ContentStore contentStore = getContentStore(storeId);
String spaceId = SnapshotIdentifier.parseSnapshotId(snapshotId).getRestoreSpaceId();
if (contentStore.spaceExists(spaceId)) {
return "{ \"spaceId\": \"" + spaceId + "\"," + "\"storeId\": \"" + storeId + "\"}";
} else {
return "{}";
}
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/spaces/snapshots/{storeId}/{snapshotId}/restore-space-id\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"@",
"ResponseBody",
"public",
"String",
"restoreSpaceId",
"(",
"HttpServletRequest",
"request",
",",
"@",
"PathVariable",
"(",
"\"storeId\"",
")",
"String",
"storeId",
",",
"@",
"PathVariable",
"(",
"\"snapshotId\"",
")",
"String",
"snapshotId",
")",
"throws",
"Exception",
"{",
"ContentStore",
"contentStore",
"=",
"getContentStore",
"(",
"storeId",
")",
";",
"String",
"spaceId",
"=",
"SnapshotIdentifier",
".",
"parseSnapshotId",
"(",
"snapshotId",
")",
".",
"getRestoreSpaceId",
"(",
")",
";",
"if",
"(",
"contentStore",
".",
"spaceExists",
"(",
"spaceId",
")",
")",
"{",
"return",
"\"{ \\\"spaceId\\\": \\\"\"",
"+",
"spaceId",
"+",
"\"\\\",\"",
"+",
"\"\\\"storeId\\\": \\\"\"",
"+",
"storeId",
"+",
"\"\\\"}\"",
";",
"}",
"else",
"{",
"return",
"\"{}\"",
";",
"}",
"}"
] | Returns the name of the restore space, if it exists, associated with a snapshot
@param request
@param snapshotId
@return
@throws ParseException | [
"Returns",
"the",
"name",
"of",
"the",
"restore",
"space",
"if",
"it",
"exists",
"associated",
"with",
"a",
"snapshot"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/duradmin/src/main/java/org/duracloud/duradmin/spaces/controller/SnapshotController.java#L300-L314 |
141,469 | duracloud/duracloud | snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/AbstractSnapshotTaskRunner.java | AbstractSnapshotTaskRunner.getValueFromJson | protected <T> T getValueFromJson(String json, String propName) throws IOException {
return (T) jsonStringToMap(json).get(propName);
} | java | protected <T> T getValueFromJson(String json, String propName) throws IOException {
return (T) jsonStringToMap(json).get(propName);
} | [
"protected",
"<",
"T",
">",
"T",
"getValueFromJson",
"(",
"String",
"json",
",",
"String",
"propName",
")",
"throws",
"IOException",
"{",
"return",
"(",
"T",
")",
"jsonStringToMap",
"(",
"json",
")",
".",
"get",
"(",
"propName",
")",
";",
"}"
] | A helper method that takes a json string and extracts the value of the specified
property.
@param json the json string
@param propName the name of the property to extract
@param <T> The type for the value expected to be returned.
@return the value of the specified property
@throws IOException | [
"A",
"helper",
"method",
"that",
"takes",
"a",
"json",
"string",
"and",
"extracts",
"the",
"value",
"of",
"the",
"specified",
"property",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/AbstractSnapshotTaskRunner.java#L79-L81 |
141,470 | duracloud/duracloud | snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/AbstractSnapshotTaskRunner.java | AbstractSnapshotTaskRunner.jsonStringToMap | protected Map jsonStringToMap(String json) throws IOException {
return new JaxbJsonSerializer<HashMap>(HashMap.class).deserialize(json);
} | java | protected Map jsonStringToMap(String json) throws IOException {
return new JaxbJsonSerializer<HashMap>(HashMap.class).deserialize(json);
} | [
"protected",
"Map",
"jsonStringToMap",
"(",
"String",
"json",
")",
"throws",
"IOException",
"{",
"return",
"new",
"JaxbJsonSerializer",
"<",
"HashMap",
">",
"(",
"HashMap",
".",
"class",
")",
".",
"deserialize",
"(",
"json",
")",
";",
"}"
] | A helper method that converts a json string into a map object.
@param json the json string
@return a map representing the json string.
@throws IOException | [
"A",
"helper",
"method",
"that",
"converts",
"a",
"json",
"string",
"into",
"a",
"map",
"object",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/AbstractSnapshotTaskRunner.java#L90-L92 |
141,471 | duracloud/duracloud | syncoptimize/src/main/java/org/duracloud/syncoptimize/SyncOptimizeDriver.java | SyncOptimizeDriver.getOptimalThreads | public int getOptimalThreads(SyncOptimizeConfig syncOptConfig)
throws IOException {
File tempDir = FileUtils.getTempDirectory();
this.dataDir = new File(tempDir, DATA_DIR_NAME);
this.workDir = new File(tempDir, WORK_DIR_NAME);
String prefix = "sync-optimize/" +
InetAddress.getLocalHost().getHostName() + "/";
TestDataHandler dataHandler = new TestDataHandler();
dataHandler.createDirectories(dataDir, workDir);
dataHandler.createTestData(dataDir,
syncOptConfig.getNumFiles(),
syncOptConfig.getSizeFiles());
SyncTestManager testManager =
new SyncTestManager(syncOptConfig, dataDir, workDir,
syncTestStatus, prefix);
int optimalThreads = testManager.runTest();
dataHandler.removeDirectories(dataDir, workDir);
return optimalThreads;
} | java | public int getOptimalThreads(SyncOptimizeConfig syncOptConfig)
throws IOException {
File tempDir = FileUtils.getTempDirectory();
this.dataDir = new File(tempDir, DATA_DIR_NAME);
this.workDir = new File(tempDir, WORK_DIR_NAME);
String prefix = "sync-optimize/" +
InetAddress.getLocalHost().getHostName() + "/";
TestDataHandler dataHandler = new TestDataHandler();
dataHandler.createDirectories(dataDir, workDir);
dataHandler.createTestData(dataDir,
syncOptConfig.getNumFiles(),
syncOptConfig.getSizeFiles());
SyncTestManager testManager =
new SyncTestManager(syncOptConfig, dataDir, workDir,
syncTestStatus, prefix);
int optimalThreads = testManager.runTest();
dataHandler.removeDirectories(dataDir, workDir);
return optimalThreads;
} | [
"public",
"int",
"getOptimalThreads",
"(",
"SyncOptimizeConfig",
"syncOptConfig",
")",
"throws",
"IOException",
"{",
"File",
"tempDir",
"=",
"FileUtils",
".",
"getTempDirectory",
"(",
")",
";",
"this",
".",
"dataDir",
"=",
"new",
"File",
"(",
"tempDir",
",",
"DATA_DIR_NAME",
")",
";",
"this",
".",
"workDir",
"=",
"new",
"File",
"(",
"tempDir",
",",
"WORK_DIR_NAME",
")",
";",
"String",
"prefix",
"=",
"\"sync-optimize/\"",
"+",
"InetAddress",
".",
"getLocalHost",
"(",
")",
".",
"getHostName",
"(",
")",
"+",
"\"/\"",
";",
"TestDataHandler",
"dataHandler",
"=",
"new",
"TestDataHandler",
"(",
")",
";",
"dataHandler",
".",
"createDirectories",
"(",
"dataDir",
",",
"workDir",
")",
";",
"dataHandler",
".",
"createTestData",
"(",
"dataDir",
",",
"syncOptConfig",
".",
"getNumFiles",
"(",
")",
",",
"syncOptConfig",
".",
"getSizeFiles",
"(",
")",
")",
";",
"SyncTestManager",
"testManager",
"=",
"new",
"SyncTestManager",
"(",
"syncOptConfig",
",",
"dataDir",
",",
"workDir",
",",
"syncTestStatus",
",",
"prefix",
")",
";",
"int",
"optimalThreads",
"=",
"testManager",
".",
"runTest",
"(",
")",
";",
"dataHandler",
".",
"removeDirectories",
"(",
"dataDir",
",",
"workDir",
")",
";",
"return",
"optimalThreads",
";",
"}"
] | Determines the optimal SyncTool thread count value. This value is
discovered by running a series of timed tests and returning the fastest
performer. The results of these tests depend highly on the machine they
are run on, and the capacity of the network available to that machine.
@param syncOptConfig tool configuration
@return optimal thread count
@throws IOException | [
"Determines",
"the",
"optimal",
"SyncTool",
"thread",
"count",
"value",
".",
"This",
"value",
"is",
"discovered",
"by",
"running",
"a",
"series",
"of",
"timed",
"tests",
"and",
"returning",
"the",
"fastest",
"performer",
".",
"The",
"results",
"of",
"these",
"tests",
"depend",
"highly",
"on",
"the",
"machine",
"they",
"are",
"run",
"on",
"and",
"the",
"capacity",
"of",
"the",
"network",
"available",
"to",
"that",
"machine",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/syncoptimize/src/main/java/org/duracloud/syncoptimize/SyncOptimizeDriver.java#L74-L97 |
141,472 | duracloud/duracloud | syncoptimize/src/main/java/org/duracloud/syncoptimize/SyncOptimizeDriver.java | SyncOptimizeDriver.main | public static void main(String[] args) throws Exception {
SyncOptimizeDriver syncOptDriver = new SyncOptimizeDriver(true);
SyncOptimizeConfig syncOptConfig =
syncOptDriver.processCommandLineArgs(args);
System.out.println("### Running Sync Thread Optimizer with configuration: " +
syncOptConfig.getPrintableConfig());
int optimalThreads = syncOptDriver.getOptimalThreads(syncOptConfig);
System.out.println("### Sync Thread Optimizer complete. Optimal thread " +
"count for running the DuraCloud SyncTool on " +
"this machine is: " + optimalThreads);
} | java | public static void main(String[] args) throws Exception {
SyncOptimizeDriver syncOptDriver = new SyncOptimizeDriver(true);
SyncOptimizeConfig syncOptConfig =
syncOptDriver.processCommandLineArgs(args);
System.out.println("### Running Sync Thread Optimizer with configuration: " +
syncOptConfig.getPrintableConfig());
int optimalThreads = syncOptDriver.getOptimalThreads(syncOptConfig);
System.out.println("### Sync Thread Optimizer complete. Optimal thread " +
"count for running the DuraCloud SyncTool on " +
"this machine is: " + optimalThreads);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"SyncOptimizeDriver",
"syncOptDriver",
"=",
"new",
"SyncOptimizeDriver",
"(",
"true",
")",
";",
"SyncOptimizeConfig",
"syncOptConfig",
"=",
"syncOptDriver",
".",
"processCommandLineArgs",
"(",
"args",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"### Running Sync Thread Optimizer with configuration: \"",
"+",
"syncOptConfig",
".",
"getPrintableConfig",
"(",
")",
")",
";",
"int",
"optimalThreads",
"=",
"syncOptDriver",
".",
"getOptimalThreads",
"(",
"syncOptConfig",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"### Sync Thread Optimizer complete. Optimal thread \"",
"+",
"\"count for running the DuraCloud SyncTool on \"",
"+",
"\"this machine is: \"",
"+",
"optimalThreads",
")",
";",
"}"
] | Picks up the command line parameters and kicks off the optimization tests
@param args
@throws Exception | [
"Picks",
"up",
"the",
"command",
"line",
"parameters",
"and",
"kicks",
"off",
"the",
"optimization",
"tests"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/syncoptimize/src/main/java/org/duracloud/syncoptimize/SyncOptimizeDriver.java#L126-L139 |
141,473 | duracloud/duracloud | snapshotdata/src/main/java/org/duracloud/snapshot/dto/bridge/CancelSnapshotBridgeResult.java | CancelSnapshotBridgeResult.deserialize | public static CancelSnapshotBridgeResult deserialize(String bridgeResult) {
JaxbJsonSerializer<CancelSnapshotBridgeResult> serializer =
new JaxbJsonSerializer<>(CancelSnapshotBridgeResult.class);
try {
return serializer.deserialize(bridgeResult);
} catch (IOException e) {
throw new SnapshotDataException(
"Unable to deserialize result due to: " + e.getMessage());
}
} | java | public static CancelSnapshotBridgeResult deserialize(String bridgeResult) {
JaxbJsonSerializer<CancelSnapshotBridgeResult> serializer =
new JaxbJsonSerializer<>(CancelSnapshotBridgeResult.class);
try {
return serializer.deserialize(bridgeResult);
} catch (IOException e) {
throw new SnapshotDataException(
"Unable to deserialize result due to: " + e.getMessage());
}
} | [
"public",
"static",
"CancelSnapshotBridgeResult",
"deserialize",
"(",
"String",
"bridgeResult",
")",
"{",
"JaxbJsonSerializer",
"<",
"CancelSnapshotBridgeResult",
">",
"serializer",
"=",
"new",
"JaxbJsonSerializer",
"<>",
"(",
"CancelSnapshotBridgeResult",
".",
"class",
")",
";",
"try",
"{",
"return",
"serializer",
".",
"deserialize",
"(",
"bridgeResult",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SnapshotDataException",
"(",
"\"Unable to deserialize result due to: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Parses properties from bridge result string
@param bridgeResult - JSON formatted set of properties | [
"Parses",
"properties",
"from",
"bridge",
"result",
"string"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/snapshotdata/src/main/java/org/duracloud/snapshot/dto/bridge/CancelSnapshotBridgeResult.java#L66-L75 |
141,474 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/SerializationUtil.java | SerializationUtil.serializeMap | public static String serializeMap(Map<String, String> map) {
if (map == null) {
map = new HashMap<String, String>();
}
XStream xstream = new XStream(new DomDriver());
return xstream.toXML(map);
} | java | public static String serializeMap(Map<String, String> map) {
if (map == null) {
map = new HashMap<String, String>();
}
XStream xstream = new XStream(new DomDriver());
return xstream.toXML(map);
} | [
"public",
"static",
"String",
"serializeMap",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"map",
")",
"{",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"}",
"XStream",
"xstream",
"=",
"new",
"XStream",
"(",
"new",
"DomDriver",
"(",
")",
")",
";",
"return",
"xstream",
".",
"toXML",
"(",
"map",
")",
";",
"}"
] | Serializes a Map to XML. If the map is either empty or null
the XML will indicate an empty map.
@param map
@return | [
"Serializes",
"a",
"Map",
"to",
"XML",
".",
"If",
"the",
"map",
"is",
"either",
"empty",
"or",
"null",
"the",
"XML",
"will",
"indicate",
"an",
"empty",
"map",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/SerializationUtil.java#L38-L44 |
141,475 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/SerializationUtil.java | SerializationUtil.deserializeMap | @SuppressWarnings("unchecked")
public static Map<String, String> deserializeMap(String map) {
if (map == null || map.equals("")) {
return new HashMap<String, String>();
} else {
XStream xstream = new XStream(new DomDriver());
return (Map<String, String>) xstream.fromXML(map);
}
} | java | @SuppressWarnings("unchecked")
public static Map<String, String> deserializeMap(String map) {
if (map == null || map.equals("")) {
return new HashMap<String, String>();
} else {
XStream xstream = new XStream(new DomDriver());
return (Map<String, String>) xstream.fromXML(map);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"deserializeMap",
"(",
"String",
"map",
")",
"{",
"if",
"(",
"map",
"==",
"null",
"||",
"map",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"}",
"else",
"{",
"XStream",
"xstream",
"=",
"new",
"XStream",
"(",
"new",
"DomDriver",
"(",
")",
")",
";",
"return",
"(",
"Map",
"<",
"String",
",",
"String",
">",
")",
"xstream",
".",
"fromXML",
"(",
"map",
")",
";",
"}",
"}"
] | DeSerializes XML into a Map. If the XML is either empty or
null an empty Map is returned.
@param map
@return | [
"DeSerializes",
"XML",
"into",
"a",
"Map",
".",
"If",
"the",
"XML",
"is",
"either",
"empty",
"or",
"null",
"an",
"empty",
"Map",
"is",
"returned",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/SerializationUtil.java#L53-L61 |
141,476 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/SerializationUtil.java | SerializationUtil.deserializeList | @SuppressWarnings("unchecked")
public static List<String> deserializeList(String list) {
if (list == null || list.equals("")) {
return new ArrayList<String>();
}
XStream xstream = new XStream(new DomDriver());
return (List<String>) xstream.fromXML(list);
} | java | @SuppressWarnings("unchecked")
public static List<String> deserializeList(String list) {
if (list == null || list.equals("")) {
return new ArrayList<String>();
}
XStream xstream = new XStream(new DomDriver());
return (List<String>) xstream.fromXML(list);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"List",
"<",
"String",
">",
"deserializeList",
"(",
"String",
"list",
")",
"{",
"if",
"(",
"list",
"==",
"null",
"||",
"list",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"}",
"XStream",
"xstream",
"=",
"new",
"XStream",
"(",
"new",
"DomDriver",
"(",
")",
")",
";",
"return",
"(",
"List",
"<",
"String",
">",
")",
"xstream",
".",
"fromXML",
"(",
"list",
")",
";",
"}"
] | DeSerializes XML into a List of Strings. If the XML is either
empty or null an empty List is returned.
@param list
@return | [
"DeSerializes",
"XML",
"into",
"a",
"List",
"of",
"Strings",
".",
"If",
"the",
"XML",
"is",
"either",
"empty",
"or",
"null",
"an",
"empty",
"List",
"is",
"returned",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/SerializationUtil.java#L85-L92 |
141,477 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/SerializationUtil.java | SerializationUtil.deserializeSet | @SuppressWarnings("unchecked")
public static Set<String> deserializeSet(String set) {
if (set == null || set.equals("")) {
return new HashSet<String>();
}
XStream xstream = new XStream(new DomDriver());
return (Set<String>) xstream.fromXML(set);
} | java | @SuppressWarnings("unchecked")
public static Set<String> deserializeSet(String set) {
if (set == null || set.equals("")) {
return new HashSet<String>();
}
XStream xstream = new XStream(new DomDriver());
return (Set<String>) xstream.fromXML(set);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Set",
"<",
"String",
">",
"deserializeSet",
"(",
"String",
"set",
")",
"{",
"if",
"(",
"set",
"==",
"null",
"||",
"set",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"}",
"XStream",
"xstream",
"=",
"new",
"XStream",
"(",
"new",
"DomDriver",
"(",
")",
")",
";",
"return",
"(",
"Set",
"<",
"String",
">",
")",
"xstream",
".",
"fromXML",
"(",
"set",
")",
";",
"}"
] | DeSerializes XML into a Set of Strings. If the XML is either
empty or null an empty List is returned.
@param set serialized as a String
@return deserialized Set | [
"DeSerializes",
"XML",
"into",
"a",
"Set",
"of",
"Strings",
".",
"If",
"the",
"XML",
"is",
"either",
"empty",
"or",
"null",
"an",
"empty",
"List",
"is",
"returned",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/SerializationUtil.java#L116-L123 |
141,478 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/ChecksumUtil.java | ChecksumUtil.wrapStream | public static DigestInputStream wrapStream(InputStream inStream,
Algorithm algorithm) {
MessageDigest streamDigest = null;
try {
streamDigest = MessageDigest.getInstance(algorithm.toString());
} catch (NoSuchAlgorithmException e) {
String error = "Could not create a MessageDigest because the " +
"required algorithm " + algorithm.toString() +
" is not supported.";
throw new RuntimeException(error);
}
DigestInputStream wrappedContent =
new DigestInputStream(inStream, streamDigest);
return wrappedContent;
} | java | public static DigestInputStream wrapStream(InputStream inStream,
Algorithm algorithm) {
MessageDigest streamDigest = null;
try {
streamDigest = MessageDigest.getInstance(algorithm.toString());
} catch (NoSuchAlgorithmException e) {
String error = "Could not create a MessageDigest because the " +
"required algorithm " + algorithm.toString() +
" is not supported.";
throw new RuntimeException(error);
}
DigestInputStream wrappedContent =
new DigestInputStream(inStream, streamDigest);
return wrappedContent;
} | [
"public",
"static",
"DigestInputStream",
"wrapStream",
"(",
"InputStream",
"inStream",
",",
"Algorithm",
"algorithm",
")",
"{",
"MessageDigest",
"streamDigest",
"=",
"null",
";",
"try",
"{",
"streamDigest",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"algorithm",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"String",
"error",
"=",
"\"Could not create a MessageDigest because the \"",
"+",
"\"required algorithm \"",
"+",
"algorithm",
".",
"toString",
"(",
")",
"+",
"\" is not supported.\"",
";",
"throw",
"new",
"RuntimeException",
"(",
"error",
")",
";",
"}",
"DigestInputStream",
"wrappedContent",
"=",
"new",
"DigestInputStream",
"(",
"inStream",
",",
"streamDigest",
")",
";",
"return",
"wrappedContent",
";",
"}"
] | Wraps an InputStream with a DigestInputStream in order to compute
a checksum as the stream is being read.
@param inStream The stream to wrap
@param algorithm The algorithm used to compute the digest
@return The original stream wrapped as a DigestInputStream | [
"Wraps",
"an",
"InputStream",
"with",
"a",
"DigestInputStream",
"in",
"order",
"to",
"compute",
"a",
"checksum",
"as",
"the",
"stream",
"is",
"being",
"read",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/ChecksumUtil.java#L129-L144 |
141,479 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/ChecksumUtil.java | ChecksumUtil.getChecksum | public static String getChecksum(DigestInputStream digestStream) {
MessageDigest digest = digestStream.getMessageDigest();
return checksumBytesToString(digest.digest());
} | java | public static String getChecksum(DigestInputStream digestStream) {
MessageDigest digest = digestStream.getMessageDigest();
return checksumBytesToString(digest.digest());
} | [
"public",
"static",
"String",
"getChecksum",
"(",
"DigestInputStream",
"digestStream",
")",
"{",
"MessageDigest",
"digest",
"=",
"digestStream",
".",
"getMessageDigest",
"(",
")",
";",
"return",
"checksumBytesToString",
"(",
"digest",
".",
"digest",
"(",
")",
")",
";",
"}"
] | Determines the checksum value of a DigestInputStream's underlying
stream after the stream has been read.
@param digestStream
@return The checksum value of the stream's contents | [
"Determines",
"the",
"checksum",
"value",
"of",
"a",
"DigestInputStream",
"s",
"underlying",
"stream",
"after",
"the",
"stream",
"has",
"been",
"read",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/ChecksumUtil.java#L153-L156 |
141,480 | duracloud/duracloud | common/src/main/java/org/duracloud/common/util/ChecksumUtil.java | ChecksumUtil.checksumBytesToString | public static String checksumBytesToString(byte[] digestBytes) {
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < digestBytes.length; i++) {
String hex = Integer.toHexString(0xff & digestBytes[i]);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
} | java | public static String checksumBytesToString(byte[] digestBytes) {
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < digestBytes.length; i++) {
String hex = Integer.toHexString(0xff & digestBytes[i]);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
} | [
"public",
"static",
"String",
"checksumBytesToString",
"(",
"byte",
"[",
"]",
"digestBytes",
")",
"{",
"StringBuffer",
"hexString",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"digestBytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"hex",
"=",
"Integer",
".",
"toHexString",
"(",
"0xff",
"&",
"digestBytes",
"[",
"i",
"]",
")",
";",
"if",
"(",
"hex",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"hexString",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"hexString",
".",
"append",
"(",
"hex",
")",
";",
"}",
"return",
"hexString",
".",
"toString",
"(",
")",
";",
"}"
] | Converts a message digest byte array into a String based
on the hex values appearing in the array. | [
"Converts",
"a",
"message",
"digest",
"byte",
"array",
"into",
"a",
"String",
"based",
"on",
"the",
"hex",
"values",
"appearing",
"in",
"the",
"array",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/common/src/main/java/org/duracloud/common/util/ChecksumUtil.java#L174-L184 |
141,481 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/manifest/xml/ManifestDocumentBinding.java | ManifestDocumentBinding.createManifestFrom | public static ChunksManifest createManifestFrom(InputStream xml) {
try {
ChunksManifestDocument doc = ChunksManifestDocument.Factory.parse(
xml);
return ManifestElementReader.createManifestFrom(doc);
} catch (XmlException e) {
throw new DuraCloudRuntimeException(e);
} catch (IOException e) {
throw new DuraCloudRuntimeException(e);
}
} | java | public static ChunksManifest createManifestFrom(InputStream xml) {
try {
ChunksManifestDocument doc = ChunksManifestDocument.Factory.parse(
xml);
return ManifestElementReader.createManifestFrom(doc);
} catch (XmlException e) {
throw new DuraCloudRuntimeException(e);
} catch (IOException e) {
throw new DuraCloudRuntimeException(e);
}
} | [
"public",
"static",
"ChunksManifest",
"createManifestFrom",
"(",
"InputStream",
"xml",
")",
"{",
"try",
"{",
"ChunksManifestDocument",
"doc",
"=",
"ChunksManifestDocument",
".",
"Factory",
".",
"parse",
"(",
"xml",
")",
";",
"return",
"ManifestElementReader",
".",
"createManifestFrom",
"(",
"doc",
")",
";",
"}",
"catch",
"(",
"XmlException",
"e",
")",
"{",
"throw",
"new",
"DuraCloudRuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"DuraCloudRuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | This method binds a ChunksManifest object to the content of the arg xml.
@param xml manifest document to be bound to ChunksManifest object
@return ChunksManifest object | [
"This",
"method",
"binds",
"a",
"ChunksManifest",
"object",
"to",
"the",
"content",
"of",
"the",
"arg",
"xml",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/manifest/xml/ManifestDocumentBinding.java#L41-L51 |
141,482 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/manifest/xml/ManifestDocumentBinding.java | ManifestDocumentBinding.createDocumentFrom | public static String createDocumentFrom(ChunksManifestBean manifest) {
ChunksManifestDocument doc = ChunksManifestDocument.Factory
.newInstance();
if (null != manifest) {
ChunksManifestType manifestType = ManifestElementWriter.createChunksManifestElementFrom(
manifest);
doc.setChunksManifest(manifestType);
}
return docToString(doc);
} | java | public static String createDocumentFrom(ChunksManifestBean manifest) {
ChunksManifestDocument doc = ChunksManifestDocument.Factory
.newInstance();
if (null != manifest) {
ChunksManifestType manifestType = ManifestElementWriter.createChunksManifestElementFrom(
manifest);
doc.setChunksManifest(manifestType);
}
return docToString(doc);
} | [
"public",
"static",
"String",
"createDocumentFrom",
"(",
"ChunksManifestBean",
"manifest",
")",
"{",
"ChunksManifestDocument",
"doc",
"=",
"ChunksManifestDocument",
".",
"Factory",
".",
"newInstance",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"manifest",
")",
"{",
"ChunksManifestType",
"manifestType",
"=",
"ManifestElementWriter",
".",
"createChunksManifestElementFrom",
"(",
"manifest",
")",
";",
"doc",
".",
"setChunksManifest",
"(",
"manifestType",
")",
";",
"}",
"return",
"docToString",
"(",
"doc",
")",
";",
"}"
] | This method serializes the arg ChunksManifest object into an xml document.
@param manifest ChunksManifest object to be serialized
@return ChunksManifest xml document | [
"This",
"method",
"serializes",
"the",
"arg",
"ChunksManifest",
"object",
"into",
"an",
"xml",
"document",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/manifest/xml/ManifestDocumentBinding.java#L59-L68 |
141,483 | duracloud/duracloud | snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/SpaceModifyingSnapshotTaskRunner.java | SpaceModifyingSnapshotTaskRunner.storeSnapshotProps | protected void storeSnapshotProps(String spaceId, String serializedProps) {
InputStream propsStream;
try {
propsStream = IOUtil.writeStringToStream(serializedProps);
} catch (IOException e) {
throw new TaskException("Unable to build stream from serialized " +
"snapshot properties due to: " +
e.getMessage());
}
ChecksumUtil checksumUtil = new ChecksumUtil(ChecksumUtil.Algorithm.MD5);
String propsChecksum = checksumUtil.generateChecksum(serializedProps);
snapshotProvider.addContent(spaceId,
Constants.SNAPSHOT_PROPS_FILENAME,
"text/x-java-properties",
null,
// Ensures that length is based on UTF-8 encoded bytes
serializedProps.getBytes(StandardCharsets.UTF_8).length,
propsChecksum,
propsStream);
} | java | protected void storeSnapshotProps(String spaceId, String serializedProps) {
InputStream propsStream;
try {
propsStream = IOUtil.writeStringToStream(serializedProps);
} catch (IOException e) {
throw new TaskException("Unable to build stream from serialized " +
"snapshot properties due to: " +
e.getMessage());
}
ChecksumUtil checksumUtil = new ChecksumUtil(ChecksumUtil.Algorithm.MD5);
String propsChecksum = checksumUtil.generateChecksum(serializedProps);
snapshotProvider.addContent(spaceId,
Constants.SNAPSHOT_PROPS_FILENAME,
"text/x-java-properties",
null,
// Ensures that length is based on UTF-8 encoded bytes
serializedProps.getBytes(StandardCharsets.UTF_8).length,
propsChecksum,
propsStream);
} | [
"protected",
"void",
"storeSnapshotProps",
"(",
"String",
"spaceId",
",",
"String",
"serializedProps",
")",
"{",
"InputStream",
"propsStream",
";",
"try",
"{",
"propsStream",
"=",
"IOUtil",
".",
"writeStringToStream",
"(",
"serializedProps",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"TaskException",
"(",
"\"Unable to build stream from serialized \"",
"+",
"\"snapshot properties due to: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"ChecksumUtil",
"checksumUtil",
"=",
"new",
"ChecksumUtil",
"(",
"ChecksumUtil",
".",
"Algorithm",
".",
"MD5",
")",
";",
"String",
"propsChecksum",
"=",
"checksumUtil",
".",
"generateChecksum",
"(",
"serializedProps",
")",
";",
"snapshotProvider",
".",
"addContent",
"(",
"spaceId",
",",
"Constants",
".",
"SNAPSHOT_PROPS_FILENAME",
",",
"\"text/x-java-properties\"",
",",
"null",
",",
"// Ensures that length is based on UTF-8 encoded bytes",
"serializedProps",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
".",
"length",
",",
"propsChecksum",
",",
"propsStream",
")",
";",
"}"
] | Stores a set of snapshot properties in the given space as a properties file.
@param spaceId the space in which the properties file should be stored
@param serializedProps properties in serialized format | [
"Stores",
"a",
"set",
"of",
"snapshot",
"properties",
"in",
"the",
"given",
"space",
"as",
"a",
"properties",
"file",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/SpaceModifyingSnapshotTaskRunner.java#L79-L99 |
141,484 | duracloud/duracloud | snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/SpaceModifyingSnapshotTaskRunner.java | SpaceModifyingSnapshotTaskRunner.getSnapshotIdFromProperties | protected String getSnapshotIdFromProperties(String spaceId) {
Properties props = new Properties();
try (InputStream is = this.snapshotProvider.getContent(spaceId, Constants.SNAPSHOT_PROPS_FILENAME)
.getContentStream()) {
props.load(is);
return props.getProperty(Constants.SNAPSHOT_ID_PROP);
} catch (NotFoundException ex) {
return null;
} catch (Exception e) {
throw new TaskException(
MessageFormat.format("Call to create snapshot failed, unable to determine existence of " +
"snapshot properties file in {0}. Error: {1}", spaceId, e.getMessage()));
}
} | java | protected String getSnapshotIdFromProperties(String spaceId) {
Properties props = new Properties();
try (InputStream is = this.snapshotProvider.getContent(spaceId, Constants.SNAPSHOT_PROPS_FILENAME)
.getContentStream()) {
props.load(is);
return props.getProperty(Constants.SNAPSHOT_ID_PROP);
} catch (NotFoundException ex) {
return null;
} catch (Exception e) {
throw new TaskException(
MessageFormat.format("Call to create snapshot failed, unable to determine existence of " +
"snapshot properties file in {0}. Error: {1}", spaceId, e.getMessage()));
}
} | [
"protected",
"String",
"getSnapshotIdFromProperties",
"(",
"String",
"spaceId",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"try",
"(",
"InputStream",
"is",
"=",
"this",
".",
"snapshotProvider",
".",
"getContent",
"(",
"spaceId",
",",
"Constants",
".",
"SNAPSHOT_PROPS_FILENAME",
")",
".",
"getContentStream",
"(",
")",
")",
"{",
"props",
".",
"load",
"(",
"is",
")",
";",
"return",
"props",
".",
"getProperty",
"(",
"Constants",
".",
"SNAPSHOT_ID_PROP",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"TaskException",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Call to create snapshot failed, unable to determine existence of \"",
"+",
"\"snapshot properties file in {0}. Error: {1}\"",
",",
"spaceId",
",",
"e",
".",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"}"
] | Returns snapshot from the snapshot properties file if it exists
@param spaceId
@return snapshot from the snapshot properties file if it exists, otherwise null | [
"Returns",
"snapshot",
"from",
"the",
"snapshot",
"properties",
"file",
"if",
"it",
"exists"
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/SpaceModifyingSnapshotTaskRunner.java#L107-L120 |
141,485 | duracloud/duracloud | snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/SpaceModifyingSnapshotTaskRunner.java | SpaceModifyingSnapshotTaskRunner.snapshotPropsPresentInSpace | protected boolean snapshotPropsPresentInSpace(String spaceId) {
try {
snapshotProvider.getContentProperties(spaceId, Constants.SNAPSHOT_PROPS_FILENAME);
return true;
} catch (NotFoundException ex) {
return false;
}
} | java | protected boolean snapshotPropsPresentInSpace(String spaceId) {
try {
snapshotProvider.getContentProperties(spaceId, Constants.SNAPSHOT_PROPS_FILENAME);
return true;
} catch (NotFoundException ex) {
return false;
}
} | [
"protected",
"boolean",
"snapshotPropsPresentInSpace",
"(",
"String",
"spaceId",
")",
"{",
"try",
"{",
"snapshotProvider",
".",
"getContentProperties",
"(",
"spaceId",
",",
"Constants",
".",
"SNAPSHOT_PROPS_FILENAME",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"NotFoundException",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Checks if the snapshot props file is in the space.
@param spaceId
@return | [
"Checks",
"if",
"the",
"snapshot",
"props",
"file",
"is",
"in",
"the",
"space",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/snapshotstorageprovider/src/main/java/org/duracloud/snapshottask/snapshot/SpaceModifyingSnapshotTaskRunner.java#L204-L211 |
141,486 | duracloud/duracloud | chunk/src/main/java/org/duracloud/chunk/manifest/xml/ManifestElementWriter.java | ManifestElementWriter.createChunksManifestElementFrom | public static ChunksManifestType createChunksManifestElementFrom(
ChunksManifestBean manifest) {
ChunksManifestType manifestType = ChunksManifestType.Factory
.newInstance();
populateElementFromObject(manifestType, manifest);
return manifestType;
} | java | public static ChunksManifestType createChunksManifestElementFrom(
ChunksManifestBean manifest) {
ChunksManifestType manifestType = ChunksManifestType.Factory
.newInstance();
populateElementFromObject(manifestType, manifest);
return manifestType;
} | [
"public",
"static",
"ChunksManifestType",
"createChunksManifestElementFrom",
"(",
"ChunksManifestBean",
"manifest",
")",
"{",
"ChunksManifestType",
"manifestType",
"=",
"ChunksManifestType",
".",
"Factory",
".",
"newInstance",
"(",
")",
";",
"populateElementFromObject",
"(",
"manifestType",
",",
"manifest",
")",
";",
"return",
"manifestType",
";",
"}"
] | This method serializes a ChunksManifest object into a ChunksManifest
xml element.
@param manifest object to be serialized
@return xml ChunksManifest element with content from arg manifest | [
"This",
"method",
"serializes",
"a",
"ChunksManifest",
"object",
"into",
"a",
"ChunksManifest",
"xml",
"element",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/chunk/src/main/java/org/duracloud/chunk/manifest/xml/ManifestElementWriter.java#L41-L48 |
141,487 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/xml/StorageAccountsDocumentBinding.java | StorageAccountsDocumentBinding.createStorageAccountsFrom | public List<StorageAccount> createStorageAccountsFrom(Element accounts) {
List<StorageAccount> accts = new ArrayList<StorageAccount>();
try {
Iterator<?> accountList = accounts.getChildren().iterator();
while (accountList.hasNext()) {
Element accountXml = (Element) accountList.next();
String type = accountXml.getChildText("storageProviderType");
StorageProviderType acctType = StorageProviderType.fromString(
type);
StorageAccountProviderBinding providerBinding = providerBindings
.get(acctType);
if (null != providerBinding) {
accts.add(providerBinding.getAccountFromXml(accountXml));
} else {
log.warn("Unexpected account type: " + acctType);
}
}
// Make sure that there is at least one storage account
if (accts.isEmpty()) {
String error = "No storage accounts could be read";
throw new StorageException(error);
}
} catch (Exception e) {
String error = "Unable to build storage account information due " +
"to error: " + e.getMessage();
log.error(error);
throw new StorageException(error, e);
}
return accts;
} | java | public List<StorageAccount> createStorageAccountsFrom(Element accounts) {
List<StorageAccount> accts = new ArrayList<StorageAccount>();
try {
Iterator<?> accountList = accounts.getChildren().iterator();
while (accountList.hasNext()) {
Element accountXml = (Element) accountList.next();
String type = accountXml.getChildText("storageProviderType");
StorageProviderType acctType = StorageProviderType.fromString(
type);
StorageAccountProviderBinding providerBinding = providerBindings
.get(acctType);
if (null != providerBinding) {
accts.add(providerBinding.getAccountFromXml(accountXml));
} else {
log.warn("Unexpected account type: " + acctType);
}
}
// Make sure that there is at least one storage account
if (accts.isEmpty()) {
String error = "No storage accounts could be read";
throw new StorageException(error);
}
} catch (Exception e) {
String error = "Unable to build storage account information due " +
"to error: " + e.getMessage();
log.error(error);
throw new StorageException(error, e);
}
return accts;
} | [
"public",
"List",
"<",
"StorageAccount",
">",
"createStorageAccountsFrom",
"(",
"Element",
"accounts",
")",
"{",
"List",
"<",
"StorageAccount",
">",
"accts",
"=",
"new",
"ArrayList",
"<",
"StorageAccount",
">",
"(",
")",
";",
"try",
"{",
"Iterator",
"<",
"?",
">",
"accountList",
"=",
"accounts",
".",
"getChildren",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"accountList",
".",
"hasNext",
"(",
")",
")",
"{",
"Element",
"accountXml",
"=",
"(",
"Element",
")",
"accountList",
".",
"next",
"(",
")",
";",
"String",
"type",
"=",
"accountXml",
".",
"getChildText",
"(",
"\"storageProviderType\"",
")",
";",
"StorageProviderType",
"acctType",
"=",
"StorageProviderType",
".",
"fromString",
"(",
"type",
")",
";",
"StorageAccountProviderBinding",
"providerBinding",
"=",
"providerBindings",
".",
"get",
"(",
"acctType",
")",
";",
"if",
"(",
"null",
"!=",
"providerBinding",
")",
"{",
"accts",
".",
"add",
"(",
"providerBinding",
".",
"getAccountFromXml",
"(",
"accountXml",
")",
")",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"\"Unexpected account type: \"",
"+",
"acctType",
")",
";",
"}",
"}",
"// Make sure that there is at least one storage account",
"if",
"(",
"accts",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"error",
"=",
"\"No storage accounts could be read\"",
";",
"throw",
"new",
"StorageException",
"(",
"error",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"error",
"=",
"\"Unable to build storage account information due \"",
"+",
"\"to error: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"log",
".",
"error",
"(",
"error",
")",
";",
"throw",
"new",
"StorageException",
"(",
"error",
",",
"e",
")",
";",
"}",
"return",
"accts",
";",
"}"
] | This method deserializes the provided xml into a durastore acct config object.
@param accounts
@return | [
"This",
"method",
"deserializes",
"the",
"provided",
"xml",
"into",
"a",
"durastore",
"acct",
"config",
"object",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/xml/StorageAccountsDocumentBinding.java#L60-L95 |
141,488 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/xml/StorageAccountsDocumentBinding.java | StorageAccountsDocumentBinding.createStorageAccountsFromXml | public List<StorageAccount> createStorageAccountsFromXml(InputStream xml) {
try {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xml);
Element root = doc.getRootElement();
return createStorageAccountsFrom(root);
} catch (Exception e) {
String error = "Could not build storage accounts from xml " +
"due to: " + e.getMessage();
throw new DuraCloudRuntimeException(error, e);
}
} | java | public List<StorageAccount> createStorageAccountsFromXml(InputStream xml) {
try {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xml);
Element root = doc.getRootElement();
return createStorageAccountsFrom(root);
} catch (Exception e) {
String error = "Could not build storage accounts from xml " +
"due to: " + e.getMessage();
throw new DuraCloudRuntimeException(error, e);
}
} | [
"public",
"List",
"<",
"StorageAccount",
">",
"createStorageAccountsFromXml",
"(",
"InputStream",
"xml",
")",
"{",
"try",
"{",
"SAXBuilder",
"builder",
"=",
"new",
"SAXBuilder",
"(",
")",
";",
"Document",
"doc",
"=",
"builder",
".",
"build",
"(",
"xml",
")",
";",
"Element",
"root",
"=",
"doc",
".",
"getRootElement",
"(",
")",
";",
"return",
"createStorageAccountsFrom",
"(",
"root",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"error",
"=",
"\"Could not build storage accounts from xml \"",
"+",
"\"due to: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"DuraCloudRuntimeException",
"(",
"error",
",",
"e",
")",
";",
"}",
"}"
] | Creates storage accounts listing from XML which includes only the
storage accounts list (not the full DuraStore config. This is used
to parse the response of the GET stores DuraStore REST call.
@param xml
@return | [
"Creates",
"storage",
"accounts",
"listing",
"from",
"XML",
"which",
"includes",
"only",
"the",
"storage",
"accounts",
"list",
"(",
"not",
"the",
"full",
"DuraStore",
"config",
".",
"This",
"is",
"used",
"to",
"parse",
"the",
"response",
"of",
"the",
"GET",
"stores",
"DuraStore",
"REST",
"call",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/xml/StorageAccountsDocumentBinding.java#L105-L116 |
141,489 | duracloud/duracloud | storageprovider/src/main/java/org/duracloud/storage/xml/StorageAccountsDocumentBinding.java | StorageAccountsDocumentBinding.createXmlFrom | public String createXmlFrom(Collection<StorageAccount> accts,
boolean includeCredentials,
boolean includeOptions) {
Element storageProviderAccounts =
createDocumentFrom(accts, includeCredentials, includeOptions);
Document document = new Document(storageProviderAccounts);
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
return outputter.outputString(document);
} | java | public String createXmlFrom(Collection<StorageAccount> accts,
boolean includeCredentials,
boolean includeOptions) {
Element storageProviderAccounts =
createDocumentFrom(accts, includeCredentials, includeOptions);
Document document = new Document(storageProviderAccounts);
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
return outputter.outputString(document);
} | [
"public",
"String",
"createXmlFrom",
"(",
"Collection",
"<",
"StorageAccount",
">",
"accts",
",",
"boolean",
"includeCredentials",
",",
"boolean",
"includeOptions",
")",
"{",
"Element",
"storageProviderAccounts",
"=",
"createDocumentFrom",
"(",
"accts",
",",
"includeCredentials",
",",
"includeOptions",
")",
";",
"Document",
"document",
"=",
"new",
"Document",
"(",
"storageProviderAccounts",
")",
";",
"XMLOutputter",
"outputter",
"=",
"new",
"XMLOutputter",
"(",
"Format",
".",
"getPrettyFormat",
"(",
")",
")",
";",
"return",
"outputter",
".",
"outputString",
"(",
"document",
")",
";",
"}"
] | Converts the provided DuraStore acct configuration into a stand-alone
XML document. This is used for the DuraStore GET stores REST call.
@param accts
@return | [
"Converts",
"the",
"provided",
"DuraStore",
"acct",
"configuration",
"into",
"a",
"stand",
"-",
"alone",
"XML",
"document",
".",
"This",
"is",
"used",
"for",
"the",
"DuraStore",
"GET",
"stores",
"REST",
"call",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/storageprovider/src/main/java/org/duracloud/storage/xml/StorageAccountsDocumentBinding.java#L156-L164 |
141,490 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/SyncTool.java | SyncTool.setSyncConfig | protected void setSyncConfig(SyncToolConfig syncConfig) {
this.syncConfig = syncConfig;
this.syncConfig.setVersion(version);
File exclusionListFile = this.syncConfig.getExcludeList();
if (exclusionListFile != null) {
this.fileExclusionManager = new FileExclusionManager(exclusionListFile);
} else {
this.fileExclusionManager = new FileExclusionManager();
}
ChangedList.getInstance()
.setFileExclusionManager(this.fileExclusionManager);
} | java | protected void setSyncConfig(SyncToolConfig syncConfig) {
this.syncConfig = syncConfig;
this.syncConfig.setVersion(version);
File exclusionListFile = this.syncConfig.getExcludeList();
if (exclusionListFile != null) {
this.fileExclusionManager = new FileExclusionManager(exclusionListFile);
} else {
this.fileExclusionManager = new FileExclusionManager();
}
ChangedList.getInstance()
.setFileExclusionManager(this.fileExclusionManager);
} | [
"protected",
"void",
"setSyncConfig",
"(",
"SyncToolConfig",
"syncConfig",
")",
"{",
"this",
".",
"syncConfig",
"=",
"syncConfig",
";",
"this",
".",
"syncConfig",
".",
"setVersion",
"(",
"version",
")",
";",
"File",
"exclusionListFile",
"=",
"this",
".",
"syncConfig",
".",
"getExcludeList",
"(",
")",
";",
"if",
"(",
"exclusionListFile",
"!=",
"null",
")",
"{",
"this",
".",
"fileExclusionManager",
"=",
"new",
"FileExclusionManager",
"(",
"exclusionListFile",
")",
";",
"}",
"else",
"{",
"this",
".",
"fileExclusionManager",
"=",
"new",
"FileExclusionManager",
"(",
")",
";",
"}",
"ChangedList",
".",
"getInstance",
"(",
")",
".",
"setFileExclusionManager",
"(",
"this",
".",
"fileExclusionManager",
")",
";",
"}"
] | Sets the configuration of the sync tool.
@param syncConfig to use for running the Sync Tool | [
"Sets",
"the",
"configuration",
"of",
"the",
"sync",
"tool",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/SyncTool.java#L83-L96 |
141,491 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/SyncTool.java | SyncTool.restartPossible | protected boolean restartPossible() {
boolean restart = false;
if (!syncConfig.isCleanStart()) {
// Determines if the configuration has been changed since the
// previous run. If it has, a restart cannot occur.
SyncToolConfigParser syncConfigParser = new SyncToolConfigParser();
SyncToolConfig prevConfig =
syncConfigParser.retrievePrevConfig(syncConfig.getWorkDir());
if (prevConfig != null) {
restart = configEquals(syncConfig, prevConfig);
}
}
return restart;
} | java | protected boolean restartPossible() {
boolean restart = false;
if (!syncConfig.isCleanStart()) {
// Determines if the configuration has been changed since the
// previous run. If it has, a restart cannot occur.
SyncToolConfigParser syncConfigParser = new SyncToolConfigParser();
SyncToolConfig prevConfig =
syncConfigParser.retrievePrevConfig(syncConfig.getWorkDir());
if (prevConfig != null) {
restart = configEquals(syncConfig, prevConfig);
}
}
return restart;
} | [
"protected",
"boolean",
"restartPossible",
"(",
")",
"{",
"boolean",
"restart",
"=",
"false",
";",
"if",
"(",
"!",
"syncConfig",
".",
"isCleanStart",
"(",
")",
")",
"{",
"// Determines if the configuration has been changed since the",
"// previous run. If it has, a restart cannot occur.",
"SyncToolConfigParser",
"syncConfigParser",
"=",
"new",
"SyncToolConfigParser",
"(",
")",
";",
"SyncToolConfig",
"prevConfig",
"=",
"syncConfigParser",
".",
"retrievePrevConfig",
"(",
"syncConfig",
".",
"getWorkDir",
"(",
")",
")",
";",
"if",
"(",
"prevConfig",
"!=",
"null",
")",
"{",
"restart",
"=",
"configEquals",
"(",
"syncConfig",
",",
"prevConfig",
")",
";",
"}",
"}",
"return",
"restart",
";",
"}"
] | Determines if this run of the sync tool will perform a restart.
@return true if restart should occur, false otherwise | [
"Determines",
"if",
"this",
"run",
"of",
"the",
"sync",
"tool",
"will",
"perform",
"a",
"restart",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/SyncTool.java#L103-L117 |
141,492 | duracloud/duracloud | synctool/src/main/java/org/duracloud/sync/SyncTool.java | SyncTool.configEquals | protected boolean configEquals(SyncToolConfig currConfig,
SyncToolConfig prevConfig) {
boolean sameHost = currConfig.getHost().equals(prevConfig.getHost());
boolean sameSpaceId =
currConfig.getSpaceId().equals(prevConfig.getSpaceId());
boolean sameStoreId = sameConfig(currConfig.getStoreId(),
prevConfig.getStoreId());
boolean sameSyncDeletes =
currConfig.syncDeletes() == prevConfig.syncDeletes();
boolean sameContentDirs =
currConfig.getContentDirs().equals(prevConfig.getContentDirs());
boolean sameSyncUpdates =
currConfig.isSyncUpdates() == prevConfig.isSyncUpdates();
boolean sameRenameUpdates =
currConfig.isRenameUpdates() == prevConfig.isRenameUpdates();
boolean sameExclude = sameConfig(currConfig.getExcludeList(),
prevConfig.getExcludeList());
boolean samePrefix = sameConfig(currConfig.getPrefix(),
prevConfig.getPrefix());
if (sameHost && sameSpaceId && sameStoreId && sameSyncDeletes &&
sameContentDirs && sameSyncUpdates && sameRenameUpdates &&
sameExclude && samePrefix) {
return true;
}
return false;
} | java | protected boolean configEquals(SyncToolConfig currConfig,
SyncToolConfig prevConfig) {
boolean sameHost = currConfig.getHost().equals(prevConfig.getHost());
boolean sameSpaceId =
currConfig.getSpaceId().equals(prevConfig.getSpaceId());
boolean sameStoreId = sameConfig(currConfig.getStoreId(),
prevConfig.getStoreId());
boolean sameSyncDeletes =
currConfig.syncDeletes() == prevConfig.syncDeletes();
boolean sameContentDirs =
currConfig.getContentDirs().equals(prevConfig.getContentDirs());
boolean sameSyncUpdates =
currConfig.isSyncUpdates() == prevConfig.isSyncUpdates();
boolean sameRenameUpdates =
currConfig.isRenameUpdates() == prevConfig.isRenameUpdates();
boolean sameExclude = sameConfig(currConfig.getExcludeList(),
prevConfig.getExcludeList());
boolean samePrefix = sameConfig(currConfig.getPrefix(),
prevConfig.getPrefix());
if (sameHost && sameSpaceId && sameStoreId && sameSyncDeletes &&
sameContentDirs && sameSyncUpdates && sameRenameUpdates &&
sameExclude && samePrefix) {
return true;
}
return false;
} | [
"protected",
"boolean",
"configEquals",
"(",
"SyncToolConfig",
"currConfig",
",",
"SyncToolConfig",
"prevConfig",
")",
"{",
"boolean",
"sameHost",
"=",
"currConfig",
".",
"getHost",
"(",
")",
".",
"equals",
"(",
"prevConfig",
".",
"getHost",
"(",
")",
")",
";",
"boolean",
"sameSpaceId",
"=",
"currConfig",
".",
"getSpaceId",
"(",
")",
".",
"equals",
"(",
"prevConfig",
".",
"getSpaceId",
"(",
")",
")",
";",
"boolean",
"sameStoreId",
"=",
"sameConfig",
"(",
"currConfig",
".",
"getStoreId",
"(",
")",
",",
"prevConfig",
".",
"getStoreId",
"(",
")",
")",
";",
"boolean",
"sameSyncDeletes",
"=",
"currConfig",
".",
"syncDeletes",
"(",
")",
"==",
"prevConfig",
".",
"syncDeletes",
"(",
")",
";",
"boolean",
"sameContentDirs",
"=",
"currConfig",
".",
"getContentDirs",
"(",
")",
".",
"equals",
"(",
"prevConfig",
".",
"getContentDirs",
"(",
")",
")",
";",
"boolean",
"sameSyncUpdates",
"=",
"currConfig",
".",
"isSyncUpdates",
"(",
")",
"==",
"prevConfig",
".",
"isSyncUpdates",
"(",
")",
";",
"boolean",
"sameRenameUpdates",
"=",
"currConfig",
".",
"isRenameUpdates",
"(",
")",
"==",
"prevConfig",
".",
"isRenameUpdates",
"(",
")",
";",
"boolean",
"sameExclude",
"=",
"sameConfig",
"(",
"currConfig",
".",
"getExcludeList",
"(",
")",
",",
"prevConfig",
".",
"getExcludeList",
"(",
")",
")",
";",
"boolean",
"samePrefix",
"=",
"sameConfig",
"(",
"currConfig",
".",
"getPrefix",
"(",
")",
",",
"prevConfig",
".",
"getPrefix",
"(",
")",
")",
";",
"if",
"(",
"sameHost",
"&&",
"sameSpaceId",
"&&",
"sameStoreId",
"&&",
"sameSyncDeletes",
"&&",
"sameContentDirs",
"&&",
"sameSyncUpdates",
"&&",
"sameRenameUpdates",
"&&",
"sameExclude",
"&&",
"samePrefix",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Determines if two sets of configuration are "equal enough" to indicate
that the content to be reviewed for sync operations has not changed on
either the local or remote end, suggesting that a re-start would be
permissable.
@param currConfig the current sync configuration
@param prevConfig the sync configuration of the previous run
@return true if the configs are "equal enough", false otherwise | [
"Determines",
"if",
"two",
"sets",
"of",
"configuration",
"are",
"equal",
"enough",
"to",
"indicate",
"that",
"the",
"content",
"to",
"be",
"reviewed",
"for",
"sync",
"operations",
"has",
"not",
"changed",
"on",
"either",
"the",
"local",
"or",
"remote",
"end",
"suggesting",
"that",
"a",
"re",
"-",
"start",
"would",
"be",
"permissable",
"."
] | dc4f3a1716d43543cc3b2e1880605f9389849b66 | https://github.com/duracloud/duracloud/blob/dc4f3a1716d43543cc3b2e1880605f9389849b66/synctool/src/main/java/org/duracloud/sync/SyncTool.java#L129-L155 |
141,493 | 3pillarlabs/spring-data-simpledb | spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/reflection/ReflectionUtils.java | ReflectionUtils.hasDeclaredGetterAndSetter | public static <T> boolean hasDeclaredGetterAndSetter(final Field field, Class<T> entityClazz) {
boolean hasDeclaredAccessorsMutators = true;
Method getter = retrieveGetterFrom(entityClazz, field.getName());
Method setter = retrieveSetterFrom(entityClazz, field.getName());
if(getter == null || setter == null) {
hasDeclaredAccessorsMutators = false;
}
return hasDeclaredAccessorsMutators;
} | java | public static <T> boolean hasDeclaredGetterAndSetter(final Field field, Class<T> entityClazz) {
boolean hasDeclaredAccessorsMutators = true;
Method getter = retrieveGetterFrom(entityClazz, field.getName());
Method setter = retrieveSetterFrom(entityClazz, field.getName());
if(getter == null || setter == null) {
hasDeclaredAccessorsMutators = false;
}
return hasDeclaredAccessorsMutators;
} | [
"public",
"static",
"<",
"T",
">",
"boolean",
"hasDeclaredGetterAndSetter",
"(",
"final",
"Field",
"field",
",",
"Class",
"<",
"T",
">",
"entityClazz",
")",
"{",
"boolean",
"hasDeclaredAccessorsMutators",
"=",
"true",
";",
"Method",
"getter",
"=",
"retrieveGetterFrom",
"(",
"entityClazz",
",",
"field",
".",
"getName",
"(",
")",
")",
";",
"Method",
"setter",
"=",
"retrieveSetterFrom",
"(",
"entityClazz",
",",
"field",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"getter",
"==",
"null",
"||",
"setter",
"==",
"null",
")",
"{",
"hasDeclaredAccessorsMutators",
"=",
"false",
";",
"}",
"return",
"hasDeclaredAccessorsMutators",
";",
"}"
] | This method checks if the declared Field is accessible through getters and setters methods Fields which have only
setters OR getters and NOT both are discarded from serialization process | [
"This",
"method",
"checks",
"if",
"the",
"declared",
"Field",
"is",
"accessible",
"through",
"getters",
"and",
"setters",
"methods",
"Fields",
"which",
"have",
"only",
"setters",
"OR",
"getters",
"and",
"NOT",
"both",
"are",
"discarded",
"from",
"serialization",
"process"
] | f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae | https://github.com/3pillarlabs/spring-data-simpledb/blob/f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae/spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/reflection/ReflectionUtils.java#L107-L118 |
141,494 | 3pillarlabs/spring-data-simpledb | spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/reflection/ReflectionUtils.java | ReflectionUtils.getFirstLevelOfReferenceAttributes | public static List<Field> getFirstLevelOfReferenceAttributes(Class<?> clazz) {
List<Field> references = new ArrayList<Field>();
List<String> referencedFields = ReflectionUtils.getReferencedAttributeNames(clazz);
for(String eachReference : referencedFields) {
Field referenceField = ReflectionUtils.getField(clazz, eachReference);
references.add(referenceField);
}
return references;
} | java | public static List<Field> getFirstLevelOfReferenceAttributes(Class<?> clazz) {
List<Field> references = new ArrayList<Field>();
List<String> referencedFields = ReflectionUtils.getReferencedAttributeNames(clazz);
for(String eachReference : referencedFields) {
Field referenceField = ReflectionUtils.getField(clazz, eachReference);
references.add(referenceField);
}
return references;
} | [
"public",
"static",
"List",
"<",
"Field",
">",
"getFirstLevelOfReferenceAttributes",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"List",
"<",
"Field",
">",
"references",
"=",
"new",
"ArrayList",
"<",
"Field",
">",
"(",
")",
";",
"List",
"<",
"String",
">",
"referencedFields",
"=",
"ReflectionUtils",
".",
"getReferencedAttributeNames",
"(",
"clazz",
")",
";",
"for",
"(",
"String",
"eachReference",
":",
"referencedFields",
")",
"{",
"Field",
"referenceField",
"=",
"ReflectionUtils",
".",
"getField",
"(",
"clazz",
",",
"eachReference",
")",
";",
"references",
".",
"add",
"(",
"referenceField",
")",
";",
"}",
"return",
"references",
";",
"}"
] | Get only the first Level of Nested Reference Attributes from a given class
@param clazz
@return List<Field> of referenced fields | [
"Get",
"only",
"the",
"first",
"Level",
"of",
"Nested",
"Reference",
"Attributes",
"from",
"a",
"given",
"class"
] | f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae | https://github.com/3pillarlabs/spring-data-simpledb/blob/f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae/spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/reflection/ReflectionUtils.java#L193-L203 |
141,495 | 3pillarlabs/spring-data-simpledb | spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/util/MapUtils.java | MapUtils.splitToChunksOfSize | public static List<Map<String, List<String>>> splitToChunksOfSize(Map<String, List<String>> rawMap, int chunkSize) {
List<Map<String, List<String>>> mapChunks = new LinkedList<Map<String, List<String>>>();
Set<Map.Entry<String, List<String>>> rawEntries = rawMap.entrySet();
Map<String, List<String>> currentChunk = new LinkedHashMap<String, List<String>>();
int rawEntryIndex = 0;
for(Map.Entry<String, List<String>> rawEntry : rawEntries) {
if(rawEntryIndex % chunkSize == 0) {
if(currentChunk.size() > 0) {
mapChunks.add(currentChunk);
}
currentChunk = new LinkedHashMap<String, List<String>>();
}
currentChunk.put(rawEntry.getKey(), rawEntry.getValue());
rawEntryIndex++;
if(rawEntryIndex == rawMap.size()) {
// finished iterating
mapChunks.add(currentChunk);
}
}
return mapChunks;
} | java | public static List<Map<String, List<String>>> splitToChunksOfSize(Map<String, List<String>> rawMap, int chunkSize) {
List<Map<String, List<String>>> mapChunks = new LinkedList<Map<String, List<String>>>();
Set<Map.Entry<String, List<String>>> rawEntries = rawMap.entrySet();
Map<String, List<String>> currentChunk = new LinkedHashMap<String, List<String>>();
int rawEntryIndex = 0;
for(Map.Entry<String, List<String>> rawEntry : rawEntries) {
if(rawEntryIndex % chunkSize == 0) {
if(currentChunk.size() > 0) {
mapChunks.add(currentChunk);
}
currentChunk = new LinkedHashMap<String, List<String>>();
}
currentChunk.put(rawEntry.getKey(), rawEntry.getValue());
rawEntryIndex++;
if(rawEntryIndex == rawMap.size()) {
// finished iterating
mapChunks.add(currentChunk);
}
}
return mapChunks;
} | [
"public",
"static",
"List",
"<",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
">",
"splitToChunksOfSize",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"rawMap",
",",
"int",
"chunkSize",
")",
"{",
"List",
"<",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
">",
"mapChunks",
"=",
"new",
"LinkedList",
"<",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
">",
"(",
")",
";",
"Set",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
">",
"rawEntries",
"=",
"rawMap",
".",
"entrySet",
"(",
")",
";",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"currentChunk",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"(",
")",
";",
"int",
"rawEntryIndex",
"=",
"0",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"rawEntry",
":",
"rawEntries",
")",
"{",
"if",
"(",
"rawEntryIndex",
"%",
"chunkSize",
"==",
"0",
")",
"{",
"if",
"(",
"currentChunk",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"mapChunks",
".",
"add",
"(",
"currentChunk",
")",
";",
"}",
"currentChunk",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"(",
")",
";",
"}",
"currentChunk",
".",
"put",
"(",
"rawEntry",
".",
"getKey",
"(",
")",
",",
"rawEntry",
".",
"getValue",
"(",
")",
")",
";",
"rawEntryIndex",
"++",
";",
"if",
"(",
"rawEntryIndex",
"==",
"rawMap",
".",
"size",
"(",
")",
")",
"{",
"// finished iterating",
"mapChunks",
".",
"add",
"(",
"currentChunk",
")",
";",
"}",
"}",
"return",
"mapChunks",
";",
"}"
] | Splits rawMap's entries into a number of chunk maps of max chunkSize elements
@param rawMap
@param chunkSize
@return | [
"Splits",
"rawMap",
"s",
"entries",
"into",
"a",
"number",
"of",
"chunk",
"maps",
"of",
"max",
"chunkSize",
"elements"
] | f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae | https://github.com/3pillarlabs/spring-data-simpledb/blob/f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae/spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/util/MapUtils.java#L22-L49 |
141,496 | 3pillarlabs/spring-data-simpledb | spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/attributeutil/AmazonSimpleDBUtil.java | AmazonSimpleDBUtil.encodeByteArray | public static String encodeByteArray(byte[] byteArray) {
try {
return new String(Base64.encodeBase64(byteArray), UTF8_ENCODING);
} catch(UnsupportedEncodingException e) {
throw new MappingException("Could not encode byteArray to UTF8 encoding", e);
}
} | java | public static String encodeByteArray(byte[] byteArray) {
try {
return new String(Base64.encodeBase64(byteArray), UTF8_ENCODING);
} catch(UnsupportedEncodingException e) {
throw new MappingException("Could not encode byteArray to UTF8 encoding", e);
}
} | [
"public",
"static",
"String",
"encodeByteArray",
"(",
"byte",
"[",
"]",
"byteArray",
")",
"{",
"try",
"{",
"return",
"new",
"String",
"(",
"Base64",
".",
"encodeBase64",
"(",
"byteArray",
")",
",",
"UTF8_ENCODING",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"MappingException",
"(",
"\"Could not encode byteArray to UTF8 encoding\"",
",",
"e",
")",
";",
"}",
"}"
] | Encodes byteArray value into a base64-encoded string.
@return string representation of the date value | [
"Encodes",
"byteArray",
"value",
"into",
"a",
"base64",
"-",
"encoded",
"string",
"."
] | f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae | https://github.com/3pillarlabs/spring-data-simpledb/blob/f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae/spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/attributeutil/AmazonSimpleDBUtil.java#L172-L178 |
141,497 | 3pillarlabs/spring-data-simpledb | spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/core/domain/DomainManager.java | DomainManager.dropDomain | protected void dropDomain(final String domainName, final AmazonSimpleDB sdb) {
try {
LOGGER.debug("Dropping domain: {}", domainName);
DeleteDomainRequest request = new DeleteDomainRequest(domainName);
sdb.deleteDomain(request);
LOGGER.debug("Dropped domain: {}", domainName);
} catch(AmazonClientException amazonException) {
throw SimpleDbExceptionTranslator.getTranslatorInstance().translateAmazonClientException(amazonException);
}
} | java | protected void dropDomain(final String domainName, final AmazonSimpleDB sdb) {
try {
LOGGER.debug("Dropping domain: {}", domainName);
DeleteDomainRequest request = new DeleteDomainRequest(domainName);
sdb.deleteDomain(request);
LOGGER.debug("Dropped domain: {}", domainName);
} catch(AmazonClientException amazonException) {
throw SimpleDbExceptionTranslator.getTranslatorInstance().translateAmazonClientException(amazonException);
}
} | [
"protected",
"void",
"dropDomain",
"(",
"final",
"String",
"domainName",
",",
"final",
"AmazonSimpleDB",
"sdb",
")",
"{",
"try",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Dropping domain: {}\"",
",",
"domainName",
")",
";",
"DeleteDomainRequest",
"request",
"=",
"new",
"DeleteDomainRequest",
"(",
"domainName",
")",
";",
"sdb",
".",
"deleteDomain",
"(",
"request",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Dropped domain: {}\"",
",",
"domainName",
")",
";",
"}",
"catch",
"(",
"AmazonClientException",
"amazonException",
")",
"{",
"throw",
"SimpleDbExceptionTranslator",
".",
"getTranslatorInstance",
"(",
")",
".",
"translateAmazonClientException",
"(",
"amazonException",
")",
";",
"}",
"}"
] | Running the delete-domain command over & over again on the same domain, or if the domain does NOT exist will NOT
result in a Amazon Exception
@param domainName | [
"Running",
"the",
"delete",
"-",
"domain",
"command",
"over",
"&",
"over",
"again",
"on",
"the",
"same",
"domain",
"or",
"if",
"the",
"domain",
"does",
"NOT",
"exist",
"will",
"NOT",
"result",
"in",
"a",
"Amazon",
"Exception"
] | f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae | https://github.com/3pillarlabs/spring-data-simpledb/blob/f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae/spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/core/domain/DomainManager.java#L62-L71 |
141,498 | 3pillarlabs/spring-data-simpledb | spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/core/DomainItemBuilder.java | DomainItemBuilder.populateDomainItem | public T populateDomainItem(SimpleDbEntityInformation<T, ?> entityInformation, Item item) {
return buildDomainItem(entityInformation, item);
} | java | public T populateDomainItem(SimpleDbEntityInformation<T, ?> entityInformation, Item item) {
return buildDomainItem(entityInformation, item);
} | [
"public",
"T",
"populateDomainItem",
"(",
"SimpleDbEntityInformation",
"<",
"T",
",",
"?",
">",
"entityInformation",
",",
"Item",
"item",
")",
"{",
"return",
"buildDomainItem",
"(",
"entityInformation",
",",
"item",
")",
";",
"}"
] | Used during deserialization process, each item being populated based on attributes retrieved from DB
@param entityInformation
@param item
@return T the Item Instance | [
"Used",
"during",
"deserialization",
"process",
"each",
"item",
"being",
"populated",
"based",
"on",
"attributes",
"retrieved",
"from",
"DB"
] | f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae | https://github.com/3pillarlabs/spring-data-simpledb/blob/f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae/spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/core/DomainItemBuilder.java#L35-L37 |
141,499 | 3pillarlabs/spring-data-simpledb | spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/core/entity/AbstractFieldWrapper.java | AbstractFieldWrapper.setFieldValue | public void setFieldValue(Object fieldValue) {
ReflectionUtils.callSetter(parentWrapper.getItem(), field.getName(), fieldValue);
} | java | public void setFieldValue(Object fieldValue) {
ReflectionUtils.callSetter(parentWrapper.getItem(), field.getName(), fieldValue);
} | [
"public",
"void",
"setFieldValue",
"(",
"Object",
"fieldValue",
")",
"{",
"ReflectionUtils",
".",
"callSetter",
"(",
"parentWrapper",
".",
"getItem",
"(",
")",
",",
"field",
".",
"getName",
"(",
")",
",",
"fieldValue",
")",
";",
"}"
] | Sets value via setter | [
"Sets",
"value",
"via",
"setter"
] | f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae | https://github.com/3pillarlabs/spring-data-simpledb/blob/f1e0eb4e48ec4674d3966e8f5bc04c95031f93ae/spring-data-simpledb-impl/src/main/java/org/springframework/data/simpledb/core/entity/AbstractFieldWrapper.java#L57-L59 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.