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
143,100
duracloud/management-console
account-management-util/src/main/java/org/duracloud/account/db/util/impl/DuracloudGroupServiceImpl.java
DuracloudGroupServiceImpl.isGroupNameValid
protected final boolean isGroupNameValid(String name) { if (name == null) { return false; } if (!name.startsWith(DuracloudGroup.PREFIX)) { return false; } if (DuracloudGroup.PUBLIC_GROUP_NAME.equalsIgnoreCase(name)) { return false; } return name.substring(DuracloudGroup.PREFIX.length()).matches( "\\A(?![_.@\\-])[a-z0-9_.@\\-]+(?<![_.@\\-])\\Z"); }
java
protected final boolean isGroupNameValid(String name) { if (name == null) { return false; } if (!name.startsWith(DuracloudGroup.PREFIX)) { return false; } if (DuracloudGroup.PUBLIC_GROUP_NAME.equalsIgnoreCase(name)) { return false; } return name.substring(DuracloudGroup.PREFIX.length()).matches( "\\A(?![_.@\\-])[a-z0-9_.@\\-]+(?<![_.@\\-])\\Z"); }
[ "protected", "final", "boolean", "isGroupNameValid", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "!", "name", ".", "startsWith", "(", "DuracloudGroup", ".", "PREFIX", ")", ")", "{", "return", "false", ";", "}", "if", "(", "DuracloudGroup", ".", "PUBLIC_GROUP_NAME", ".", "equalsIgnoreCase", "(", "name", ")", ")", "{", "return", "false", ";", "}", "return", "name", ".", "substring", "(", "DuracloudGroup", ".", "PREFIX", ".", "length", "(", ")", ")", ".", "matches", "(", "\"\\\\A(?![_.@\\\\-])[a-z0-9_.@\\\\-]+(?<![_.@\\\\-])\\\\Z\"", ")", ";", "}" ]
This method is 'protected' for testing purposes only.
[ "This", "method", "is", "protected", "for", "testing", "purposes", "only", "." ]
7331015c01f9ac5cc5c0aa8ae9a2a1a77e9f4ac6
https://github.com/duracloud/management-console/blob/7331015c01f9ac5cc5c0aa8ae9a2a1a77e9f4ac6/account-management-util/src/main/java/org/duracloud/account/db/util/impl/DuracloudGroupServiceImpl.java#L85-L100
143,101
duracloud/management-console
account-management-monitor/src/main/java/org/duracloud/account/monitor/duplication/domain/DuplicationReport.java
DuplicationReport.getDupIssues
public List<DuplicationInfo> getDupIssues() { List<DuplicationInfo> dupIssues = new LinkedList<>(); for (DuplicationInfo dupInfo : dupInfos.values()) { if (dupInfo.hasIssues()) { dupIssues.add(dupInfo); } } return dupIssues; }
java
public List<DuplicationInfo> getDupIssues() { List<DuplicationInfo> dupIssues = new LinkedList<>(); for (DuplicationInfo dupInfo : dupInfos.values()) { if (dupInfo.hasIssues()) { dupIssues.add(dupInfo); } } return dupIssues; }
[ "public", "List", "<", "DuplicationInfo", ">", "getDupIssues", "(", ")", "{", "List", "<", "DuplicationInfo", ">", "dupIssues", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "DuplicationInfo", "dupInfo", ":", "dupInfos", ".", "values", "(", ")", ")", "{", "if", "(", "dupInfo", ".", "hasIssues", "(", ")", ")", "{", "dupIssues", ".", "add", "(", "dupInfo", ")", ";", "}", "}", "return", "dupIssues", ";", "}" ]
This method gets all issues discovered for all checked accounts @return list of duplication infos with issues
[ "This", "method", "gets", "all", "issues", "discovered", "for", "all", "checked", "accounts" ]
7331015c01f9ac5cc5c0aa8ae9a2a1a77e9f4ac6
https://github.com/duracloud/management-console/blob/7331015c01f9ac5cc5c0aa8ae9a2a1a77e9f4ac6/account-management-monitor/src/main/java/org/duracloud/account/monitor/duplication/domain/DuplicationReport.java#L54-L62
143,102
scireum/server-sass
src/main/java/org/serversass/ast/FunctionCall.java
FunctionCall.appendNameAndParameters
protected static void appendNameAndParameters(StringBuilder sb, String name, List<Expression> parameters) { sb.append(name); sb.append("("); boolean first = true; for (Expression expr : parameters) { if (!first) { sb.append(", "); } first = false; sb.append(expr); } sb.append(")"); }
java
protected static void appendNameAndParameters(StringBuilder sb, String name, List<Expression> parameters) { sb.append(name); sb.append("("); boolean first = true; for (Expression expr : parameters) { if (!first) { sb.append(", "); } first = false; sb.append(expr); } sb.append(")"); }
[ "protected", "static", "void", "appendNameAndParameters", "(", "StringBuilder", "sb", ",", "String", "name", ",", "List", "<", "Expression", ">", "parameters", ")", "{", "sb", ".", "append", "(", "name", ")", ";", "sb", ".", "append", "(", "\"(\"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "Expression", "expr", ":", "parameters", ")", "{", "if", "(", "!", "first", ")", "{", "sb", ".", "append", "(", "\", \"", ")", ";", "}", "first", "=", "false", ";", "sb", ".", "append", "(", "expr", ")", ";", "}", "sb", ".", "append", "(", "\")\"", ")", ";", "}" ]
Appends the name and parameters to the given string builder. @param sb the target to write the output to @param name the name of the function @param parameters the list of parameters
[ "Appends", "the", "name", "and", "parameters", "to", "the", "given", "string", "builder", "." ]
e74af983567f10c43420d70cd31165dd080ba8fc
https://github.com/scireum/server-sass/blob/e74af983567f10c43420d70cd31165dd080ba8fc/src/main/java/org/serversass/ast/FunctionCall.java#L48-L60
143,103
scireum/server-sass
src/main/java/org/serversass/ast/FunctionCall.java
FunctionCall.getExpectedParam
public Expression getExpectedParam(int index) { if (parameters.size() <= index) { throw new IllegalArgumentException("Parameter index out of bounds: " + index + ". Function call: " + this); } return parameters.get(index); }
java
public Expression getExpectedParam(int index) { if (parameters.size() <= index) { throw new IllegalArgumentException("Parameter index out of bounds: " + index + ". Function call: " + this); } return parameters.get(index); }
[ "public", "Expression", "getExpectedParam", "(", "int", "index", ")", "{", "if", "(", "parameters", ".", "size", "(", ")", "<=", "index", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Parameter index out of bounds: \"", "+", "index", "+", "\". Function call: \"", "+", "this", ")", ";", "}", "return", "parameters", ".", "get", "(", "index", ")", ";", "}" ]
Returns the parameter at the expected index. @param index the number of the parameter to access @return the expression representing at the given index @throws IllegalArgumentException if the index is out of bounds
[ "Returns", "the", "parameter", "at", "the", "expected", "index", "." ]
e74af983567f10c43420d70cd31165dd080ba8fc
https://github.com/scireum/server-sass/blob/e74af983567f10c43420d70cd31165dd080ba8fc/src/main/java/org/serversass/ast/FunctionCall.java#L96-L102
143,104
scireum/server-sass
src/main/java/org/serversass/Scope.java
Scope.get
public Expression get(String name) { if (variables.containsKey(name)) { return variables.get(name); } if (parent == null) { return new Value(""); } return parent.get(name); }
java
public Expression get(String name) { if (variables.containsKey(name)) { return variables.get(name); } if (parent == null) { return new Value(""); } return parent.get(name); }
[ "public", "Expression", "get", "(", "String", "name", ")", "{", "if", "(", "variables", ".", "containsKey", "(", "name", ")", ")", "{", "return", "variables", ".", "get", "(", "name", ")", ";", "}", "if", "(", "parent", "==", "null", ")", "{", "return", "new", "Value", "(", "\"\"", ")", ";", "}", "return", "parent", ".", "get", "(", "name", ")", ";", "}" ]
Returns the value previously set for the given variable. @param name the variable to lookup @return the value associated with the given name. Uses the parent scope if no variable with the given name exists. Returns a {@link Value} with "" as content, in case the value is completely unknown.
[ "Returns", "the", "value", "previously", "set", "for", "the", "given", "variable", "." ]
e74af983567f10c43420d70cd31165dd080ba8fc
https://github.com/scireum/server-sass/blob/e74af983567f10c43420d70cd31165dd080ba8fc/src/main/java/org/serversass/Scope.java#L61-L69
143,105
duracloud/management-console
account-management-monitor/src/main/java/org/duracloud/account/monitor/duplication/DuplicationMonitor.java
DuplicationMonitor.monitorDuplication
public DuplicationReport monitorDuplication() { log.info("starting duplication monitor"); DuplicationReport report = new DuplicationReport(); for (String host : dupHosts.keySet()) { DuplicationInfo info = new DuplicationInfo(host); try { // Connect to storage providers ContentStoreManager storeManager = getStoreManager(host); ContentStore primary = storeManager.getPrimaryContentStore(); String primaryStoreId = primary.getStoreId(); List<ContentStore> secondaryList = getSecondaryStores(storeManager, primaryStoreId); // Get primary space listing and count List<String> primarySpaces = getSpaces(host, primary); countSpaces(host, info, primary, primarySpaces, true); // Get space listing and space counts for secondary providers for (ContentStore secondary : secondaryList) { List<String> secondarySpaces = getSpaces(host, secondary); if (primarySpaces.size() != secondarySpaces.size()) { info.addIssue("The spaces listings do not match " + "between primary and secondary " + "provider: " + secondary.getStorageProviderType()); } // Determine item count for secondary provider spaces countSpaces(host, info, secondary, secondarySpaces, false); } // Compare the space counts between providers compareSpaces(primaryStoreId, info); } catch (Exception e) { String error = e.getClass() + " exception encountered while " + "running dup monitor for host " + host + ". Exception message: " + e.getMessage(); log.error(error); info.addIssue(error); } finally { report.addDupInfo(host, info); } } return report; }
java
public DuplicationReport monitorDuplication() { log.info("starting duplication monitor"); DuplicationReport report = new DuplicationReport(); for (String host : dupHosts.keySet()) { DuplicationInfo info = new DuplicationInfo(host); try { // Connect to storage providers ContentStoreManager storeManager = getStoreManager(host); ContentStore primary = storeManager.getPrimaryContentStore(); String primaryStoreId = primary.getStoreId(); List<ContentStore> secondaryList = getSecondaryStores(storeManager, primaryStoreId); // Get primary space listing and count List<String> primarySpaces = getSpaces(host, primary); countSpaces(host, info, primary, primarySpaces, true); // Get space listing and space counts for secondary providers for (ContentStore secondary : secondaryList) { List<String> secondarySpaces = getSpaces(host, secondary); if (primarySpaces.size() != secondarySpaces.size()) { info.addIssue("The spaces listings do not match " + "between primary and secondary " + "provider: " + secondary.getStorageProviderType()); } // Determine item count for secondary provider spaces countSpaces(host, info, secondary, secondarySpaces, false); } // Compare the space counts between providers compareSpaces(primaryStoreId, info); } catch (Exception e) { String error = e.getClass() + " exception encountered while " + "running dup monitor for host " + host + ". Exception message: " + e.getMessage(); log.error(error); info.addIssue(error); } finally { report.addDupInfo(host, info); } } return report; }
[ "public", "DuplicationReport", "monitorDuplication", "(", ")", "{", "log", ".", "info", "(", "\"starting duplication monitor\"", ")", ";", "DuplicationReport", "report", "=", "new", "DuplicationReport", "(", ")", ";", "for", "(", "String", "host", ":", "dupHosts", ".", "keySet", "(", ")", ")", "{", "DuplicationInfo", "info", "=", "new", "DuplicationInfo", "(", "host", ")", ";", "try", "{", "// Connect to storage providers", "ContentStoreManager", "storeManager", "=", "getStoreManager", "(", "host", ")", ";", "ContentStore", "primary", "=", "storeManager", ".", "getPrimaryContentStore", "(", ")", ";", "String", "primaryStoreId", "=", "primary", ".", "getStoreId", "(", ")", ";", "List", "<", "ContentStore", ">", "secondaryList", "=", "getSecondaryStores", "(", "storeManager", ",", "primaryStoreId", ")", ";", "// Get primary space listing and count", "List", "<", "String", ">", "primarySpaces", "=", "getSpaces", "(", "host", ",", "primary", ")", ";", "countSpaces", "(", "host", ",", "info", ",", "primary", ",", "primarySpaces", ",", "true", ")", ";", "// Get space listing and space counts for secondary providers", "for", "(", "ContentStore", "secondary", ":", "secondaryList", ")", "{", "List", "<", "String", ">", "secondarySpaces", "=", "getSpaces", "(", "host", ",", "secondary", ")", ";", "if", "(", "primarySpaces", ".", "size", "(", ")", "!=", "secondarySpaces", ".", "size", "(", ")", ")", "{", "info", ".", "addIssue", "(", "\"The spaces listings do not match \"", "+", "\"between primary and secondary \"", "+", "\"provider: \"", "+", "secondary", ".", "getStorageProviderType", "(", ")", ")", ";", "}", "// Determine item count for secondary provider spaces", "countSpaces", "(", "host", ",", "info", ",", "secondary", ",", "secondarySpaces", ",", "false", ")", ";", "}", "// Compare the space counts between providers", "compareSpaces", "(", "primaryStoreId", ",", "info", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "String", "error", "=", "e", ".", "getClass", "(", ")", "+", "\" exception encountered while \"", "+", "\"running dup monitor for host \"", "+", "host", "+", "\". Exception message: \"", "+", "e", ".", "getMessage", "(", ")", ";", "log", ".", "error", "(", "error", ")", ";", "info", ".", "addIssue", "(", "error", ")", ";", "}", "finally", "{", "report", ".", "addDupInfo", "(", "host", ",", "info", ")", ";", "}", "}", "return", "report", ";", "}" ]
This method performs the duplication checks. These checks compare the number of content items in identically named spaces. @return DuplicationReport report
[ "This", "method", "performs", "the", "duplication", "checks", ".", "These", "checks", "compare", "the", "number", "of", "content", "items", "in", "identically", "named", "spaces", "." ]
7331015c01f9ac5cc5c0aa8ae9a2a1a77e9f4ac6
https://github.com/duracloud/management-console/blob/7331015c01f9ac5cc5c0aa8ae9a2a1a77e9f4ac6/account-management-monitor/src/main/java/org/duracloud/account/monitor/duplication/DuplicationMonitor.java#L57-L102
143,106
opentable/otj-jaxrs
client/src/main/java/com/opentable/jaxrs/CalculateThreads.java
CalculateThreads.calculateThreads
public static int calculateThreads(final int executorThreads, final String name) { // For current standard 8 core machines this is 10 regardless. // On Java 10, you might get less than 8 core reported, but it will still size as if it's 8 // Beyond 8 core you MIGHT undersize if running on Docker, but otherwise should be fine. final int optimalThreads= Math.max(BASE_OPTIMAL_THREADS, (Runtime.getRuntime().availableProcessors() + THREAD_OVERHEAD)); int threadsChosen = optimalThreads; if (executorThreads > optimalThreads) { // They requested more, sure we can do that! threadsChosen = executorThreads; LOG.warn("Requested more than optimal threads. This is not necessarily an error, but you may be overallocating."); } else { // They weren't auto tuning (<0)) if (executorThreads > 0) { LOG.warn("You requested less than optimal threads. We've ignored that."); } } LOG.debug("For factory {}, Optimal Threads {}, Configured Threads {}", name, optimalThreads, threadsChosen); return threadsChosen; }
java
public static int calculateThreads(final int executorThreads, final String name) { // For current standard 8 core machines this is 10 regardless. // On Java 10, you might get less than 8 core reported, but it will still size as if it's 8 // Beyond 8 core you MIGHT undersize if running on Docker, but otherwise should be fine. final int optimalThreads= Math.max(BASE_OPTIMAL_THREADS, (Runtime.getRuntime().availableProcessors() + THREAD_OVERHEAD)); int threadsChosen = optimalThreads; if (executorThreads > optimalThreads) { // They requested more, sure we can do that! threadsChosen = executorThreads; LOG.warn("Requested more than optimal threads. This is not necessarily an error, but you may be overallocating."); } else { // They weren't auto tuning (<0)) if (executorThreads > 0) { LOG.warn("You requested less than optimal threads. We've ignored that."); } } LOG.debug("For factory {}, Optimal Threads {}, Configured Threads {}", name, optimalThreads, threadsChosen); return threadsChosen; }
[ "public", "static", "int", "calculateThreads", "(", "final", "int", "executorThreads", ",", "final", "String", "name", ")", "{", "// For current standard 8 core machines this is 10 regardless.", "// On Java 10, you might get less than 8 core reported, but it will still size as if it's 8", "// Beyond 8 core you MIGHT undersize if running on Docker, but otherwise should be fine.", "final", "int", "optimalThreads", "=", "Math", ".", "max", "(", "BASE_OPTIMAL_THREADS", ",", "(", "Runtime", ".", "getRuntime", "(", ")", ".", "availableProcessors", "(", ")", "+", "THREAD_OVERHEAD", ")", ")", ";", "int", "threadsChosen", "=", "optimalThreads", ";", "if", "(", "executorThreads", ">", "optimalThreads", ")", "{", "// They requested more, sure we can do that!", "threadsChosen", "=", "executorThreads", ";", "LOG", ".", "warn", "(", "\"Requested more than optimal threads. This is not necessarily an error, but you may be overallocating.\"", ")", ";", "}", "else", "{", "// They weren't auto tuning (<0))", "if", "(", "executorThreads", ">", "0", ")", "{", "LOG", ".", "warn", "(", "\"You requested less than optimal threads. We've ignored that.\"", ")", ";", "}", "}", "LOG", ".", "debug", "(", "\"For factory {}, Optimal Threads {}, Configured Threads {}\"", ",", "name", ",", "optimalThreads", ",", "threadsChosen", ")", ";", "return", "threadsChosen", ";", "}" ]
Calculate optimal threads. If they exceed the specified executorThreads, use optimal threads instead. Emit appropriate logging @param executorThreads executor threads - what the caller wishes to use for size @param name client pool name. Used for logging. @return int actual threads to use
[ "Calculate", "optimal", "threads", ".", "If", "they", "exceed", "the", "specified", "executorThreads", "use", "optimal", "threads", "instead", ".", "Emit", "appropriate", "logging" ]
384e7094fe5a56d41b2a9970bfd783fa85cbbcb8
https://github.com/opentable/otj-jaxrs/blob/384e7094fe5a56d41b2a9970bfd783fa85cbbcb8/client/src/main/java/com/opentable/jaxrs/CalculateThreads.java#L29-L48
143,107
opentable/otj-jaxrs
client/src/main/java/com/opentable/jaxrs/JaxRsClientFactory.java
JaxRsClientFactory.addFeatureToAllClients
@SafeVarargs public final synchronized JaxRsClientFactory addFeatureToAllClients(Class<? extends Feature>... features) { return addFeatureToGroup(PrivateFeatureGroup.WILDCARD, features); }
java
@SafeVarargs public final synchronized JaxRsClientFactory addFeatureToAllClients(Class<? extends Feature>... features) { return addFeatureToGroup(PrivateFeatureGroup.WILDCARD, features); }
[ "@", "SafeVarargs", "public", "final", "synchronized", "JaxRsClientFactory", "addFeatureToAllClients", "(", "Class", "<", "?", "extends", "Feature", ">", "...", "features", ")", "{", "return", "addFeatureToGroup", "(", "PrivateFeatureGroup", ".", "WILDCARD", ",", "features", ")", ";", "}" ]
Register a list of features for all created clients.
[ "Register", "a", "list", "of", "features", "for", "all", "created", "clients", "." ]
384e7094fe5a56d41b2a9970bfd783fa85cbbcb8
https://github.com/opentable/otj-jaxrs/blob/384e7094fe5a56d41b2a9970bfd783fa85cbbcb8/client/src/main/java/com/opentable/jaxrs/JaxRsClientFactory.java#L151-L154
143,108
opentable/otj-jaxrs
client/src/main/java/com/opentable/jaxrs/JaxRsClientFactory.java
JaxRsClientFactory.createClientProxy
public <T> T createClientProxy(Class<T> proxyClass, WebTarget baseTarget) { return factory(ctx).createClientProxy(proxyClass, baseTarget); }
java
public <T> T createClientProxy(Class<T> proxyClass, WebTarget baseTarget) { return factory(ctx).createClientProxy(proxyClass, baseTarget); }
[ "public", "<", "T", ">", "T", "createClientProxy", "(", "Class", "<", "T", ">", "proxyClass", ",", "WebTarget", "baseTarget", ")", "{", "return", "factory", "(", "ctx", ")", ".", "createClientProxy", "(", "proxyClass", ",", "baseTarget", ")", ";", "}" ]
Create a Client proxy for the given interface type. Note that different JAX-RS providers behave slightly differently for this feature. @param proxyClass the class to implement @param baseTarget the API root @return a proxy implementation that executes requests
[ "Create", "a", "Client", "proxy", "for", "the", "given", "interface", "type", ".", "Note", "that", "different", "JAX", "-", "RS", "providers", "behave", "slightly", "differently", "for", "this", "feature", "." ]
384e7094fe5a56d41b2a9970bfd783fa85cbbcb8
https://github.com/opentable/otj-jaxrs/blob/384e7094fe5a56d41b2a9970bfd783fa85cbbcb8/client/src/main/java/com/opentable/jaxrs/JaxRsClientFactory.java#L276-L278
143,109
Nanopublication/nanopub-java
src/main/java/org/nanopub/extra/security/SignatureUtils.java
SignatureUtils.seemsToHaveSignature
public static boolean seemsToHaveSignature(Nanopub nanopub) { for (Statement st : nanopub.getPubinfo()) { if (st.getPredicate().equals(NanopubSignatureElement.HAS_SIGNATURE_ELEMENT)) return true; if (st.getPredicate().equals(NanopubSignatureElement.HAS_SIGNATURE_TARGET)) return true; if (st.getPredicate().equals(NanopubSignatureElement.HAS_SIGNATURE)) return true; if (st.getPredicate().equals(CryptoElement.HAS_PUBLIC_KEY)) return true; } return false; }
java
public static boolean seemsToHaveSignature(Nanopub nanopub) { for (Statement st : nanopub.getPubinfo()) { if (st.getPredicate().equals(NanopubSignatureElement.HAS_SIGNATURE_ELEMENT)) return true; if (st.getPredicate().equals(NanopubSignatureElement.HAS_SIGNATURE_TARGET)) return true; if (st.getPredicate().equals(NanopubSignatureElement.HAS_SIGNATURE)) return true; if (st.getPredicate().equals(CryptoElement.HAS_PUBLIC_KEY)) return true; } return false; }
[ "public", "static", "boolean", "seemsToHaveSignature", "(", "Nanopub", "nanopub", ")", "{", "for", "(", "Statement", "st", ":", "nanopub", ".", "getPubinfo", "(", ")", ")", "{", "if", "(", "st", ".", "getPredicate", "(", ")", ".", "equals", "(", "NanopubSignatureElement", ".", "HAS_SIGNATURE_ELEMENT", ")", ")", "return", "true", ";", "if", "(", "st", ".", "getPredicate", "(", ")", ".", "equals", "(", "NanopubSignatureElement", ".", "HAS_SIGNATURE_TARGET", ")", ")", "return", "true", ";", "if", "(", "st", ".", "getPredicate", "(", ")", ".", "equals", "(", "NanopubSignatureElement", ".", "HAS_SIGNATURE", ")", ")", "return", "true", ";", "if", "(", "st", ".", "getPredicate", "(", ")", ".", "equals", "(", "CryptoElement", ".", "HAS_PUBLIC_KEY", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
This includes legacy signatures. Might include false positives.
[ "This", "includes", "legacy", "signatures", ".", "Might", "include", "false", "positives", "." ]
8bae9e87a8e9c2709e6afdcc5e02519607f6032b
https://github.com/Nanopublication/nanopub-java/blob/8bae9e87a8e9c2709e6afdcc5e02519607f6032b/src/main/java/org/nanopub/extra/security/SignatureUtils.java#L192-L200
143,110
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.workflowCuration
private void workflowCuration(JsonSimple response, JsonSimple message) { String oid = message.getString(null, "oid"); if (!workflowCompleted(oid)) { return; } // Resolve relationships before we continue try { JSONArray relations = mapRelations(oid); // Unless there was an error, we should be good to go if (relations != null) { JsonObject request = createTask(response, oid, "curation-request"); if (!relations.isEmpty()) { request.put("relationships", relations); } } } catch (Exception ex) { log.error("Error processing relations: ", ex); return; } }
java
private void workflowCuration(JsonSimple response, JsonSimple message) { String oid = message.getString(null, "oid"); if (!workflowCompleted(oid)) { return; } // Resolve relationships before we continue try { JSONArray relations = mapRelations(oid); // Unless there was an error, we should be good to go if (relations != null) { JsonObject request = createTask(response, oid, "curation-request"); if (!relations.isEmpty()) { request.put("relationships", relations); } } } catch (Exception ex) { log.error("Error processing relations: ", ex); return; } }
[ "private", "void", "workflowCuration", "(", "JsonSimple", "response", ",", "JsonSimple", "message", ")", "{", "String", "oid", "=", "message", ".", "getString", "(", "null", ",", "\"oid\"", ")", ";", "if", "(", "!", "workflowCompleted", "(", "oid", ")", ")", "{", "return", ";", "}", "// Resolve relationships before we continue", "try", "{", "JSONArray", "relations", "=", "mapRelations", "(", "oid", ")", ";", "// Unless there was an error, we should be good to go", "if", "(", "relations", "!=", "null", ")", "{", "JsonObject", "request", "=", "createTask", "(", "response", ",", "oid", ",", "\"curation-request\"", ")", ";", "if", "(", "!", "relations", ".", "isEmpty", "(", ")", ")", "{", "request", ".", "put", "(", "\"relationships\"", ",", "relations", ")", ";", "}", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "\"Error processing relations: \"", ",", "ex", ")", ";", "return", ";", "}", "}" ]
Assess a workflow event to see how it effects curation @param response The response object @param message The incoming message
[ "Assess", "a", "workflow", "event", "to", "see", "how", "it", "effects", "curation" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L236-L258
143,111
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.mapRelations
private JSONArray mapRelations(String oid) { // We want our parsed data for reading JsonSimple formData = parsedFormData(oid); if (formData == null) { log.error("Error parsing form data"); return null; } // And raw data to see existing relations and write new ones JsonSimple rawData = getDataFromStorage(oid); if (rawData == null) { log.error("Error reading data from storage"); return null; } // Existing relationship data JSONArray relations = rawData.writeArray("relationships"); boolean changed = false; // For all configured relationships for (String baseField : relationFields.keySet()) { JsonSimple relationConfig = relationFields.get(baseField); // Find the path we need to look under for our related object List<String> basePath = relationConfig.getStringList("path"); if (basePath == null || basePath.isEmpty()) { log.error("Ignoring invalid relationship '{}'. No 'path'" + " provided in configuration", baseField); continue; } // Get our base object Object object = formData.getPath(basePath.toArray()); if (object instanceof JsonObject) { // And process it JsonObject newRelation = lookForRelation(oid, baseField, relationConfig, new JsonSimple((JsonObject) object)); if (newRelation != null && !isKnownRelation(relations, newRelation)) { log.info("Adding relation: '{}' => '{}'", baseField, newRelation.get("identifier")); relations.add(newRelation); changed = true; } } // If base path points at an array if (object instanceof JSONArray) { // Try every entry for (Object loopObject : (JSONArray) object) { if (loopObject instanceof JsonObject) { JsonObject newRelation = lookForRelation(oid, baseField, relationConfig, new JsonSimple( (JsonObject) loopObject)); if (newRelation != null && !isKnownRelation(relations, newRelation)) { log.info("Adding relation: '{}' => '{}'", baseField, newRelation.get("identifier")); relations.add(newRelation); changed = true; } } } } } // Do we need to store our object again? if (changed) { try { saveObjectData(rawData, oid); } catch (TransactionException ex) { log.error("Error updating object '{}' in storage: ", oid, ex); return null; } } return relations; }
java
private JSONArray mapRelations(String oid) { // We want our parsed data for reading JsonSimple formData = parsedFormData(oid); if (formData == null) { log.error("Error parsing form data"); return null; } // And raw data to see existing relations and write new ones JsonSimple rawData = getDataFromStorage(oid); if (rawData == null) { log.error("Error reading data from storage"); return null; } // Existing relationship data JSONArray relations = rawData.writeArray("relationships"); boolean changed = false; // For all configured relationships for (String baseField : relationFields.keySet()) { JsonSimple relationConfig = relationFields.get(baseField); // Find the path we need to look under for our related object List<String> basePath = relationConfig.getStringList("path"); if (basePath == null || basePath.isEmpty()) { log.error("Ignoring invalid relationship '{}'. No 'path'" + " provided in configuration", baseField); continue; } // Get our base object Object object = formData.getPath(basePath.toArray()); if (object instanceof JsonObject) { // And process it JsonObject newRelation = lookForRelation(oid, baseField, relationConfig, new JsonSimple((JsonObject) object)); if (newRelation != null && !isKnownRelation(relations, newRelation)) { log.info("Adding relation: '{}' => '{}'", baseField, newRelation.get("identifier")); relations.add(newRelation); changed = true; } } // If base path points at an array if (object instanceof JSONArray) { // Try every entry for (Object loopObject : (JSONArray) object) { if (loopObject instanceof JsonObject) { JsonObject newRelation = lookForRelation(oid, baseField, relationConfig, new JsonSimple( (JsonObject) loopObject)); if (newRelation != null && !isKnownRelation(relations, newRelation)) { log.info("Adding relation: '{}' => '{}'", baseField, newRelation.get("identifier")); relations.add(newRelation); changed = true; } } } } } // Do we need to store our object again? if (changed) { try { saveObjectData(rawData, oid); } catch (TransactionException ex) { log.error("Error updating object '{}' in storage: ", oid, ex); return null; } } return relations; }
[ "private", "JSONArray", "mapRelations", "(", "String", "oid", ")", "{", "// We want our parsed data for reading", "JsonSimple", "formData", "=", "parsedFormData", "(", "oid", ")", ";", "if", "(", "formData", "==", "null", ")", "{", "log", ".", "error", "(", "\"Error parsing form data\"", ")", ";", "return", "null", ";", "}", "// And raw data to see existing relations and write new ones", "JsonSimple", "rawData", "=", "getDataFromStorage", "(", "oid", ")", ";", "if", "(", "rawData", "==", "null", ")", "{", "log", ".", "error", "(", "\"Error reading data from storage\"", ")", ";", "return", "null", ";", "}", "// Existing relationship data", "JSONArray", "relations", "=", "rawData", ".", "writeArray", "(", "\"relationships\"", ")", ";", "boolean", "changed", "=", "false", ";", "// For all configured relationships", "for", "(", "String", "baseField", ":", "relationFields", ".", "keySet", "(", ")", ")", "{", "JsonSimple", "relationConfig", "=", "relationFields", ".", "get", "(", "baseField", ")", ";", "// Find the path we need to look under for our related object", "List", "<", "String", ">", "basePath", "=", "relationConfig", ".", "getStringList", "(", "\"path\"", ")", ";", "if", "(", "basePath", "==", "null", "||", "basePath", ".", "isEmpty", "(", ")", ")", "{", "log", ".", "error", "(", "\"Ignoring invalid relationship '{}'. No 'path'\"", "+", "\" provided in configuration\"", ",", "baseField", ")", ";", "continue", ";", "}", "// Get our base object", "Object", "object", "=", "formData", ".", "getPath", "(", "basePath", ".", "toArray", "(", ")", ")", ";", "if", "(", "object", "instanceof", "JsonObject", ")", "{", "// And process it", "JsonObject", "newRelation", "=", "lookForRelation", "(", "oid", ",", "baseField", ",", "relationConfig", ",", "new", "JsonSimple", "(", "(", "JsonObject", ")", "object", ")", ")", ";", "if", "(", "newRelation", "!=", "null", "&&", "!", "isKnownRelation", "(", "relations", ",", "newRelation", ")", ")", "{", "log", ".", "info", "(", "\"Adding relation: '{}' => '{}'\"", ",", "baseField", ",", "newRelation", ".", "get", "(", "\"identifier\"", ")", ")", ";", "relations", ".", "add", "(", "newRelation", ")", ";", "changed", "=", "true", ";", "}", "}", "// If base path points at an array", "if", "(", "object", "instanceof", "JSONArray", ")", "{", "// Try every entry", "for", "(", "Object", "loopObject", ":", "(", "JSONArray", ")", "object", ")", "{", "if", "(", "loopObject", "instanceof", "JsonObject", ")", "{", "JsonObject", "newRelation", "=", "lookForRelation", "(", "oid", ",", "baseField", ",", "relationConfig", ",", "new", "JsonSimple", "(", "(", "JsonObject", ")", "loopObject", ")", ")", ";", "if", "(", "newRelation", "!=", "null", "&&", "!", "isKnownRelation", "(", "relations", ",", "newRelation", ")", ")", "{", "log", ".", "info", "(", "\"Adding relation: '{}' => '{}'\"", ",", "baseField", ",", "newRelation", ".", "get", "(", "\"identifier\"", ")", ")", ";", "relations", ".", "add", "(", "newRelation", ")", ";", "changed", "=", "true", ";", "}", "}", "}", "}", "}", "// Do we need to store our object again?", "if", "(", "changed", ")", "{", "try", "{", "saveObjectData", "(", "rawData", ",", "oid", ")", ";", "}", "catch", "(", "TransactionException", "ex", ")", "{", "log", ".", "error", "(", "\"Error updating object '{}' in storage: \"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "}", "return", "relations", ";", "}" ]
Map all the relationships buried in this record's data @param oid The object ID being curated @returns True is ready to proceed, otherwise False
[ "Map", "all", "the", "relationships", "buried", "in", "this", "record", "s", "data" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L283-L358
143,112
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.isKnownRelation
private boolean isKnownRelation(JSONArray relations, JsonObject newRelation) { // Does it have an OID? Highest priority. Avoids infinite loops // between ReDBox collections pointing at each other, so strict if (newRelation.containsKey("oid")) { for (Object relation : relations) { JsonObject json = (JsonObject) relation; String knownOid = (String) json.get("oid"); String newOid = (String) newRelation.get("oid"); // Do they match? if (knownOid.equals(newOid)) { log.debug("Known ReDBox linkage '{}'", knownOid); return true; } } return false; } // Mint records we are less strict about and happy // to allow multiple links in differing fields. for (Object relation : relations) { JsonObject json = (JsonObject) relation; if (json.containsKey("identifier")) { String knownId = (String) json.get("identifier"); String knownField = (String) json.get("field"); String newId = (String) newRelation.get("identifier"); String newField = (String) newRelation.get("field"); // And does the ID match? if (knownId.equals(newId) && knownField.equals(newField)) { return true; } } } // No match found return false; }
java
private boolean isKnownRelation(JSONArray relations, JsonObject newRelation) { // Does it have an OID? Highest priority. Avoids infinite loops // between ReDBox collections pointing at each other, so strict if (newRelation.containsKey("oid")) { for (Object relation : relations) { JsonObject json = (JsonObject) relation; String knownOid = (String) json.get("oid"); String newOid = (String) newRelation.get("oid"); // Do they match? if (knownOid.equals(newOid)) { log.debug("Known ReDBox linkage '{}'", knownOid); return true; } } return false; } // Mint records we are less strict about and happy // to allow multiple links in differing fields. for (Object relation : relations) { JsonObject json = (JsonObject) relation; if (json.containsKey("identifier")) { String knownId = (String) json.get("identifier"); String knownField = (String) json.get("field"); String newId = (String) newRelation.get("identifier"); String newField = (String) newRelation.get("field"); // And does the ID match? if (knownId.equals(newId) && knownField.equals(newField)) { return true; } } } // No match found return false; }
[ "private", "boolean", "isKnownRelation", "(", "JSONArray", "relations", ",", "JsonObject", "newRelation", ")", "{", "// Does it have an OID? Highest priority. Avoids infinite loops", "// between ReDBox collections pointing at each other, so strict", "if", "(", "newRelation", ".", "containsKey", "(", "\"oid\"", ")", ")", "{", "for", "(", "Object", "relation", ":", "relations", ")", "{", "JsonObject", "json", "=", "(", "JsonObject", ")", "relation", ";", "String", "knownOid", "=", "(", "String", ")", "json", ".", "get", "(", "\"oid\"", ")", ";", "String", "newOid", "=", "(", "String", ")", "newRelation", ".", "get", "(", "\"oid\"", ")", ";", "// Do they match?", "if", "(", "knownOid", ".", "equals", "(", "newOid", ")", ")", "{", "log", ".", "debug", "(", "\"Known ReDBox linkage '{}'\"", ",", "knownOid", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}", "// Mint records we are less strict about and happy", "// to allow multiple links in differing fields.", "for", "(", "Object", "relation", ":", "relations", ")", "{", "JsonObject", "json", "=", "(", "JsonObject", ")", "relation", ";", "if", "(", "json", ".", "containsKey", "(", "\"identifier\"", ")", ")", "{", "String", "knownId", "=", "(", "String", ")", "json", ".", "get", "(", "\"identifier\"", ")", ";", "String", "knownField", "=", "(", "String", ")", "json", ".", "get", "(", "\"field\"", ")", ";", "String", "newId", "=", "(", "String", ")", "newRelation", ".", "get", "(", "\"identifier\"", ")", ";", "String", "newField", "=", "(", "String", ")", "newRelation", ".", "get", "(", "\"field\"", ")", ";", "// And does the ID match?", "if", "(", "knownId", ".", "equals", "(", "newId", ")", "&&", "knownField", ".", "equals", "(", "newField", ")", ")", "{", "return", "true", ";", "}", "}", "}", "// No match found", "return", "false", ";", "}" ]
Test whether the field provided is already a known relationship @param relations The list of current relationships @param field The cleaned field to provide some context @param id The ID of the related object @returns True is it is a known relationship
[ "Test", "whether", "the", "field", "provided", "is", "already", "a", "known", "relationship" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L498-L533
143,113
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.publish
private JsonSimple publish(JsonSimple message, String oid) throws TransactionException { log.debug("Publishing '{}'", oid); JsonSimple response = new JsonSimple(); try { DigitalObject object = storage.getObject(oid); Properties metadata = object.getMetadata(); // Already published? if (!metadata.containsKey(PUBLISH_PROPERTY)) { metadata.setProperty(PUBLISH_PROPERTY, "true"); storeProperties(object, metadata); log.info("Publication flag set '{}'", oid); audit(response, oid, "Publication flag set"); } else { log.info("Publication flag is already set '{}'", oid); } } catch (StorageException ex) { throw new TransactionException("Error setting publish property: ", ex); } // Make a final pass through the curation tool(s), // allows for external publication. eg. VITAL JsonSimple itemConfig = getConfigFromStorage(oid); if (itemConfig == null) { log.error("Error accessing item configuration!"); } else { List<String> list = itemConfig.getStringList("transformer", "curation"); if (list != null && !list.isEmpty()) { for (String id : list) { JsonObject order = newTransform(response, id, oid); JsonObject config = (JsonObject) order.get("config"); JsonObject overrides = itemConfig.getObject( "transformerOverrides", id); if (overrides != null) { config.putAll(overrides); } } } } // Don't forget to publish children publishRelations(response, oid); return response; }
java
private JsonSimple publish(JsonSimple message, String oid) throws TransactionException { log.debug("Publishing '{}'", oid); JsonSimple response = new JsonSimple(); try { DigitalObject object = storage.getObject(oid); Properties metadata = object.getMetadata(); // Already published? if (!metadata.containsKey(PUBLISH_PROPERTY)) { metadata.setProperty(PUBLISH_PROPERTY, "true"); storeProperties(object, metadata); log.info("Publication flag set '{}'", oid); audit(response, oid, "Publication flag set"); } else { log.info("Publication flag is already set '{}'", oid); } } catch (StorageException ex) { throw new TransactionException("Error setting publish property: ", ex); } // Make a final pass through the curation tool(s), // allows for external publication. eg. VITAL JsonSimple itemConfig = getConfigFromStorage(oid); if (itemConfig == null) { log.error("Error accessing item configuration!"); } else { List<String> list = itemConfig.getStringList("transformer", "curation"); if (list != null && !list.isEmpty()) { for (String id : list) { JsonObject order = newTransform(response, id, oid); JsonObject config = (JsonObject) order.get("config"); JsonObject overrides = itemConfig.getObject( "transformerOverrides", id); if (overrides != null) { config.putAll(overrides); } } } } // Don't forget to publish children publishRelations(response, oid); return response; }
[ "private", "JsonSimple", "publish", "(", "JsonSimple", "message", ",", "String", "oid", ")", "throws", "TransactionException", "{", "log", ".", "debug", "(", "\"Publishing '{}'\"", ",", "oid", ")", ";", "JsonSimple", "response", "=", "new", "JsonSimple", "(", ")", ";", "try", "{", "DigitalObject", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "Properties", "metadata", "=", "object", ".", "getMetadata", "(", ")", ";", "// Already published?", "if", "(", "!", "metadata", ".", "containsKey", "(", "PUBLISH_PROPERTY", ")", ")", "{", "metadata", ".", "setProperty", "(", "PUBLISH_PROPERTY", ",", "\"true\"", ")", ";", "storeProperties", "(", "object", ",", "metadata", ")", ";", "log", ".", "info", "(", "\"Publication flag set '{}'\"", ",", "oid", ")", ";", "audit", "(", "response", ",", "oid", ",", "\"Publication flag set\"", ")", ";", "}", "else", "{", "log", ".", "info", "(", "\"Publication flag is already set '{}'\"", ",", "oid", ")", ";", "}", "}", "catch", "(", "StorageException", "ex", ")", "{", "throw", "new", "TransactionException", "(", "\"Error setting publish property: \"", ",", "ex", ")", ";", "}", "// Make a final pass through the curation tool(s),", "// allows for external publication. eg. VITAL", "JsonSimple", "itemConfig", "=", "getConfigFromStorage", "(", "oid", ")", ";", "if", "(", "itemConfig", "==", "null", ")", "{", "log", ".", "error", "(", "\"Error accessing item configuration!\"", ")", ";", "}", "else", "{", "List", "<", "String", ">", "list", "=", "itemConfig", ".", "getStringList", "(", "\"transformer\"", ",", "\"curation\"", ")", ";", "if", "(", "list", "!=", "null", "&&", "!", "list", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "String", "id", ":", "list", ")", "{", "JsonObject", "order", "=", "newTransform", "(", "response", ",", "id", ",", "oid", ")", ";", "JsonObject", "config", "=", "(", "JsonObject", ")", "order", ".", "get", "(", "\"config\"", ")", ";", "JsonObject", "overrides", "=", "itemConfig", ".", "getObject", "(", "\"transformerOverrides\"", ",", "id", ")", ";", "if", "(", "overrides", "!=", "null", ")", "{", "config", ".", "putAll", "(", "overrides", ")", ";", "}", "}", "}", "}", "// Don't forget to publish children", "publishRelations", "(", "response", ",", "oid", ")", ";", "return", "response", ";", "}" ]
Get the requested object ready for publication. This would typically just involve setting a flag @param message The incoming message @param oid The object identifier to publish @return JsonSimple The response object @throws TransactionException If an error occurred
[ "Get", "the", "requested", "object", "ready", "for", "publication", ".", "This", "would", "typically", "just", "involve", "setting", "a", "flag" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1233-L1279
143,114
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.publishRelations
private void publishRelations(JsonSimple response, String oid) throws TransactionException { log.debug("Publishing Children of '{}'", oid); JsonSimple data = getDataFromStorage(oid); if (data == null) { log.error("Error accessing item data! '{}'", oid); emailObjectLink(response, oid, "An error occured publishing the related objects for this" + " record. Please check the system logs."); return; } JSONArray relations = data.writeArray("relationships"); for (Object relation : relations) { JsonSimple json = new JsonSimple((JsonObject) relation); String broker = json.getString(null, "broker"); boolean localRecord = broker.equals(brokerUrl); String relatedId = json.getString(null, "identifier"); // We need to find OIDs to match IDs (only for local records) String relatedOid = json.getString(null, "oid"); if (relatedOid == null && localRecord) { String identifier = json.getString(null, "identifier"); if (identifier == null) { log.error("NULL identifer provided!"); } relatedOid = idToOid(identifier); if (relatedOid == null) { log.error("Cannot resolve identifer: '{}'", identifier); } } // We only publish downstream relations (ie. we are their authority) boolean authority = json.getBoolean(false, "authority"); boolean relationPublishRequested = json.getBoolean(false, "relationPublishedRequested"); if (authority && !relationPublishRequested) { // Is this relationship using a curated ID? boolean isCurated = json.getBoolean(false, "isCurated"); if (isCurated) { log.debug(" * Publishing '{}'", relatedId); // It is a local object if (localRecord) { createTask(response, relatedOid, "publish"); // Or remote } else { JsonObject task = createTask(response, broker, relatedOid, "publish"); // We won't know OIDs for remote systems task.remove("oid"); task.put("identifier", relatedId); } log.debug(" * Writing relationPublishedRequested for '{}'", relatedId); json.getJsonObject().put("relationPublishedRequested",true); saveObjectData(data, oid); } else { log.debug(" * Ignoring non-curated relationship '{}'", relatedId); } } } }
java
private void publishRelations(JsonSimple response, String oid) throws TransactionException { log.debug("Publishing Children of '{}'", oid); JsonSimple data = getDataFromStorage(oid); if (data == null) { log.error("Error accessing item data! '{}'", oid); emailObjectLink(response, oid, "An error occured publishing the related objects for this" + " record. Please check the system logs."); return; } JSONArray relations = data.writeArray("relationships"); for (Object relation : relations) { JsonSimple json = new JsonSimple((JsonObject) relation); String broker = json.getString(null, "broker"); boolean localRecord = broker.equals(brokerUrl); String relatedId = json.getString(null, "identifier"); // We need to find OIDs to match IDs (only for local records) String relatedOid = json.getString(null, "oid"); if (relatedOid == null && localRecord) { String identifier = json.getString(null, "identifier"); if (identifier == null) { log.error("NULL identifer provided!"); } relatedOid = idToOid(identifier); if (relatedOid == null) { log.error("Cannot resolve identifer: '{}'", identifier); } } // We only publish downstream relations (ie. we are their authority) boolean authority = json.getBoolean(false, "authority"); boolean relationPublishRequested = json.getBoolean(false, "relationPublishedRequested"); if (authority && !relationPublishRequested) { // Is this relationship using a curated ID? boolean isCurated = json.getBoolean(false, "isCurated"); if (isCurated) { log.debug(" * Publishing '{}'", relatedId); // It is a local object if (localRecord) { createTask(response, relatedOid, "publish"); // Or remote } else { JsonObject task = createTask(response, broker, relatedOid, "publish"); // We won't know OIDs for remote systems task.remove("oid"); task.put("identifier", relatedId); } log.debug(" * Writing relationPublishedRequested for '{}'", relatedId); json.getJsonObject().put("relationPublishedRequested",true); saveObjectData(data, oid); } else { log.debug(" * Ignoring non-curated relationship '{}'", relatedId); } } } }
[ "private", "void", "publishRelations", "(", "JsonSimple", "response", ",", "String", "oid", ")", "throws", "TransactionException", "{", "log", ".", "debug", "(", "\"Publishing Children of '{}'\"", ",", "oid", ")", ";", "JsonSimple", "data", "=", "getDataFromStorage", "(", "oid", ")", ";", "if", "(", "data", "==", "null", ")", "{", "log", ".", "error", "(", "\"Error accessing item data! '{}'\"", ",", "oid", ")", ";", "emailObjectLink", "(", "response", ",", "oid", ",", "\"An error occured publishing the related objects for this\"", "+", "\" record. Please check the system logs.\"", ")", ";", "return", ";", "}", "JSONArray", "relations", "=", "data", ".", "writeArray", "(", "\"relationships\"", ")", ";", "for", "(", "Object", "relation", ":", "relations", ")", "{", "JsonSimple", "json", "=", "new", "JsonSimple", "(", "(", "JsonObject", ")", "relation", ")", ";", "String", "broker", "=", "json", ".", "getString", "(", "null", ",", "\"broker\"", ")", ";", "boolean", "localRecord", "=", "broker", ".", "equals", "(", "brokerUrl", ")", ";", "String", "relatedId", "=", "json", ".", "getString", "(", "null", ",", "\"identifier\"", ")", ";", "// We need to find OIDs to match IDs (only for local records)", "String", "relatedOid", "=", "json", ".", "getString", "(", "null", ",", "\"oid\"", ")", ";", "if", "(", "relatedOid", "==", "null", "&&", "localRecord", ")", "{", "String", "identifier", "=", "json", ".", "getString", "(", "null", ",", "\"identifier\"", ")", ";", "if", "(", "identifier", "==", "null", ")", "{", "log", ".", "error", "(", "\"NULL identifer provided!\"", ")", ";", "}", "relatedOid", "=", "idToOid", "(", "identifier", ")", ";", "if", "(", "relatedOid", "==", "null", ")", "{", "log", ".", "error", "(", "\"Cannot resolve identifer: '{}'\"", ",", "identifier", ")", ";", "}", "}", "// We only publish downstream relations (ie. we are their authority)", "boolean", "authority", "=", "json", ".", "getBoolean", "(", "false", ",", "\"authority\"", ")", ";", "boolean", "relationPublishRequested", "=", "json", ".", "getBoolean", "(", "false", ",", "\"relationPublishedRequested\"", ")", ";", "if", "(", "authority", "&&", "!", "relationPublishRequested", ")", "{", "// Is this relationship using a curated ID?", "boolean", "isCurated", "=", "json", ".", "getBoolean", "(", "false", ",", "\"isCurated\"", ")", ";", "if", "(", "isCurated", ")", "{", "log", ".", "debug", "(", "\" * Publishing '{}'\"", ",", "relatedId", ")", ";", "// It is a local object", "if", "(", "localRecord", ")", "{", "createTask", "(", "response", ",", "relatedOid", ",", "\"publish\"", ")", ";", "// Or remote", "}", "else", "{", "JsonObject", "task", "=", "createTask", "(", "response", ",", "broker", ",", "relatedOid", ",", "\"publish\"", ")", ";", "// We won't know OIDs for remote systems", "task", ".", "remove", "(", "\"oid\"", ")", ";", "task", ".", "put", "(", "\"identifier\"", ",", "relatedId", ")", ";", "}", "log", ".", "debug", "(", "\" * Writing relationPublishedRequested for '{}'\"", ",", "relatedId", ")", ";", "json", ".", "getJsonObject", "(", ")", ".", "put", "(", "\"relationPublishedRequested\"", ",", "true", ")", ";", "saveObjectData", "(", "data", ",", "oid", ")", ";", "}", "else", "{", "log", ".", "debug", "(", "\" * Ignoring non-curated relationship '{}'\"", ",", "relatedId", ")", ";", "}", "}", "}", "}" ]
Send out requests to all relations to publish @param oid The object identifier to publish @throws TransactionException
[ "Send", "out", "requests", "to", "all", "relations", "to", "publish" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1288-L1349
143,115
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.reharvest
private void reharvest(JsonSimple response, JsonSimple message) { String oid = message.getString(null, "oid"); try { if (oid != null) { setRenderFlag(oid); // Transformer config JsonSimple itemConfig = getConfigFromStorage(oid); if (itemConfig == null) { log.error("Error accessing item configuration!"); return; } itemConfig.getJsonObject().put("oid", oid); // Tool chain scheduleTransformers(itemConfig, response); JsonObject order = newIndex(response, oid); order.put("forceCommit", true); createTask(response, oid, "clear-render-flag"); } else { log.error("Cannot reharvest without an OID!"); } } catch (Exception ex) { log.error("Error during reharvest setup: ", ex); } }
java
private void reharvest(JsonSimple response, JsonSimple message) { String oid = message.getString(null, "oid"); try { if (oid != null) { setRenderFlag(oid); // Transformer config JsonSimple itemConfig = getConfigFromStorage(oid); if (itemConfig == null) { log.error("Error accessing item configuration!"); return; } itemConfig.getJsonObject().put("oid", oid); // Tool chain scheduleTransformers(itemConfig, response); JsonObject order = newIndex(response, oid); order.put("forceCommit", true); createTask(response, oid, "clear-render-flag"); } else { log.error("Cannot reharvest without an OID!"); } } catch (Exception ex) { log.error("Error during reharvest setup: ", ex); } }
[ "private", "void", "reharvest", "(", "JsonSimple", "response", ",", "JsonSimple", "message", ")", "{", "String", "oid", "=", "message", ".", "getString", "(", "null", ",", "\"oid\"", ")", ";", "try", "{", "if", "(", "oid", "!=", "null", ")", "{", "setRenderFlag", "(", "oid", ")", ";", "// Transformer config", "JsonSimple", "itemConfig", "=", "getConfigFromStorage", "(", "oid", ")", ";", "if", "(", "itemConfig", "==", "null", ")", "{", "log", ".", "error", "(", "\"Error accessing item configuration!\"", ")", ";", "return", ";", "}", "itemConfig", ".", "getJsonObject", "(", ")", ".", "put", "(", "\"oid\"", ",", "oid", ")", ";", "// Tool chain", "scheduleTransformers", "(", "itemConfig", ",", "response", ")", ";", "JsonObject", "order", "=", "newIndex", "(", "response", ",", "oid", ")", ";", "order", ".", "put", "(", "\"forceCommit\"", ",", "true", ")", ";", "createTask", "(", "response", ",", "oid", ",", "\"clear-render-flag\"", ")", ";", "}", "else", "{", "log", ".", "error", "(", "\"Cannot reharvest without an OID!\"", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "\"Error during reharvest setup: \"", ",", "ex", ")", ";", "}", "}" ]
Generate a fairly common list of orders to transform and index an object. This mirrors the traditional tool chain. @param message The response to modify @param message The message we received
[ "Generate", "a", "fairly", "common", "list", "of", "orders", "to", "transform", "and", "index", "an", "object", ".", "This", "mirrors", "the", "traditional", "tool", "chain", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1526-L1552
143,116
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.emailObjectLink
private void emailObjectLink(JsonSimple response, String oid, String message) { String link = urlBase + "default/detail/" + oid; String text = "This is an automated message from the "; text += "ReDBox Curation Manager.\n\n" + message; text += "\n\nYou can find this object here:\n" + link; email(response, oid, text); }
java
private void emailObjectLink(JsonSimple response, String oid, String message) { String link = urlBase + "default/detail/" + oid; String text = "This is an automated message from the "; text += "ReDBox Curation Manager.\n\n" + message; text += "\n\nYou can find this object here:\n" + link; email(response, oid, text); }
[ "private", "void", "emailObjectLink", "(", "JsonSimple", "response", ",", "String", "oid", ",", "String", "message", ")", "{", "String", "link", "=", "urlBase", "+", "\"default/detail/\"", "+", "oid", ";", "String", "text", "=", "\"This is an automated message from the \"", ";", "text", "+=", "\"ReDBox Curation Manager.\\n\\n\"", "+", "message", ";", "text", "+=", "\"\\n\\nYou can find this object here:\\n\"", "+", "link", ";", "email", "(", "response", ",", "oid", ",", "text", ")", ";", "}" ]
Generate an order to send an email to the intended recipient with a link to an object @param response The response to add an order to @param message The message we want to send
[ "Generate", "an", "order", "to", "send", "an", "email", "to", "the", "intended", "recipient", "with", "a", "link", "to", "an", "object" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1563-L1569
143,117
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.email
private void email(JsonSimple response, String oid, String text) { JsonObject object = newMessage(response, EmailNotificationConsumer.LISTENER_ID); JsonObject message = (JsonObject) object.get("message"); message.put("to", emailAddress); message.put("body", text); message.put("oid", oid); }
java
private void email(JsonSimple response, String oid, String text) { JsonObject object = newMessage(response, EmailNotificationConsumer.LISTENER_ID); JsonObject message = (JsonObject) object.get("message"); message.put("to", emailAddress); message.put("body", text); message.put("oid", oid); }
[ "private", "void", "email", "(", "JsonSimple", "response", ",", "String", "oid", ",", "String", "text", ")", "{", "JsonObject", "object", "=", "newMessage", "(", "response", ",", "EmailNotificationConsumer", ".", "LISTENER_ID", ")", ";", "JsonObject", "message", "=", "(", "JsonObject", ")", "object", ".", "get", "(", "\"message\"", ")", ";", "message", ".", "put", "(", "\"to\"", ",", "emailAddress", ")", ";", "message", ".", "put", "(", "\"body\"", ",", "text", ")", ";", "message", ".", "put", "(", "\"oid\"", ",", "oid", ")", ";", "}" ]
Generate an order to send an email to the intended recipient @param response The response to add an order to @param message The message we want to send
[ "Generate", "an", "order", "to", "send", "an", "email", "to", "the", "intended", "recipient" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1579-L1586
143,118
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.audit
private void audit(JsonSimple response, String oid, String message) { JsonObject order = newSubscription(response, oid); JsonObject messageObject = (JsonObject) order.get("message"); messageObject.put("eventType", message); }
java
private void audit(JsonSimple response, String oid, String message) { JsonObject order = newSubscription(response, oid); JsonObject messageObject = (JsonObject) order.get("message"); messageObject.put("eventType", message); }
[ "private", "void", "audit", "(", "JsonSimple", "response", ",", "String", "oid", ",", "String", "message", ")", "{", "JsonObject", "order", "=", "newSubscription", "(", "response", ",", "oid", ")", ";", "JsonObject", "messageObject", "=", "(", "JsonObject", ")", "order", ".", "get", "(", "\"message\"", ")", ";", "messageObject", ".", "put", "(", "\"eventType\"", ",", "message", ")", ";", "}" ]
Generate an order to add a message to the System's audit log @param response The response to add an order to @param oid The object ID we are logging @param message The message we want to log
[ "Generate", "an", "order", "to", "add", "a", "message", "to", "the", "System", "s", "audit", "log" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1598-L1602
143,119
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.scheduleTransformers
private void scheduleTransformers(JsonSimple message, JsonSimple response) { String oid = message.getString(null, "oid"); List<String> list = message.getStringList("transformer", "metadata"); if (list != null && !list.isEmpty()) { for (String id : list) { JsonObject order = newTransform(response, id, oid); // Add item config to message... if it exists JsonObject itemConfig = message.getObject( "transformerOverrides", id); if (itemConfig != null) { JsonObject config = (JsonObject) order.get("config"); config.putAll(itemConfig); } } } }
java
private void scheduleTransformers(JsonSimple message, JsonSimple response) { String oid = message.getString(null, "oid"); List<String> list = message.getStringList("transformer", "metadata"); if (list != null && !list.isEmpty()) { for (String id : list) { JsonObject order = newTransform(response, id, oid); // Add item config to message... if it exists JsonObject itemConfig = message.getObject( "transformerOverrides", id); if (itemConfig != null) { JsonObject config = (JsonObject) order.get("config"); config.putAll(itemConfig); } } } }
[ "private", "void", "scheduleTransformers", "(", "JsonSimple", "message", ",", "JsonSimple", "response", ")", "{", "String", "oid", "=", "message", ".", "getString", "(", "null", ",", "\"oid\"", ")", ";", "List", "<", "String", ">", "list", "=", "message", ".", "getStringList", "(", "\"transformer\"", ",", "\"metadata\"", ")", ";", "if", "(", "list", "!=", "null", "&&", "!", "list", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "String", "id", ":", "list", ")", "{", "JsonObject", "order", "=", "newTransform", "(", "response", ",", "id", ",", "oid", ")", ";", "// Add item config to message... if it exists", "JsonObject", "itemConfig", "=", "message", ".", "getObject", "(", "\"transformerOverrides\"", ",", "id", ")", ";", "if", "(", "itemConfig", "!=", "null", ")", "{", "JsonObject", "config", "=", "(", "JsonObject", ")", "order", ".", "get", "(", "\"config\"", ")", ";", "config", ".", "putAll", "(", "itemConfig", ")", ";", "}", "}", "}", "}" ]
Generate orders for the list of normal transformers scheduled to execute on the tool chain @param message The incoming message, which contains the tool chain config for this object @param response The response to edit @param oid The object to schedule for clearing
[ "Generate", "orders", "for", "the", "list", "of", "normal", "transformers", "scheduled", "to", "execute", "on", "the", "tool", "chain" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1616-L1631
143,120
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.setRenderFlag
private void setRenderFlag(String oid) { try { DigitalObject object = storage.getObject(oid); Properties props = object.getMetadata(); props.setProperty("render-pending", "true"); storeProperties(object, props); } catch (StorageException ex) { log.error("Error accessing storage for '{}'", oid, ex); } }
java
private void setRenderFlag(String oid) { try { DigitalObject object = storage.getObject(oid); Properties props = object.getMetadata(); props.setProperty("render-pending", "true"); storeProperties(object, props); } catch (StorageException ex) { log.error("Error accessing storage for '{}'", oid, ex); } }
[ "private", "void", "setRenderFlag", "(", "String", "oid", ")", "{", "try", "{", "DigitalObject", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "Properties", "props", "=", "object", ".", "getMetadata", "(", ")", ";", "props", ".", "setProperty", "(", "\"render-pending\"", ",", "\"true\"", ")", ";", "storeProperties", "(", "object", ",", "props", ")", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Error accessing storage for '{}'\"", ",", "oid", ",", "ex", ")", ";", "}", "}" ]
Set the render flag for objects that are starting in the tool chain @param oid The object to set
[ "Set", "the", "render", "flag", "for", "objects", "that", "are", "starting", "in", "the", "tool", "chain" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1670-L1679
143,121
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.createTask
private JsonObject createTask(JsonSimple response, String oid, String task) { return createTask(response, null, oid, task); }
java
private JsonObject createTask(JsonSimple response, String oid, String task) { return createTask(response, null, oid, task); }
[ "private", "JsonObject", "createTask", "(", "JsonSimple", "response", ",", "String", "oid", ",", "String", "task", ")", "{", "return", "createTask", "(", "response", ",", "null", ",", "oid", ",", "task", ")", ";", "}" ]
Create a task. Tasks are basically just trivial messages that will come back to this manager for later action. @param response The response to edit @param oid The object to schedule for clearing @param task The task String to use on receipt @return JsonObject Access to the 'message' node of this task to provide further details after creation.
[ "Create", "a", "task", ".", "Tasks", "are", "basically", "just", "trivial", "messages", "that", "will", "come", "back", "to", "this", "manager", "for", "later", "action", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1695-L1697
143,122
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.createTask
private JsonObject createTask(JsonSimple response, String broker, String oid, String task) { JsonObject object = newMessage(response, TransactionManagerQueueConsumer.LISTENER_ID); if (broker != null) { object.put("broker", broker); } JsonObject message = (JsonObject) object.get("message"); message.put("task", task); message.put("oid", oid); return message; }
java
private JsonObject createTask(JsonSimple response, String broker, String oid, String task) { JsonObject object = newMessage(response, TransactionManagerQueueConsumer.LISTENER_ID); if (broker != null) { object.put("broker", broker); } JsonObject message = (JsonObject) object.get("message"); message.put("task", task); message.put("oid", oid); return message; }
[ "private", "JsonObject", "createTask", "(", "JsonSimple", "response", ",", "String", "broker", ",", "String", "oid", ",", "String", "task", ")", "{", "JsonObject", "object", "=", "newMessage", "(", "response", ",", "TransactionManagerQueueConsumer", ".", "LISTENER_ID", ")", ";", "if", "(", "broker", "!=", "null", ")", "{", "object", ".", "put", "(", "\"broker\"", ",", "broker", ")", ";", "}", "JsonObject", "message", "=", "(", "JsonObject", ")", "object", ".", "get", "(", "\"message\"", ")", ";", "message", ".", "put", "(", "\"task\"", ",", "task", ")", ";", "message", ".", "put", "(", "\"oid\"", ",", "oid", ")", ";", "return", "message", ";", "}" ]
Create a task. This is a more detailed option allowing for tasks being sent to remote brokers. @param response The response to edit @param broker The broker URL to use @param oid The object to schedule for clearing @param task The task String to use on receipt @return JsonObject Access to the 'message' node of this task to provide further details after creation.
[ "Create", "a", "task", ".", "This", "is", "a", "more", "detailed", "option", "allowing", "for", "tasks", "being", "sent", "to", "remote", "brokers", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1714-L1725
143,123
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.newIndex
private JsonObject newIndex(JsonSimple response, String oid) { JsonObject order = createNewOrder(response, TransactionManagerQueueConsumer.OrderType.INDEXER.toString()); order.put("oid", oid); return order; }
java
private JsonObject newIndex(JsonSimple response, String oid) { JsonObject order = createNewOrder(response, TransactionManagerQueueConsumer.OrderType.INDEXER.toString()); order.put("oid", oid); return order; }
[ "private", "JsonObject", "newIndex", "(", "JsonSimple", "response", ",", "String", "oid", ")", "{", "JsonObject", "order", "=", "createNewOrder", "(", "response", ",", "TransactionManagerQueueConsumer", ".", "OrderType", ".", "INDEXER", ".", "toString", "(", ")", ")", ";", "order", ".", "put", "(", "\"oid\"", ",", "oid", ")", ";", "return", "order", ";", "}" ]
Creation of new Orders with appropriate default nodes
[ "Creation", "of", "new", "Orders", "with", "appropriate", "default", "nodes" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1731-L1736
143,124
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.getConfigFromStorage
private JsonSimple getConfigFromStorage(String oid) { String configOid = null; String configPid = null; // Get our object and look for its config info try { DigitalObject object = storage.getObject(oid); Properties metadata = object.getMetadata(); configOid = metadata.getProperty("jsonConfigOid"); configPid = metadata.getProperty("jsonConfigPid"); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); return null; } // Validate if (configOid == null || configPid == null) { log.error("Unable to find configuration for OID '{}'", oid); return null; } // Grab the config from storage try { DigitalObject object = storage.getObject(configOid); Payload payload = object.getPayload(configPid); try { return new JsonSimple(payload.open()); } catch (IOException ex) { log.error("Error accessing config '{}' in storage: ", configOid, ex); } finally { payload.close(); } } catch (StorageException ex) { log.error("Error accessing object in storage: ", ex); } // Something screwed the pooch return null; }
java
private JsonSimple getConfigFromStorage(String oid) { String configOid = null; String configPid = null; // Get our object and look for its config info try { DigitalObject object = storage.getObject(oid); Properties metadata = object.getMetadata(); configOid = metadata.getProperty("jsonConfigOid"); configPid = metadata.getProperty("jsonConfigPid"); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); return null; } // Validate if (configOid == null || configPid == null) { log.error("Unable to find configuration for OID '{}'", oid); return null; } // Grab the config from storage try { DigitalObject object = storage.getObject(configOid); Payload payload = object.getPayload(configPid); try { return new JsonSimple(payload.open()); } catch (IOException ex) { log.error("Error accessing config '{}' in storage: ", configOid, ex); } finally { payload.close(); } } catch (StorageException ex) { log.error("Error accessing object in storage: ", ex); } // Something screwed the pooch return null; }
[ "private", "JsonSimple", "getConfigFromStorage", "(", "String", "oid", ")", "{", "String", "configOid", "=", "null", ";", "String", "configPid", "=", "null", ";", "// Get our object and look for its config info", "try", "{", "DigitalObject", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "Properties", "metadata", "=", "object", ".", "getMetadata", "(", ")", ";", "configOid", "=", "metadata", ".", "getProperty", "(", "\"jsonConfigOid\"", ")", ";", "configPid", "=", "metadata", ".", "getProperty", "(", "\"jsonConfigPid\"", ")", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Error accessing object '{}' in storage: \"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "// Validate", "if", "(", "configOid", "==", "null", "||", "configPid", "==", "null", ")", "{", "log", ".", "error", "(", "\"Unable to find configuration for OID '{}'\"", ",", "oid", ")", ";", "return", "null", ";", "}", "// Grab the config from storage", "try", "{", "DigitalObject", "object", "=", "storage", ".", "getObject", "(", "configOid", ")", ";", "Payload", "payload", "=", "object", ".", "getPayload", "(", "configPid", ")", ";", "try", "{", "return", "new", "JsonSimple", "(", "payload", ".", "open", "(", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"Error accessing config '{}' in storage: \"", ",", "configOid", ",", "ex", ")", ";", "}", "finally", "{", "payload", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Error accessing object in storage: \"", ",", "ex", ")", ";", "}", "// Something screwed the pooch", "return", "null", ";", "}" ]
Get the stored harvest configuration from storage for the indicated object. @param oid The object we want config for
[ "Get", "the", "stored", "harvest", "configuration", "from", "storage", "for", "the", "indicated", "object", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1790-L1829
143,125
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.parsedFormData
private JsonSimple parsedFormData(String oid) { // Get our data from Storage Payload payload = null; try { DigitalObject object = storage.getObject(oid); payload = getDataPayload(object); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); return null; } // Parse the JSON try { try { return FormDataParser.parse(payload.open()); } catch (IOException ex) { log.error("Error parsing data '{}': ", oid, ex); return null; } finally { payload.close(); } } catch (StorageException ex) { log.error("Error accessing data '{}' in storage: ", oid, ex); return null; } }
java
private JsonSimple parsedFormData(String oid) { // Get our data from Storage Payload payload = null; try { DigitalObject object = storage.getObject(oid); payload = getDataPayload(object); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); return null; } // Parse the JSON try { try { return FormDataParser.parse(payload.open()); } catch (IOException ex) { log.error("Error parsing data '{}': ", oid, ex); return null; } finally { payload.close(); } } catch (StorageException ex) { log.error("Error accessing data '{}' in storage: ", oid, ex); return null; } }
[ "private", "JsonSimple", "parsedFormData", "(", "String", "oid", ")", "{", "// Get our data from Storage", "Payload", "payload", "=", "null", ";", "try", "{", "DigitalObject", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "payload", "=", "getDataPayload", "(", "object", ")", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Error accessing object '{}' in storage: \"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "// Parse the JSON", "try", "{", "try", "{", "return", "FormDataParser", ".", "parse", "(", "payload", ".", "open", "(", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"Error parsing data '{}': \"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "finally", "{", "payload", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Error accessing data '{}' in storage: \"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "}" ]
Get the form data from storage for the indicated object and parse it into a JSON structure. @param oid The object we want
[ "Get", "the", "form", "data", "from", "storage", "for", "the", "indicated", "object", "and", "parse", "it", "into", "a", "JSON", "structure", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1838-L1863
143,126
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.getObjectMetadata
private Properties getObjectMetadata(String oid) { try { DigitalObject object = storage.getObject(oid); return object.getMetadata(); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); return null; } }
java
private Properties getObjectMetadata(String oid) { try { DigitalObject object = storage.getObject(oid); return object.getMetadata(); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); return null; } }
[ "private", "Properties", "getObjectMetadata", "(", "String", "oid", ")", "{", "try", "{", "DigitalObject", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "return", "object", ".", "getMetadata", "(", ")", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Error accessing object '{}' in storage: \"", ",", "oid", ",", "ex", ")", ";", "return", "null", ";", "}", "}" ]
Get the metadata properties for the indicated object. @param oid The object we want config for
[ "Get", "the", "metadata", "properties", "for", "the", "indicated", "object", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1904-L1912
143,127
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java
CurationManager.saveObjectData
private void saveObjectData(JsonSimple data, String oid) throws TransactionException { // Get from storage DigitalObject object = null; try { object = storage.getObject(oid); getDataPayload(object); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); throw new TransactionException(ex); } // Store modifications String jsonString = data.toString(true); try { updateDataPayload(object, jsonString); } catch (Exception ex) { log.error("Unable to store data '{}': ", oid, ex); throw new TransactionException(ex); } }
java
private void saveObjectData(JsonSimple data, String oid) throws TransactionException { // Get from storage DigitalObject object = null; try { object = storage.getObject(oid); getDataPayload(object); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); throw new TransactionException(ex); } // Store modifications String jsonString = data.toString(true); try { updateDataPayload(object, jsonString); } catch (Exception ex) { log.error("Unable to store data '{}': ", oid, ex); throw new TransactionException(ex); } }
[ "private", "void", "saveObjectData", "(", "JsonSimple", "data", ",", "String", "oid", ")", "throws", "TransactionException", "{", "// Get from storage", "DigitalObject", "object", "=", "null", ";", "try", "{", "object", "=", "storage", ".", "getObject", "(", "oid", ")", ";", "getDataPayload", "(", "object", ")", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "log", ".", "error", "(", "\"Error accessing object '{}' in storage: \"", ",", "oid", ",", "ex", ")", ";", "throw", "new", "TransactionException", "(", "ex", ")", ";", "}", "// Store modifications", "String", "jsonString", "=", "data", ".", "toString", "(", "true", ")", ";", "try", "{", "updateDataPayload", "(", "object", ",", "jsonString", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "\"Unable to store data '{}': \"", ",", "oid", ",", "ex", ")", ";", "throw", "new", "TransactionException", "(", "ex", ")", ";", "}", "}" ]
Save the provided object data back into storage @param data The data to save @param oid The object we want it saved in
[ "Save", "the", "provided", "object", "data", "back", "into", "storage" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/CurationManager.java#L1922-L1942
143,128
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java
FormDataParser.parse
public static JsonSimple parse(String input) throws IOException { ByteArrayInputStream bytes = new ByteArrayInputStream( input.getBytes("UTF-8")); return parse(bytes); }
java
public static JsonSimple parse(String input) throws IOException { ByteArrayInputStream bytes = new ByteArrayInputStream( input.getBytes("UTF-8")); return parse(bytes); }
[ "public", "static", "JsonSimple", "parse", "(", "String", "input", ")", "throws", "IOException", "{", "ByteArrayInputStream", "bytes", "=", "new", "ByteArrayInputStream", "(", "input", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ";", "return", "parse", "(", "bytes", ")", ";", "}" ]
A wrapper for Stream based parsing. This method accepts a String and will internally create a Stream for it. @param input The form data to parse from a String @return JsonSimple The parsed form data in JSON @throws IOException if there are errors reading/parsing the form data
[ "A", "wrapper", "for", "Stream", "based", "parsing", ".", "This", "method", "accepts", "a", "String", "and", "will", "internally", "create", "a", "Stream", "for", "it", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java#L58-L62
143,129
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java
FormDataParser.parse
public static JsonSimple parse(InputStream input) throws IOException { JsonSimple inputData = new JsonSimple(input); JsonSimple responseData = new JsonSimple(); // Go through every top level node JsonObject object = inputData.getJsonObject(); for (Object key : object.keySet()) { // Ignoring some non-form related nodes String strKey = validString(key); if (!EXCLUDED_FIELDS.contains(strKey)) { // And parse them into the repsonse String data = validString(object.get(key)); parseField(responseData, strKey, data); } } return responseData; }
java
public static JsonSimple parse(InputStream input) throws IOException { JsonSimple inputData = new JsonSimple(input); JsonSimple responseData = new JsonSimple(); // Go through every top level node JsonObject object = inputData.getJsonObject(); for (Object key : object.keySet()) { // Ignoring some non-form related nodes String strKey = validString(key); if (!EXCLUDED_FIELDS.contains(strKey)) { // And parse them into the repsonse String data = validString(object.get(key)); parseField(responseData, strKey, data); } } return responseData; }
[ "public", "static", "JsonSimple", "parse", "(", "InputStream", "input", ")", "throws", "IOException", "{", "JsonSimple", "inputData", "=", "new", "JsonSimple", "(", "input", ")", ";", "JsonSimple", "responseData", "=", "new", "JsonSimple", "(", ")", ";", "// Go through every top level node", "JsonObject", "object", "=", "inputData", ".", "getJsonObject", "(", ")", ";", "for", "(", "Object", "key", ":", "object", ".", "keySet", "(", ")", ")", "{", "// Ignoring some non-form related nodes", "String", "strKey", "=", "validString", "(", "key", ")", ";", "if", "(", "!", "EXCLUDED_FIELDS", ".", "contains", "(", "strKey", ")", ")", "{", "// And parse them into the repsonse", "String", "data", "=", "validString", "(", "object", ".", "get", "(", "key", ")", ")", ";", "parseField", "(", "responseData", ",", "strKey", ",", "data", ")", ";", "}", "}", "return", "responseData", ";", "}" ]
Accept and parse raw JSON data from an InputStream. Field name String literals will be broken down into meaningful JSON data structures. @param input The form data to parse from an InputStream @return JsonSimple The parsed form data in JSON @throws IOException if there are errors reading/parsing the form data
[ "Accept", "and", "parse", "raw", "JSON", "data", "from", "an", "InputStream", ".", "Field", "name", "String", "literals", "will", "be", "broken", "down", "into", "meaningful", "JSON", "data", "structures", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java#L72-L88
143,130
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java
FormDataParser.validString
private static String validString(Object data) throws IOException { // Null is ok if (data == null) { return ""; } if (!(data instanceof String)) { throw new IOException("Invalid non-String value found!"); } return (String) data; }
java
private static String validString(Object data) throws IOException { // Null is ok if (data == null) { return ""; } if (!(data instanceof String)) { throw new IOException("Invalid non-String value found!"); } return (String) data; }
[ "private", "static", "String", "validString", "(", "Object", "data", ")", "throws", "IOException", "{", "// Null is ok", "if", "(", "data", "==", "null", ")", "{", "return", "\"\"", ";", "}", "if", "(", "!", "(", "data", "instanceof", "String", ")", ")", "{", "throw", "new", "IOException", "(", "\"Invalid non-String value found!\"", ")", ";", "}", "return", "(", "String", ")", "data", ";", "}" ]
Ensures one of the generic objects coming from the JSON library is in fact a String. @param data The generic object @return String The String instance of the object @throws IOException if the object is not a String
[ "Ensures", "one", "of", "the", "generic", "objects", "coming", "from", "the", "JSON", "library", "is", "in", "fact", "a", "String", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java#L98-L107
143,131
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java
FormDataParser.parseField
private static void parseField(JsonSimple response, String field, String data) throws IOException { // Break it into pieces String [] fieldParts = field.split("\\."); // These are used as replacable pointers // to the last object used on the path JsonObject lastObject = null; JSONArray lastArray = null; for (int i = 0; i < fieldParts.length; i++) { // What is this segment? String segment = fieldParts[i]; int number = parseInt(segment); //************************** // 1 (of 3) The first segment adds our // new empty object to the repsonse if (i == 0) { JsonObject topObject = response.getJsonObject(); // Numbers aren't allowed here if (number != -1) { throw new IOException("Field '" + field + "' starts with" + " an array... this is illegal form data!"); } // Really simple fields... just one segment if (i + 1 == fieldParts.length) { topObject.put(segment, data); // Longer field, but what to add? } else { String nextSegment = fieldParts[i + 1]; int nextNumber = parseInt(nextSegment); // Objects... nextSegment is a String key if (nextNumber == -1) { lastObject = getObject(topObject, segment); lastArray = null; // Arrays... nextSegment is an integer index } else { lastObject = null; lastArray = getArray(topObject, segment); } } } else { //************************** // 2 (of 3) The last segment is pretty simple if (i == (fieldParts.length - 1)) { lastObject.put(segment, data); //************************** // 3 (of 3) Anything in between } else { // Check what comes next String nextSegment = fieldParts[i + 1]; int nextNumber = parseInt(nextSegment); // We are populating an object if (lastArray == null) { // So we shouldn't be looking at a number if (number != -1) { // In theory you'd need a logic bug to reach here; // illegal syntax should have been caught already. throw new IOException("Field '" + field + "' has an" + " illegal syntax!"); } // Objects... nextSegment is a String key if (nextNumber == -1) { lastObject = getObject(lastObject, segment); lastArray = null; // Arrays... nextSegment is an integer index } else { lastArray = getArray(lastObject, segment); lastObject = null; } // Populating an array } else { // We should be looking at number if (number == -1) { // In theory you'd need a logic bug to reach here; // illegal syntax should have been caught already. throw new IOException("Field '" + field + "' has an" + " illegal syntax!"); } // This is actually quite simple, because we can only // store objects. lastObject = getObject(lastArray, number); lastArray = null; } } } } }
java
private static void parseField(JsonSimple response, String field, String data) throws IOException { // Break it into pieces String [] fieldParts = field.split("\\."); // These are used as replacable pointers // to the last object used on the path JsonObject lastObject = null; JSONArray lastArray = null; for (int i = 0; i < fieldParts.length; i++) { // What is this segment? String segment = fieldParts[i]; int number = parseInt(segment); //************************** // 1 (of 3) The first segment adds our // new empty object to the repsonse if (i == 0) { JsonObject topObject = response.getJsonObject(); // Numbers aren't allowed here if (number != -1) { throw new IOException("Field '" + field + "' starts with" + " an array... this is illegal form data!"); } // Really simple fields... just one segment if (i + 1 == fieldParts.length) { topObject.put(segment, data); // Longer field, but what to add? } else { String nextSegment = fieldParts[i + 1]; int nextNumber = parseInt(nextSegment); // Objects... nextSegment is a String key if (nextNumber == -1) { lastObject = getObject(topObject, segment); lastArray = null; // Arrays... nextSegment is an integer index } else { lastObject = null; lastArray = getArray(topObject, segment); } } } else { //************************** // 2 (of 3) The last segment is pretty simple if (i == (fieldParts.length - 1)) { lastObject.put(segment, data); //************************** // 3 (of 3) Anything in between } else { // Check what comes next String nextSegment = fieldParts[i + 1]; int nextNumber = parseInt(nextSegment); // We are populating an object if (lastArray == null) { // So we shouldn't be looking at a number if (number != -1) { // In theory you'd need a logic bug to reach here; // illegal syntax should have been caught already. throw new IOException("Field '" + field + "' has an" + " illegal syntax!"); } // Objects... nextSegment is a String key if (nextNumber == -1) { lastObject = getObject(lastObject, segment); lastArray = null; // Arrays... nextSegment is an integer index } else { lastArray = getArray(lastObject, segment); lastObject = null; } // Populating an array } else { // We should be looking at number if (number == -1) { // In theory you'd need a logic bug to reach here; // illegal syntax should have been caught already. throw new IOException("Field '" + field + "' has an" + " illegal syntax!"); } // This is actually quite simple, because we can only // store objects. lastObject = getObject(lastArray, number); lastArray = null; } } } } }
[ "private", "static", "void", "parseField", "(", "JsonSimple", "response", ",", "String", "field", ",", "String", "data", ")", "throws", "IOException", "{", "// Break it into pieces", "String", "[", "]", "fieldParts", "=", "field", ".", "split", "(", "\"\\\\.\"", ")", ";", "// These are used as replacable pointers", "// to the last object used on the path", "JsonObject", "lastObject", "=", "null", ";", "JSONArray", "lastArray", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "fieldParts", ".", "length", ";", "i", "++", ")", "{", "// What is this segment?", "String", "segment", "=", "fieldParts", "[", "i", "]", ";", "int", "number", "=", "parseInt", "(", "segment", ")", ";", "//**************************", "// 1 (of 3) The first segment adds our", "// new empty object to the repsonse", "if", "(", "i", "==", "0", ")", "{", "JsonObject", "topObject", "=", "response", ".", "getJsonObject", "(", ")", ";", "// Numbers aren't allowed here", "if", "(", "number", "!=", "-", "1", ")", "{", "throw", "new", "IOException", "(", "\"Field '\"", "+", "field", "+", "\"' starts with\"", "+", "\" an array... this is illegal form data!\"", ")", ";", "}", "// Really simple fields... just one segment", "if", "(", "i", "+", "1", "==", "fieldParts", ".", "length", ")", "{", "topObject", ".", "put", "(", "segment", ",", "data", ")", ";", "// Longer field, but what to add?", "}", "else", "{", "String", "nextSegment", "=", "fieldParts", "[", "i", "+", "1", "]", ";", "int", "nextNumber", "=", "parseInt", "(", "nextSegment", ")", ";", "// Objects... nextSegment is a String key", "if", "(", "nextNumber", "==", "-", "1", ")", "{", "lastObject", "=", "getObject", "(", "topObject", ",", "segment", ")", ";", "lastArray", "=", "null", ";", "// Arrays... nextSegment is an integer index ", "}", "else", "{", "lastObject", "=", "null", ";", "lastArray", "=", "getArray", "(", "topObject", ",", "segment", ")", ";", "}", "}", "}", "else", "{", "//**************************", "// 2 (of 3) The last segment is pretty simple", "if", "(", "i", "==", "(", "fieldParts", ".", "length", "-", "1", ")", ")", "{", "lastObject", ".", "put", "(", "segment", ",", "data", ")", ";", "//**************************", "// 3 (of 3) Anything in between", "}", "else", "{", "// Check what comes next", "String", "nextSegment", "=", "fieldParts", "[", "i", "+", "1", "]", ";", "int", "nextNumber", "=", "parseInt", "(", "nextSegment", ")", ";", "// We are populating an object", "if", "(", "lastArray", "==", "null", ")", "{", "// So we shouldn't be looking at a number", "if", "(", "number", "!=", "-", "1", ")", "{", "// In theory you'd need a logic bug to reach here;", "// illegal syntax should have been caught already.", "throw", "new", "IOException", "(", "\"Field '\"", "+", "field", "+", "\"' has an\"", "+", "\" illegal syntax!\"", ")", ";", "}", "// Objects... nextSegment is a String key", "if", "(", "nextNumber", "==", "-", "1", ")", "{", "lastObject", "=", "getObject", "(", "lastObject", ",", "segment", ")", ";", "lastArray", "=", "null", ";", "// Arrays... nextSegment is an integer index ", "}", "else", "{", "lastArray", "=", "getArray", "(", "lastObject", ",", "segment", ")", ";", "lastObject", "=", "null", ";", "}", "// Populating an array", "}", "else", "{", "// We should be looking at number", "if", "(", "number", "==", "-", "1", ")", "{", "// In theory you'd need a logic bug to reach here;", "// illegal syntax should have been caught already.", "throw", "new", "IOException", "(", "\"Field '\"", "+", "field", "+", "\"' has an\"", "+", "\" illegal syntax!\"", ")", ";", "}", "// This is actually quite simple, because we can only", "// store objects. ", "lastObject", "=", "getObject", "(", "lastArray", ",", "number", ")", ";", "lastArray", "=", "null", ";", "}", "}", "}", "}", "}" ]
Parse an individual field into the response object. @param response The response JSON data structure being built. @param field The current field name to parse @param data The data contained in this current field @throws IOException if errors occur during the parse
[ "Parse", "an", "individual", "field", "into", "the", "response", "object", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java#L117-L216
143,132
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java
FormDataParser.getArray
private static JSONArray getArray(JsonObject object, String key) throws IOException { // Get the existing one if (object.containsKey(key)) { Object existing = object.get(key); if (!(existing instanceof JSONArray)) { throw new IOException("Invalid field structure, '" + key + "' expected to be an array, but incompatible " + "data type already present."); } return (JSONArray) existing; // Or add a new one } else { JSONArray newObject = new JSONArray(); object.put(key, newObject); return newObject; } }
java
private static JSONArray getArray(JsonObject object, String key) throws IOException { // Get the existing one if (object.containsKey(key)) { Object existing = object.get(key); if (!(existing instanceof JSONArray)) { throw new IOException("Invalid field structure, '" + key + "' expected to be an array, but incompatible " + "data type already present."); } return (JSONArray) existing; // Or add a new one } else { JSONArray newObject = new JSONArray(); object.put(key, newObject); return newObject; } }
[ "private", "static", "JSONArray", "getArray", "(", "JsonObject", "object", ",", "String", "key", ")", "throws", "IOException", "{", "// Get the existing one", "if", "(", "object", ".", "containsKey", "(", "key", ")", ")", "{", "Object", "existing", "=", "object", ".", "get", "(", "key", ")", ";", "if", "(", "!", "(", "existing", "instanceof", "JSONArray", ")", ")", "{", "throw", "new", "IOException", "(", "\"Invalid field structure, '\"", "+", "key", "+", "\"' expected to be an array, but incompatible \"", "+", "\"data type already present.\"", ")", ";", "}", "return", "(", "JSONArray", ")", "existing", ";", "// Or add a new one", "}", "else", "{", "JSONArray", "newObject", "=", "new", "JSONArray", "(", ")", ";", "object", ".", "put", "(", "key", ",", "newObject", ")", ";", "return", "newObject", ";", "}", "}" ]
Get a child JSON Array from an incoming JSON object. If the child does not exist it will be created. @param object The incoming object we are to look inside @param key The child node we are looking for @return JSONArray The child we found or created @throws IOException if there is a type mismatch on existing data
[ "Get", "a", "child", "JSON", "Array", "from", "an", "incoming", "JSON", "object", ".", "If", "the", "child", "does", "not", "exist", "it", "will", "be", "created", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java#L271-L289
143,133
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java
FormDataParser.getObject
private static JsonObject getObject(JsonObject object, String key) throws IOException { // Get the existing one if (object.containsKey(key)) { Object existing = object.get(key); if (!(existing instanceof JsonObject)) { throw new IOException("Invalid field structure, '" + key + "' expected to be an object, but incompatible " + "data type already present."); } return (JsonObject) existing; // Or add a new one } else { JsonObject newObject = new JsonObject(); object.put(key, newObject); return newObject; } }
java
private static JsonObject getObject(JsonObject object, String key) throws IOException { // Get the existing one if (object.containsKey(key)) { Object existing = object.get(key); if (!(existing instanceof JsonObject)) { throw new IOException("Invalid field structure, '" + key + "' expected to be an object, but incompatible " + "data type already present."); } return (JsonObject) existing; // Or add a new one } else { JsonObject newObject = new JsonObject(); object.put(key, newObject); return newObject; } }
[ "private", "static", "JsonObject", "getObject", "(", "JsonObject", "object", ",", "String", "key", ")", "throws", "IOException", "{", "// Get the existing one", "if", "(", "object", ".", "containsKey", "(", "key", ")", ")", "{", "Object", "existing", "=", "object", ".", "get", "(", "key", ")", ";", "if", "(", "!", "(", "existing", "instanceof", "JsonObject", ")", ")", "{", "throw", "new", "IOException", "(", "\"Invalid field structure, '\"", "+", "key", "+", "\"' expected to be an object, but incompatible \"", "+", "\"data type already present.\"", ")", ";", "}", "return", "(", "JsonObject", ")", "existing", ";", "// Or add a new one", "}", "else", "{", "JsonObject", "newObject", "=", "new", "JsonObject", "(", ")", ";", "object", ".", "put", "(", "key", ",", "newObject", ")", ";", "return", "newObject", ";", "}", "}" ]
Get a child JSON Object from an incoming JSON object. If the child does not exist it will be created. @param object The incoming object we are to look inside @param key The child node we are looking for @return JsonObject The child we found or created @throws IOException if there is a type mismatch on existing data
[ "Get", "a", "child", "JSON", "Object", "from", "an", "incoming", "JSON", "object", ".", "If", "the", "child", "does", "not", "exist", "it", "will", "be", "created", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java#L300-L318
143,134
redbox-mint/redbox
plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java
FormDataParser.parseInt
private static int parseInt(String integer) throws IOException { try { int value = Integer.parseInt(integer); if (value < 0) { throw new IOException("Invalid number in field name: '" + integer + "'"); } return value; } catch (NumberFormatException ex) { // It's not an integer return -1; } }
java
private static int parseInt(String integer) throws IOException { try { int value = Integer.parseInt(integer); if (value < 0) { throw new IOException("Invalid number in field name: '" + integer + "'"); } return value; } catch (NumberFormatException ex) { // It's not an integer return -1; } }
[ "private", "static", "int", "parseInt", "(", "String", "integer", ")", "throws", "IOException", "{", "try", "{", "int", "value", "=", "Integer", ".", "parseInt", "(", "integer", ")", ";", "if", "(", "value", "<", "0", ")", "{", "throw", "new", "IOException", "(", "\"Invalid number in field name: '\"", "+", "integer", "+", "\"'\"", ")", ";", "}", "return", "value", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "// It's not an integer", "return", "-", "1", ";", "}", "}" ]
Parse a String to an integer. This wrapper is simply to avoid the try catch statement repeatedly. Tests for -1 are sufficient, since it is illegal in form data. Valid integers below 1 throw exceptions because of this illegality. @param integer The incoming integer to parse @return int The parsed integer, or -1 if it is not an integer @throws IOException if errors occur during the parse
[ "Parse", "a", "String", "to", "an", "integer", ".", "This", "wrapper", "is", "simply", "to", "avoid", "the", "try", "catch", "statement", "repeatedly", ".", "Tests", "for", "-", "1", "are", "sufficient", "since", "it", "is", "illegal", "in", "form", "data", ".", "Valid", "integers", "below", "1", "throw", "exceptions", "because", "of", "this", "illegality", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transaction/curation/src/main/java/com/googlecode/fascinator/redbox/plugins/curation/redbox/FormDataParser.java#L330-L342
143,135
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.init
@Override public void init(String jsonString) throws TransformerException { try { setConfig(new JsonSimpleConfig(jsonString)); } catch (IOException e) { throw new TransformerException(e); } }
java
@Override public void init(String jsonString) throws TransformerException { try { setConfig(new JsonSimpleConfig(jsonString)); } catch (IOException e) { throw new TransformerException(e); } }
[ "@", "Override", "public", "void", "init", "(", "String", "jsonString", ")", "throws", "TransformerException", "{", "try", "{", "setConfig", "(", "new", "JsonSimpleConfig", "(", "jsonString", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "TransformerException", "(", "e", ")", ";", "}", "}" ]
Initializes the plugin using the specified JSON String @param jsonString JSON configuration string @throws TransformerException if there was an error in initialization
[ "Initializes", "the", "plugin", "using", "the", "specified", "JSON", "String" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L161-L168
143,136
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.process
private DigitalObject process(DigitalObject in, String jsonConfig) throws TransformerException { String oid = in.getId(); // Workflow payload JsonSimple workflow = null; try { Payload workflowPayload = in.getPayload("workflow.metadata"); workflow = new JsonSimple(workflowPayload.open()); workflowPayload.close(); } catch (StorageException ex) { error("Error accessing workflow data from Object!\nOID: '" + oid + "'", ex); } catch (IOException ex) { error("Error parsing workflow data from Object!\nOID: '" + oid + "'", ex); } // Make sure it is live String step = workflow.getString(null, "step"); if (step == null || !step.equals("live")) { log.warn("Object is not live! '{}'", oid); return in; } // Make sure we have a title String title = workflow.getString(null, Strings.NODE_FORMDATA, "title"); if (title == null) { error("No title provided in Object form data!\nOID: '" + oid + "'"); } // Object metadata Properties metadata = null; try { metadata = in.getMetadata(); } catch (StorageException ex) { error("Error reading Object metadata!\nOID: '" + oid + "'", ex); } // Now that we have all the data we need, go do the real work return processObject(in, workflow, metadata); }
java
private DigitalObject process(DigitalObject in, String jsonConfig) throws TransformerException { String oid = in.getId(); // Workflow payload JsonSimple workflow = null; try { Payload workflowPayload = in.getPayload("workflow.metadata"); workflow = new JsonSimple(workflowPayload.open()); workflowPayload.close(); } catch (StorageException ex) { error("Error accessing workflow data from Object!\nOID: '" + oid + "'", ex); } catch (IOException ex) { error("Error parsing workflow data from Object!\nOID: '" + oid + "'", ex); } // Make sure it is live String step = workflow.getString(null, "step"); if (step == null || !step.equals("live")) { log.warn("Object is not live! '{}'", oid); return in; } // Make sure we have a title String title = workflow.getString(null, Strings.NODE_FORMDATA, "title"); if (title == null) { error("No title provided in Object form data!\nOID: '" + oid + "'"); } // Object metadata Properties metadata = null; try { metadata = in.getMetadata(); } catch (StorageException ex) { error("Error reading Object metadata!\nOID: '" + oid + "'", ex); } // Now that we have all the data we need, go do the real work return processObject(in, workflow, metadata); }
[ "private", "DigitalObject", "process", "(", "DigitalObject", "in", ",", "String", "jsonConfig", ")", "throws", "TransformerException", "{", "String", "oid", "=", "in", ".", "getId", "(", ")", ";", "// Workflow payload", "JsonSimple", "workflow", "=", "null", ";", "try", "{", "Payload", "workflowPayload", "=", "in", ".", "getPayload", "(", "\"workflow.metadata\"", ")", ";", "workflow", "=", "new", "JsonSimple", "(", "workflowPayload", ".", "open", "(", ")", ")", ";", "workflowPayload", ".", "close", "(", ")", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "error", "(", "\"Error accessing workflow data from Object!\\nOID: '\"", "+", "oid", "+", "\"'\"", ",", "ex", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "error", "(", "\"Error parsing workflow data from Object!\\nOID: '\"", "+", "oid", "+", "\"'\"", ",", "ex", ")", ";", "}", "// Make sure it is live", "String", "step", "=", "workflow", ".", "getString", "(", "null", ",", "\"step\"", ")", ";", "if", "(", "step", "==", "null", "||", "!", "step", ".", "equals", "(", "\"live\"", ")", ")", "{", "log", ".", "warn", "(", "\"Object is not live! '{}'\"", ",", "oid", ")", ";", "return", "in", ";", "}", "// Make sure we have a title", "String", "title", "=", "workflow", ".", "getString", "(", "null", ",", "Strings", ".", "NODE_FORMDATA", ",", "\"title\"", ")", ";", "if", "(", "title", "==", "null", ")", "{", "error", "(", "\"No title provided in Object form data!\\nOID: '\"", "+", "oid", "+", "\"'\"", ")", ";", "}", "// Object metadata", "Properties", "metadata", "=", "null", ";", "try", "{", "metadata", "=", "in", ".", "getMetadata", "(", ")", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "error", "(", "\"Error reading Object metadata!\\nOID: '\"", "+", "oid", "+", "\"'\"", ",", "ex", ")", ";", "}", "// Now that we have all the data we need, go do the real work", "return", "processObject", "(", "in", ",", "workflow", ",", "metadata", ")", ";", "}" ]
Top level wrapping method for a processing an object. This method first performs all the basic checks whether this Object is technically ready to go to VITAL (no matter what the workflow says). @param param Map of key/value pairs to add to the index
[ "Top", "level", "wrapping", "method", "for", "a", "processing", "an", "object", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L521-L562
143,137
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.processObject
private DigitalObject processObject(DigitalObject object, JsonSimple workflow, Properties metadata) throws TransformerException { String oid = object.getId(); String title = workflow.getString(null, Strings.NODE_FORMDATA, "title"); FedoraClient fedora = null; try { fedora = fedoraConnect(); } catch (TransformerException ex) { error("Error connecting to VITAL", ex, oid, title); } // Find out if we've sent it to VITAL before String vitalPid = metadata.getProperty(Strings.PROP_VITAL_KEY); if (vitalPid != null) { log.debug("Existing VITAL object: '{}'", vitalPid); // Make sure it exists, we'll test the DC datastream if (!datastreamExists(fedora, vitalPid, "DC")) { // How did this happen? Better let someone know String message = " !!! WARNING !!! The expected VITAL object '" + vitalPid + "' was not found. A new object will be created instead!"; error(message, null, oid, title); vitalPid = null; } } // A new VITAL object if (vitalPid == null) { try { vitalPid = createNewObject(fedora, object.getId()); log.debug("New VITAL object created: '{}'", vitalPid); metadata.setProperty(Strings.PROP_VITAL_KEY, vitalPid); // Trigger a save on the object's metadata object.close(); } catch (Exception ex) { error("Failed to create object in VITAL", ex, oid, title); } } // Do we have any wait conditions to test? if (!waitProperties.isEmpty()) { boolean process = false; for (String test : waitProperties) { String value = metadata.getProperty(test); if (value != null) { // We found a property we've been told to wait for log.info("Wait condition '{}' found.", test); process = true; } } // Are we continuing? if (!process) { log.info("No wait conditions have been met, processing halted"); return object; } } // Need to make sure the object is active try { String isActive = metadata.getProperty(Strings.PROP_VITAL_ACTIVE); if (isActive == null) { log.info("Activating object in fedora: '{}'", oid); String cutTitle = title; if (cutTitle.length() > 250) { cutTitle = cutTitle.substring(0, 250) + "..."; } fedora.getAPIM().modifyObject(vitalPid, "A", cutTitle, null, "ReDBox activating object: '" + oid + "'"); // Record this so we don't do it again metadata.setProperty(Strings.PROP_VITAL_ACTIVE, "true"); object.close(); } } catch (Exception ex) { error("Failed to activate object in VITAL", ex, oid, title); } // Submit all the payloads to VITAL now try { processDatastreams(fedora, object, vitalPid); } catch (Exception ex) { error("Failed to send object to VITAL", ex, oid, title); } return object; }
java
private DigitalObject processObject(DigitalObject object, JsonSimple workflow, Properties metadata) throws TransformerException { String oid = object.getId(); String title = workflow.getString(null, Strings.NODE_FORMDATA, "title"); FedoraClient fedora = null; try { fedora = fedoraConnect(); } catch (TransformerException ex) { error("Error connecting to VITAL", ex, oid, title); } // Find out if we've sent it to VITAL before String vitalPid = metadata.getProperty(Strings.PROP_VITAL_KEY); if (vitalPid != null) { log.debug("Existing VITAL object: '{}'", vitalPid); // Make sure it exists, we'll test the DC datastream if (!datastreamExists(fedora, vitalPid, "DC")) { // How did this happen? Better let someone know String message = " !!! WARNING !!! The expected VITAL object '" + vitalPid + "' was not found. A new object will be created instead!"; error(message, null, oid, title); vitalPid = null; } } // A new VITAL object if (vitalPid == null) { try { vitalPid = createNewObject(fedora, object.getId()); log.debug("New VITAL object created: '{}'", vitalPid); metadata.setProperty(Strings.PROP_VITAL_KEY, vitalPid); // Trigger a save on the object's metadata object.close(); } catch (Exception ex) { error("Failed to create object in VITAL", ex, oid, title); } } // Do we have any wait conditions to test? if (!waitProperties.isEmpty()) { boolean process = false; for (String test : waitProperties) { String value = metadata.getProperty(test); if (value != null) { // We found a property we've been told to wait for log.info("Wait condition '{}' found.", test); process = true; } } // Are we continuing? if (!process) { log.info("No wait conditions have been met, processing halted"); return object; } } // Need to make sure the object is active try { String isActive = metadata.getProperty(Strings.PROP_VITAL_ACTIVE); if (isActive == null) { log.info("Activating object in fedora: '{}'", oid); String cutTitle = title; if (cutTitle.length() > 250) { cutTitle = cutTitle.substring(0, 250) + "..."; } fedora.getAPIM().modifyObject(vitalPid, "A", cutTitle, null, "ReDBox activating object: '" + oid + "'"); // Record this so we don't do it again metadata.setProperty(Strings.PROP_VITAL_ACTIVE, "true"); object.close(); } } catch (Exception ex) { error("Failed to activate object in VITAL", ex, oid, title); } // Submit all the payloads to VITAL now try { processDatastreams(fedora, object, vitalPid); } catch (Exception ex) { error("Failed to send object to VITAL", ex, oid, title); } return object; }
[ "private", "DigitalObject", "processObject", "(", "DigitalObject", "object", ",", "JsonSimple", "workflow", ",", "Properties", "metadata", ")", "throws", "TransformerException", "{", "String", "oid", "=", "object", ".", "getId", "(", ")", ";", "String", "title", "=", "workflow", ".", "getString", "(", "null", ",", "Strings", ".", "NODE_FORMDATA", ",", "\"title\"", ")", ";", "FedoraClient", "fedora", "=", "null", ";", "try", "{", "fedora", "=", "fedoraConnect", "(", ")", ";", "}", "catch", "(", "TransformerException", "ex", ")", "{", "error", "(", "\"Error connecting to VITAL\"", ",", "ex", ",", "oid", ",", "title", ")", ";", "}", "// Find out if we've sent it to VITAL before", "String", "vitalPid", "=", "metadata", ".", "getProperty", "(", "Strings", ".", "PROP_VITAL_KEY", ")", ";", "if", "(", "vitalPid", "!=", "null", ")", "{", "log", ".", "debug", "(", "\"Existing VITAL object: '{}'\"", ",", "vitalPid", ")", ";", "// Make sure it exists, we'll test the DC datastream", "if", "(", "!", "datastreamExists", "(", "fedora", ",", "vitalPid", ",", "\"DC\"", ")", ")", "{", "// How did this happen? Better let someone know", "String", "message", "=", "\" !!! WARNING !!! The expected VITAL object '\"", "+", "vitalPid", "+", "\"' was not found. A new object will be created instead!\"", ";", "error", "(", "message", ",", "null", ",", "oid", ",", "title", ")", ";", "vitalPid", "=", "null", ";", "}", "}", "// A new VITAL object", "if", "(", "vitalPid", "==", "null", ")", "{", "try", "{", "vitalPid", "=", "createNewObject", "(", "fedora", ",", "object", ".", "getId", "(", ")", ")", ";", "log", ".", "debug", "(", "\"New VITAL object created: '{}'\"", ",", "vitalPid", ")", ";", "metadata", ".", "setProperty", "(", "Strings", ".", "PROP_VITAL_KEY", ",", "vitalPid", ")", ";", "// Trigger a save on the object's metadata", "object", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "error", "(", "\"Failed to create object in VITAL\"", ",", "ex", ",", "oid", ",", "title", ")", ";", "}", "}", "// Do we have any wait conditions to test?", "if", "(", "!", "waitProperties", ".", "isEmpty", "(", ")", ")", "{", "boolean", "process", "=", "false", ";", "for", "(", "String", "test", ":", "waitProperties", ")", "{", "String", "value", "=", "metadata", ".", "getProperty", "(", "test", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "// We found a property we've been told to wait for", "log", ".", "info", "(", "\"Wait condition '{}' found.\"", ",", "test", ")", ";", "process", "=", "true", ";", "}", "}", "// Are we continuing?", "if", "(", "!", "process", ")", "{", "log", ".", "info", "(", "\"No wait conditions have been met, processing halted\"", ")", ";", "return", "object", ";", "}", "}", "// Need to make sure the object is active", "try", "{", "String", "isActive", "=", "metadata", ".", "getProperty", "(", "Strings", ".", "PROP_VITAL_ACTIVE", ")", ";", "if", "(", "isActive", "==", "null", ")", "{", "log", ".", "info", "(", "\"Activating object in fedora: '{}'\"", ",", "oid", ")", ";", "String", "cutTitle", "=", "title", ";", "if", "(", "cutTitle", ".", "length", "(", ")", ">", "250", ")", "{", "cutTitle", "=", "cutTitle", ".", "substring", "(", "0", ",", "250", ")", "+", "\"...\"", ";", "}", "fedora", ".", "getAPIM", "(", ")", ".", "modifyObject", "(", "vitalPid", ",", "\"A\"", ",", "cutTitle", ",", "null", ",", "\"ReDBox activating object: '\"", "+", "oid", "+", "\"'\"", ")", ";", "// Record this so we don't do it again", "metadata", ".", "setProperty", "(", "Strings", ".", "PROP_VITAL_ACTIVE", ",", "\"true\"", ")", ";", "object", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "error", "(", "\"Failed to activate object in VITAL\"", ",", "ex", ",", "oid", ",", "title", ")", ";", "}", "// Submit all the payloads to VITAL now", "try", "{", "processDatastreams", "(", "fedora", ",", "object", ",", "vitalPid", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "error", "(", "\"Failed to send object to VITAL\"", ",", "ex", ",", "oid", ",", "title", ")", ";", "}", "return", "object", ";", "}" ]
Middle level wrapping method for processing objects. Now we are looking at what actually needs to be done. Has the object already been put in VITAL, or is it new. @param object The Object in question @param workflow The workflow data for the object @param metadata The Object's metadata
[ "Middle", "level", "wrapping", "method", "for", "processing", "objects", ".", "Now", "we", "are", "looking", "at", "what", "actually", "needs", "to", "be", "done", ".", "Has", "the", "object", "already", "been", "put", "in", "VITAL", "or", "is", "it", "new", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L573-L658
143,138
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.createNewObject
private String createNewObject(FedoraClient fedora, String oid) throws Exception { InputStream in = null; byte[] template = null; // Start by reading our FOXML template into memory try { if (foxmlTemplate != null) { // We have a user provided template in = new FileInputStream(foxmlTemplate); template = IOUtils.toByteArray(in); } else { // Use the built in template in = getClass().getResourceAsStream("/foxml_template.xml"); template = IOUtils.toByteArray(in); } } catch (IOException ex) { throw new Exception( "Error accessing FOXML Template, please check system configuration!"); } finally { if (in != null) { in.close(); } } String vitalPid = fedora.getAPIM().ingest(template, Strings.FOXML_VERSION, "ReDBox creating new object: '" + oid + "'"); log.info("New VITAL PID: '{}'", vitalPid); return vitalPid; }
java
private String createNewObject(FedoraClient fedora, String oid) throws Exception { InputStream in = null; byte[] template = null; // Start by reading our FOXML template into memory try { if (foxmlTemplate != null) { // We have a user provided template in = new FileInputStream(foxmlTemplate); template = IOUtils.toByteArray(in); } else { // Use the built in template in = getClass().getResourceAsStream("/foxml_template.xml"); template = IOUtils.toByteArray(in); } } catch (IOException ex) { throw new Exception( "Error accessing FOXML Template, please check system configuration!"); } finally { if (in != null) { in.close(); } } String vitalPid = fedora.getAPIM().ingest(template, Strings.FOXML_VERSION, "ReDBox creating new object: '" + oid + "'"); log.info("New VITAL PID: '{}'", vitalPid); return vitalPid; }
[ "private", "String", "createNewObject", "(", "FedoraClient", "fedora", ",", "String", "oid", ")", "throws", "Exception", "{", "InputStream", "in", "=", "null", ";", "byte", "[", "]", "template", "=", "null", ";", "// Start by reading our FOXML template into memory", "try", "{", "if", "(", "foxmlTemplate", "!=", "null", ")", "{", "// We have a user provided template", "in", "=", "new", "FileInputStream", "(", "foxmlTemplate", ")", ";", "template", "=", "IOUtils", ".", "toByteArray", "(", "in", ")", ";", "}", "else", "{", "// Use the built in template", "in", "=", "getClass", "(", ")", ".", "getResourceAsStream", "(", "\"/foxml_template.xml\"", ")", ";", "template", "=", "IOUtils", ".", "toByteArray", "(", "in", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "Exception", "(", "\"Error accessing FOXML Template, please check system configuration!\"", ")", ";", "}", "finally", "{", "if", "(", "in", "!=", "null", ")", "{", "in", ".", "close", "(", ")", ";", "}", "}", "String", "vitalPid", "=", "fedora", ".", "getAPIM", "(", ")", ".", "ingest", "(", "template", ",", "Strings", ".", "FOXML_VERSION", ",", "\"ReDBox creating new object: '\"", "+", "oid", "+", "\"'\"", ")", ";", "log", ".", "info", "(", "\"New VITAL PID: '{}'\"", ",", "vitalPid", ")", ";", "return", "vitalPid", ";", "}" ]
Create a new VITAL object and return the PID. @param fedora An instantiated fedora client @param oid The ID of the ReDBox object we will store here. For logging @return String The new VITAL PID that was just created
[ "Create", "a", "new", "VITAL", "object", "and", "return", "the", "PID", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L667-L696
143,139
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.processDatastreams
private void processDatastreams(FedoraClient fedora, DigitalObject object, String vitalPid) throws Exception { int sent = 0; // Each payload we care about needs to be sent for (String ourPid : pids.keySet()) { // Fascinator packages have unpredictable names, // so we just use the extension // eg. 'e6e174fe-3508-4c8a-8530-1d6bb644d10a.tfpackage' String realPid = ourPid; if (ourPid.equals(".tfpackage")) { realPid = getPackagePid(object); if (realPid == null) { String message = partialUploadErrorMessage(ourPid, sent, pids.size(), vitalPid); throw new Exception(message + "\n\nPackage not found."); } } log.info("Processing PID to send to VITAL: '{}'", ourPid); // Get our configuration JsonSimple thisPid = pids.get(ourPid); String dsId = thisPid.getString(realPid, "dsID"); String label = thisPid.getString(dsId, "label"); String status = thisPid.getString("A", "status"); String controlGroup = thisPid.getString("X", "controlGroup"); boolean versionable = thisPid.getBoolean(true, "versionable"); boolean retainIds = thisPid.getBoolean(true, "retainIds"); String[] altIds = {}; if (retainIds && datastreamExists(fedora, vitalPid, dsId)) { altIds = getAltIds(fedora, vitalPid, dsId); for (String altId : altIds) { log.debug("Retaining alt ID: '{}' => {}'", dsId, altId); } } // MIME Type Payload payload = null; String mimeType = null; try { payload = object.getPayload(realPid); } catch (StorageException ex) { String message = partialUploadErrorMessage(realPid, sent, pids.size(), vitalPid); throw new Exception(message + "\n\nError accessing payload '" + realPid + "' : ", ex); } mimeType = payload.getContentType(); // Default to binary data if (mimeType == null) { mimeType = "application/octet-stream"; } try { sendToVital(fedora, object, realPid, vitalPid, dsId, altIds, label, mimeType, controlGroup, status, versionable); } catch (Exception ex) { String message = partialUploadErrorMessage(realPid, sent, pids.size(), vitalPid); throw new Exception(message, ex); } // Increase our counter sent++; } // End for loop // Datastreams are taken care of, now handle attachments try { processAttachments(fedora, object, vitalPid); } catch (Exception ex) { throw new Exception("Error processing attachments: ", ex); } }
java
private void processDatastreams(FedoraClient fedora, DigitalObject object, String vitalPid) throws Exception { int sent = 0; // Each payload we care about needs to be sent for (String ourPid : pids.keySet()) { // Fascinator packages have unpredictable names, // so we just use the extension // eg. 'e6e174fe-3508-4c8a-8530-1d6bb644d10a.tfpackage' String realPid = ourPid; if (ourPid.equals(".tfpackage")) { realPid = getPackagePid(object); if (realPid == null) { String message = partialUploadErrorMessage(ourPid, sent, pids.size(), vitalPid); throw new Exception(message + "\n\nPackage not found."); } } log.info("Processing PID to send to VITAL: '{}'", ourPid); // Get our configuration JsonSimple thisPid = pids.get(ourPid); String dsId = thisPid.getString(realPid, "dsID"); String label = thisPid.getString(dsId, "label"); String status = thisPid.getString("A", "status"); String controlGroup = thisPid.getString("X", "controlGroup"); boolean versionable = thisPid.getBoolean(true, "versionable"); boolean retainIds = thisPid.getBoolean(true, "retainIds"); String[] altIds = {}; if (retainIds && datastreamExists(fedora, vitalPid, dsId)) { altIds = getAltIds(fedora, vitalPid, dsId); for (String altId : altIds) { log.debug("Retaining alt ID: '{}' => {}'", dsId, altId); } } // MIME Type Payload payload = null; String mimeType = null; try { payload = object.getPayload(realPid); } catch (StorageException ex) { String message = partialUploadErrorMessage(realPid, sent, pids.size(), vitalPid); throw new Exception(message + "\n\nError accessing payload '" + realPid + "' : ", ex); } mimeType = payload.getContentType(); // Default to binary data if (mimeType == null) { mimeType = "application/octet-stream"; } try { sendToVital(fedora, object, realPid, vitalPid, dsId, altIds, label, mimeType, controlGroup, status, versionable); } catch (Exception ex) { String message = partialUploadErrorMessage(realPid, sent, pids.size(), vitalPid); throw new Exception(message, ex); } // Increase our counter sent++; } // End for loop // Datastreams are taken care of, now handle attachments try { processAttachments(fedora, object, vitalPid); } catch (Exception ex) { throw new Exception("Error processing attachments: ", ex); } }
[ "private", "void", "processDatastreams", "(", "FedoraClient", "fedora", ",", "DigitalObject", "object", ",", "String", "vitalPid", ")", "throws", "Exception", "{", "int", "sent", "=", "0", ";", "// Each payload we care about needs to be sent", "for", "(", "String", "ourPid", ":", "pids", ".", "keySet", "(", ")", ")", "{", "// Fascinator packages have unpredictable names,", "// so we just use the extension", "// eg. 'e6e174fe-3508-4c8a-8530-1d6bb644d10a.tfpackage'", "String", "realPid", "=", "ourPid", ";", "if", "(", "ourPid", ".", "equals", "(", "\".tfpackage\"", ")", ")", "{", "realPid", "=", "getPackagePid", "(", "object", ")", ";", "if", "(", "realPid", "==", "null", ")", "{", "String", "message", "=", "partialUploadErrorMessage", "(", "ourPid", ",", "sent", ",", "pids", ".", "size", "(", ")", ",", "vitalPid", ")", ";", "throw", "new", "Exception", "(", "message", "+", "\"\\n\\nPackage not found.\"", ")", ";", "}", "}", "log", ".", "info", "(", "\"Processing PID to send to VITAL: '{}'\"", ",", "ourPid", ")", ";", "// Get our configuration", "JsonSimple", "thisPid", "=", "pids", ".", "get", "(", "ourPid", ")", ";", "String", "dsId", "=", "thisPid", ".", "getString", "(", "realPid", ",", "\"dsID\"", ")", ";", "String", "label", "=", "thisPid", ".", "getString", "(", "dsId", ",", "\"label\"", ")", ";", "String", "status", "=", "thisPid", ".", "getString", "(", "\"A\"", ",", "\"status\"", ")", ";", "String", "controlGroup", "=", "thisPid", ".", "getString", "(", "\"X\"", ",", "\"controlGroup\"", ")", ";", "boolean", "versionable", "=", "thisPid", ".", "getBoolean", "(", "true", ",", "\"versionable\"", ")", ";", "boolean", "retainIds", "=", "thisPid", ".", "getBoolean", "(", "true", ",", "\"retainIds\"", ")", ";", "String", "[", "]", "altIds", "=", "{", "}", ";", "if", "(", "retainIds", "&&", "datastreamExists", "(", "fedora", ",", "vitalPid", ",", "dsId", ")", ")", "{", "altIds", "=", "getAltIds", "(", "fedora", ",", "vitalPid", ",", "dsId", ")", ";", "for", "(", "String", "altId", ":", "altIds", ")", "{", "log", ".", "debug", "(", "\"Retaining alt ID: '{}' => {}'\"", ",", "dsId", ",", "altId", ")", ";", "}", "}", "// MIME Type", "Payload", "payload", "=", "null", ";", "String", "mimeType", "=", "null", ";", "try", "{", "payload", "=", "object", ".", "getPayload", "(", "realPid", ")", ";", "}", "catch", "(", "StorageException", "ex", ")", "{", "String", "message", "=", "partialUploadErrorMessage", "(", "realPid", ",", "sent", ",", "pids", ".", "size", "(", ")", ",", "vitalPid", ")", ";", "throw", "new", "Exception", "(", "message", "+", "\"\\n\\nError accessing payload '\"", "+", "realPid", "+", "\"' : \"", ",", "ex", ")", ";", "}", "mimeType", "=", "payload", ".", "getContentType", "(", ")", ";", "// Default to binary data", "if", "(", "mimeType", "==", "null", ")", "{", "mimeType", "=", "\"application/octet-stream\"", ";", "}", "try", "{", "sendToVital", "(", "fedora", ",", "object", ",", "realPid", ",", "vitalPid", ",", "dsId", ",", "altIds", ",", "label", ",", "mimeType", ",", "controlGroup", ",", "status", ",", "versionable", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "String", "message", "=", "partialUploadErrorMessage", "(", "realPid", ",", "sent", ",", "pids", ".", "size", "(", ")", ",", "vitalPid", ")", ";", "throw", "new", "Exception", "(", "message", ",", "ex", ")", ";", "}", "// Increase our counter", "sent", "++", ";", "}", "// End for loop", "// Datastreams are taken care of, now handle attachments", "try", "{", "processAttachments", "(", "fedora", ",", "object", ",", "vitalPid", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "Exception", "(", "\"Error processing attachments: \"", ",", "ex", ")", ";", "}", "}" ]
Method responsible for arranging submissions to VITAL to store our datastreams. @param fedora An instantiated fedora client @param object The Object to submit @param vitalPid The VITAL PID to use @throws Exception on any errors
[ "Method", "responsible", "for", "arranging", "submissions", "to", "VITAL", "to", "store", "our", "datastreams", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L707-L779
143,140
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.getPackagePid
private String getPackagePid(DigitalObject object) throws Exception { for (String pid : object.getPayloadIdList()) { if (pid.endsWith(".tfpackage")) { return pid; } } return null; }
java
private String getPackagePid(DigitalObject object) throws Exception { for (String pid : object.getPayloadIdList()) { if (pid.endsWith(".tfpackage")) { return pid; } } return null; }
[ "private", "String", "getPackagePid", "(", "DigitalObject", "object", ")", "throws", "Exception", "{", "for", "(", "String", "pid", ":", "object", ".", "getPayloadIdList", "(", ")", ")", "{", "if", "(", "pid", ".", "endsWith", "(", "\".tfpackage\"", ")", ")", "{", "return", "pid", ";", "}", "}", "return", "null", ";", "}" ]
For the given digital object, find the Fascinator package inside. @param object The object with a package @return String The payload ID of the package, NULL if not found @throws Exception if any errors occur
[ "For", "the", "given", "digital", "object", "find", "the", "Fascinator", "package", "inside", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L955-L962
143,141
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.resolveAltIds
private String[] resolveAltIds(String[] oldArray, String mimeType, int count) { // First, find the valid list we want String key = null; for (String mimeTest : attachAltIds.keySet()) { // Ignore 'default' if (mimeTest.equals(Strings.LITERAL_DEFAULT)) { continue; } // Is it a broad group? if (mimeTest.endsWith("/")) { if (mimeType.startsWith(mimeTest)) { key = mimeTest; } // Or a specific mime type? } else { if (mimeType.equals(mimeTest)) { key = mimeTest; } } } // Use default if not found if (key == null) { key = Strings.LITERAL_DEFAULT; } // Loop through the ids we're going to use for (String newId : attachAltIds.get(key)) { // If there is a format requirement, use it String formatted = String.format(newId, count); // Modify our arrray (if we it's not there) oldArray = growArray(oldArray, formatted); } return oldArray; }
java
private String[] resolveAltIds(String[] oldArray, String mimeType, int count) { // First, find the valid list we want String key = null; for (String mimeTest : attachAltIds.keySet()) { // Ignore 'default' if (mimeTest.equals(Strings.LITERAL_DEFAULT)) { continue; } // Is it a broad group? if (mimeTest.endsWith("/")) { if (mimeType.startsWith(mimeTest)) { key = mimeTest; } // Or a specific mime type? } else { if (mimeType.equals(mimeTest)) { key = mimeTest; } } } // Use default if not found if (key == null) { key = Strings.LITERAL_DEFAULT; } // Loop through the ids we're going to use for (String newId : attachAltIds.get(key)) { // If there is a format requirement, use it String formatted = String.format(newId, count); // Modify our arrray (if we it's not there) oldArray = growArray(oldArray, formatted); } return oldArray; }
[ "private", "String", "[", "]", "resolveAltIds", "(", "String", "[", "]", "oldArray", ",", "String", "mimeType", ",", "int", "count", ")", "{", "// First, find the valid list we want", "String", "key", "=", "null", ";", "for", "(", "String", "mimeTest", ":", "attachAltIds", ".", "keySet", "(", ")", ")", "{", "// Ignore 'default'", "if", "(", "mimeTest", ".", "equals", "(", "Strings", ".", "LITERAL_DEFAULT", ")", ")", "{", "continue", ";", "}", "// Is it a broad group?", "if", "(", "mimeTest", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "if", "(", "mimeType", ".", "startsWith", "(", "mimeTest", ")", ")", "{", "key", "=", "mimeTest", ";", "}", "// Or a specific mime type?", "}", "else", "{", "if", "(", "mimeType", ".", "equals", "(", "mimeTest", ")", ")", "{", "key", "=", "mimeTest", ";", "}", "}", "}", "// Use default if not found", "if", "(", "key", "==", "null", ")", "{", "key", "=", "Strings", ".", "LITERAL_DEFAULT", ";", "}", "// Loop through the ids we're going to use", "for", "(", "String", "newId", ":", "attachAltIds", ".", "get", "(", "key", ")", ")", "{", "// If there is a format requirement, use it", "String", "formatted", "=", "String", ".", "format", "(", "newId", ",", "count", ")", ";", "// Modify our arrray (if we it's not there)", "oldArray", "=", "growArray", "(", "oldArray", ",", "formatted", ")", ";", "}", "return", "oldArray", ";", "}" ]
For the given mime type, ensure that the array of alternate identifiers is correct. If identifiers are missing they will be added to the array. @param oldArray The old array of identifiers @param mimeType The mime type of the datastream @param count The attachment count, to use in the format call @return String[] An array containing all of the old IDs with any that were missing for the mime type
[ "For", "the", "given", "mime", "type", "ensure", "that", "the", "array", "of", "alternate", "identifiers", "is", "correct", ".", "If", "identifiers", "are", "missing", "they", "will", "be", "added", "to", "the", "array", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L974-L1007
143,142
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.growArray
private String[] growArray(String[] oldArray, String newElement) { // Look for the element first for (String element : oldArray) { if (element.equals(newElement)) { // If it's already there, we're done return oldArray; } } log.debug("Adding ID: '{}'", newElement); // Ok, we know we need a new array int length = oldArray.length + 1; String[] newArray = new String[length]; // Copy the old array contents System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); // And the new element, and return newArray[length - 1] = newElement; return newArray; }
java
private String[] growArray(String[] oldArray, String newElement) { // Look for the element first for (String element : oldArray) { if (element.equals(newElement)) { // If it's already there, we're done return oldArray; } } log.debug("Adding ID: '{}'", newElement); // Ok, we know we need a new array int length = oldArray.length + 1; String[] newArray = new String[length]; // Copy the old array contents System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); // And the new element, and return newArray[length - 1] = newElement; return newArray; }
[ "private", "String", "[", "]", "growArray", "(", "String", "[", "]", "oldArray", ",", "String", "newElement", ")", "{", "// Look for the element first", "for", "(", "String", "element", ":", "oldArray", ")", "{", "if", "(", "element", ".", "equals", "(", "newElement", ")", ")", "{", "// If it's already there, we're done", "return", "oldArray", ";", "}", "}", "log", ".", "debug", "(", "\"Adding ID: '{}'\"", ",", "newElement", ")", ";", "// Ok, we know we need a new array", "int", "length", "=", "oldArray", ".", "length", "+", "1", ";", "String", "[", "]", "newArray", "=", "new", "String", "[", "length", "]", ";", "// Copy the old array contents", "System", ".", "arraycopy", "(", "oldArray", ",", "0", ",", "newArray", ",", "0", ",", "oldArray", ".", "length", ")", ";", "// And the new element, and return", "newArray", "[", "length", "-", "1", "]", "=", "newElement", ";", "return", "newArray", ";", "}" ]
Check the array for the new element, and if not found, generate a new array containing all of the old elements plus the new. @param oldArray The old array of data @param newElement The new element we want @return String[] An array containing all of the old data
[ "Check", "the", "array", "for", "the", "new", "element", "and", "if", "not", "found", "generate", "a", "new", "array", "containing", "all", "of", "the", "old", "elements", "plus", "the", "new", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L1017-L1035
143,143
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.datastreamExists
private boolean datastreamExists(FedoraClient fedora, String vitalPid, String dsPid) { try { // Some options: // * getAPIA().listDatastreams... seems best // * getAPIM().getDatastream... causes Exceptions against new IDs // * getAPIM().getDatastreams... is limited to a single state DatastreamDef[] streams = fedora.getAPIA().listDatastreams( vitalPid, null); for (DatastreamDef stream : streams) { if (stream.getID().equals(dsPid)) { return true; } } } catch (Exception ex) { log.error("API Query error: ", ex); } return false; }
java
private boolean datastreamExists(FedoraClient fedora, String vitalPid, String dsPid) { try { // Some options: // * getAPIA().listDatastreams... seems best // * getAPIM().getDatastream... causes Exceptions against new IDs // * getAPIM().getDatastreams... is limited to a single state DatastreamDef[] streams = fedora.getAPIA().listDatastreams( vitalPid, null); for (DatastreamDef stream : streams) { if (stream.getID().equals(dsPid)) { return true; } } } catch (Exception ex) { log.error("API Query error: ", ex); } return false; }
[ "private", "boolean", "datastreamExists", "(", "FedoraClient", "fedora", ",", "String", "vitalPid", ",", "String", "dsPid", ")", "{", "try", "{", "// Some options:", "// * getAPIA().listDatastreams... seems best", "// * getAPIM().getDatastream... causes Exceptions against new IDs", "// * getAPIM().getDatastreams... is limited to a single state", "DatastreamDef", "[", "]", "streams", "=", "fedora", ".", "getAPIA", "(", ")", ".", "listDatastreams", "(", "vitalPid", ",", "null", ")", ";", "for", "(", "DatastreamDef", "stream", ":", "streams", ")", "{", "if", "(", "stream", ".", "getID", "(", ")", ".", "equals", "(", "dsPid", ")", ")", "{", "return", "true", ";", "}", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "\"API Query error: \"", ",", "ex", ")", ";", "}", "return", "false", ";", "}" ]
Test for the existence of a given datastream in VITAL. @param fedora An instantiated fedora client @param vitalPid The VITAL PID to use @param dsPid The datastream ID on the object @returns boolean True is found, False if not found or there are errors
[ "Test", "for", "the", "existence", "of", "a", "given", "datastream", "in", "VITAL", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L1195-L1213
143,144
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.getAltIds
private String[] getAltIds(FedoraClient fedora, String vitalPid, String dsPid) { Datastream ds = getDatastream(fedora, vitalPid, dsPid); if (ds != null) { return ds.getAltIDs(); } return new String[]{}; }
java
private String[] getAltIds(FedoraClient fedora, String vitalPid, String dsPid) { Datastream ds = getDatastream(fedora, vitalPid, dsPid); if (ds != null) { return ds.getAltIDs(); } return new String[]{}; }
[ "private", "String", "[", "]", "getAltIds", "(", "FedoraClient", "fedora", ",", "String", "vitalPid", ",", "String", "dsPid", ")", "{", "Datastream", "ds", "=", "getDatastream", "(", "fedora", ",", "vitalPid", ",", "dsPid", ")", ";", "if", "(", "ds", "!=", "null", ")", "{", "return", "ds", ".", "getAltIDs", "(", ")", ";", "}", "return", "new", "String", "[", "]", "{", "}", ";", "}" ]
Find and return any alternate identifiers already in use in fedora for the given datastream. @param fedora An instantiated fedora client @param vitalPid The VITAL PID to use @param dsPid The datastream ID on the object @returns String[] An array or String identifiers, will be empty if datastream does not exist.
[ "Find", "and", "return", "any", "alternate", "identifiers", "already", "in", "use", "in", "fedora", "for", "the", "given", "datastream", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L1225-L1232
143,145
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.fedoraLogEntry
private String fedoraLogEntry(DigitalObject object, String pid) { String message = fedoraMessageTemplate.replace("[[PID]]", pid); return message.replace("[[OID]]", object.getId()); }
java
private String fedoraLogEntry(DigitalObject object, String pid) { String message = fedoraMessageTemplate.replace("[[PID]]", pid); return message.replace("[[OID]]", object.getId()); }
[ "private", "String", "fedoraLogEntry", "(", "DigitalObject", "object", ",", "String", "pid", ")", "{", "String", "message", "=", "fedoraMessageTemplate", ".", "replace", "(", "\"[[PID]]\"", ",", "pid", ")", ";", "return", "message", ".", "replace", "(", "\"[[OID]]\"", ",", "object", ".", "getId", "(", ")", ")", ";", "}" ]
Build a Log entry to use in Fedora. Replace all the template placeholders @param object The Object being submitted @param pid The PID in our system
[ "Build", "a", "Log", "entry", "to", "use", "in", "Fedora", ".", "Replace", "all", "the", "template", "placeholders" ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L1260-L1263
143,146
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.getTempFile
private File getTempFile(DigitalObject object, String pid) throws Exception { // Create file in temp space, use OID in path for uniqueness File directory = new File(tmpDir, object.getId()); File target = new File(directory, pid); if (!target.exists()) { target.getParentFile().mkdirs(); target.createNewFile(); } // These can happily throw exceptions higher Payload payload = object.getPayload(pid); InputStream in = payload.open(); FileOutputStream out = null; // But here, the payload must receive // a close before throwing the error try { out = new FileOutputStream(target); IOUtils.copyLarge(in, out); } catch (Exception ex) { close(out); target.delete(); payload.close(); throw ex; } // We close out here, because the catch statement needed to close // before it could delete... so it can't be in 'finally' close(out); payload.close(); return target; }
java
private File getTempFile(DigitalObject object, String pid) throws Exception { // Create file in temp space, use OID in path for uniqueness File directory = new File(tmpDir, object.getId()); File target = new File(directory, pid); if (!target.exists()) { target.getParentFile().mkdirs(); target.createNewFile(); } // These can happily throw exceptions higher Payload payload = object.getPayload(pid); InputStream in = payload.open(); FileOutputStream out = null; // But here, the payload must receive // a close before throwing the error try { out = new FileOutputStream(target); IOUtils.copyLarge(in, out); } catch (Exception ex) { close(out); target.delete(); payload.close(); throw ex; } // We close out here, because the catch statement needed to close // before it could delete... so it can't be in 'finally' close(out); payload.close(); return target; }
[ "private", "File", "getTempFile", "(", "DigitalObject", "object", ",", "String", "pid", ")", "throws", "Exception", "{", "// Create file in temp space, use OID in path for uniqueness", "File", "directory", "=", "new", "File", "(", "tmpDir", ",", "object", ".", "getId", "(", ")", ")", ";", "File", "target", "=", "new", "File", "(", "directory", ",", "pid", ")", ";", "if", "(", "!", "target", ".", "exists", "(", ")", ")", "{", "target", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "target", ".", "createNewFile", "(", ")", ";", "}", "// These can happily throw exceptions higher", "Payload", "payload", "=", "object", ".", "getPayload", "(", "pid", ")", ";", "InputStream", "in", "=", "payload", ".", "open", "(", ")", ";", "FileOutputStream", "out", "=", "null", ";", "// But here, the payload must receive", "// a close before throwing the error", "try", "{", "out", "=", "new", "FileOutputStream", "(", "target", ")", ";", "IOUtils", ".", "copyLarge", "(", "in", ",", "out", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "close", "(", "out", ")", ";", "target", ".", "delete", "(", ")", ";", "payload", ".", "close", "(", ")", ";", "throw", "ex", ";", "}", "// We close out here, because the catch statement needed to close", "// before it could delete... so it can't be in 'finally'", "close", "(", "out", ")", ";", "payload", ".", "close", "(", ")", ";", "return", "target", ";", "}" ]
Stream the data out of storage to our temp directory. @param object Our digital object. @param pid The payload ID to retrieve. @return File The file creating in the temp directory @throws Exception on any errors
[ "Stream", "the", "data", "out", "of", "storage", "to", "our", "temp", "directory", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L1291-L1325
143,147
redbox-mint/redbox
plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java
VitalTransformer.getBytes
private byte[] getBytes(DigitalObject object, String pid) throws Exception { // These can happily throw exceptions higher Payload payload = object.getPayload(pid); InputStream in = payload.open(); byte[] result = null; // But here, the payload must receive // a close before throwing the error try { result = IOUtils.toByteArray(in); } catch (Exception ex) { throw ex; } finally { payload.close(); } return result; }
java
private byte[] getBytes(DigitalObject object, String pid) throws Exception { // These can happily throw exceptions higher Payload payload = object.getPayload(pid); InputStream in = payload.open(); byte[] result = null; // But here, the payload must receive // a close before throwing the error try { result = IOUtils.toByteArray(in); } catch (Exception ex) { throw ex; } finally { payload.close(); } return result; }
[ "private", "byte", "[", "]", "getBytes", "(", "DigitalObject", "object", ",", "String", "pid", ")", "throws", "Exception", "{", "// These can happily throw exceptions higher", "Payload", "payload", "=", "object", ".", "getPayload", "(", "pid", ")", ";", "InputStream", "in", "=", "payload", ".", "open", "(", ")", ";", "byte", "[", "]", "result", "=", "null", ";", "// But here, the payload must receive", "// a close before throwing the error", "try", "{", "result", "=", "IOUtils", ".", "toByteArray", "(", "in", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "ex", ";", "}", "finally", "{", "payload", ".", "close", "(", ")", ";", "}", "return", "result", ";", "}" ]
Retrieve the payload from storage and return as a byte array. @param object Our digital object. @param pid The payload ID to retrieve. @return byte[] The byte array containing payload data @throws Exception on any errors
[ "Retrieve", "the", "payload", "from", "storage", "and", "return", "as", "a", "byte", "array", "." ]
1db230f218031b85c48c8603cbb04fce7ac6de0c
https://github.com/redbox-mint/redbox/blob/1db230f218031b85c48c8603cbb04fce7ac6de0c/plugins/transformer/vital-fedora2/src/main/java/com/googlecode/fascinator/redbox/VitalTransformer.java#L1335-L1352
143,148
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/tools/ParameterFinder.java
ParameterFinder.find
public static HashMap<String, String> find(HashMap<String, String> props, String path) { // Kein Pfad angegeben. Also treffen alle. if (path == null || path.length() == 0) return props; // Die neue Map fuer die naechste Runde HashMap<String, String> next = new HashMap<>(); String[] keys = path.split("\\."); String key = keys[0]; boolean endsWith = key.startsWith("*"); boolean startsWith = key.endsWith("*"); key = key.replace("*", ""); Iterator<String> e = props.keySet().iterator(); while (e.hasNext()) { String name = e.next(); String[] names = name.split("\\."); if (startsWith && !endsWith && !names[0].startsWith(key)) // Beginnt mit? continue; else if (!startsWith && endsWith && !names[0].endsWith(key)) // Endet mit? continue; else if (startsWith && endsWith && !names[0].contains(key)) // Enthaelt? continue; else if (!startsWith && !endsWith && !names[0].equals(key)) // Ist gleich? continue; // Wenn wir einen Wert haben, uebernehmen wir ihn in die naechste Runde. // Wir schneiden den geprueften Teil ab String newName = name.substring(name.indexOf(".") + 1); next.put(newName, props.get(name)); } // Wir sind hinten angekommen if (!path.contains(".")) return next; // naechste Runde return find(next, path.substring(path.indexOf(".") + 1)); }
java
public static HashMap<String, String> find(HashMap<String, String> props, String path) { // Kein Pfad angegeben. Also treffen alle. if (path == null || path.length() == 0) return props; // Die neue Map fuer die naechste Runde HashMap<String, String> next = new HashMap<>(); String[] keys = path.split("\\."); String key = keys[0]; boolean endsWith = key.startsWith("*"); boolean startsWith = key.endsWith("*"); key = key.replace("*", ""); Iterator<String> e = props.keySet().iterator(); while (e.hasNext()) { String name = e.next(); String[] names = name.split("\\."); if (startsWith && !endsWith && !names[0].startsWith(key)) // Beginnt mit? continue; else if (!startsWith && endsWith && !names[0].endsWith(key)) // Endet mit? continue; else if (startsWith && endsWith && !names[0].contains(key)) // Enthaelt? continue; else if (!startsWith && !endsWith && !names[0].equals(key)) // Ist gleich? continue; // Wenn wir einen Wert haben, uebernehmen wir ihn in die naechste Runde. // Wir schneiden den geprueften Teil ab String newName = name.substring(name.indexOf(".") + 1); next.put(newName, props.get(name)); } // Wir sind hinten angekommen if (!path.contains(".")) return next; // naechste Runde return find(next, path.substring(path.indexOf(".") + 1)); }
[ "public", "static", "HashMap", "<", "String", ",", "String", ">", "find", "(", "HashMap", "<", "String", ",", "String", ">", "props", ",", "String", "path", ")", "{", "// Kein Pfad angegeben. Also treffen alle.", "if", "(", "path", "==", "null", "||", "path", ".", "length", "(", ")", "==", "0", ")", "return", "props", ";", "// Die neue Map fuer die naechste Runde", "HashMap", "<", "String", ",", "String", ">", "next", "=", "new", "HashMap", "<>", "(", ")", ";", "String", "[", "]", "keys", "=", "path", ".", "split", "(", "\"\\\\.\"", ")", ";", "String", "key", "=", "keys", "[", "0", "]", ";", "boolean", "endsWith", "=", "key", ".", "startsWith", "(", "\"*\"", ")", ";", "boolean", "startsWith", "=", "key", ".", "endsWith", "(", "\"*\"", ")", ";", "key", "=", "key", ".", "replace", "(", "\"*\"", ",", "\"\"", ")", ";", "Iterator", "<", "String", ">", "e", "=", "props", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "e", ".", "hasNext", "(", ")", ")", "{", "String", "name", "=", "e", ".", "next", "(", ")", ";", "String", "[", "]", "names", "=", "name", ".", "split", "(", "\"\\\\.\"", ")", ";", "if", "(", "startsWith", "&&", "!", "endsWith", "&&", "!", "names", "[", "0", "]", ".", "startsWith", "(", "key", ")", ")", "// Beginnt mit?", "continue", ";", "else", "if", "(", "!", "startsWith", "&&", "endsWith", "&&", "!", "names", "[", "0", "]", ".", "endsWith", "(", "key", ")", ")", "// Endet mit?", "continue", ";", "else", "if", "(", "startsWith", "&&", "endsWith", "&&", "!", "names", "[", "0", "]", ".", "contains", "(", "key", ")", ")", "// Enthaelt?", "continue", ";", "else", "if", "(", "!", "startsWith", "&&", "!", "endsWith", "&&", "!", "names", "[", "0", "]", ".", "equals", "(", "key", ")", ")", "// Ist gleich?", "continue", ";", "// Wenn wir einen Wert haben, uebernehmen wir ihn in die naechste Runde.", "// Wir schneiden den geprueften Teil ab", "String", "newName", "=", "name", ".", "substring", "(", "name", ".", "indexOf", "(", "\".\"", ")", "+", "1", ")", ";", "next", ".", "put", "(", "newName", ",", "props", ".", "get", "(", "name", ")", ")", ";", "}", "// Wir sind hinten angekommen", "if", "(", "!", "path", ".", "contains", "(", "\".\"", ")", ")", "return", "next", ";", "// naechste Runde", "return", "find", "(", "next", ",", "path", ".", "substring", "(", "path", ".", "indexOf", "(", "\".\"", ")", "+", "1", ")", ")", ";", "}" ]
Sucht in props nach allen Schluesseln im genannten Pfad und liefert sie zurueck. @param props die Properties, in denen gesucht werden soll. @param path der Pfad. Es koennen Wildcards verwendet werden. Etwa so: Params_*.TAN2StepPar*.ParTAN2Step*.TAN2StepParams*.*secfunc") @return Liefert die gefundenen Properties. Als Schluessel wird jeweils nicht der gesamte Pfad verwendet sondern nur der Teil hinter dem letzten Punkt.
[ "Sucht", "in", "props", "nach", "allen", "Schluesseln", "im", "genannten", "Pfad", "und", "liefert", "sie", "zurueck", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/tools/ParameterFinder.java#L32-L74
143,149
Chorus-bdd/Chorus
interpreter/chorus/src/main/java/org/chorusbdd/chorus/Chorus.java
Chorus.run
public boolean run() { boolean passed; ExecutionToken t = createExecutionToken(); List<FeatureToken> features = getFeatureList(t); startTests(t, features); initializeInterpreter(); processFeatures(t, features); endTests(t, features); passed = t.getEndState() == EndState.PASSED || t.getEndState() == EndState.PENDING; dispose(); return passed; }
java
public boolean run() { boolean passed; ExecutionToken t = createExecutionToken(); List<FeatureToken> features = getFeatureList(t); startTests(t, features); initializeInterpreter(); processFeatures(t, features); endTests(t, features); passed = t.getEndState() == EndState.PASSED || t.getEndState() == EndState.PENDING; dispose(); return passed; }
[ "public", "boolean", "run", "(", ")", "{", "boolean", "passed", ";", "ExecutionToken", "t", "=", "createExecutionToken", "(", ")", ";", "List", "<", "FeatureToken", ">", "features", "=", "getFeatureList", "(", "t", ")", ";", "startTests", "(", "t", ",", "features", ")", ";", "initializeInterpreter", "(", ")", ";", "processFeatures", "(", "t", ",", "features", ")", ";", "endTests", "(", "t", ",", "features", ")", ";", "passed", "=", "t", ".", "getEndState", "(", ")", "==", "EndState", ".", "PASSED", "||", "t", ".", "getEndState", "(", ")", "==", "EndState", ".", "PENDING", ";", "dispose", "(", ")", ";", "return", "passed", ";", "}" ]
Run interpreter using just the base configuration and the listeners provided @return true, if all tests passed or were marked pending
[ "Run", "interpreter", "using", "just", "the", "base", "configuration", "and", "the", "listeners", "provided" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus/src/main/java/org/chorusbdd/chorus/Chorus.java#L134-L145
143,150
Chorus-bdd/Chorus
interpreter/chorus/src/main/java/org/chorusbdd/chorus/Chorus.java
Chorus.getSuiteName
public String getSuiteName() { return configReader.isSet(ChorusConfigProperty.SUITE_NAME) ? concatenateName(configReader.getValues(ChorusConfigProperty.SUITE_NAME)) : ""; }
java
public String getSuiteName() { return configReader.isSet(ChorusConfigProperty.SUITE_NAME) ? concatenateName(configReader.getValues(ChorusConfigProperty.SUITE_NAME)) : ""; }
[ "public", "String", "getSuiteName", "(", ")", "{", "return", "configReader", ".", "isSet", "(", "ChorusConfigProperty", ".", "SUITE_NAME", ")", "?", "concatenateName", "(", "configReader", ".", "getValues", "(", "ChorusConfigProperty", ".", "SUITE_NAME", ")", ")", ":", "\"\"", ";", "}" ]
to get the suite name we concatenate all the values provided for suite name switch
[ "to", "get", "the", "suite", "name", "we", "concatenate", "all", "the", "values", "provided", "for", "suite", "name", "switch" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus/src/main/java/org/chorusbdd/chorus/Chorus.java#L196-L200
143,151
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/GV/parsers/ParseCamt05200103.java
ParseCamt05200103.checkDebit
private BigDecimal checkDebit(BigDecimal d, CreditDebitCode code) { if (d == null || code == null || code == CreditDebitCode.CRDT) return d; return BigDecimal.ZERO.subtract(d); }
java
private BigDecimal checkDebit(BigDecimal d, CreditDebitCode code) { if (d == null || code == null || code == CreditDebitCode.CRDT) return d; return BigDecimal.ZERO.subtract(d); }
[ "private", "BigDecimal", "checkDebit", "(", "BigDecimal", "d", ",", "CreditDebitCode", "code", ")", "{", "if", "(", "d", "==", "null", "||", "code", "==", "null", "||", "code", "==", "CreditDebitCode", ".", "CRDT", ")", "return", "d", ";", "return", "BigDecimal", ".", "ZERO", ".", "subtract", "(", "d", ")", ";", "}" ]
Prueft, ob es sich um einen Soll-Betrag handelt und setzt in dem Fall ein negatives Vorzeichen vor den Wert. @param d die zu pruefende Zahl. @param code das Soll-/Haben-Kennzeichen. @return der ggf korrigierte Betrag.
[ "Prueft", "ob", "es", "sich", "um", "einen", "Soll", "-", "Betrag", "handelt", "und", "setzt", "in", "dem", "Fall", "ein", "negatives", "Vorzeichen", "vor", "den", "Wert", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/GV/parsers/ParseCamt05200103.java#L299-L304
143,152
Chorus-bdd/Chorus
interpreter/chorus-context/src/main/java/org/chorusbdd/chorus/context/ChorusContext.java
ChorusContext.get
@SuppressWarnings({"unchecked", "unused"}) public <T> T get(String key, Class<T> type) { try { return (T) state.get(key); } catch (ClassCastException cce) { return null; } }
java
@SuppressWarnings({"unchecked", "unused"}) public <T> T get(String key, Class<T> type) { try { return (T) state.get(key); } catch (ClassCastException cce) { return null; } }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"unused\"", "}", ")", "public", "<", "T", ">", "T", "get", "(", "String", "key", ",", "Class", "<", "T", ">", "type", ")", "{", "try", "{", "return", "(", "T", ")", "state", ".", "get", "(", "key", ")", ";", "}", "catch", "(", "ClassCastException", "cce", ")", "{", "return", "null", ";", "}", "}" ]
This get method will return the value if its type matches the type parameter @param key to lookup @param type the expected type of the value @return null if the key does not exist or the type is incorrect
[ "This", "get", "method", "will", "return", "the", "value", "if", "its", "type", "matches", "the", "type", "parameter" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-context/src/main/java/org/chorusbdd/chorus/context/ChorusContext.java#L85-L92
143,153
Chorus-bdd/Chorus
services/chorus-webagent/src/main/java/org/chorusbdd/chorus/tools/webagent/jettyhandler/AbstractWebAgentHandler.java
AbstractWebAgentHandler.getResourceSuffix
protected String getResourceSuffix(String target) { int index = target.lastIndexOf('/'); if ( index > -1 ) { target = target.substring(index + 1); } return target; }
java
protected String getResourceSuffix(String target) { int index = target.lastIndexOf('/'); if ( index > -1 ) { target = target.substring(index + 1); } return target; }
[ "protected", "String", "getResourceSuffix", "(", "String", "target", ")", "{", "int", "index", "=", "target", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", ">", "-", "1", ")", "{", "target", "=", "target", ".", "substring", "(", "index", "+", "1", ")", ";", "}", "return", "target", ";", "}" ]
just find the stylesheet name, disregarding nested folder names
[ "just", "find", "the", "stylesheet", "name", "disregarding", "nested", "folder", "names" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/services/chorus-webagent/src/main/java/org/chorusbdd/chorus/tools/webagent/jettyhandler/AbstractWebAgentHandler.java#L71-L77
143,154
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/GV/parsers/AbstractCamtParser.java
AbstractCamtParser.trim
protected String trim(String s) { if (s == null || s.length() == 0) return s; return s.trim(); }
java
protected String trim(String s) { if (s == null || s.length() == 0) return s; return s.trim(); }
[ "protected", "String", "trim", "(", "String", "s", ")", "{", "if", "(", "s", "==", "null", "||", "s", ".", "length", "(", ")", "==", "0", ")", "return", "s", ";", "return", "s", ".", "trim", "(", ")", ";", "}" ]
Entfernt die Whitespaces des Textes. Manche Banken fuellen den Gegenkontoinhaber rechts auf 70 Zeichen mit Leerzeichen auf. @param s der Text. NPE-Sicher. @return der getrimmte Text.
[ "Entfernt", "die", "Whitespaces", "des", "Textes", ".", "Manche", "Banken", "fuellen", "den", "Gegenkontoinhaber", "rechts", "auf", "70", "Zeichen", "mit", "Leerzeichen", "auf", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/GV/parsers/AbstractCamtParser.java#L29-L34
143,155
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/GV/parsers/AbstractCamtParser.java
AbstractCamtParser.trim
protected List<String> trim(List<String> list) { if (list == null || list.size() == 0) return list; List<String> result = new ArrayList<String>(); for (String s : list) { s = trim(s); if (s == null || s.length() == 0) continue; result.add(s); } return result; }
java
protected List<String> trim(List<String> list) { if (list == null || list.size() == 0) return list; List<String> result = new ArrayList<String>(); for (String s : list) { s = trim(s); if (s == null || s.length() == 0) continue; result.add(s); } return result; }
[ "protected", "List", "<", "String", ">", "trim", "(", "List", "<", "String", ">", "list", ")", "{", "if", "(", "list", "==", "null", "||", "list", ".", "size", "(", ")", "==", "0", ")", "return", "list", ";", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "s", ":", "list", ")", "{", "s", "=", "trim", "(", "s", ")", ";", "if", "(", "s", "==", "null", "||", "s", ".", "length", "(", ")", "==", "0", ")", "continue", ";", "result", ".", "add", "(", "s", ")", ";", "}", "return", "result", ";", "}" ]
Entfernt die Whitespaces in der Liste der Texte. @param list Liste der Texte. NPE-Sicher. Leere Zeilen werden uebersprungen. @return die getrimmte Liste.
[ "Entfernt", "die", "Whitespaces", "in", "der", "Liste", "der", "Texte", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/GV/parsers/AbstractCamtParser.java#L42-L57
143,156
Chorus-bdd/Chorus
interpreter/chorus-processes/src/main/java/org/chorusbdd/chorus/processes/manager/ProcessManagerImpl.java
ProcessManagerImpl.startProcess
public synchronized void startProcess(String configName, String processName, Properties processProperties) throws Exception { ProcessManagerConfig runtimeConfig = getProcessManagerConfig(configName, processProperties); if ( runtimeConfig.isEnabled()) { //could be disabled in some profiles doStart(processName, runtimeConfig); } else { log.info("Not starting process " + processName + " since enabled=false"); } }
java
public synchronized void startProcess(String configName, String processName, Properties processProperties) throws Exception { ProcessManagerConfig runtimeConfig = getProcessManagerConfig(configName, processProperties); if ( runtimeConfig.isEnabled()) { //could be disabled in some profiles doStart(processName, runtimeConfig); } else { log.info("Not starting process " + processName + " since enabled=false"); } }
[ "public", "synchronized", "void", "startProcess", "(", "String", "configName", ",", "String", "processName", ",", "Properties", "processProperties", ")", "throws", "Exception", "{", "ProcessManagerConfig", "runtimeConfig", "=", "getProcessManagerConfig", "(", "configName", ",", "processProperties", ")", ";", "if", "(", "runtimeConfig", ".", "isEnabled", "(", ")", ")", "{", "//could be disabled in some profiles", "doStart", "(", "processName", ",", "runtimeConfig", ")", ";", "}", "else", "{", "log", ".", "info", "(", "\"Not starting process \"", "+", "processName", "+", "\" since enabled=false\"", ")", ";", "}", "}" ]
Starts a record Java process using properties defined in a properties file alongside the feature file @throws Exception
[ "Starts", "a", "record", "Java", "process", "using", "properties", "defined", "in", "a", "properties", "file", "alongside", "the", "feature", "file" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-processes/src/main/java/org/chorusbdd/chorus/processes/manager/ProcessManagerImpl.java#L88-L97
143,157
Chorus-bdd/Chorus
interpreter/chorus-processes/src/main/java/org/chorusbdd/chorus/processes/manager/ProcessManagerImpl.java
ProcessManagerImpl.incrementPortsIfDuplicateName
private void incrementPortsIfDuplicateName(String configName, ProcessConfigBean config) { int startedCount = getNumberOfInstancesStarted(configName); int debugPort = config.getDebugPort(); if ( debugPort != -1) { config.setDebugPort(debugPort + startedCount); } int remotingPort = config.getRemotingPort(); if (remotingPort != -1) { config.setRemotingPort(remotingPort + startedCount); } }
java
private void incrementPortsIfDuplicateName(String configName, ProcessConfigBean config) { int startedCount = getNumberOfInstancesStarted(configName); int debugPort = config.getDebugPort(); if ( debugPort != -1) { config.setDebugPort(debugPort + startedCount); } int remotingPort = config.getRemotingPort(); if (remotingPort != -1) { config.setRemotingPort(remotingPort + startedCount); } }
[ "private", "void", "incrementPortsIfDuplicateName", "(", "String", "configName", ",", "ProcessConfigBean", "config", ")", "{", "int", "startedCount", "=", "getNumberOfInstancesStarted", "(", "configName", ")", ";", "int", "debugPort", "=", "config", ".", "getDebugPort", "(", ")", ";", "if", "(", "debugPort", "!=", "-", "1", ")", "{", "config", ".", "setDebugPort", "(", "debugPort", "+", "startedCount", ")", ";", "}", "int", "remotingPort", "=", "config", ".", "getRemotingPort", "(", ")", ";", "if", "(", "remotingPort", "!=", "-", "1", ")", "{", "config", ".", "setRemotingPort", "(", "remotingPort", "+", "startedCount", ")", ";", "}", "}" ]
If we already have an instance of a process with this name, auto increment ports to avoid a conflict
[ "If", "we", "already", "have", "an", "instance", "of", "a", "process", "with", "this", "name", "auto", "increment", "ports", "to", "avoid", "a", "conflict" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-processes/src/main/java/org/chorusbdd/chorus/processes/manager/ProcessManagerImpl.java#L120-L132
143,158
Chorus-bdd/Chorus
interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/StepProcessor.java
StepProcessor.runSteps
public StepEndState runSteps(ExecutionToken executionToken, StepInvokerProvider stepInvokerProvider, List<StepToken> stepList, StepCatalogue stepCatalogue, boolean skip) { for (StepToken step : stepList) { StepEndState endState = processStep(executionToken, stepInvokerProvider, step, stepCatalogue, skip); switch (endState) { case PASSED: break; case FAILED: skip = true;//skip (don't execute) the rest of the steps break; case UNDEFINED: skip = true;//skip (don't execute) the rest of the steps break; case PENDING: skip = true;//skip (don't execute) the rest of the steps break; case TIMEOUT: skip = true;//skip (don't execute) the rest of the steps break; case SKIPPED: case DRYRUN: break; default : throw new RuntimeException("Unhandled step state " + endState); } } StepEndState stepMacroEndState = StepMacro.calculateStepMacroEndState(stepList); return stepMacroEndState; }
java
public StepEndState runSteps(ExecutionToken executionToken, StepInvokerProvider stepInvokerProvider, List<StepToken> stepList, StepCatalogue stepCatalogue, boolean skip) { for (StepToken step : stepList) { StepEndState endState = processStep(executionToken, stepInvokerProvider, step, stepCatalogue, skip); switch (endState) { case PASSED: break; case FAILED: skip = true;//skip (don't execute) the rest of the steps break; case UNDEFINED: skip = true;//skip (don't execute) the rest of the steps break; case PENDING: skip = true;//skip (don't execute) the rest of the steps break; case TIMEOUT: skip = true;//skip (don't execute) the rest of the steps break; case SKIPPED: case DRYRUN: break; default : throw new RuntimeException("Unhandled step state " + endState); } } StepEndState stepMacroEndState = StepMacro.calculateStepMacroEndState(stepList); return stepMacroEndState; }
[ "public", "StepEndState", "runSteps", "(", "ExecutionToken", "executionToken", ",", "StepInvokerProvider", "stepInvokerProvider", ",", "List", "<", "StepToken", ">", "stepList", ",", "StepCatalogue", "stepCatalogue", ",", "boolean", "skip", ")", "{", "for", "(", "StepToken", "step", ":", "stepList", ")", "{", "StepEndState", "endState", "=", "processStep", "(", "executionToken", ",", "stepInvokerProvider", ",", "step", ",", "stepCatalogue", ",", "skip", ")", ";", "switch", "(", "endState", ")", "{", "case", "PASSED", ":", "break", ";", "case", "FAILED", ":", "skip", "=", "true", ";", "//skip (don't execute) the rest of the steps", "break", ";", "case", "UNDEFINED", ":", "skip", "=", "true", ";", "//skip (don't execute) the rest of the steps", "break", ";", "case", "PENDING", ":", "skip", "=", "true", ";", "//skip (don't execute) the rest of the steps", "break", ";", "case", "TIMEOUT", ":", "skip", "=", "true", ";", "//skip (don't execute) the rest of the steps", "break", ";", "case", "SKIPPED", ":", "case", "DRYRUN", ":", "break", ";", "default", ":", "throw", "new", "RuntimeException", "(", "\"Unhandled step state \"", "+", "endState", ")", ";", "}", "}", "StepEndState", "stepMacroEndState", "=", "StepMacro", ".", "calculateStepMacroEndState", "(", "stepList", ")", ";", "return", "stepMacroEndState", ";", "}" ]
Process all steps in stepList @param skip, do not actually execute (but mark as skipped if not unimplemented) @return a StepEndState is the StepMacro step's end state, if these steps are executed as part of a StepMacro rather than scenario
[ "Process", "all", "steps", "in", "stepList" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/StepProcessor.java#L84-L114
143,159
Chorus-bdd/Chorus
interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/StepProcessor.java
StepProcessor.sortInvokersByPattern
private void sortInvokersByPattern(List<StepInvoker> stepInvokers) { Collections.sort(stepInvokers, new Comparator<StepInvoker>() { public int compare(StepInvoker o1, StepInvoker o2) { return o1.getStepPattern().toString().compareTo(o2.getStepPattern().toString()); } }); }
java
private void sortInvokersByPattern(List<StepInvoker> stepInvokers) { Collections.sort(stepInvokers, new Comparator<StepInvoker>() { public int compare(StepInvoker o1, StepInvoker o2) { return o1.getStepPattern().toString().compareTo(o2.getStepPattern().toString()); } }); }
[ "private", "void", "sortInvokersByPattern", "(", "List", "<", "StepInvoker", ">", "stepInvokers", ")", "{", "Collections", ".", "sort", "(", "stepInvokers", ",", "new", "Comparator", "<", "StepInvoker", ">", "(", ")", "{", "public", "int", "compare", "(", "StepInvoker", "o1", ",", "StepInvoker", "o2", ")", "{", "return", "o1", ".", "getStepPattern", "(", ")", ".", "toString", "(", ")", ".", "compareTo", "(", "o2", ".", "getStepPattern", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}", ")", ";", "}" ]
prefer fully determinate behaviour. The only sensible solution is to sort by pattern
[ "prefer", "fully", "determinate", "behaviour", ".", "The", "only", "sensible", "solution", "is", "to", "sort", "by", "pattern" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/StepProcessor.java#L190-L196
143,160
IBM-Cloud/gp-java-client
src/main/java/com/ibm/g11n/pipeline/client/DocumentTranslationRequestData.java
DocumentTranslationRequestData.getTargetLanguagesMap
public Map<String, Map<String, Set<String>>> getTargetLanguagesMap() { if (targetLanguagesMap == null) { assert false; return Collections.emptyMap(); } return Collections.unmodifiableMap(targetLanguagesMap); }
java
public Map<String, Map<String, Set<String>>> getTargetLanguagesMap() { if (targetLanguagesMap == null) { assert false; return Collections.emptyMap(); } return Collections.unmodifiableMap(targetLanguagesMap); }
[ "public", "Map", "<", "String", ",", "Map", "<", "String", ",", "Set", "<", "String", ">", ">", ">", "getTargetLanguagesMap", "(", ")", "{", "if", "(", "targetLanguagesMap", "==", "null", ")", "{", "assert", "false", ";", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}", "return", "Collections", ".", "unmodifiableMap", "(", "targetLanguagesMap", ")", ";", "}" ]
Returns the map containing target languages indexed by document type and ids. This method always returns non-null map. @return The map containing target languages indexed by document type and ids.
[ "Returns", "the", "map", "containing", "target", "languages", "indexed", "by", "document", "type", "and", "ids", ".", "This", "method", "always", "returns", "non", "-", "null", "map", "." ]
b015a081d7a7313bc48c448087fbc07bce860427
https://github.com/IBM-Cloud/gp-java-client/blob/b015a081d7a7313bc48c448087fbc07bce860427/src/main/java/com/ibm/g11n/pipeline/client/DocumentTranslationRequestData.java#L88-L94
143,161
imsweb/seerapi-client-java
src/main/java/com/imsweb/seerapi/client/staging/cs/CsStagingData.java
CsStagingData.getSsf
public String getSsf(Integer id) { if (id < 1 || id > 25) throw new IllegalStateException("Site specific factor must be between 1 and 25."); return getInput(INPUT_SSF_PREFIX + id); }
java
public String getSsf(Integer id) { if (id < 1 || id > 25) throw new IllegalStateException("Site specific factor must be between 1 and 25."); return getInput(INPUT_SSF_PREFIX + id); }
[ "public", "String", "getSsf", "(", "Integer", "id", ")", "{", "if", "(", "id", "<", "1", "||", "id", ">", "25", ")", "throw", "new", "IllegalStateException", "(", "\"Site specific factor must be between 1 and 25.\"", ")", ";", "return", "getInput", "(", "INPUT_SSF_PREFIX", "+", "id", ")", ";", "}" ]
Get the specified input site-specific factor @param id site-specific factor number @return ssf value
[ "Get", "the", "specified", "input", "site", "-", "specific", "factor" ]
04f509961c3a5ece7b232ecb8d8cb8f89d810a85
https://github.com/imsweb/seerapi-client-java/blob/04f509961c3a5ece7b232ecb8d8cb8f89d810a85/src/main/java/com/imsweb/seerapi/client/staging/cs/CsStagingData.java#L191-L196
143,162
imsweb/seerapi-client-java
src/main/java/com/imsweb/seerapi/client/staging/cs/CsStagingData.java
CsStagingData.setSsf
public void setSsf(Integer id, String ssf) { if (id < 1 || id > 25) throw new IllegalStateException("Site specific factor must be between 1 and 25."); setInput(INPUT_SSF_PREFIX + id, ssf); }
java
public void setSsf(Integer id, String ssf) { if (id < 1 || id > 25) throw new IllegalStateException("Site specific factor must be between 1 and 25."); setInput(INPUT_SSF_PREFIX + id, ssf); }
[ "public", "void", "setSsf", "(", "Integer", "id", ",", "String", "ssf", ")", "{", "if", "(", "id", "<", "1", "||", "id", ">", "25", ")", "throw", "new", "IllegalStateException", "(", "\"Site specific factor must be between 1 and 25.\"", ")", ";", "setInput", "(", "INPUT_SSF_PREFIX", "+", "id", ",", "ssf", ")", ";", "}" ]
Set the specified input site-specific factor @param id site-specific factor number @param ssf site-specfic factor value
[ "Set", "the", "specified", "input", "site", "-", "specific", "factor" ]
04f509961c3a5ece7b232ecb8d8cb8f89d810a85
https://github.com/imsweb/seerapi-client-java/blob/04f509961c3a5ece7b232ecb8d8cb8f89d810a85/src/main/java/com/imsweb/seerapi/client/staging/cs/CsStagingData.java#L203-L208
143,163
Chorus-bdd/Chorus
extensions/chorus-websockets/src/main/java/org/chorusbdd/chorus/websockets/client/WebSocketStepPublisher.java
WebSocketStepPublisher.addStepInvoker
private void addStepInvoker(StepInvoker stepInvoker) { if ( connected.get() ) { throw new ChorusException("You cannot add more steps once the WebSocketStepPublisher is connected"); } stepInvokers.put(stepInvoker.getId(), stepInvoker); }
java
private void addStepInvoker(StepInvoker stepInvoker) { if ( connected.get() ) { throw new ChorusException("You cannot add more steps once the WebSocketStepPublisher is connected"); } stepInvokers.put(stepInvoker.getId(), stepInvoker); }
[ "private", "void", "addStepInvoker", "(", "StepInvoker", "stepInvoker", ")", "{", "if", "(", "connected", ".", "get", "(", ")", ")", "{", "throw", "new", "ChorusException", "(", "\"You cannot add more steps once the WebSocketStepPublisher is connected\"", ")", ";", "}", "stepInvokers", ".", "put", "(", "stepInvoker", ".", "getId", "(", ")", ",", "stepInvoker", ")", ";", "}" ]
Add a step to be published
[ "Add", "a", "step", "to", "be", "published" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/extensions/chorus-websockets/src/main/java/org/chorusbdd/chorus/websockets/client/WebSocketStepPublisher.java#L124-L129
143,164
Chorus-bdd/Chorus
extensions/chorus-websockets/src/main/java/org/chorusbdd/chorus/websockets/client/WebSocketStepPublisher.java
WebSocketStepPublisher.publish
public WebSocketStepPublisher publish() { if (connected.getAndSet(true) == false) { try { log.info("Connecting"); boolean connected = chorusWebSocketClient.connectBlocking(); if ( ! connected) { throw new StepPublisherException("Failed to connect to WebSocketsManagerImpl"); } ConnectMessage connect = new ConnectMessage(chorusClientId, "".equals(description) ? chorusClientId : description); chorusWebSocketClient.sendMessage(connect); log.info("Publishing steps"); stepInvokers.values().stream().forEach(invoker -> { publishStep(invoker); }); log.info("Sending Aligned"); StepsAlignedMessage stepsAlignedMessage = new StepsAlignedMessage(chorusClientId); chorusWebSocketClient.sendMessage(stepsAlignedMessage); } catch (Exception e) { throw new ChorusException("Failed to connect and publish steps", e); } } return this; }
java
public WebSocketStepPublisher publish() { if (connected.getAndSet(true) == false) { try { log.info("Connecting"); boolean connected = chorusWebSocketClient.connectBlocking(); if ( ! connected) { throw new StepPublisherException("Failed to connect to WebSocketsManagerImpl"); } ConnectMessage connect = new ConnectMessage(chorusClientId, "".equals(description) ? chorusClientId : description); chorusWebSocketClient.sendMessage(connect); log.info("Publishing steps"); stepInvokers.values().stream().forEach(invoker -> { publishStep(invoker); }); log.info("Sending Aligned"); StepsAlignedMessage stepsAlignedMessage = new StepsAlignedMessage(chorusClientId); chorusWebSocketClient.sendMessage(stepsAlignedMessage); } catch (Exception e) { throw new ChorusException("Failed to connect and publish steps", e); } } return this; }
[ "public", "WebSocketStepPublisher", "publish", "(", ")", "{", "if", "(", "connected", ".", "getAndSet", "(", "true", ")", "==", "false", ")", "{", "try", "{", "log", ".", "info", "(", "\"Connecting\"", ")", ";", "boolean", "connected", "=", "chorusWebSocketClient", ".", "connectBlocking", "(", ")", ";", "if", "(", "!", "connected", ")", "{", "throw", "new", "StepPublisherException", "(", "\"Failed to connect to WebSocketsManagerImpl\"", ")", ";", "}", "ConnectMessage", "connect", "=", "new", "ConnectMessage", "(", "chorusClientId", ",", "\"\"", ".", "equals", "(", "description", ")", "?", "chorusClientId", ":", "description", ")", ";", "chorusWebSocketClient", ".", "sendMessage", "(", "connect", ")", ";", "log", ".", "info", "(", "\"Publishing steps\"", ")", ";", "stepInvokers", ".", "values", "(", ")", ".", "stream", "(", ")", ".", "forEach", "(", "invoker", "->", "{", "publishStep", "(", "invoker", ")", ";", "}", ")", ";", "log", ".", "info", "(", "\"Sending Aligned\"", ")", ";", "StepsAlignedMessage", "stepsAlignedMessage", "=", "new", "StepsAlignedMessage", "(", "chorusClientId", ")", ";", "chorusWebSocketClient", ".", "sendMessage", "(", "stepsAlignedMessage", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ChorusException", "(", "\"Failed to connect and publish steps\"", ",", "e", ")", ";", "}", "}", "return", "this", ";", "}" ]
Connect to the server and publish all steps
[ "Connect", "to", "the", "server", "and", "publish", "all", "steps" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/extensions/chorus-websockets/src/main/java/org/chorusbdd/chorus/websockets/client/WebSocketStepPublisher.java#L135-L165
143,165
Chorus-bdd/Chorus
interpreter/chorus-util/src/main/java/org/chorusbdd/chorus/util/assertion/ChorusAssert.java
ChorusAssert.assertEquals
static public void assertEquals(String message, float expected, float actual, float delta) { if (Float.compare(expected, actual) == 0) return; if (!(Math.abs(expected - actual) <= delta)) failNotEquals(message, new Float(expected), new Float(actual)); }
java
static public void assertEquals(String message, float expected, float actual, float delta) { if (Float.compare(expected, actual) == 0) return; if (!(Math.abs(expected - actual) <= delta)) failNotEquals(message, new Float(expected), new Float(actual)); }
[ "static", "public", "void", "assertEquals", "(", "String", "message", ",", "float", "expected", ",", "float", "actual", ",", "float", "delta", ")", "{", "if", "(", "Float", ".", "compare", "(", "expected", ",", "actual", ")", "==", "0", ")", "return", ";", "if", "(", "!", "(", "Math", ".", "abs", "(", "expected", "-", "actual", ")", "<=", "delta", ")", ")", "failNotEquals", "(", "message", ",", "new", "Float", "(", "expected", ")", ",", "new", "Float", "(", "actual", ")", ")", ";", "}" ]
Asserts that two floats are equal concerning a positive delta. If they are not an AssertionFailedError is thrown with the given message. If the expected value is infinity then the delta value is ignored.
[ "Asserts", "that", "two", "floats", "are", "equal", "concerning", "a", "positive", "delta", ".", "If", "they", "are", "not", "an", "AssertionFailedError", "is", "thrown", "with", "the", "given", "message", ".", "If", "the", "expected", "value", "is", "infinity", "then", "the", "delta", "value", "is", "ignored", "." ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-util/src/main/java/org/chorusbdd/chorus/util/assertion/ChorusAssert.java#L146-L151
143,166
Chorus-bdd/Chorus
interpreter/chorus-util/src/main/java/org/chorusbdd/chorus/util/assertion/ChorusAssert.java
ChorusAssert.assertEquals
static public void assertEquals(String message, char expected, char actual) { assertEquals(message, new Character(expected), new Character(actual)); }
java
static public void assertEquals(String message, char expected, char actual) { assertEquals(message, new Character(expected), new Character(actual)); }
[ "static", "public", "void", "assertEquals", "(", "String", "message", ",", "char", "expected", ",", "char", "actual", ")", "{", "assertEquals", "(", "message", ",", "new", "Character", "(", "expected", ")", ",", "new", "Character", "(", "actual", ")", ")", ";", "}" ]
Asserts that two chars are equal. If they are not an AssertionFailedError is thrown with the given message.
[ "Asserts", "that", "two", "chars", "are", "equal", ".", "If", "they", "are", "not", "an", "AssertionFailedError", "is", "thrown", "with", "the", "given", "message", "." ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-util/src/main/java/org/chorusbdd/chorus/util/assertion/ChorusAssert.java#L202-L204
143,167
Chorus-bdd/Chorus
interpreter/chorus-util/src/main/java/org/chorusbdd/chorus/util/assertion/ChorusAssert.java
ChorusAssert.assertEquals
static public void assertEquals(String message, short expected, short actual) { assertEquals(message, new Short(expected), new Short(actual)); }
java
static public void assertEquals(String message, short expected, short actual) { assertEquals(message, new Short(expected), new Short(actual)); }
[ "static", "public", "void", "assertEquals", "(", "String", "message", ",", "short", "expected", ",", "short", "actual", ")", "{", "assertEquals", "(", "message", ",", "new", "Short", "(", "expected", ")", ",", "new", "Short", "(", "actual", ")", ")", ";", "}" ]
Asserts that two shorts are equal. If they are not an AssertionFailedError is thrown with the given message.
[ "Asserts", "that", "two", "shorts", "are", "equal", ".", "If", "they", "are", "not", "an", "AssertionFailedError", "is", "thrown", "with", "the", "given", "message", "." ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-util/src/main/java/org/chorusbdd/chorus/util/assertion/ChorusAssert.java#L215-L217
143,168
Chorus-bdd/Chorus
interpreter/chorus-handlerconfig/src/main/java/org/chorusbdd/chorus/handlerconfig/configproperty/ConfigPropertyParser.java
ConfigPropertyParser.getDefaultValidationPattern
private Optional<Pattern> getDefaultValidationPattern(Class javaType) { return javaType.isEnum() ? Optional.of(createValidationPatternFromEnumType(javaType)) : getDefaultPatternIfPrimitive(javaType); }
java
private Optional<Pattern> getDefaultValidationPattern(Class javaType) { return javaType.isEnum() ? Optional.of(createValidationPatternFromEnumType(javaType)) : getDefaultPatternIfPrimitive(javaType); }
[ "private", "Optional", "<", "Pattern", ">", "getDefaultValidationPattern", "(", "Class", "javaType", ")", "{", "return", "javaType", ".", "isEnum", "(", ")", "?", "Optional", ".", "of", "(", "createValidationPatternFromEnumType", "(", "javaType", ")", ")", ":", "getDefaultPatternIfPrimitive", "(", "javaType", ")", ";", "}" ]
Try to create a sensible default for validation pattern, in the case where the java type of the parameter is an enum type or a primitive or primitive wrapper type @param javaType @return
[ "Try", "to", "create", "a", "sensible", "default", "for", "validation", "pattern", "in", "the", "case", "where", "the", "java", "type", "of", "the", "parameter", "is", "an", "enum", "type", "or", "a", "primitive", "or", "primitive", "wrapper", "type" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-handlerconfig/src/main/java/org/chorusbdd/chorus/handlerconfig/configproperty/ConfigPropertyParser.java#L158-L162
143,169
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/protocol/MultipleSyntaxElements.java
MultipleSyntaxElements.containsOnly
private boolean containsOnly(String s, char c) { for (char c2 : s.toCharArray()) { if (c != c2) return false; } return true; }
java
private boolean containsOnly(String s, char c) { for (char c2 : s.toCharArray()) { if (c != c2) return false; } return true; }
[ "private", "boolean", "containsOnly", "(", "String", "s", ",", "char", "c", ")", "{", "for", "(", "char", "c2", ":", "s", ".", "toCharArray", "(", ")", ")", "{", "if", "(", "c", "!=", "c2", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
Prueft, ob der Text s nur aus dem Zeichen c besteht. @param s der Text. @param c das Zeichen. @return true, wenn der Text nur dieses Zeichen enthaelt.
[ "Prueft", "ob", "der", "Text", "s", "nur", "aus", "dem", "Zeichen", "c", "besteht", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/protocol/MultipleSyntaxElements.java#L533-L540
143,170
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/GV/AbstractSEPAGV.java
AbstractSEPAGV.getPainGenerator
protected final PainGeneratorIf getPainGenerator() { if (this.generator == null) { try { this.generator = PainGeneratorFactory.get(this, this.getPainVersion()); } catch (Exception e) { String msg = HBCIUtils.getLocMsg("EXCMSG_JOB_CREATE_ERR", this.getPainJobName()); throw new HBCI_Exception(msg, e); } } return this.generator; }
java
protected final PainGeneratorIf getPainGenerator() { if (this.generator == null) { try { this.generator = PainGeneratorFactory.get(this, this.getPainVersion()); } catch (Exception e) { String msg = HBCIUtils.getLocMsg("EXCMSG_JOB_CREATE_ERR", this.getPainJobName()); throw new HBCI_Exception(msg, e); } } return this.generator; }
[ "protected", "final", "PainGeneratorIf", "getPainGenerator", "(", ")", "{", "if", "(", "this", ".", "generator", "==", "null", ")", "{", "try", "{", "this", ".", "generator", "=", "PainGeneratorFactory", ".", "get", "(", "this", ",", "this", ".", "getPainVersion", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "String", "msg", "=", "HBCIUtils", ".", "getLocMsg", "(", "\"EXCMSG_JOB_CREATE_ERR\"", ",", "this", ".", "getPainJobName", "(", ")", ")", ";", "throw", "new", "HBCI_Exception", "(", "msg", ",", "e", ")", ";", "}", "}", "return", "this", ".", "generator", ";", "}" ]
Liefert den passenden SEPA-Generator. @return der SEPA-Generator.
[ "Liefert", "den", "passenden", "SEPA", "-", "Generator", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/GV/AbstractSEPAGV.java#L218-L229
143,171
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/protocol/SyntaxElement.java
SyntaxElement.enumerateSegs
public int enumerateSegs(int startValue, boolean allowOverwrite) { int idx = startValue; for (MultipleSyntaxElements s : getChildContainers()) { if (s != null) idx = s.enumerateSegs(idx, allowOverwrite); } return idx; }
java
public int enumerateSegs(int startValue, boolean allowOverwrite) { int idx = startValue; for (MultipleSyntaxElements s : getChildContainers()) { if (s != null) idx = s.enumerateSegs(idx, allowOverwrite); } return idx; }
[ "public", "int", "enumerateSegs", "(", "int", "startValue", ",", "boolean", "allowOverwrite", ")", "{", "int", "idx", "=", "startValue", ";", "for", "(", "MultipleSyntaxElements", "s", ":", "getChildContainers", "(", ")", ")", "{", "if", "(", "s", "!=", "null", ")", "idx", "=", "s", ".", "enumerateSegs", "(", "idx", ",", "allowOverwrite", ")", ";", "}", "return", "idx", ";", "}" ]
loop through all child-elements; the segments found there will be sequentially enumerated starting with num startValue; if startValue is zero, the segments will not be enumerated, but all given the number 0 @param startValue value to be used for the first segment found @return next sequence number usable for enumeration
[ "loop", "through", "all", "child", "-", "elements", ";", "the", "segments", "found", "there", "will", "be", "sequentially", "enumerated", "starting", "with", "num", "startValue", ";", "if", "startValue", "is", "zero", "the", "segments", "will", "not", "be", "enumerated", "but", "all", "given", "the", "number", "0" ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/protocol/SyntaxElement.java#L315-L324
143,172
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/protocol/SyntaxElement.java
SyntaxElement.extractValues
public void extractValues(HashMap<String, String> values) { for (MultipleSyntaxElements l : childContainers) { l.extractValues(values); } }
java
public void extractValues(HashMap<String, String> values) { for (MultipleSyntaxElements l : childContainers) { l.extractValues(values); } }
[ "public", "void", "extractValues", "(", "HashMap", "<", "String", ",", "String", ">", "values", ")", "{", "for", "(", "MultipleSyntaxElements", "l", ":", "childContainers", ")", "{", "l", ".", "extractValues", "(", "values", ")", ";", "}", "}" ]
fuellt die hashtable 'values' mit den werten der de-syntaxelemente; dazu wird in allen anderen typen von syntaxelementen die liste der child-elemente durchlaufen und deren 'fillValues' methode aufgerufen
[ "fuellt", "die", "hashtable", "values", "mit", "den", "werten", "der", "de", "-", "syntaxelemente", ";", "dazu", "wird", "in", "allen", "anderen", "typen", "von", "syntaxelementen", "die", "liste", "der", "child", "-", "elemente", "durchlaufen", "und", "deren", "fillValues", "methode", "aufgerufen" ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/protocol/SyntaxElement.java#L443-L447
143,173
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/protocol/SyntaxElement.java
SyntaxElement.validate
public void validate() { if (!needsRequestTag || haveRequestTag) { for (MultipleSyntaxElements l : childContainers) { l.validate(); } /* wenn keine exception geworfen wurde, dann ist das aktuelle element offensichtlich valid */ setValid(true); } }
java
public void validate() { if (!needsRequestTag || haveRequestTag) { for (MultipleSyntaxElements l : childContainers) { l.validate(); } /* wenn keine exception geworfen wurde, dann ist das aktuelle element offensichtlich valid */ setValid(true); } }
[ "public", "void", "validate", "(", ")", "{", "if", "(", "!", "needsRequestTag", "||", "haveRequestTag", ")", "{", "for", "(", "MultipleSyntaxElements", "l", ":", "childContainers", ")", "{", "l", ".", "validate", "(", ")", ";", "}", "/* wenn keine exception geworfen wurde, dann ist das aktuelle element\n offensichtlich valid */", "setValid", "(", "true", ")", ";", "}", "}" ]
ueberpreuft, ob das syntaxelement alle restriktionen einhaelt; ist das nicht der fall, so wird eine Exception ausgeloest. die meisten syntaxelemente koennen sich nicht selbst ueberpruefen, sondern rufen statt dessen die validate-funktion der child-elemente auf
[ "ueberpreuft", "ob", "das", "syntaxelement", "alle", "restriktionen", "einhaelt", ";", "ist", "das", "nicht", "der", "fall", "so", "wird", "eine", "Exception", "ausgeloest", ".", "die", "meisten", "syntaxelemente", "koennen", "sich", "nicht", "selbst", "ueberpruefen", "sondern", "rufen", "statt", "dessen", "die", "validate", "-", "funktion", "der", "child", "-", "elemente", "auf" ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/protocol/SyntaxElement.java#L705-L715
143,174
Chorus-bdd/Chorus
interpreter/chorus-remoting/src/main/java/org/chorusbdd/chorus/remoting/jmx/remotingmanager/ChorusHandlerJmxProxy.java
ChorusHandlerJmxProxy.invokeStep
public Object invokeStep(String remoteStepInvokerId, String stepTokenId, List<String> params) throws Exception { try { //call the remote method Object[] args = {remoteStepInvokerId, stepTokenId, ChorusContext.getContext().getSnapshot(), params}; String[] signature = {"java.lang.String", "java.lang.String", "java.util.Map", "java.util.List"}; log.debug(String.format("About to invoke step (%s) on MBean (%s)", remoteStepInvokerId, objectName)); JmxStepResult r = (JmxStepResult) mBeanServerConnection.invoke(objectName, "invokeStep", args, signature); //update the local context with any changes made remotely Map newContextState = r.getChorusContext(); ChorusContext.resetContext(newContextState); //return the result which the remote step method returned return r.getResult(); } catch (MBeanException e) { throw e.getTargetException(); } }
java
public Object invokeStep(String remoteStepInvokerId, String stepTokenId, List<String> params) throws Exception { try { //call the remote method Object[] args = {remoteStepInvokerId, stepTokenId, ChorusContext.getContext().getSnapshot(), params}; String[] signature = {"java.lang.String", "java.lang.String", "java.util.Map", "java.util.List"}; log.debug(String.format("About to invoke step (%s) on MBean (%s)", remoteStepInvokerId, objectName)); JmxStepResult r = (JmxStepResult) mBeanServerConnection.invoke(objectName, "invokeStep", args, signature); //update the local context with any changes made remotely Map newContextState = r.getChorusContext(); ChorusContext.resetContext(newContextState); //return the result which the remote step method returned return r.getResult(); } catch (MBeanException e) { throw e.getTargetException(); } }
[ "public", "Object", "invokeStep", "(", "String", "remoteStepInvokerId", ",", "String", "stepTokenId", ",", "List", "<", "String", ">", "params", ")", "throws", "Exception", "{", "try", "{", "//call the remote method", "Object", "[", "]", "args", "=", "{", "remoteStepInvokerId", ",", "stepTokenId", ",", "ChorusContext", ".", "getContext", "(", ")", ".", "getSnapshot", "(", ")", ",", "params", "}", ";", "String", "[", "]", "signature", "=", "{", "\"java.lang.String\"", ",", "\"java.lang.String\"", ",", "\"java.util.Map\"", ",", "\"java.util.List\"", "}", ";", "log", ".", "debug", "(", "String", ".", "format", "(", "\"About to invoke step (%s) on MBean (%s)\"", ",", "remoteStepInvokerId", ",", "objectName", ")", ")", ";", "JmxStepResult", "r", "=", "(", "JmxStepResult", ")", "mBeanServerConnection", ".", "invoke", "(", "objectName", ",", "\"invokeStep\"", ",", "args", ",", "signature", ")", ";", "//update the local context with any changes made remotely", "Map", "newContextState", "=", "r", ".", "getChorusContext", "(", ")", ";", "ChorusContext", ".", "resetContext", "(", "newContextState", ")", ";", "//return the result which the remote step method returned", "return", "r", ".", "getResult", "(", ")", ";", "}", "catch", "(", "MBeanException", "e", ")", "{", "throw", "e", ".", "getTargetException", "(", ")", ";", "}", "}" ]
Calls the invoke Step method on the remote MBean. The current ChorusContext will be serialized as part of this and marshalled to the remote bean. @param remoteStepInvokerId the id of the step to call @param params params to pass in the call
[ "Calls", "the", "invoke", "Step", "method", "on", "the", "remote", "MBean", ".", "The", "current", "ChorusContext", "will", "be", "serialized", "as", "part", "of", "this", "and", "marshalled", "to", "the", "remote", "bean", "." ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-remoting/src/main/java/org/chorusbdd/chorus/remoting/jmx/remotingmanager/ChorusHandlerJmxProxy.java#L89-L106
143,175
Chorus-bdd/Chorus
interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java
HandlerManager.processStartOfScope
public void processStartOfScope(Scope scopeStarting, Iterable<Object> handlerInstances) throws Exception { for (Object handler : handlerInstances) { Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class); Scope handlerScope = handlerAnnotation.scope(); injectResourceFieldsForScope(scopeStarting, handler, handlerScope, handlerInstances); runLifecycleMethods(handler, handlerScope, scopeStarting, false); } }
java
public void processStartOfScope(Scope scopeStarting, Iterable<Object> handlerInstances) throws Exception { for (Object handler : handlerInstances) { Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class); Scope handlerScope = handlerAnnotation.scope(); injectResourceFieldsForScope(scopeStarting, handler, handlerScope, handlerInstances); runLifecycleMethods(handler, handlerScope, scopeStarting, false); } }
[ "public", "void", "processStartOfScope", "(", "Scope", "scopeStarting", ",", "Iterable", "<", "Object", ">", "handlerInstances", ")", "throws", "Exception", "{", "for", "(", "Object", "handler", ":", "handlerInstances", ")", "{", "Handler", "handlerAnnotation", "=", "handler", ".", "getClass", "(", ")", ".", "getAnnotation", "(", "Handler", ".", "class", ")", ";", "Scope", "handlerScope", "=", "handlerAnnotation", ".", "scope", "(", ")", ";", "injectResourceFieldsForScope", "(", "scopeStarting", ",", "handler", ",", "handlerScope", ",", "handlerInstances", ")", ";", "runLifecycleMethods", "(", "handler", ",", "handlerScope", ",", "scopeStarting", ",", "false", ")", ";", "}", "}" ]
Scope is starting, perform the required processing on the supplied handlers.
[ "Scope", "is", "starting", "perform", "the", "required", "processing", "on", "the", "supplied", "handlers", "." ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java#L117-L125
143,176
Chorus-bdd/Chorus
interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java
HandlerManager.processEndOfScope
public void processEndOfScope(Scope scopeEnding, Iterable<Object> handlerInstances) throws Exception { for (Object handler : handlerInstances) { Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class); Scope scope = handlerAnnotation.scope(); runLifecycleMethods(handler, scope, scopeEnding, true); //dispose handler instances with a scope which matches the scopeEnding if (scope == scopeEnding) { disposeSpringResources(handler, scopeEnding); } } }
java
public void processEndOfScope(Scope scopeEnding, Iterable<Object> handlerInstances) throws Exception { for (Object handler : handlerInstances) { Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class); Scope scope = handlerAnnotation.scope(); runLifecycleMethods(handler, scope, scopeEnding, true); //dispose handler instances with a scope which matches the scopeEnding if (scope == scopeEnding) { disposeSpringResources(handler, scopeEnding); } } }
[ "public", "void", "processEndOfScope", "(", "Scope", "scopeEnding", ",", "Iterable", "<", "Object", ">", "handlerInstances", ")", "throws", "Exception", "{", "for", "(", "Object", "handler", ":", "handlerInstances", ")", "{", "Handler", "handlerAnnotation", "=", "handler", ".", "getClass", "(", ")", ".", "getAnnotation", "(", "Handler", ".", "class", ")", ";", "Scope", "scope", "=", "handlerAnnotation", ".", "scope", "(", ")", ";", "runLifecycleMethods", "(", "handler", ",", "scope", ",", "scopeEnding", ",", "true", ")", ";", "//dispose handler instances with a scope which matches the scopeEnding", "if", "(", "scope", "==", "scopeEnding", ")", "{", "disposeSpringResources", "(", "handler", ",", "scopeEnding", ")", ";", "}", "}", "}" ]
Scope is ending, perform the required processing on the supplied handlers.
[ "Scope", "is", "ending", "perform", "the", "required", "processing", "on", "the", "supplied", "handlers", "." ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java#L149-L161
143,177
Chorus-bdd/Chorus
interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java
HandlerManager.getMethodScope
private Scope getMethodScope(boolean isDestroy, Method method) { Scope methodScope; if ( isDestroy ) { Destroy annotation = method.getAnnotation(Destroy.class); methodScope = annotation != null ? annotation.scope() : null; } else { Initialize annotation = method.getAnnotation(Initialize.class); methodScope = annotation != null ? annotation.scope() : null; } return methodScope; }
java
private Scope getMethodScope(boolean isDestroy, Method method) { Scope methodScope; if ( isDestroy ) { Destroy annotation = method.getAnnotation(Destroy.class); methodScope = annotation != null ? annotation.scope() : null; } else { Initialize annotation = method.getAnnotation(Initialize.class); methodScope = annotation != null ? annotation.scope() : null; } return methodScope; }
[ "private", "Scope", "getMethodScope", "(", "boolean", "isDestroy", ",", "Method", "method", ")", "{", "Scope", "methodScope", ";", "if", "(", "isDestroy", ")", "{", "Destroy", "annotation", "=", "method", ".", "getAnnotation", "(", "Destroy", ".", "class", ")", ";", "methodScope", "=", "annotation", "!=", "null", "?", "annotation", ".", "scope", "(", ")", ":", "null", ";", "}", "else", "{", "Initialize", "annotation", "=", "method", ".", "getAnnotation", "(", "Initialize", ".", "class", ")", ";", "methodScope", "=", "annotation", "!=", "null", "?", "annotation", ".", "scope", "(", ")", ":", "null", ";", "}", "return", "methodScope", ";", "}" ]
return the scope of a lifecycle method, or null if the method is not a lifecycle method
[ "return", "the", "scope", "of", "a", "lifecycle", "method", "or", "null", "if", "the", "method", "is", "not", "a", "lifecycle", "method" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java#L190-L200
143,178
Chorus-bdd/Chorus
interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java
HandlerManager.injectResourceFields
private void injectResourceFields(Object handler, Iterable<Object> handlerInstances, Scope... scopes) { Class<?> featureClass = handler.getClass(); List<Field> allFields = new ArrayList<>(); addAllPublicFields(featureClass, allFields); log.trace("Now examining handler fields for ChorusResource annotation " + allFields); HashSet<Scope> scopeSet = new HashSet<>(Arrays.asList(scopes)); for (Field field : allFields) { setChorusResource(handler, handlerInstances, field, scopeSet); } }
java
private void injectResourceFields(Object handler, Iterable<Object> handlerInstances, Scope... scopes) { Class<?> featureClass = handler.getClass(); List<Field> allFields = new ArrayList<>(); addAllPublicFields(featureClass, allFields); log.trace("Now examining handler fields for ChorusResource annotation " + allFields); HashSet<Scope> scopeSet = new HashSet<>(Arrays.asList(scopes)); for (Field field : allFields) { setChorusResource(handler, handlerInstances, field, scopeSet); } }
[ "private", "void", "injectResourceFields", "(", "Object", "handler", ",", "Iterable", "<", "Object", ">", "handlerInstances", ",", "Scope", "...", "scopes", ")", "{", "Class", "<", "?", ">", "featureClass", "=", "handler", ".", "getClass", "(", ")", ";", "List", "<", "Field", ">", "allFields", "=", "new", "ArrayList", "<>", "(", ")", ";", "addAllPublicFields", "(", "featureClass", ",", "allFields", ")", ";", "log", ".", "trace", "(", "\"Now examining handler fields for ChorusResource annotation \"", "+", "allFields", ")", ";", "HashSet", "<", "Scope", ">", "scopeSet", "=", "new", "HashSet", "<>", "(", "Arrays", ".", "asList", "(", "scopes", ")", ")", ";", "for", "(", "Field", "field", ":", "allFields", ")", "{", "setChorusResource", "(", "handler", ",", "handlerInstances", ",", "field", ",", "scopeSet", ")", ";", "}", "}" ]
Here we set the values of any handler fields annotated with @ChorusResource
[ "Here", "we", "set", "the", "values", "of", "any", "handler", "fields", "annotated", "with" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java#L217-L228
143,179
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/sepa/SepaVersion.java
SepaVersion.byURN
public static SepaVersion byURN(String urn) { SepaVersion test = new SepaVersion(null, 0, urn, null, false); if (urn == null || urn.length() == 0) return test; for (List<SepaVersion> types : knownVersions.values()) { for (SepaVersion v : types) { if (v.equals(test)) return v; } } // keine passende Version gefunden. Dann erzeugen wir selbst eine return test; }
java
public static SepaVersion byURN(String urn) { SepaVersion test = new SepaVersion(null, 0, urn, null, false); if (urn == null || urn.length() == 0) return test; for (List<SepaVersion> types : knownVersions.values()) { for (SepaVersion v : types) { if (v.equals(test)) return v; } } // keine passende Version gefunden. Dann erzeugen wir selbst eine return test; }
[ "public", "static", "SepaVersion", "byURN", "(", "String", "urn", ")", "{", "SepaVersion", "test", "=", "new", "SepaVersion", "(", "null", ",", "0", ",", "urn", ",", "null", ",", "false", ")", ";", "if", "(", "urn", "==", "null", "||", "urn", ".", "length", "(", ")", "==", "0", ")", "return", "test", ";", "for", "(", "List", "<", "SepaVersion", ">", "types", ":", "knownVersions", ".", "values", "(", ")", ")", "{", "for", "(", "SepaVersion", "v", ":", "types", ")", "{", "if", "(", "v", ".", "equals", "(", "test", ")", ")", "return", "v", ";", "}", "}", "// keine passende Version gefunden. Dann erzeugen wir selbst eine", "return", "test", ";", "}" ]
Liefert die SEPA-Version aus dem URN. @param urn URN. In der Form "urn:iso:std:iso:20022:tech:xsd:pain.001.002.03" oder in der alten Form "sepade.pain.001.001.02.xsd". @return die SEPA-Version.
[ "Liefert", "die", "SEPA", "-", "Version", "aus", "dem", "URN", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/sepa/SepaVersion.java#L157-L172
143,180
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/sepa/SepaVersion.java
SepaVersion.findType
private static Type findType(String type, String value) throws IllegalArgumentException { if (type == null || type.length() == 0) throw new IllegalArgumentException("no SEPA type type given"); if (value == null || value.length() == 0) throw new IllegalArgumentException("no SEPA version value given"); for (Type t : Type.values()) { if (t.getType().equalsIgnoreCase(type) && t.getValue().equals(value)) return t; } throw new IllegalArgumentException("unknown SEPA version type: " + type + "." + value); }
java
private static Type findType(String type, String value) throws IllegalArgumentException { if (type == null || type.length() == 0) throw new IllegalArgumentException("no SEPA type type given"); if (value == null || value.length() == 0) throw new IllegalArgumentException("no SEPA version value given"); for (Type t : Type.values()) { if (t.getType().equalsIgnoreCase(type) && t.getValue().equals(value)) return t; } throw new IllegalArgumentException("unknown SEPA version type: " + type + "." + value); }
[ "private", "static", "Type", "findType", "(", "String", "type", ",", "String", "value", ")", "throws", "IllegalArgumentException", "{", "if", "(", "type", "==", "null", "||", "type", ".", "length", "(", ")", "==", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"no SEPA type type given\"", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "length", "(", ")", "==", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"no SEPA version value given\"", ")", ";", "for", "(", "Type", "t", ":", "Type", ".", "values", "(", ")", ")", "{", "if", "(", "t", ".", "getType", "(", ")", ".", "equalsIgnoreCase", "(", "type", ")", "&&", "t", ".", "getValue", "(", ")", ".", "equals", "(", "value", ")", ")", "return", "t", ";", "}", "throw", "new", "IllegalArgumentException", "(", "\"unknown SEPA version type: \"", "+", "type", "+", "\".\"", "+", "value", ")", ";", "}" ]
Liefert den enum-Type fuer den angegebenen Wert. @param type der Type. "pain", "camt". @param value der Wert. 001, 002, 008, .... @return der zugehoerige Enum-Wert. @throws IllegalArgumentException wenn der Typ unbekannt ist.
[ "Liefert", "den", "enum", "-", "Type", "fuer", "den", "angegebenen", "Wert", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/sepa/SepaVersion.java#L182-L194
143,181
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/sepa/SepaVersion.java
SepaVersion.autodetect
public static SepaVersion autodetect(InputStream xml) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(true); factory.setValidating(false); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(xml); Node root = doc.getFirstChild(); // Das ist das Element mit dem Namen "Document" if (root == null) throw new IllegalArgumentException("XML data did not contain a root element"); String uri = root.getNamespaceURI(); if (uri == null) return null; return SepaVersion.byURN(uri); } catch (IllegalArgumentException e) { throw e; } catch (Exception e2) { throw new IllegalArgumentException(e2); } }
java
public static SepaVersion autodetect(InputStream xml) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(true); factory.setValidating(false); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(xml); Node root = doc.getFirstChild(); // Das ist das Element mit dem Namen "Document" if (root == null) throw new IllegalArgumentException("XML data did not contain a root element"); String uri = root.getNamespaceURI(); if (uri == null) return null; return SepaVersion.byURN(uri); } catch (IllegalArgumentException e) { throw e; } catch (Exception e2) { throw new IllegalArgumentException(e2); } }
[ "public", "static", "SepaVersion", "autodetect", "(", "InputStream", "xml", ")", "{", "try", "{", "DocumentBuilderFactory", "factory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setIgnoringComments", "(", "true", ")", ";", "factory", ".", "setValidating", "(", "false", ")", ";", "factory", ".", "setNamespaceAware", "(", "true", ")", ";", "DocumentBuilder", "builder", "=", "factory", ".", "newDocumentBuilder", "(", ")", ";", "Document", "doc", "=", "builder", ".", "parse", "(", "xml", ")", ";", "Node", "root", "=", "doc", ".", "getFirstChild", "(", ")", ";", "// Das ist das Element mit dem Namen \"Document\"", "if", "(", "root", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"XML data did not contain a root element\"", ")", ";", "String", "uri", "=", "root", ".", "getNamespaceURI", "(", ")", ";", "if", "(", "uri", "==", "null", ")", "return", "null", ";", "return", "SepaVersion", ".", "byURN", "(", "uri", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e2", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e2", ")", ";", "}", "}" ]
Ermittelt die SEPA-Version aus dem uebergebenen XML-Stream. @param xml der XML-Stream. Achtung: Da der Stream hierbei gelesen werden muss, sollte eine Kopie des Streams uebergeben werden. Denn nach dem Lesen des Streams, kann er nicht erneut gelesen werden. Der Stream wird von dieser Methode nicht geschlossen. Das ist Aufgabe des Aufrufers. @return die ermittelte SEPA-Version oder NULL wenn das XML-Document keine entsprechenden Informationen enthielt.
[ "Ermittelt", "die", "SEPA", "-", "Version", "aus", "dem", "uebergebenen", "XML", "-", "Stream", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/sepa/SepaVersion.java#L236-L260
143,182
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/sepa/SepaVersion.java
SepaVersion.getGeneratorClass
public String getGeneratorClass(String jobName) { StringBuilder sb = new StringBuilder(); sb.append(PainGeneratorIf.class.getPackage().getName()); sb.append(".Gen"); sb.append(jobName); sb.append(this.type.getValue()); sb.append(new DecimalFormat(DF_MAJOR).format(this.major)); sb.append(new DecimalFormat(DF_MINOR).format(this.minor)); return sb.toString(); }
java
public String getGeneratorClass(String jobName) { StringBuilder sb = new StringBuilder(); sb.append(PainGeneratorIf.class.getPackage().getName()); sb.append(".Gen"); sb.append(jobName); sb.append(this.type.getValue()); sb.append(new DecimalFormat(DF_MAJOR).format(this.major)); sb.append(new DecimalFormat(DF_MINOR).format(this.minor)); return sb.toString(); }
[ "public", "String", "getGeneratorClass", "(", "String", "jobName", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "PainGeneratorIf", ".", "class", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ")", ";", "sb", ".", "append", "(", "\".Gen\"", ")", ";", "sb", ".", "append", "(", "jobName", ")", ";", "sb", ".", "append", "(", "this", ".", "type", ".", "getValue", "(", ")", ")", ";", "sb", ".", "append", "(", "new", "DecimalFormat", "(", "DF_MAJOR", ")", ".", "format", "(", "this", ".", "major", ")", ")", ";", "sb", ".", "append", "(", "new", "DecimalFormat", "(", "DF_MINOR", ")", ".", "format", "(", "this", ".", "minor", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Erzeugt den Namen der Java-Klasse des zugehoerigen SEPA-Generators. @param jobName der Job-Name. Z.Bsp. "UebSEPA". @return der Name der Java-Klasse des zugehoerigen SEPA-Generators.
[ "Erzeugt", "den", "Namen", "der", "Java", "-", "Klasse", "des", "zugehoerigen", "SEPA", "-", "Generators", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/sepa/SepaVersion.java#L332-L342
143,183
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/sepa/SepaVersion.java
SepaVersion.getParserClass
public String getParserClass() { StringBuilder sb = new StringBuilder(); sb.append(ISEPAParser.class.getPackage().getName()); sb.append(".Parse"); sb.append(this.type.getType()); sb.append(this.type.getValue()); sb.append(new DecimalFormat(DF_MAJOR).format(this.major)); sb.append(new DecimalFormat(DF_MINOR).format(this.minor)); return sb.toString(); }
java
public String getParserClass() { StringBuilder sb = new StringBuilder(); sb.append(ISEPAParser.class.getPackage().getName()); sb.append(".Parse"); sb.append(this.type.getType()); sb.append(this.type.getValue()); sb.append(new DecimalFormat(DF_MAJOR).format(this.major)); sb.append(new DecimalFormat(DF_MINOR).format(this.minor)); return sb.toString(); }
[ "public", "String", "getParserClass", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "ISEPAParser", ".", "class", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ")", ";", "sb", ".", "append", "(", "\".Parse\"", ")", ";", "sb", ".", "append", "(", "this", ".", "type", ".", "getType", "(", ")", ")", ";", "sb", ".", "append", "(", "this", ".", "type", ".", "getValue", "(", ")", ")", ";", "sb", ".", "append", "(", "new", "DecimalFormat", "(", "DF_MAJOR", ")", ".", "format", "(", "this", ".", "major", ")", ")", ";", "sb", ".", "append", "(", "new", "DecimalFormat", "(", "DF_MINOR", ")", ".", "format", "(", "this", ".", "minor", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Erzeugt den Namen der Java-Klasse des zugehoerigen SEPA-Parsers. @return der Name der Java-Klasse des zugehoerigen SEPA-Parsers.
[ "Erzeugt", "den", "Namen", "der", "Java", "-", "Klasse", "des", "zugehoerigen", "SEPA", "-", "Parsers", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/sepa/SepaVersion.java#L349-L360
143,184
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/sepa/SepaVersion.java
SepaVersion.canGenerate
public boolean canGenerate(String jobName) { try { Class.forName(this.getGeneratorClass(jobName)); return true; } catch (ClassNotFoundException e) { return false; } }
java
public boolean canGenerate(String jobName) { try { Class.forName(this.getGeneratorClass(jobName)); return true; } catch (ClassNotFoundException e) { return false; } }
[ "public", "boolean", "canGenerate", "(", "String", "jobName", ")", "{", "try", "{", "Class", ".", "forName", "(", "this", ".", "getGeneratorClass", "(", "jobName", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "return", "false", ";", "}", "}" ]
Prueft, ob fuer die SEPA-Version ein Generator vorhanden ist, der fuer den angegebenen HBCI4Java-Job die SEPA-XML-Dateien erzeugen kann. @param jobName der Job-Name. Z.Bsp. "UebSEPA". @return true, wenn ein Generator vorhanden ist.
[ "Prueft", "ob", "fuer", "die", "SEPA", "-", "Version", "ein", "Generator", "vorhanden", "ist", "der", "fuer", "den", "angegebenen", "HBCI4Java", "-", "Job", "die", "SEPA", "-", "XML", "-", "Dateien", "erzeugen", "kann", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/sepa/SepaVersion.java#L369-L376
143,185
Chorus-bdd/Chorus
extensions/chorus-websockets/src/main/java/org/chorusbdd/chorus/websockets/client/TimeoutStepExecutor.java
TimeoutStepExecutor.runWithinPeriod
void runWithinPeriod(Runnable runnable, ExecuteStepMessage executeStepMessage, int timeout, TimeUnit unit) { if ( ! isRunningAStep.getAndSet(true)) { this.currentlyExecutingStep = executeStepMessage; Future<String> future = null; try { future = scheduledExecutorService.submit(runStepAndResetIsRunning(runnable), "OK"); future.get(timeout, unit); } catch (TimeoutException e) { //Timed out waiting for the step to run //We should try to cancel and interrupt the thread which is running the step - although this isn't //guaranteed to succeed. future.cancel(true); log.warn("A step failed to execute within " + timeout + " " + unit + ", attempting to cancel the step"); //Here the step server should have timed out the step and proceed already - we don't need to send a failure message } catch (Exception e) { String ms = "Exception while executing step [" + e.getMessage() + "]"; log.error(ms, e); stepFailureConsumer.accept(ms, executeStepMessage); } } else { //server will time out this step String message = "Cannot execute a test step, a step is already in progress [" + currentlyExecutingStep.getStepId() + ", " + currentlyExecutingStep.getPattern() + "]"; log.error(message); stepFailureConsumer.accept(message, executeStepMessage); } }
java
void runWithinPeriod(Runnable runnable, ExecuteStepMessage executeStepMessage, int timeout, TimeUnit unit) { if ( ! isRunningAStep.getAndSet(true)) { this.currentlyExecutingStep = executeStepMessage; Future<String> future = null; try { future = scheduledExecutorService.submit(runStepAndResetIsRunning(runnable), "OK"); future.get(timeout, unit); } catch (TimeoutException e) { //Timed out waiting for the step to run //We should try to cancel and interrupt the thread which is running the step - although this isn't //guaranteed to succeed. future.cancel(true); log.warn("A step failed to execute within " + timeout + " " + unit + ", attempting to cancel the step"); //Here the step server should have timed out the step and proceed already - we don't need to send a failure message } catch (Exception e) { String ms = "Exception while executing step [" + e.getMessage() + "]"; log.error(ms, e); stepFailureConsumer.accept(ms, executeStepMessage); } } else { //server will time out this step String message = "Cannot execute a test step, a step is already in progress [" + currentlyExecutingStep.getStepId() + ", " + currentlyExecutingStep.getPattern() + "]"; log.error(message); stepFailureConsumer.accept(message, executeStepMessage); } }
[ "void", "runWithinPeriod", "(", "Runnable", "runnable", ",", "ExecuteStepMessage", "executeStepMessage", ",", "int", "timeout", ",", "TimeUnit", "unit", ")", "{", "if", "(", "!", "isRunningAStep", ".", "getAndSet", "(", "true", ")", ")", "{", "this", ".", "currentlyExecutingStep", "=", "executeStepMessage", ";", "Future", "<", "String", ">", "future", "=", "null", ";", "try", "{", "future", "=", "scheduledExecutorService", ".", "submit", "(", "runStepAndResetIsRunning", "(", "runnable", ")", ",", "\"OK\"", ")", ";", "future", ".", "get", "(", "timeout", ",", "unit", ")", ";", "}", "catch", "(", "TimeoutException", "e", ")", "{", "//Timed out waiting for the step to run", "//We should try to cancel and interrupt the thread which is running the step - although this isn't", "//guaranteed to succeed.", "future", ".", "cancel", "(", "true", ")", ";", "log", ".", "warn", "(", "\"A step failed to execute within \"", "+", "timeout", "+", "\" \"", "+", "unit", "+", "\", attempting to cancel the step\"", ")", ";", "//Here the step server should have timed out the step and proceed already - we don't need to send a failure message", "}", "catch", "(", "Exception", "e", ")", "{", "String", "ms", "=", "\"Exception while executing step [\"", "+", "e", ".", "getMessage", "(", ")", "+", "\"]\"", ";", "log", ".", "error", "(", "ms", ",", "e", ")", ";", "stepFailureConsumer", ".", "accept", "(", "ms", ",", "executeStepMessage", ")", ";", "}", "}", "else", "{", "//server will time out this step", "String", "message", "=", "\"Cannot execute a test step, a step is already in progress [\"", "+", "currentlyExecutingStep", ".", "getStepId", "(", ")", "+", "\", \"", "+", "currentlyExecutingStep", ".", "getPattern", "(", ")", "+", "\"]\"", ";", "log", ".", "error", "(", "message", ")", ";", "stepFailureConsumer", ".", "accept", "(", "message", ",", "executeStepMessage", ")", ";", "}", "}" ]
Run a task on the scheduled executor so that we can try to interrupt it and time out if it fails
[ "Run", "a", "task", "on", "the", "scheduled", "executor", "so", "that", "we", "can", "try", "to", "interrupt", "it", "and", "time", "out", "if", "it", "fails" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/extensions/chorus-websockets/src/main/java/org/chorusbdd/chorus/websockets/client/TimeoutStepExecutor.java#L65-L90
143,186
Chorus-bdd/Chorus
extensions/chorus-websockets/src/main/java/org/chorusbdd/chorus/websockets/client/TimeoutStepExecutor.java
TimeoutStepExecutor.runStepAndResetIsRunning
private Runnable runStepAndResetIsRunning(Runnable runnable) { return () -> { try { runnable.run(); } catch (Throwable t) { //we're in control of the runnable and it should catch it's own execeptions, but just in case it doesn't log.error("Exeception while running a step", t); } finally { isRunningAStep.getAndSet(false); } }; }
java
private Runnable runStepAndResetIsRunning(Runnable runnable) { return () -> { try { runnable.run(); } catch (Throwable t) { //we're in control of the runnable and it should catch it's own execeptions, but just in case it doesn't log.error("Exeception while running a step", t); } finally { isRunningAStep.getAndSet(false); } }; }
[ "private", "Runnable", "runStepAndResetIsRunning", "(", "Runnable", "runnable", ")", "{", "return", "(", ")", "->", "{", "try", "{", "runnable", ".", "run", "(", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "//we're in control of the runnable and it should catch it's own execeptions, but just in case it doesn't", "log", ".", "error", "(", "\"Exeception while running a step\"", ",", "t", ")", ";", "}", "finally", "{", "isRunningAStep", ".", "getAndSet", "(", "false", ")", ";", "}", "}", ";", "}" ]
Wrap the runnable which executed the step, and only unset currentlyExecutingStep when it has completed If the step blocks and can't be interrupted, then we don't want to start any other steps
[ "Wrap", "the", "runnable", "which", "executed", "the", "step", "and", "only", "unset", "currentlyExecutingStep", "when", "it", "has", "completed", "If", "the", "step", "blocks", "and", "can", "t", "be", "interrupted", "then", "we", "don", "t", "want", "to", "start", "any", "other", "steps" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/extensions/chorus-websockets/src/main/java/org/chorusbdd/chorus/websockets/client/TimeoutStepExecutor.java#L96-L107
143,187
Chorus-bdd/Chorus
interpreter/chorus-util/src/main/java/org/chorusbdd/chorus/util/ExceptionHandling.java
ExceptionHandling.findStackTraceElement
private static StackTraceElement findStackTraceElement(Throwable t) { StackTraceElement element = t.getStackTrace().length > 0 ? t.getStackTrace()[0] : null; int index = 0; String chorusAssertClassName = ChorusAssert.class.getName(); String junitAssertClassName = "org.junit.Assert"; //junit may not be in classpath so don't use Assert.class.getName() String junitLegacyClassName = "junit.framework.Assert"; //need to support alternative (legacy?) junit 3 style Assert while ( element != null && ( element.getClassName().contains(chorusAssertClassName) || element.getClassName().contains(junitAssertClassName) || element.getClassName().contains(junitLegacyClassName)) ) { index += 1; element = t.getStackTrace().length > index ? t.getStackTrace()[index] : null; } return element; }
java
private static StackTraceElement findStackTraceElement(Throwable t) { StackTraceElement element = t.getStackTrace().length > 0 ? t.getStackTrace()[0] : null; int index = 0; String chorusAssertClassName = ChorusAssert.class.getName(); String junitAssertClassName = "org.junit.Assert"; //junit may not be in classpath so don't use Assert.class.getName() String junitLegacyClassName = "junit.framework.Assert"; //need to support alternative (legacy?) junit 3 style Assert while ( element != null && ( element.getClassName().contains(chorusAssertClassName) || element.getClassName().contains(junitAssertClassName) || element.getClassName().contains(junitLegacyClassName)) ) { index += 1; element = t.getStackTrace().length > index ? t.getStackTrace()[index] : null; } return element; }
[ "private", "static", "StackTraceElement", "findStackTraceElement", "(", "Throwable", "t", ")", "{", "StackTraceElement", "element", "=", "t", ".", "getStackTrace", "(", ")", ".", "length", ">", "0", "?", "t", ".", "getStackTrace", "(", ")", "[", "0", "]", ":", "null", ";", "int", "index", "=", "0", ";", "String", "chorusAssertClassName", "=", "ChorusAssert", ".", "class", ".", "getName", "(", ")", ";", "String", "junitAssertClassName", "=", "\"org.junit.Assert\"", ";", "//junit may not be in classpath so don't use Assert.class.getName()", "String", "junitLegacyClassName", "=", "\"junit.framework.Assert\"", ";", "//need to support alternative (legacy?) junit 3 style Assert", "while", "(", "element", "!=", "null", "&&", "(", "element", ".", "getClassName", "(", ")", ".", "contains", "(", "chorusAssertClassName", ")", "||", "element", ".", "getClassName", "(", ")", ".", "contains", "(", "junitAssertClassName", ")", "||", "element", ".", "getClassName", "(", ")", ".", "contains", "(", "junitLegacyClassName", ")", ")", ")", "{", "index", "+=", "1", ";", "element", "=", "t", ".", "getStackTrace", "(", ")", ".", "length", ">", "index", "?", "t", ".", "getStackTrace", "(", ")", "[", "index", "]", ":", "null", ";", "}", "return", "element", ";", "}" ]
we want to skip frames with the JUnit or ChorusAssert
[ "we", "want", "to", "skip", "frames", "with", "the", "JUnit", "or", "ChorusAssert" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-util/src/main/java/org/chorusbdd/chorus/util/ExceptionHandling.java#L57-L72
143,188
Chorus-bdd/Chorus
interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/startup/InterpreterBuilder.java
InterpreterBuilder.buildAndConfigure
public ChorusInterpreter buildAndConfigure(ConfigProperties config, SubsystemManager subsystemManager) { ChorusInterpreter chorusInterpreter = new ChorusInterpreter(listenerSupport); chorusInterpreter.setHandlerClassBasePackages(config.getValues(ChorusConfigProperty.HANDLER_PACKAGES)); chorusInterpreter.setScenarioTimeoutMillis(Integer.valueOf(config.getValue(ChorusConfigProperty.SCENARIO_TIMEOUT)) * 1000); chorusInterpreter.setDryRun(config.isTrue(ChorusConfigProperty.DRY_RUN)); chorusInterpreter.setSubsystemManager(subsystemManager); StepCatalogue stepCatalogue = createStepCatalogue(config); chorusInterpreter.setStepCatalogue(stepCatalogue); return chorusInterpreter; }
java
public ChorusInterpreter buildAndConfigure(ConfigProperties config, SubsystemManager subsystemManager) { ChorusInterpreter chorusInterpreter = new ChorusInterpreter(listenerSupport); chorusInterpreter.setHandlerClassBasePackages(config.getValues(ChorusConfigProperty.HANDLER_PACKAGES)); chorusInterpreter.setScenarioTimeoutMillis(Integer.valueOf(config.getValue(ChorusConfigProperty.SCENARIO_TIMEOUT)) * 1000); chorusInterpreter.setDryRun(config.isTrue(ChorusConfigProperty.DRY_RUN)); chorusInterpreter.setSubsystemManager(subsystemManager); StepCatalogue stepCatalogue = createStepCatalogue(config); chorusInterpreter.setStepCatalogue(stepCatalogue); return chorusInterpreter; }
[ "public", "ChorusInterpreter", "buildAndConfigure", "(", "ConfigProperties", "config", ",", "SubsystemManager", "subsystemManager", ")", "{", "ChorusInterpreter", "chorusInterpreter", "=", "new", "ChorusInterpreter", "(", "listenerSupport", ")", ";", "chorusInterpreter", ".", "setHandlerClassBasePackages", "(", "config", ".", "getValues", "(", "ChorusConfigProperty", ".", "HANDLER_PACKAGES", ")", ")", ";", "chorusInterpreter", ".", "setScenarioTimeoutMillis", "(", "Integer", ".", "valueOf", "(", "config", ".", "getValue", "(", "ChorusConfigProperty", ".", "SCENARIO_TIMEOUT", ")", ")", "*", "1000", ")", ";", "chorusInterpreter", ".", "setDryRun", "(", "config", ".", "isTrue", "(", "ChorusConfigProperty", ".", "DRY_RUN", ")", ")", ";", "chorusInterpreter", ".", "setSubsystemManager", "(", "subsystemManager", ")", ";", "StepCatalogue", "stepCatalogue", "=", "createStepCatalogue", "(", "config", ")", ";", "chorusInterpreter", ".", "setStepCatalogue", "(", "stepCatalogue", ")", ";", "return", "chorusInterpreter", ";", "}" ]
Run the interpreter, collating results into the executionToken
[ "Run", "the", "interpreter", "collating", "results", "into", "the", "executionToken" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/startup/InterpreterBuilder.java#L56-L66
143,189
Chorus-bdd/Chorus
interpreter/chorus-stepinvoker/src/main/java/org/chorusbdd/chorus/stepinvoker/TypeCoercion.java
TypeCoercion.coerceType
public static <T> T coerceType(ChorusLog log, String value, Class<T> requiredType) { T result = null; try { if ( "null".equals(value)) { result = null; } else if (isStringType(requiredType)) { result = (T) value; } else if (isStringBufferType(requiredType)) { result = (T) new StringBuffer(value); } else if (isIntType(requiredType)) { result = (T) new Integer(value); } else if (isLongType(requiredType)) { result = (T) new Long(value); } else if (isFloatType(requiredType)) { result = (T) new Float(value); } else if (isDoubleType(requiredType)) { result = (T) new Double(value); } else if (isBigDecimalType(requiredType)) { result = (T) new BigDecimal(value); } else if (isBigIntegerType(requiredType)) { result = (T) new BigInteger(value); } else if (isBooleanType(requiredType) && "true".equalsIgnoreCase(value) //be stricter than Boolean.parseValue || "false".equalsIgnoreCase(value)) { //do not accept 'wibble' as a boolean false value //dont create new Booleans (there are only 2 possible values) result = (T) (Boolean) Boolean.parseBoolean(value); } else if (isShortType(requiredType)) { result = (T) new Short(value); } else if (isByteType(requiredType)) { result = (T) new Byte(value); } else if (isCharType(requiredType) && value.length() == 1) { result = (T) (Character) value.toCharArray()[0]; } else if (isEnumeratedType(requiredType)) { result = (T)coerceEnum(value, requiredType); } else if (isObjectType(requiredType)) {//attempt to convert the String to the most appropriate value result = (T)coerceObject(value); } } catch (Throwable t) { //Only log at debug since this failure may be an 'expected' NumberFormatException for example //There may be another handler method which provides a matching type and this is expected to fail //Even if something else has gone wrong with the conversion, we don't want to propagate errors since //this causes unpredictable output from the interpreter, we simply want the step not to be matched in this case log.debug("Exception when coercing value " + value + " to a " + requiredType, t); } return result; }
java
public static <T> T coerceType(ChorusLog log, String value, Class<T> requiredType) { T result = null; try { if ( "null".equals(value)) { result = null; } else if (isStringType(requiredType)) { result = (T) value; } else if (isStringBufferType(requiredType)) { result = (T) new StringBuffer(value); } else if (isIntType(requiredType)) { result = (T) new Integer(value); } else if (isLongType(requiredType)) { result = (T) new Long(value); } else if (isFloatType(requiredType)) { result = (T) new Float(value); } else if (isDoubleType(requiredType)) { result = (T) new Double(value); } else if (isBigDecimalType(requiredType)) { result = (T) new BigDecimal(value); } else if (isBigIntegerType(requiredType)) { result = (T) new BigInteger(value); } else if (isBooleanType(requiredType) && "true".equalsIgnoreCase(value) //be stricter than Boolean.parseValue || "false".equalsIgnoreCase(value)) { //do not accept 'wibble' as a boolean false value //dont create new Booleans (there are only 2 possible values) result = (T) (Boolean) Boolean.parseBoolean(value); } else if (isShortType(requiredType)) { result = (T) new Short(value); } else if (isByteType(requiredType)) { result = (T) new Byte(value); } else if (isCharType(requiredType) && value.length() == 1) { result = (T) (Character) value.toCharArray()[0]; } else if (isEnumeratedType(requiredType)) { result = (T)coerceEnum(value, requiredType); } else if (isObjectType(requiredType)) {//attempt to convert the String to the most appropriate value result = (T)coerceObject(value); } } catch (Throwable t) { //Only log at debug since this failure may be an 'expected' NumberFormatException for example //There may be another handler method which provides a matching type and this is expected to fail //Even if something else has gone wrong with the conversion, we don't want to propagate errors since //this causes unpredictable output from the interpreter, we simply want the step not to be matched in this case log.debug("Exception when coercing value " + value + " to a " + requiredType, t); } return result; }
[ "public", "static", "<", "T", ">", "T", "coerceType", "(", "ChorusLog", "log", ",", "String", "value", ",", "Class", "<", "T", ">", "requiredType", ")", "{", "T", "result", "=", "null", ";", "try", "{", "if", "(", "\"null\"", ".", "equals", "(", "value", ")", ")", "{", "result", "=", "null", ";", "}", "else", "if", "(", "isStringType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "value", ";", "}", "else", "if", "(", "isStringBufferType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "StringBuffer", "(", "value", ")", ";", "}", "else", "if", "(", "isIntType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "Integer", "(", "value", ")", ";", "}", "else", "if", "(", "isLongType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "Long", "(", "value", ")", ";", "}", "else", "if", "(", "isFloatType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "Float", "(", "value", ")", ";", "}", "else", "if", "(", "isDoubleType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "Double", "(", "value", ")", ";", "}", "else", "if", "(", "isBigDecimalType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "BigDecimal", "(", "value", ")", ";", "}", "else", "if", "(", "isBigIntegerType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "BigInteger", "(", "value", ")", ";", "}", "else", "if", "(", "isBooleanType", "(", "requiredType", ")", "&&", "\"true\"", ".", "equalsIgnoreCase", "(", "value", ")", "//be stricter than Boolean.parseValue", "||", "\"false\"", ".", "equalsIgnoreCase", "(", "value", ")", ")", "{", "//do not accept 'wibble' as a boolean false value", "//dont create new Booleans (there are only 2 possible values)", "result", "=", "(", "T", ")", "(", "Boolean", ")", "Boolean", ".", "parseBoolean", "(", "value", ")", ";", "}", "else", "if", "(", "isShortType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "Short", "(", "value", ")", ";", "}", "else", "if", "(", "isByteType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "new", "Byte", "(", "value", ")", ";", "}", "else", "if", "(", "isCharType", "(", "requiredType", ")", "&&", "value", ".", "length", "(", ")", "==", "1", ")", "{", "result", "=", "(", "T", ")", "(", "Character", ")", "value", ".", "toCharArray", "(", ")", "[", "0", "]", ";", "}", "else", "if", "(", "isEnumeratedType", "(", "requiredType", ")", ")", "{", "result", "=", "(", "T", ")", "coerceEnum", "(", "value", ",", "requiredType", ")", ";", "}", "else", "if", "(", "isObjectType", "(", "requiredType", ")", ")", "{", "//attempt to convert the String to the most appropriate value", "result", "=", "(", "T", ")", "coerceObject", "(", "value", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "//Only log at debug since this failure may be an 'expected' NumberFormatException for example", "//There may be another handler method which provides a matching type and this is expected to fail", "//Even if something else has gone wrong with the conversion, we don't want to propagate errors since", "//this causes unpredictable output from the interpreter, we simply want the step not to be matched in this case", "log", ".", "debug", "(", "\"Exception when coercing value \"", "+", "value", "+", "\" to a \"", "+", "requiredType", ",", "t", ")", ";", "}", "return", "result", ";", "}" ]
Will attempt to convert the String to the required type @return the coerced value, or null if the value cannot be converted to the required type
[ "Will", "attempt", "to", "convert", "the", "String", "to", "the", "required", "type" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-stepinvoker/src/main/java/org/chorusbdd/chorus/stepinvoker/TypeCoercion.java#L53-L99
143,190
Chorus-bdd/Chorus
interpreter/chorus-stepinvoker/src/main/java/org/chorusbdd/chorus/stepinvoker/TypeCoercion.java
TypeCoercion.coerceObject
private static <T> T coerceObject(String value) { T result; //try boolean first if ("true".equals(value) || "false".equals(value)) { result = (T) (Boolean) Boolean.parseBoolean(value); } //then float numbers else if (floatPattern.matcher(value).matches()) { //handle overflow by converting to BigDecimal BigDecimal bd = new BigDecimal(value); Double d = bd.doubleValue(); result = (T) ((d == Double.NEGATIVE_INFINITY || d == Double.POSITIVE_INFINITY) ? bd : d); } //then int numbers else if (intPattern.matcher(value).matches()) { //handle overflow by converting to BigInteger BigInteger bd = new BigInteger(value); result = (T) (bd.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) == 1 ? bd : bd.longValue()); } //else just pass the String value to the Object parameter else { result = (T) value; } return result; }
java
private static <T> T coerceObject(String value) { T result; //try boolean first if ("true".equals(value) || "false".equals(value)) { result = (T) (Boolean) Boolean.parseBoolean(value); } //then float numbers else if (floatPattern.matcher(value).matches()) { //handle overflow by converting to BigDecimal BigDecimal bd = new BigDecimal(value); Double d = bd.doubleValue(); result = (T) ((d == Double.NEGATIVE_INFINITY || d == Double.POSITIVE_INFINITY) ? bd : d); } //then int numbers else if (intPattern.matcher(value).matches()) { //handle overflow by converting to BigInteger BigInteger bd = new BigInteger(value); result = (T) (bd.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) == 1 ? bd : bd.longValue()); } //else just pass the String value to the Object parameter else { result = (T) value; } return result; }
[ "private", "static", "<", "T", ">", "T", "coerceObject", "(", "String", "value", ")", "{", "T", "result", ";", "//try boolean first", "if", "(", "\"true\"", ".", "equals", "(", "value", ")", "||", "\"false\"", ".", "equals", "(", "value", ")", ")", "{", "result", "=", "(", "T", ")", "(", "Boolean", ")", "Boolean", ".", "parseBoolean", "(", "value", ")", ";", "}", "//then float numbers", "else", "if", "(", "floatPattern", ".", "matcher", "(", "value", ")", ".", "matches", "(", ")", ")", "{", "//handle overflow by converting to BigDecimal", "BigDecimal", "bd", "=", "new", "BigDecimal", "(", "value", ")", ";", "Double", "d", "=", "bd", ".", "doubleValue", "(", ")", ";", "result", "=", "(", "T", ")", "(", "(", "d", "==", "Double", ".", "NEGATIVE_INFINITY", "||", "d", "==", "Double", ".", "POSITIVE_INFINITY", ")", "?", "bd", ":", "d", ")", ";", "}", "//then int numbers", "else", "if", "(", "intPattern", ".", "matcher", "(", "value", ")", ".", "matches", "(", ")", ")", "{", "//handle overflow by converting to BigInteger", "BigInteger", "bd", "=", "new", "BigInteger", "(", "value", ")", ";", "result", "=", "(", "T", ")", "(", "bd", ".", "compareTo", "(", "BigInteger", ".", "valueOf", "(", "Long", ".", "MAX_VALUE", ")", ")", "==", "1", "?", "bd", ":", "bd", ".", "longValue", "(", ")", ")", ";", "}", "//else just pass the String value to the Object parameter", "else", "{", "result", "=", "(", "T", ")", "value", ";", "}", "return", "result", ";", "}" ]
Rules for object coercion are probably most important for the ChorusContext Here when we set the value of a variable, these rules are used to determine how the String value supplied is represented - since float pattern comes first I set the variable x with value 1.2 will become a float within the ChorusContext - this will give some extra utility if we add more powerful comparison methods to ChorusContext
[ "Rules", "for", "object", "coercion", "are", "probably", "most", "important", "for", "the", "ChorusContext", "Here", "when", "we", "set", "the", "value", "of", "a", "variable", "these", "rules", "are", "used", "to", "determine", "how", "the", "String", "value", "supplied", "is", "represented", "-", "since", "float", "pattern", "comes", "first", "I", "set", "the", "variable", "x", "with", "value", "1", ".", "2", "will", "become", "a", "float", "within", "the", "ChorusContext", "-", "this", "will", "give", "some", "extra", "utility", "if", "we", "add", "more", "powerful", "comparison", "methods", "to", "ChorusContext" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-stepinvoker/src/main/java/org/chorusbdd/chorus/stepinvoker/TypeCoercion.java#L108-L132
143,191
Chorus-bdd/Chorus
interpreter/chorus-handlerconfig/src/main/java/org/chorusbdd/chorus/handlerconfig/ChorusProperties.java
ChorusProperties.mergeConfigurationAndProfileProperties
private PropertyOperations mergeConfigurationAndProfileProperties(PropertyOperations props) { PropertyOperations result; result = mergeConfigurationProperties(props); result = mergeProfileProperties(result); return result; }
java
private PropertyOperations mergeConfigurationAndProfileProperties(PropertyOperations props) { PropertyOperations result; result = mergeConfigurationProperties(props); result = mergeProfileProperties(result); return result; }
[ "private", "PropertyOperations", "mergeConfigurationAndProfileProperties", "(", "PropertyOperations", "props", ")", "{", "PropertyOperations", "result", ";", "result", "=", "mergeConfigurationProperties", "(", "props", ")", ";", "result", "=", "mergeProfileProperties", "(", "result", ")", ";", "return", "result", ";", "}" ]
Some property keys may be prefixed with the name of a configuration or the name of a profile If this matches the current configration/profile we strip this prefix and merge the new property over the top of any default ones This enables us to declare properties which are only active in a certain profile or configuration We do configurations first, so if we take it to the extreme we could have the below for a processes.myProcess.remotingPort property configurations.configA.profiles.profile1.processes.myProcess.remotingPort = 12345 The above property would be only set while running feature configuration A in profile 1
[ "Some", "property", "keys", "may", "be", "prefixed", "with", "the", "name", "of", "a", "configuration", "or", "the", "name", "of", "a", "profile" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-handlerconfig/src/main/java/org/chorusbdd/chorus/handlerconfig/ChorusProperties.java#L102-L107
143,192
Chorus-bdd/Chorus
interpreter/chorus-handlerconfig/src/main/java/org/chorusbdd/chorus/handlerconfig/ChorusProperties.java
ChorusProperties.addPropertiesFromDatabase
private PropertyOperations addPropertiesFromDatabase(PropertyOperations sourceProperties) { PropertyOperations dbPropsOnly = sourceProperties.filterByKeyPrefix(ChorusConstants.DATABASE_CONFIGS_PROPERTY_GROUP + ".") .removeKeyPrefix(ChorusConstants.DATABASE_CONFIGS_PROPERTY_GROUP + "."); dbPropsOnly = VariableExpandingPropertyLoader.expandVariables(dbPropsOnly, currentFeature); Map<String, Properties> dbPropsByDbName = dbPropsOnly.splitKeyAndGroup("\\.").loadPropertyGroups(); PropertyOperations o = sourceProperties; for ( Map.Entry<String, Properties> m : dbPropsByDbName.entrySet()) { log.debug("Creating loader for database properties " + m.getKey()); //current properties which may be from properties files or classpath take precedence over db properties so merge them on top o = properties(new JdbcPropertyLoader(m.getValue())).merge(o); } return o; }
java
private PropertyOperations addPropertiesFromDatabase(PropertyOperations sourceProperties) { PropertyOperations dbPropsOnly = sourceProperties.filterByKeyPrefix(ChorusConstants.DATABASE_CONFIGS_PROPERTY_GROUP + ".") .removeKeyPrefix(ChorusConstants.DATABASE_CONFIGS_PROPERTY_GROUP + "."); dbPropsOnly = VariableExpandingPropertyLoader.expandVariables(dbPropsOnly, currentFeature); Map<String, Properties> dbPropsByDbName = dbPropsOnly.splitKeyAndGroup("\\.").loadPropertyGroups(); PropertyOperations o = sourceProperties; for ( Map.Entry<String, Properties> m : dbPropsByDbName.entrySet()) { log.debug("Creating loader for database properties " + m.getKey()); //current properties which may be from properties files or classpath take precedence over db properties so merge them on top o = properties(new JdbcPropertyLoader(m.getValue())).merge(o); } return o; }
[ "private", "PropertyOperations", "addPropertiesFromDatabase", "(", "PropertyOperations", "sourceProperties", ")", "{", "PropertyOperations", "dbPropsOnly", "=", "sourceProperties", ".", "filterByKeyPrefix", "(", "ChorusConstants", ".", "DATABASE_CONFIGS_PROPERTY_GROUP", "+", "\".\"", ")", ".", "removeKeyPrefix", "(", "ChorusConstants", ".", "DATABASE_CONFIGS_PROPERTY_GROUP", "+", "\".\"", ")", ";", "dbPropsOnly", "=", "VariableExpandingPropertyLoader", ".", "expandVariables", "(", "dbPropsOnly", ",", "currentFeature", ")", ";", "Map", "<", "String", ",", "Properties", ">", "dbPropsByDbName", "=", "dbPropsOnly", ".", "splitKeyAndGroup", "(", "\"\\\\.\"", ")", ".", "loadPropertyGroups", "(", ")", ";", "PropertyOperations", "o", "=", "sourceProperties", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Properties", ">", "m", ":", "dbPropsByDbName", ".", "entrySet", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Creating loader for database properties \"", "+", "m", ".", "getKey", "(", ")", ")", ";", "//current properties which may be from properties files or classpath take precedence over db properties so merge them on top", "o", "=", "properties", "(", "new", "JdbcPropertyLoader", "(", "m", ".", "getValue", "(", ")", ")", ")", ".", "merge", "(", "o", ")", ";", "}", "return", "o", ";", "}" ]
If there are any database properties defined in sourceProperties then use them to merge extra properties from the databsase @param sourceProperties @return
[ "If", "there", "are", "any", "database", "properties", "defined", "in", "sourceProperties", "then", "use", "them", "to", "merge", "extra", "properties", "from", "the", "databsase" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-handlerconfig/src/main/java/org/chorusbdd/chorus/handlerconfig/ChorusProperties.java#L160-L173
143,193
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/exceptions/HBCI_Exception.java
HBCI_Exception.isFatal
public boolean isFatal() { if (this.fatal) // dann brauchen wir den Cause nicht mehr checken return true; Throwable t = this.getCause(); if (t == this) return false; // sind wir selbst if (t instanceof HBCI_Exception) return ((HBCI_Exception) t).isFatal(); return false; }
java
public boolean isFatal() { if (this.fatal) // dann brauchen wir den Cause nicht mehr checken return true; Throwable t = this.getCause(); if (t == this) return false; // sind wir selbst if (t instanceof HBCI_Exception) return ((HBCI_Exception) t).isFatal(); return false; }
[ "public", "boolean", "isFatal", "(", ")", "{", "if", "(", "this", ".", "fatal", ")", "// dann brauchen wir den Cause nicht mehr checken", "return", "true", ";", "Throwable", "t", "=", "this", ".", "getCause", "(", ")", ";", "if", "(", "t", "==", "this", ")", "return", "false", ";", "// sind wir selbst", "if", "(", "t", "instanceof", "HBCI_Exception", ")", "return", "(", "(", "HBCI_Exception", ")", "t", ")", ".", "isFatal", "(", ")", ";", "return", "false", ";", "}" ]
Liefert true, wenn die Exception oder ihr Cause als fatal eingestuft wurde. @return true, wenn die Exception oder ihr Cause als fatal eingestuft wurde.
[ "Liefert", "true", "wenn", "die", "Exception", "oder", "ihr", "Cause", "als", "fatal", "eingestuft", "wurde", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/exceptions/HBCI_Exception.java#L88-L99
143,194
imsweb/seerapi-client-java
src/main/java/com/imsweb/seerapi/client/staging/SchemaLookup.java
SchemaLookup.setInput
public void setInput(String key, String value) { if (getAllowedKeys() != null && !getAllowedKeys().contains(key)) throw new IllegalStateException("The input key " + key + " is not allowed for lookups"); _inputs.put(key, value); }
java
public void setInput(String key, String value) { if (getAllowedKeys() != null && !getAllowedKeys().contains(key)) throw new IllegalStateException("The input key " + key + " is not allowed for lookups"); _inputs.put(key, value); }
[ "public", "void", "setInput", "(", "String", "key", ",", "String", "value", ")", "{", "if", "(", "getAllowedKeys", "(", ")", "!=", "null", "&&", "!", "getAllowedKeys", "(", ")", ".", "contains", "(", "key", ")", ")", "throw", "new", "IllegalStateException", "(", "\"The input key \"", "+", "key", "+", "\" is not allowed for lookups\"", ")", ";", "_inputs", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
Set the value of a single input. @param key key of input @param value value of input
[ "Set", "the", "value", "of", "a", "single", "input", "." ]
04f509961c3a5ece7b232ecb8d8cb8f89d810a85
https://github.com/imsweb/seerapi-client-java/blob/04f509961c3a5ece7b232ecb8d8cb8f89d810a85/src/main/java/com/imsweb/seerapi/client/staging/SchemaLookup.java#L69-L74
143,195
Chorus-bdd/Chorus
extensions/chorus-sql/src/main/java/org/chorusbdd/chorus/sql/manager/DefaultSqlManager.java
DefaultSqlManager.executeJdbcStatements
private void executeJdbcStatements(Connection connection, String configName, String statements, String description) { Statement stmt = createStatement(configName, connection); try { log.debug("Executing statement [" + description + "]"); List<String> stmtsToExecute = Stream.of(statements.split(";")) .map(String::trim) .filter(s -> s.length() > 0) .collect(Collectors.toList()); if ( log.isTraceEnabled()) { log.trace("These statements will be executed:"); stmtsToExecute.forEach(s -> log.trace("Statement: [" + s + "]")); } for ( String currentStatement : stmtsToExecute) { stmt.execute(currentStatement); log.trace("Executing statement: " + currentStatement + " OK!"); } } catch (SQLException e) { throw new ChorusException( String.format("Failed while executing statement [%s] on database + %s [%s]", description, configName, e.toString(), e) ); } }
java
private void executeJdbcStatements(Connection connection, String configName, String statements, String description) { Statement stmt = createStatement(configName, connection); try { log.debug("Executing statement [" + description + "]"); List<String> stmtsToExecute = Stream.of(statements.split(";")) .map(String::trim) .filter(s -> s.length() > 0) .collect(Collectors.toList()); if ( log.isTraceEnabled()) { log.trace("These statements will be executed:"); stmtsToExecute.forEach(s -> log.trace("Statement: [" + s + "]")); } for ( String currentStatement : stmtsToExecute) { stmt.execute(currentStatement); log.trace("Executing statement: " + currentStatement + " OK!"); } } catch (SQLException e) { throw new ChorusException( String.format("Failed while executing statement [%s] on database + %s [%s]", description, configName, e.toString(), e) ); } }
[ "private", "void", "executeJdbcStatements", "(", "Connection", "connection", ",", "String", "configName", ",", "String", "statements", ",", "String", "description", ")", "{", "Statement", "stmt", "=", "createStatement", "(", "configName", ",", "connection", ")", ";", "try", "{", "log", ".", "debug", "(", "\"Executing statement [\"", "+", "description", "+", "\"]\"", ")", ";", "List", "<", "String", ">", "stmtsToExecute", "=", "Stream", ".", "of", "(", "statements", ".", "split", "(", "\";\"", ")", ")", ".", "map", "(", "String", "::", "trim", ")", ".", "filter", "(", "s", "->", "s", ".", "length", "(", ")", ">", "0", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "{", "log", ".", "trace", "(", "\"These statements will be executed:\"", ")", ";", "stmtsToExecute", ".", "forEach", "(", "s", "->", "log", ".", "trace", "(", "\"Statement: [\"", "+", "s", "+", "\"]\"", ")", ")", ";", "}", "for", "(", "String", "currentStatement", ":", "stmtsToExecute", ")", "{", "stmt", ".", "execute", "(", "currentStatement", ")", ";", "log", ".", "trace", "(", "\"Executing statement: \"", "+", "currentStatement", "+", "\" OK!\"", ")", ";", "}", "}", "catch", "(", "SQLException", "e", ")", "{", "throw", "new", "ChorusException", "(", "String", ".", "format", "(", "\"Failed while executing statement [%s] on database + %s [%s]\"", ",", "description", ",", "configName", ",", "e", ".", "toString", "(", ")", ",", "e", ")", ")", ";", "}", "}" ]
Execute one or more SQL statements @param statements, a String which may contain one or more semi-colon-delimited SQL statements
[ "Execute", "one", "or", "more", "SQL", "statements" ]
1eea7ca858876bce821bb49b43fd5b6ba1737997
https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/extensions/chorus-sql/src/main/java/org/chorusbdd/chorus/sql/manager/DefaultSqlManager.java#L148-L173
143,196
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/manager/FlickerRenderer.java
FlickerRenderer.stop
public final void stop() { if (this.thread != null) { try { if (this.thread != null) { this.thread.interrupt(); synchronized (this.thread) { this.thread.notifyAll(); } } } finally { this.thread = null; } } }
java
public final void stop() { if (this.thread != null) { try { if (this.thread != null) { this.thread.interrupt(); synchronized (this.thread) { this.thread.notifyAll(); } } } finally { this.thread = null; } } }
[ "public", "final", "void", "stop", "(", ")", "{", "if", "(", "this", ".", "thread", "!=", "null", ")", "{", "try", "{", "if", "(", "this", ".", "thread", "!=", "null", ")", "{", "this", ".", "thread", ".", "interrupt", "(", ")", ";", "synchronized", "(", "this", ".", "thread", ")", "{", "this", ".", "thread", ".", "notifyAll", "(", ")", ";", "}", "}", "}", "finally", "{", "this", ".", "thread", "=", "null", ";", "}", "}", "}" ]
Stoppt das Rendern.
[ "Stoppt", "das", "Rendern", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/manager/FlickerRenderer.java#L204-L217
143,197
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/manager/HBCIUtils.java
HBCIUtils.getNameForBLZ
public static String getNameForBLZ(String blz) { BankInfo info = getBankInfo(blz); if (info == null) return ""; return info.getName() != null ? info.getName() : ""; }
java
public static String getNameForBLZ(String blz) { BankInfo info = getBankInfo(blz); if (info == null) return ""; return info.getName() != null ? info.getName() : ""; }
[ "public", "static", "String", "getNameForBLZ", "(", "String", "blz", ")", "{", "BankInfo", "info", "=", "getBankInfo", "(", "blz", ")", ";", "if", "(", "info", "==", "null", ")", "return", "\"\"", ";", "return", "info", ".", "getName", "(", ")", "!=", "null", "?", "info", ".", "getName", "(", ")", ":", "\"\"", ";", "}" ]
Ermittelt zu einer gegebenen Bankleitzahl den Namen des Institutes. @param blz die Bankleitzahl @return den Namen des dazugehörigen Kreditinstitutes. Falls die Bankleitzahl unbekannt ist, so wird ein leerer String zurückgegeben
[ "Ermittelt", "zu", "einer", "gegebenen", "Bankleitzahl", "den", "Namen", "des", "Institutes", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/manager/HBCIUtils.java#L50-L55
143,198
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/manager/HBCIUtils.java
HBCIUtils.searchBankInfo
public static List<BankInfo> searchBankInfo(String query) { if (query != null) query = query.trim(); List<BankInfo> list = new LinkedList<BankInfo>(); if (query == null || query.length() < 3) return list; query = query.toLowerCase(); for (BankInfo info : banks.values()) { String blz = info.getBlz(); String bic = info.getBic(); String name = info.getName(); String loc = info.getLocation(); // Anhand der BLZ? if (blz != null && blz.startsWith(query)) { list.add(info); continue; } // Anhand der BIC? if (bic != null && bic.toLowerCase().startsWith(query)) { list.add(info); continue; } // Anhand des Namens? if (name != null && name.toLowerCase().contains(query)) { list.add(info); continue; } // Anhand des Orts? if (loc != null && loc.toLowerCase().contains(query)) { list.add(info); continue; } } Collections.sort(list, new Comparator<BankInfo>() { /** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @Override public int compare(BankInfo o1, BankInfo o2) { if (o1 == null || o1.getBlz() == null) return -1; if (o2 == null || o2.getBlz() == null) return 1; return o1.getBlz().compareTo(o2.getBlz()); } }); return list; }
java
public static List<BankInfo> searchBankInfo(String query) { if (query != null) query = query.trim(); List<BankInfo> list = new LinkedList<BankInfo>(); if (query == null || query.length() < 3) return list; query = query.toLowerCase(); for (BankInfo info : banks.values()) { String blz = info.getBlz(); String bic = info.getBic(); String name = info.getName(); String loc = info.getLocation(); // Anhand der BLZ? if (blz != null && blz.startsWith(query)) { list.add(info); continue; } // Anhand der BIC? if (bic != null && bic.toLowerCase().startsWith(query)) { list.add(info); continue; } // Anhand des Namens? if (name != null && name.toLowerCase().contains(query)) { list.add(info); continue; } // Anhand des Orts? if (loc != null && loc.toLowerCase().contains(query)) { list.add(info); continue; } } Collections.sort(list, new Comparator<BankInfo>() { /** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @Override public int compare(BankInfo o1, BankInfo o2) { if (o1 == null || o1.getBlz() == null) return -1; if (o2 == null || o2.getBlz() == null) return 1; return o1.getBlz().compareTo(o2.getBlz()); } }); return list; }
[ "public", "static", "List", "<", "BankInfo", ">", "searchBankInfo", "(", "String", "query", ")", "{", "if", "(", "query", "!=", "null", ")", "query", "=", "query", ".", "trim", "(", ")", ";", "List", "<", "BankInfo", ">", "list", "=", "new", "LinkedList", "<", "BankInfo", ">", "(", ")", ";", "if", "(", "query", "==", "null", "||", "query", ".", "length", "(", ")", "<", "3", ")", "return", "list", ";", "query", "=", "query", ".", "toLowerCase", "(", ")", ";", "for", "(", "BankInfo", "info", ":", "banks", ".", "values", "(", ")", ")", "{", "String", "blz", "=", "info", ".", "getBlz", "(", ")", ";", "String", "bic", "=", "info", ".", "getBic", "(", ")", ";", "String", "name", "=", "info", ".", "getName", "(", ")", ";", "String", "loc", "=", "info", ".", "getLocation", "(", ")", ";", "// Anhand der BLZ?", "if", "(", "blz", "!=", "null", "&&", "blz", ".", "startsWith", "(", "query", ")", ")", "{", "list", ".", "add", "(", "info", ")", ";", "continue", ";", "}", "// Anhand der BIC?", "if", "(", "bic", "!=", "null", "&&", "bic", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "query", ")", ")", "{", "list", ".", "add", "(", "info", ")", ";", "continue", ";", "}", "// Anhand des Namens?", "if", "(", "name", "!=", "null", "&&", "name", ".", "toLowerCase", "(", ")", ".", "contains", "(", "query", ")", ")", "{", "list", ".", "add", "(", "info", ")", ";", "continue", ";", "}", "// Anhand des Orts?", "if", "(", "loc", "!=", "null", "&&", "loc", ".", "toLowerCase", "(", ")", ".", "contains", "(", "query", ")", ")", "{", "list", ".", "add", "(", "info", ")", ";", "continue", ";", "}", "}", "Collections", ".", "sort", "(", "list", ",", "new", "Comparator", "<", "BankInfo", ">", "(", ")", "{", "/**\n * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)\n */", "@", "Override", "public", "int", "compare", "(", "BankInfo", "o1", ",", "BankInfo", "o2", ")", "{", "if", "(", "o1", "==", "null", "||", "o1", ".", "getBlz", "(", ")", "==", "null", ")", "return", "-", "1", ";", "if", "(", "o2", "==", "null", "||", "o2", ".", "getBlz", "(", ")", "==", "null", ")", "return", "1", ";", "return", "o1", ".", "getBlz", "(", ")", ".", "compareTo", "(", "o2", ".", "getBlz", "(", ")", ")", ";", "}", "}", ")", ";", "return", "list", ";", "}" ]
Liefert eine Liste von Bank-Informationen, die zum angegebenen Suchbegriff passen. @param query der Suchbegriff. Der Suchbegriff muss mindestens 3 Zeichen enthalten und ist nicht case-sensitive. Der Suchbegriff kann im Ort der Bank oder in deren Namen enthalten sein. Oder die BLZ oder BIC beginnt mit diesem Text. @return die Liste der Bank-Informationen. Die Ergebnis-Liste ist nach BLZ sortiert. Die Funktion liefert niemals NULL sondern hoechstens eine leere Liste.
[ "Liefert", "eine", "Liste", "von", "Bank", "-", "Informationen", "die", "zum", "angegebenen", "Suchbegriff", "passen", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/manager/HBCIUtils.java#L78-L134
143,199
adorsys/hbci4java-adorsys
src/main/java/org/kapott/hbci/manager/HBCIUtils.java
HBCIUtils.getIBANForKonto
public static String getIBANForKonto(Konto k) { String konto = k.number; // Die Unterkonto-Nummer muss mit eingerechnet werden. // Aber nur, wenn sie numerisch ist. Bei irgendeiner Bank wurde // "EUR" als Unterkontonummer verwendet. Das geht natuerlich nicht, // weil damit nicht gerechnet werden kann // Wir machen das auch nur dann, wenn beide Nummern zusammen max. // 10 Zeichen ergeben if (k.subnumber != null && k.subnumber.length() > 0 && k.subnumber.matches("[0-9]{1,8}") && k.number.length() + k.subnumber.length() <= 10) konto += k.subnumber; ///////////////// // Pruefziffer berechnen // Siehe http://www.iban.de/iban-pruefsumme.html String zeros = "0000000000"; String filledKonto = zeros.substring(0, 10 - konto.length()) + konto; // 10-stellig mit Nullen fuellen StringBuffer sb = new StringBuffer(); sb.append(k.blz); sb.append(filledKonto); sb.append("1314"); // hartcodiert fuer "DE sb.append("00"); // fest vorgegeben BigInteger mod = new BigInteger(sb.toString()).mod(new BigInteger("97")); // "97" ist fest vorgegeben in ISO // 7064/Modulo 97-10 String checksum = String.valueOf(98 - mod.intValue()); // "98" ist fest vorgegeben in ISO 7064/Modulo 97-10 if (checksum.length() < 2) checksum = "0" + checksum; // ///////////////// StringBuffer result = new StringBuffer(); result.append("DE"); result.append(checksum); result.append(k.blz); result.append(filledKonto); return result.toString(); }
java
public static String getIBANForKonto(Konto k) { String konto = k.number; // Die Unterkonto-Nummer muss mit eingerechnet werden. // Aber nur, wenn sie numerisch ist. Bei irgendeiner Bank wurde // "EUR" als Unterkontonummer verwendet. Das geht natuerlich nicht, // weil damit nicht gerechnet werden kann // Wir machen das auch nur dann, wenn beide Nummern zusammen max. // 10 Zeichen ergeben if (k.subnumber != null && k.subnumber.length() > 0 && k.subnumber.matches("[0-9]{1,8}") && k.number.length() + k.subnumber.length() <= 10) konto += k.subnumber; ///////////////// // Pruefziffer berechnen // Siehe http://www.iban.de/iban-pruefsumme.html String zeros = "0000000000"; String filledKonto = zeros.substring(0, 10 - konto.length()) + konto; // 10-stellig mit Nullen fuellen StringBuffer sb = new StringBuffer(); sb.append(k.blz); sb.append(filledKonto); sb.append("1314"); // hartcodiert fuer "DE sb.append("00"); // fest vorgegeben BigInteger mod = new BigInteger(sb.toString()).mod(new BigInteger("97")); // "97" ist fest vorgegeben in ISO // 7064/Modulo 97-10 String checksum = String.valueOf(98 - mod.intValue()); // "98" ist fest vorgegeben in ISO 7064/Modulo 97-10 if (checksum.length() < 2) checksum = "0" + checksum; // ///////////////// StringBuffer result = new StringBuffer(); result.append("DE"); result.append(checksum); result.append(k.blz); result.append(filledKonto); return result.toString(); }
[ "public", "static", "String", "getIBANForKonto", "(", "Konto", "k", ")", "{", "String", "konto", "=", "k", ".", "number", ";", "// Die Unterkonto-Nummer muss mit eingerechnet werden.", "// Aber nur, wenn sie numerisch ist. Bei irgendeiner Bank wurde", "// \"EUR\" als Unterkontonummer verwendet. Das geht natuerlich nicht,", "// weil damit nicht gerechnet werden kann", "// Wir machen das auch nur dann, wenn beide Nummern zusammen max.", "// 10 Zeichen ergeben", "if", "(", "k", ".", "subnumber", "!=", "null", "&&", "k", ".", "subnumber", ".", "length", "(", ")", ">", "0", "&&", "k", ".", "subnumber", ".", "matches", "(", "\"[0-9]{1,8}\"", ")", "&&", "k", ".", "number", ".", "length", "(", ")", "+", "k", ".", "subnumber", ".", "length", "(", ")", "<=", "10", ")", "konto", "+=", "k", ".", "subnumber", ";", "/////////////////", "// Pruefziffer berechnen", "// Siehe http://www.iban.de/iban-pruefsumme.html", "String", "zeros", "=", "\"0000000000\"", ";", "String", "filledKonto", "=", "zeros", ".", "substring", "(", "0", ",", "10", "-", "konto", ".", "length", "(", ")", ")", "+", "konto", ";", "// 10-stellig mit Nullen fuellen", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "k", ".", "blz", ")", ";", "sb", ".", "append", "(", "filledKonto", ")", ";", "sb", ".", "append", "(", "\"1314\"", ")", ";", "// hartcodiert fuer \"DE", "sb", ".", "append", "(", "\"00\"", ")", ";", "// fest vorgegeben", "BigInteger", "mod", "=", "new", "BigInteger", "(", "sb", ".", "toString", "(", ")", ")", ".", "mod", "(", "new", "BigInteger", "(", "\"97\"", ")", ")", ";", "// \"97\" ist fest vorgegeben in ISO", "// 7064/Modulo 97-10", "String", "checksum", "=", "String", ".", "valueOf", "(", "98", "-", "mod", ".", "intValue", "(", ")", ")", ";", "// \"98\" ist fest vorgegeben in ISO 7064/Modulo 97-10", "if", "(", "checksum", ".", "length", "(", ")", "<", "2", ")", "checksum", "=", "\"0\"", "+", "checksum", ";", "//", "/////////////////", "StringBuffer", "result", "=", "new", "StringBuffer", "(", ")", ";", "result", ".", "append", "(", "\"DE\"", ")", ";", "result", ".", "append", "(", "checksum", ")", ";", "result", ".", "append", "(", "k", ".", "blz", ")", ";", "result", ".", "append", "(", "filledKonto", ")", ";", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Berechnet die IBAN fuer ein angegebenes deutsches Konto. @param k das Konto. @return die berechnete IBAN.
[ "Berechnet", "die", "IBAN", "fuer", "ein", "angegebenes", "deutsches", "Konto", "." ]
5e24f7e429d6b555e1d993196b4cf1adda6433cf
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/hbci/manager/HBCIUtils.java#L157-L198