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
partition
stringclasses
1 value
guardtime/ksi-java-sdk
ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java
HashTreeBuilder.add
public void add(ImprintNode node, IdentityMetadata metadata) throws HashException, KSIException { addToHeads(heads, aggregate(node, metadata)); }
java
public void add(ImprintNode node, IdentityMetadata metadata) throws HashException, KSIException { addToHeads(heads, aggregate(node, metadata)); }
[ "public", "void", "add", "(", "ImprintNode", "node", ",", "IdentityMetadata", "metadata", ")", "throws", "HashException", ",", "KSIException", "{", "addToHeads", "(", "heads", ",", "aggregate", "(", "node", ",", "metadata", ")", ")", ";", "}" ]
Adds a new leaf with its metadata to the hash tree. @param node leaf node to be added, must not be null. @param metadata node's metadata, must not be null @throws HashException @throws KSIException
[ "Adds", "a", "new", "leaf", "with", "its", "metadata", "to", "the", "hash", "tree", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java#L100-L102
train
guardtime/ksi-java-sdk
ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java
HashTreeBuilder.calculateHeight
public long calculateHeight(ImprintNode node) throws HashException { LinkedList<ImprintNode> tmpHeads = new LinkedList<>(); for (ImprintNode in : heads) { tmpHeads.add(new ImprintNode(in)); } addToHeads(tmpHeads, new ImprintNode(node)); ImprintNode root = getRootNode(tmpHeads); logger.debug("Adding node with hash {} and height {}, the hash tree height would be {}", node.getValue(), node.getLevel(), root.getLevel()); return root.getLevel(); }
java
public long calculateHeight(ImprintNode node) throws HashException { LinkedList<ImprintNode> tmpHeads = new LinkedList<>(); for (ImprintNode in : heads) { tmpHeads.add(new ImprintNode(in)); } addToHeads(tmpHeads, new ImprintNode(node)); ImprintNode root = getRootNode(tmpHeads); logger.debug("Adding node with hash {} and height {}, the hash tree height would be {}", node.getValue(), node.getLevel(), root.getLevel()); return root.getLevel(); }
[ "public", "long", "calculateHeight", "(", "ImprintNode", "node", ")", "throws", "HashException", "{", "LinkedList", "<", "ImprintNode", ">", "tmpHeads", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "ImprintNode", "in", ":", "heads", ")", "{", ...
Calculates the height of the hash tree in case a new node would be added. @param node a leaf to be added to the tree, must not be null. @return Height of the hash tree. @throws HashException
[ "Calculates", "the", "height", "of", "the", "hash", "tree", "in", "case", "a", "new", "node", "would", "be", "added", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java#L114-L126
train
guardtime/ksi-java-sdk
ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java
HashTreeBuilder.calculateHeight
public long calculateHeight(ImprintNode node, IdentityMetadata metadata) throws HashException, KSIException { return calculateHeight(aggregate(node, metadata)); }
java
public long calculateHeight(ImprintNode node, IdentityMetadata metadata) throws HashException, KSIException { return calculateHeight(aggregate(node, metadata)); }
[ "public", "long", "calculateHeight", "(", "ImprintNode", "node", ",", "IdentityMetadata", "metadata", ")", "throws", "HashException", ",", "KSIException", "{", "return", "calculateHeight", "(", "aggregate", "(", "node", ",", "metadata", ")", ")", ";", "}" ]
Calculates the height of the hash tree in case a new node with metadata would be added. @param node a leaf to be added to the tree, must not be null. @param metadata metadata associated with the node. @return Height of the hash tree. @throws HashException @throws KSIException
[ "Calculates", "the", "height", "of", "the", "hash", "tree", "in", "case", "a", "new", "node", "with", "metadata", "would", "be", "added", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java#L137-L139
train
guardtime/ksi-java-sdk
ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java
HashTreeBuilder.add
public void add(ImprintNode... nodes) throws HashException { notNull(nodes, "Nodes"); for (ImprintNode node : nodes) { add(node); } }
java
public void add(ImprintNode... nodes) throws HashException { notNull(nodes, "Nodes"); for (ImprintNode node : nodes) { add(node); } }
[ "public", "void", "add", "(", "ImprintNode", "...", "nodes", ")", "throws", "HashException", "{", "notNull", "(", "nodes", ",", "\"Nodes\"", ")", ";", "for", "(", "ImprintNode", "node", ":", "nodes", ")", "{", "add", "(", "node", ")", ";", "}", "}" ]
Adds a new array of child nodes to the hash tree. @param nodes array of nodes to be added. @throws HashException
[ "Adds", "a", "new", "array", "of", "child", "nodes", "to", "the", "hash", "tree", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-blocksigner/src/main/java/com/guardtime/ksi/tree/HashTreeBuilder.java#L148-L153
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/KSIBuilder.java
KSIBuilder.setKsiProtocolSignerClient
public KSIBuilder setKsiProtocolSignerClient(KSISigningClient signingClient) { Util.notNull(signingClient, "KSI Signing Client"); return setKsiProtocolSigningService(new KSISigningClientServiceAdapter(signingClient)); }
java
public KSIBuilder setKsiProtocolSignerClient(KSISigningClient signingClient) { Util.notNull(signingClient, "KSI Signing Client"); return setKsiProtocolSigningService(new KSISigningClientServiceAdapter(signingClient)); }
[ "public", "KSIBuilder", "setKsiProtocolSignerClient", "(", "KSISigningClient", "signingClient", ")", "{", "Util", ".", "notNull", "(", "signingClient", ",", "\"KSI Signing Client\"", ")", ";", "return", "setKsiProtocolSigningService", "(", "new", "KSISigningClientServiceAda...
Sets the signer client to be used in signing process. @param signingClient instance of {@link KSISigningClient}. @return Instance of {@link KSIBuilder}.
[ "Sets", "the", "signer", "client", "to", "be", "used", "in", "signing", "process", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/KSIBuilder.java#L135-L138
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/KSIBuilder.java
KSIBuilder.setKsiProtocolExtenderClient
public KSIBuilder setKsiProtocolExtenderClient(KSIExtenderClient extenderClient) { Util.notNull(extenderClient, "KSI Extender Client"); return setKsiProtocolExtendingService(new KSIExtendingClientServiceAdapter(extenderClient)); }
java
public KSIBuilder setKsiProtocolExtenderClient(KSIExtenderClient extenderClient) { Util.notNull(extenderClient, "KSI Extender Client"); return setKsiProtocolExtendingService(new KSIExtendingClientServiceAdapter(extenderClient)); }
[ "public", "KSIBuilder", "setKsiProtocolExtenderClient", "(", "KSIExtenderClient", "extenderClient", ")", "{", "Util", ".", "notNull", "(", "extenderClient", ",", "\"KSI Extender Client\"", ")", ";", "return", "setKsiProtocolExtendingService", "(", "new", "KSIExtendingClient...
Sets the extender client to be used in verification and extending process. @param extenderClient instance of {@link KSIExtenderClient}. @return Instance of {@link KSIBuilder}.
[ "Sets", "the", "extender", "client", "to", "be", "used", "in", "verification", "and", "extending", "process", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/KSIBuilder.java#L147-L150
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/trust/JKSTrustStore.java
JKSTrustStore.isTrusted
public boolean isTrusted(X509Certificate certificate, Store certStore) throws CryptoException { try { if (certificate == null) { throw new CryptoException("Invalid input parameter. Certificate can not be null"); } LOGGER.info("Checking if certificate with subjectDN={} is trusted", certificate.getSubjectDN()); Store certificateStore = certStore; if (certificateStore == null) { certificateStore = new JcaCertStore(new ArrayList()); } checkConstraints(certSelector, certificate); X509CertSelector selector = new X509CertSelector(); selector.setCertificate(certificate); CertStore pkixParamsCertStore = new JcaCertStoreBuilder().addCertificates(certificateStore).build(); PKIXBuilderParameters buildParams = new PKIXBuilderParameters(keyStore, selector); buildParams.addCertStore(pkixParamsCertStore); buildParams.setRevocationEnabled(false); CertPathBuilder builder = CertPathBuilder.getInstance(ALGORITHM_PKIX); PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult) builder.build(buildParams); // Build certificate path CertPath certPath = result.getCertPath(); // Set validation parameters PKIXParameters params = new PKIXParameters(keyStore); params.setRevocationEnabled(false); // Validate certificate path CertPathValidator validator = CertPathValidator.getInstance(ALGORITHM_PKIX); validator.validate(certPath, params); return true; } catch (CertPathValidatorException e) { LOGGER.debug("Cert path validation failed", e); return false; } catch (CertPathBuilderException e) { LOGGER.debug("Cert path building failed", e); return false; } catch (GeneralSecurityException e) { throw new CryptoException("General security error occurred. " + e.getMessage(), e); } }
java
public boolean isTrusted(X509Certificate certificate, Store certStore) throws CryptoException { try { if (certificate == null) { throw new CryptoException("Invalid input parameter. Certificate can not be null"); } LOGGER.info("Checking if certificate with subjectDN={} is trusted", certificate.getSubjectDN()); Store certificateStore = certStore; if (certificateStore == null) { certificateStore = new JcaCertStore(new ArrayList()); } checkConstraints(certSelector, certificate); X509CertSelector selector = new X509CertSelector(); selector.setCertificate(certificate); CertStore pkixParamsCertStore = new JcaCertStoreBuilder().addCertificates(certificateStore).build(); PKIXBuilderParameters buildParams = new PKIXBuilderParameters(keyStore, selector); buildParams.addCertStore(pkixParamsCertStore); buildParams.setRevocationEnabled(false); CertPathBuilder builder = CertPathBuilder.getInstance(ALGORITHM_PKIX); PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult) builder.build(buildParams); // Build certificate path CertPath certPath = result.getCertPath(); // Set validation parameters PKIXParameters params = new PKIXParameters(keyStore); params.setRevocationEnabled(false); // Validate certificate path CertPathValidator validator = CertPathValidator.getInstance(ALGORITHM_PKIX); validator.validate(certPath, params); return true; } catch (CertPathValidatorException e) { LOGGER.debug("Cert path validation failed", e); return false; } catch (CertPathBuilderException e) { LOGGER.debug("Cert path building failed", e); return false; } catch (GeneralSecurityException e) { throw new CryptoException("General security error occurred. " + e.getMessage(), e); } }
[ "public", "boolean", "isTrusted", "(", "X509Certificate", "certificate", ",", "Store", "certStore", ")", "throws", "CryptoException", "{", "try", "{", "if", "(", "certificate", "==", "null", ")", "{", "throw", "new", "CryptoException", "(", "\"Invalid input parame...
This method is used to check if certificate is trusted or not. @param certificate instance of PKI X.509 certificate. not null. @param certStore additional certificates to be used to check if certificate chain is trusted or not. @return true if certificate is trusted, false otherwise @throws CryptoException will be thrown when exception occurs turning certificate path building
[ "This", "method", "is", "used", "to", "check", "if", "certificate", "is", "trusted", "or", "not", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/trust/JKSTrustStore.java#L138-L182
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/trust/JKSTrustStore.java
JKSTrustStore.loadFile
@SuppressWarnings("resource") private InputStream loadFile(String trustStorePath) throws FileNotFoundException { InputStream input; try { input = new FileInputStream(trustStorePath); } catch (FileNotFoundException e) { LOGGER.warn("File {} not found. Fallback to classpath.", trustStorePath); input = Thread.currentThread().getContextClassLoader().getResourceAsStream(trustStorePath); } if (input == null) { throw new FileNotFoundException("File " + trustStorePath + " does not exist"); } return input; }
java
@SuppressWarnings("resource") private InputStream loadFile(String trustStorePath) throws FileNotFoundException { InputStream input; try { input = new FileInputStream(trustStorePath); } catch (FileNotFoundException e) { LOGGER.warn("File {} not found. Fallback to classpath.", trustStorePath); input = Thread.currentThread().getContextClassLoader().getResourceAsStream(trustStorePath); } if (input == null) { throw new FileNotFoundException("File " + trustStorePath + " does not exist"); } return input; }
[ "@", "SuppressWarnings", "(", "\"resource\"", ")", "private", "InputStream", "loadFile", "(", "String", "trustStorePath", ")", "throws", "FileNotFoundException", "{", "InputStream", "input", ";", "try", "{", "input", "=", "new", "FileInputStream", "(", "trustStorePa...
This method is used to find file from disk or classpath. @param trustStorePath file to load @return instance of {@link InputStream} containing content of the file @throws FileNotFoundException if file does not exist
[ "This", "method", "is", "used", "to", "find", "file", "from", "disk", "or", "classpath", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/trust/JKSTrustStore.java#L194-L207
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/publication/PublicationData.java
PublicationData.getPublicationString
public String getPublicationString() { byte[] imprint = publicationHash.getImprint(); byte[] data = new byte[imprint.length + 8]; System.arraycopy(Util.toByteArray(publicationTime.getTime() / 1000), 0, data, 0, 8); System.arraycopy(imprint, 0, data, 8, imprint.length); return Base32.encodeWithDashes(Util.addCrc32(data)); }
java
public String getPublicationString() { byte[] imprint = publicationHash.getImprint(); byte[] data = new byte[imprint.length + 8]; System.arraycopy(Util.toByteArray(publicationTime.getTime() / 1000), 0, data, 0, 8); System.arraycopy(imprint, 0, data, 8, imprint.length); return Base32.encodeWithDashes(Util.addCrc32(data)); }
[ "public", "String", "getPublicationString", "(", ")", "{", "byte", "[", "]", "imprint", "=", "publicationHash", ".", "getImprint", "(", ")", ";", "byte", "[", "]", "data", "=", "new", "byte", "[", "imprint", ".", "length", "+", "8", "]", ";", "System",...
Returns a publication string that is a base-32 encoded value that is meant published to print media as human readable text @return returns a base-32 encoded publication string
[ "Returns", "a", "publication", "string", "that", "is", "a", "base", "-", "32", "encoded", "value", "that", "is", "meant", "published", "to", "print", "media", "as", "human", "readable", "text" ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/publication/PublicationData.java#L160-L167
train
guardtime/ksi-java-sdk
ksi-service-client/src/main/java/com/guardtime/ksi/pdu/v1/AbstractKSIRequest.java
AbstractKSIRequest.calculateMac
protected DataHash calculateMac() throws KSIException { try { HashAlgorithm algorithm = HashAlgorithm.getByName("DEFAULT"); algorithm.checkExpiration(); return new DataHash(algorithm, Util.calculateHMAC(getContent(), this.loginKey, algorithm.getName())); } catch (IOException e) { throw new KSIProtocolException("Problem with HMAC", e); } catch (InvalidKeyException e) { throw new KSIProtocolException("Problem with HMAC key.", e); } catch (NoSuchAlgorithmException e) { // If the default algorithm changes to be outside of MD5 / SHA1 / // SHA256 list. throw new KSIProtocolException("Unsupported HMAC algorithm.", e); } catch (HashException e) { throw new KSIProtocolException(e.getMessage(), e); } }
java
protected DataHash calculateMac() throws KSIException { try { HashAlgorithm algorithm = HashAlgorithm.getByName("DEFAULT"); algorithm.checkExpiration(); return new DataHash(algorithm, Util.calculateHMAC(getContent(), this.loginKey, algorithm.getName())); } catch (IOException e) { throw new KSIProtocolException("Problem with HMAC", e); } catch (InvalidKeyException e) { throw new KSIProtocolException("Problem with HMAC key.", e); } catch (NoSuchAlgorithmException e) { // If the default algorithm changes to be outside of MD5 / SHA1 / // SHA256 list. throw new KSIProtocolException("Unsupported HMAC algorithm.", e); } catch (HashException e) { throw new KSIProtocolException(e.getMessage(), e); } }
[ "protected", "DataHash", "calculateMac", "(", ")", "throws", "KSIException", "{", "try", "{", "HashAlgorithm", "algorithm", "=", "HashAlgorithm", ".", "getByName", "(", "\"DEFAULT\"", ")", ";", "algorithm", ".", "checkExpiration", "(", ")", ";", "return", "new",...
Calculates the MAC based on header and payload TLVs. @return Calculated data hash. @throws KSIException if HMAC generation fails.
[ "Calculates", "the", "MAC", "based", "on", "header", "and", "payload", "TLVs", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-service-client/src/main/java/com/guardtime/ksi/pdu/v1/AbstractKSIRequest.java#L132-L148
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/unisignature/verifier/VerificationContextBuilder.java
VerificationContextBuilder.setDocumentHash
public VerificationContextBuilder setDocumentHash(DataHash documentHash, Long level) { this.documentHash = documentHash; this.inputHashLevel = level; return this; }
java
public VerificationContextBuilder setDocumentHash(DataHash documentHash, Long level) { this.documentHash = documentHash; this.inputHashLevel = level; return this; }
[ "public", "VerificationContextBuilder", "setDocumentHash", "(", "DataHash", "documentHash", ",", "Long", "level", ")", "{", "this", ".", "documentHash", "=", "documentHash", ";", "this", ".", "inputHashLevel", "=", "level", ";", "return", "this", ";", "}" ]
Used to set the hash and local aggregation tree height. If present then this hash must equal to signature input hash. @param documentHash document hash @return instance of {@link VerificationContextBuilder}
[ "Used", "to", "set", "the", "hash", "and", "local", "aggregation", "tree", "height", ".", "If", "present", "then", "this", "hash", "must", "equal", "to", "signature", "input", "hash", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/unisignature/verifier/VerificationContextBuilder.java#L121-L125
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/unisignature/verifier/VerificationContextBuilder.java
VerificationContextBuilder.createVerificationContext
@Deprecated public final VerificationContext createVerificationContext() throws KSIException { if (signature == null) { throw new KSIException("Failed to createSignature verification context. Signature must be present."); } if (extendingService == null) { throw new KSIException("Failed to createSignature verification context. KSI extending service must be present."); } if (publicationsFile == null) { throw new KSIException("Failed to createSignature verification context. PublicationsFile must be present."); } return new KSIVerificationContext(publicationsFile, signature, userPublication, extendingAllowed, extendingService, documentHash, inputHashLevel); }
java
@Deprecated public final VerificationContext createVerificationContext() throws KSIException { if (signature == null) { throw new KSIException("Failed to createSignature verification context. Signature must be present."); } if (extendingService == null) { throw new KSIException("Failed to createSignature verification context. KSI extending service must be present."); } if (publicationsFile == null) { throw new KSIException("Failed to createSignature verification context. PublicationsFile must be present."); } return new KSIVerificationContext(publicationsFile, signature, userPublication, extendingAllowed, extendingService, documentHash, inputHashLevel); }
[ "@", "Deprecated", "public", "final", "VerificationContext", "createVerificationContext", "(", ")", "throws", "KSIException", "{", "if", "(", "signature", "==", "null", ")", "{", "throw", "new", "KSIException", "(", "\"Failed to createSignature verification context. Signa...
Builds the verification context. @return instance of verification context @throws KSIException when error occurs (e.g mandatory parameters aren't present)
[ "Builds", "the", "verification", "context", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/unisignature/verifier/VerificationContextBuilder.java#L149-L161
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/unisignature/inmemory/InMemoryAggregationChainLink.java
InMemoryAggregationChainLink.getIdentityFromLegacyId
private String getIdentityFromLegacyId() throws CharacterCodingException { byte[] data = legacyId; int len = Util.toShort(data, 1); return Util.decodeString(data, 3, len); }
java
private String getIdentityFromLegacyId() throws CharacterCodingException { byte[] data = legacyId; int len = Util.toShort(data, 1); return Util.decodeString(data, 3, len); }
[ "private", "String", "getIdentityFromLegacyId", "(", ")", "throws", "CharacterCodingException", "{", "byte", "[", "]", "data", "=", "legacyId", ";", "int", "len", "=", "Util", ".", "toShort", "(", "data", ",", "1", ")", ";", "return", "Util", ".", "decodeS...
Decodes link identity from legacy id. @return decoded link identity decoded from legacy id.
[ "Decodes", "link", "identity", "from", "legacy", "id", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/unisignature/inmemory/InMemoryAggregationChainLink.java#L188-L192
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/unisignature/inmemory/InMemoryAggregationChainLink.java
InMemoryAggregationChainLink.hash
protected final DataHash hash(byte[] hash1, byte[] hash2, long level, HashAlgorithm algorithm) throws InvalidAggregationHashChainException { if (!algorithm.isImplemented()) { throw new InvalidAggregationHashChainException("Invalid aggregation hash chain. Hash algorithm " + algorithm.getName() + " is not implemented"); } DataHasher hasher = new DataHasher(algorithm, false); hasher.addData(hash1); hasher.addData(hash2); hasher.addData(Util.encodeUnsignedLong(level)); return hasher.getHash(); }
java
protected final DataHash hash(byte[] hash1, byte[] hash2, long level, HashAlgorithm algorithm) throws InvalidAggregationHashChainException { if (!algorithm.isImplemented()) { throw new InvalidAggregationHashChainException("Invalid aggregation hash chain. Hash algorithm " + algorithm.getName() + " is not implemented"); } DataHasher hasher = new DataHasher(algorithm, false); hasher.addData(hash1); hasher.addData(hash2); hasher.addData(Util.encodeUnsignedLong(level)); return hasher.getHash(); }
[ "protected", "final", "DataHash", "hash", "(", "byte", "[", "]", "hash1", ",", "byte", "[", "]", "hash2", ",", "long", "level", ",", "HashAlgorithm", "algorithm", ")", "throws", "InvalidAggregationHashChainException", "{", "if", "(", "!", "algorithm", ".", "...
Hash two hashes together. @param hash1 first hash @param hash2 second hash @param level level @param algorithm hash algorithm to use @return instance of {@link DataHash}
[ "Hash", "two", "hashes", "together", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/unisignature/inmemory/InMemoryAggregationChainLink.java#L214-L223
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVInputStream.java
TLVInputStream.readElement
public TLVElement readElement() throws IOException, TLVParserException { TlvHeader header = readHeader(); TLVElement element = new TLVElement(header.tlv16, header.nonCritical, header.forwarded, header.type); int count = countNestedTlvElements(header); if (count > 0) { readNestedElements(element, count); } else { element.setContent(readTlvContent(header)); } return element; }
java
public TLVElement readElement() throws IOException, TLVParserException { TlvHeader header = readHeader(); TLVElement element = new TLVElement(header.tlv16, header.nonCritical, header.forwarded, header.type); int count = countNestedTlvElements(header); if (count > 0) { readNestedElements(element, count); } else { element.setContent(readTlvContent(header)); } return element; }
[ "public", "TLVElement", "readElement", "(", ")", "throws", "IOException", ",", "TLVParserException", "{", "TlvHeader", "header", "=", "readHeader", "(", ")", ";", "TLVElement", "element", "=", "new", "TLVElement", "(", "header", ".", "tlv16", ",", "header", "....
Reads the next TLV element from the stream. @return Instance of {@link TLVElement}. @throws IOException when reading from underlying stream fails. @throws TLVParserException when input stream is null.
[ "Reads", "the", "next", "TLV", "element", "from", "the", "stream", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVInputStream.java#L81-L91
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVInputStream.java
TLVInputStream.readTlvContent
private byte[] readTlvContent(TlvHeader header) throws IOException { byte[] data = new byte[header.getDataLength()]; in.readFully(data); return data; }
java
private byte[] readTlvContent(TlvHeader header) throws IOException { byte[] data = new byte[header.getDataLength()]; in.readFully(data); return data; }
[ "private", "byte", "[", "]", "readTlvContent", "(", "TlvHeader", "header", ")", "throws", "IOException", "{", "byte", "[", "]", "data", "=", "new", "byte", "[", "header", ".", "getDataLength", "(", ")", "]", ";", "in", ".", "readFully", "(", "data", ")...
Reads the TLV content bytes from the underlying stream. @param header instance of {@link TlvHeader}, not null. @return TLV content bytes. @throws IOException if an I/O error occurs.
[ "Reads", "the", "TLV", "content", "bytes", "from", "the", "underlying", "stream", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVInputStream.java#L217-L221
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/unisignature/verifier/policies/ContextAwarePolicyAdapter.java
ContextAwarePolicyAdapter.createPolicy
public static ContextAwarePolicy createPolicy(Policy policy, PublicationsHandler handler, KSIExtendingService extendingService) { if(policy instanceof UserProvidedPublicationBasedVerificationPolicy){ throw new IllegalArgumentException("Unsupported verification policy."); } Util.notNull(handler, "Publications handler"); Util.notNull(extendingService, "Extending service"); return new ContextAwarePolicyAdapter(policy, new PolicyContext(handler, extendingService)); }
java
public static ContextAwarePolicy createPolicy(Policy policy, PublicationsHandler handler, KSIExtendingService extendingService) { if(policy instanceof UserProvidedPublicationBasedVerificationPolicy){ throw new IllegalArgumentException("Unsupported verification policy."); } Util.notNull(handler, "Publications handler"); Util.notNull(extendingService, "Extending service"); return new ContextAwarePolicyAdapter(policy, new PolicyContext(handler, extendingService)); }
[ "public", "static", "ContextAwarePolicy", "createPolicy", "(", "Policy", "policy", ",", "PublicationsHandler", "handler", ",", "KSIExtendingService", "extendingService", ")", "{", "if", "(", "policy", "instanceof", "UserProvidedPublicationBasedVerificationPolicy", ")", "{",...
Method creating context aware policy using user provided policy with needed components. @param policy Policy. @param handler Publications handler. @param extendingService Extender client. @return Policy with suitable context.
[ "Method", "creating", "context", "aware", "policy", "using", "user", "provided", "policy", "with", "needed", "components", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/unisignature/verifier/policies/ContextAwarePolicyAdapter.java#L161-L168
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/unisignature/verifier/policies/ContextAwarePolicyAdapter.java
ContextAwarePolicyAdapter.setFallbackPolicy
public void setFallbackPolicy(Policy fallbackPolicy) { Policy p = fallbackPolicy; while (p != null) { if (!(p instanceof ContextAwarePolicy)) { throw new IllegalArgumentException("Fallback policy must be instance of ContextAwarePolicy"); } p = p.getFallbackPolicy(); } this.policy.setFallbackPolicy(fallbackPolicy); }
java
public void setFallbackPolicy(Policy fallbackPolicy) { Policy p = fallbackPolicy; while (p != null) { if (!(p instanceof ContextAwarePolicy)) { throw new IllegalArgumentException("Fallback policy must be instance of ContextAwarePolicy"); } p = p.getFallbackPolicy(); } this.policy.setFallbackPolicy(fallbackPolicy); }
[ "public", "void", "setFallbackPolicy", "(", "Policy", "fallbackPolicy", ")", "{", "Policy", "p", "=", "fallbackPolicy", ";", "while", "(", "p", "!=", "null", ")", "{", "if", "(", "!", "(", "p", "instanceof", "ContextAwarePolicy", ")", ")", "{", "throw", ...
Sets a fallback policy to be used when signature does not verify with given policy. @param fallbackPolicy the fallback policy used when signature does not verify with given policy. All fallback policies in he chain must be instances of {@link ContextAwarePolicy}.
[ "Sets", "a", "fallback", "policy", "to", "be", "used", "when", "signature", "does", "not", "verify", "with", "given", "policy", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/unisignature/verifier/policies/ContextAwarePolicyAdapter.java#L195-L204
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/Util.java
Util.decodeString
public static String decodeString(byte[] buf, int ofs, int len) throws CharacterCodingException { if (ofs < 0 || len < 0 || ofs + len < 0 || ofs + len > buf.length) { throw new IndexOutOfBoundsException(); } CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder().onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); return decoder.decode(ByteBuffer.wrap(buf, ofs, len)).toString(); }
java
public static String decodeString(byte[] buf, int ofs, int len) throws CharacterCodingException { if (ofs < 0 || len < 0 || ofs + len < 0 || ofs + len > buf.length) { throw new IndexOutOfBoundsException(); } CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder().onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); return decoder.decode(ByteBuffer.wrap(buf, ofs, len)).toString(); }
[ "public", "static", "String", "decodeString", "(", "byte", "[", "]", "buf", ",", "int", "ofs", ",", "int", "len", ")", "throws", "CharacterCodingException", "{", "if", "(", "ofs", "<", "0", "||", "len", "<", "0", "||", "ofs", "+", "len", "<", "0", ...
Decodes UTF-8 string from the given buffer. @param buf the buffer. @param ofs offset of the UTF-8 data in the buffer. @param len length of the UTF-8 data to decode. @return The decoded string. @throws CharacterCodingException when the specified data is not in valid UTF-8 format.
[ "Decodes", "UTF", "-", "8", "string", "from", "the", "given", "buffer", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/Util.java#L146-L154
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/Util.java
Util.toByteArray
public static byte[] toByteArray(String value) { if (value == null) { return null; } try { CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder().onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); ByteBuffer buf = encoder.encode(CharBuffer.wrap(value)); // don't use ByteBuffer.array(), as it returns internal, and // possibly larger, byte array byte[] res = new byte[buf.remaining()]; buf.get(res); return res; } catch (CharacterCodingException e) { throw new RuntimeException("Unexpected exception", e); } }
java
public static byte[] toByteArray(String value) { if (value == null) { return null; } try { CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder().onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); ByteBuffer buf = encoder.encode(CharBuffer.wrap(value)); // don't use ByteBuffer.array(), as it returns internal, and // possibly larger, byte array byte[] res = new byte[buf.remaining()]; buf.get(res); return res; } catch (CharacterCodingException e) { throw new RuntimeException("Unexpected exception", e); } }
[ "public", "static", "byte", "[", "]", "toByteArray", "(", "String", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "try", "{", "CharsetEncoder", "encoder", "=", "Charset", ".", "forName", "(", "\"UTF-8\"", ")...
Encodes the given string in UTF-8. @param value the string to encode. @return A newly allocated array containing the encoding result.
[ "Encodes", "the", "given", "string", "in", "UTF", "-", "8", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/Util.java#L164-L180
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/Util.java
Util.copyOf
public static byte[] copyOf(byte[] b, int off, int len) throws NullPointerException, ArrayIndexOutOfBoundsException { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } byte[] copy = new byte[len]; System.arraycopy(b, off, copy, 0, len); return copy; }
java
public static byte[] copyOf(byte[] b, int off, int len) throws NullPointerException, ArrayIndexOutOfBoundsException { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } byte[] copy = new byte[len]; System.arraycopy(b, off, copy, 0, len); return copy; }
[ "public", "static", "byte", "[", "]", "copyOf", "(", "byte", "[", "]", "b", ",", "int", "off", ",", "int", "len", ")", "throws", "NullPointerException", ",", "ArrayIndexOutOfBoundsException", "{", "if", "(", "b", "==", "null", ")", "{", "throw", "new", ...
Creates a copy of a section of the given byte array. @param b the array to copy. @param off the start offset of the data within {@code b}. @param len the number of bytes to copy. @return The copy of the requested section of {@code b}. @throws NullPointerException if {@code b} is null. @throws ArrayIndexOutOfBoundsException if the half-range {@code [off..off+len)} is not in {@code [0..b.length)}.
[ "Creates", "a", "copy", "of", "a", "section", "of", "the", "given", "byte", "array", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/Util.java#L248-L259
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/Util.java
Util.join
public static byte[] join(byte[] a, byte[] b) { byte[] result = new byte[a.length + b.length]; System.arraycopy(a, 0, result, 0, a.length); System.arraycopy(b, 0, result, a.length, b.length); return result; }
java
public static byte[] join(byte[] a, byte[] b) { byte[] result = new byte[a.length + b.length]; System.arraycopy(a, 0, result, 0, a.length); System.arraycopy(b, 0, result, a.length, b.length); return result; }
[ "public", "static", "byte", "[", "]", "join", "(", "byte", "[", "]", "a", ",", "byte", "[", "]", "b", ")", "{", "byte", "[", "]", "result", "=", "new", "byte", "[", "a", ".", "length", "+", "b", ".", "length", "]", ";", "System", ".", "arrayc...
Joins two byte arrays into one. @param a first byte array to join, not null. @param b second byte array to join, not null. @return Joined byte array.
[ "Joins", "two", "byte", "arrays", "into", "one", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/Util.java#L271-L276
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/Util.java
Util.decodeUnsignedLong
public static long decodeUnsignedLong(byte[] buf, int ofs, int len) throws IllegalArgumentException { if (ofs < 0 || len < 0 || ofs + len < 0 || ofs + len > buf.length) { throw new IndexOutOfBoundsException(); } if (len > 8 || len == 8 && buf[ofs] < 0) { throw new IllegalArgumentException("Integers of at most 63 unsigned bits supported by this implementation"); } long t = 0; for (int i = 0; i < len; ++i) { t = (t << 8) | ((long) buf[ofs + i] & 0xff); } return t; }
java
public static long decodeUnsignedLong(byte[] buf, int ofs, int len) throws IllegalArgumentException { if (ofs < 0 || len < 0 || ofs + len < 0 || ofs + len > buf.length) { throw new IndexOutOfBoundsException(); } if (len > 8 || len == 8 && buf[ofs] < 0) { throw new IllegalArgumentException("Integers of at most 63 unsigned bits supported by this implementation"); } long t = 0; for (int i = 0; i < len; ++i) { t = (t << 8) | ((long) buf[ofs + i] & 0xff); } return t; }
[ "public", "static", "long", "decodeUnsignedLong", "(", "byte", "[", "]", "buf", ",", "int", "ofs", ",", "int", "len", ")", "throws", "IllegalArgumentException", "{", "if", "(", "ofs", "<", "0", "||", "len", "<", "0", "||", "ofs", "+", "len", "<", "0"...
Decodes an unsigned integer from the given buffer. @param buf the buffer. @param ofs offset of the data in the buffer. @param len length of the data to decode. @return The decoded value. @throws IllegalArgumentException when result does not fit into 63-bit unsigned integer.
[ "Decodes", "an", "unsigned", "integer", "from", "the", "given", "buffer", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/Util.java#L489-L501
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/Util.java
Util.calculateHMAC
public static byte[] calculateHMAC(byte[] message, byte[] keyBytes, String algorithm) throws NoSuchAlgorithmException, InvalidKeyException { if (keyBytes == null) { throw new IllegalArgumentException("Invalid HMAC key: null"); } String hmacAlgorithmName = "Hmac" + algorithm.toUpperCase().replaceAll("[^\\p{Alnum}]", ""); SecretKeySpec key = new SecretKeySpec(keyBytes, hmacAlgorithmName); Mac mac = Mac.getInstance(hmacAlgorithmName); mac.init(key); return mac.doFinal(message); }
java
public static byte[] calculateHMAC(byte[] message, byte[] keyBytes, String algorithm) throws NoSuchAlgorithmException, InvalidKeyException { if (keyBytes == null) { throw new IllegalArgumentException("Invalid HMAC key: null"); } String hmacAlgorithmName = "Hmac" + algorithm.toUpperCase().replaceAll("[^\\p{Alnum}]", ""); SecretKeySpec key = new SecretKeySpec(keyBytes, hmacAlgorithmName); Mac mac = Mac.getInstance(hmacAlgorithmName); mac.init(key); return mac.doFinal(message); }
[ "public", "static", "byte", "[", "]", "calculateHMAC", "(", "byte", "[", "]", "message", ",", "byte", "[", "]", "keyBytes", ",", "String", "algorithm", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeyException", "{", "if", "(", "keyBytes", "==", "...
Calculates the RFC 2104 compatible HMAC for the given message, key, and algorithm. @param message message for which the MAC is to be calculated. @param keyBytes key for calculation. @param algorithm algorithm to be used (MD5, SHA1, SHA256). @return HMAC as byte array. @throws NoSuchAlgorithmException if invalid algorithm is provided. @throws InvalidKeyException if invalid key is provided. @throws IllegalArgumentException if HMAC key is null.
[ "Calculates", "the", "RFC", "2104", "compatible", "HMAC", "for", "the", "given", "message", "key", "and", "algorithm", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/Util.java#L545-L555
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/Util.java
Util.equalsIgnoreOrder
public static boolean equalsIgnoreOrder(Collection<?> c1, Collection<?> c2) { return (c1 == null && c2 == null) || (c1 != null && c2 != null && c1.size() == c2.size() && c1.containsAll(c2) && c2.containsAll(c1)); }
java
public static boolean equalsIgnoreOrder(Collection<?> c1, Collection<?> c2) { return (c1 == null && c2 == null) || (c1 != null && c2 != null && c1.size() == c2.size() && c1.containsAll(c2) && c2.containsAll(c1)); }
[ "public", "static", "boolean", "equalsIgnoreOrder", "(", "Collection", "<", "?", ">", "c1", ",", "Collection", "<", "?", ">", "c2", ")", "{", "return", "(", "c1", "==", "null", "&&", "c2", "==", "null", ")", "||", "(", "c1", "!=", "null", "&&", "c2...
Checks if two collections are equal ignoring the order of components. It's safe to pass collections that might be null. @param c1 first collection. @param c2 second collection. @return True, if both lists are null or if they have exactly the same components.
[ "Checks", "if", "two", "collections", "are", "equal", "ignoring", "the", "order", "of", "components", ".", "It", "s", "safe", "to", "pass", "collections", "that", "might", "be", "null", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/Util.java#L728-L730
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVStructure.java
TLVStructure.verifyCriticalFlag
protected void verifyCriticalFlag(TLVElement element) throws TLVParserException { if (!element.isNonCritical()) { throw new TLVParserException("Unknown critical TLV element with tag=0x" + Integer.toHexString(element.getType()) + " encountered"); } }
java
protected void verifyCriticalFlag(TLVElement element) throws TLVParserException { if (!element.isNonCritical()) { throw new TLVParserException("Unknown critical TLV element with tag=0x" + Integer.toHexString(element.getType()) + " encountered"); } }
[ "protected", "void", "verifyCriticalFlag", "(", "TLVElement", "element", ")", "throws", "TLVParserException", "{", "if", "(", "!", "element", ".", "isNonCritical", "(", ")", ")", "{", "throw", "new", "TLVParserException", "(", "\"Unknown critical TLV element with tag=...
Checks if the TLV element is critical or not. @param element TLV element to check. @throws TLVParserException when unknown critical TLV element is encountered.
[ "Checks", "if", "the", "TLV", "element", "is", "critical", "or", "not", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVStructure.java#L70-L74
train
guardtime/ksi-java-sdk
ksi-service-ha/src/main/java/com/guardtime/ksi/service/ha/SigningHAService.java
SigningHAService.sign
public Future<AggregationResponse> sign(DataHash dataHash, Long level) throws KSIException { Util.notNull(dataHash, "dataHash"); Util.notNull(level, "level"); final Collection<Callable<AggregationResponse>> tasks = new ArrayList<>(subservices.size()); for (KSISigningService subservice : subservices) { tasks.add(new SigningTask(subservice, dataHash, level)); } return new ServiceCallFuture<>( executorService.submit(new ServiceCallsTask<>(executorService, tasks)) ); }
java
public Future<AggregationResponse> sign(DataHash dataHash, Long level) throws KSIException { Util.notNull(dataHash, "dataHash"); Util.notNull(level, "level"); final Collection<Callable<AggregationResponse>> tasks = new ArrayList<>(subservices.size()); for (KSISigningService subservice : subservices) { tasks.add(new SigningTask(subservice, dataHash, level)); } return new ServiceCallFuture<>( executorService.submit(new ServiceCallsTask<>(executorService, tasks)) ); }
[ "public", "Future", "<", "AggregationResponse", ">", "sign", "(", "DataHash", "dataHash", ",", "Long", "level", ")", "throws", "KSIException", "{", "Util", ".", "notNull", "(", "dataHash", ",", "\"dataHash\"", ")", ";", "Util", ".", "notNull", "(", "level", ...
Creates a non-blocking signing request. Sends the request to all the subservices in parallel. First successful response is used, others are cancelled. Request fails only if all the subservices fail. @see KSISigningService#sign(DataHash, Long)
[ "Creates", "a", "non", "-", "blocking", "signing", "request", ".", "Sends", "the", "request", "to", "all", "the", "subservices", "in", "parallel", ".", "First", "successful", "response", "is", "used", "others", "are", "cancelled", ".", "Request", "fails", "o...
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-service-ha/src/main/java/com/guardtime/ksi/service/ha/SigningHAService.java#L71-L81
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/hashing/DataHasher.java
DataHasher.addData
public final DataHasher addData(byte[] data) { Util.notNull(data, "Date"); return addData(data, 0, data.length); }
java
public final DataHasher addData(byte[] data) { Util.notNull(data, "Date"); return addData(data, 0, data.length); }
[ "public", "final", "DataHasher", "addData", "(", "byte", "[", "]", "data", ")", "{", "Util", ".", "notNull", "(", "data", ",", "\"Date\"", ")", ";", "return", "addData", "(", "data", ",", "0", ",", "data", ".", "length", ")", ";", "}" ]
Adds data to the digest using the specified array of bytes, starting at an offset of 0. @param data the array of bytes. @return The same {@link DataHasher} object for chaining calls. @throws NullPointerException when input data is null.
[ "Adds", "data", "to", "the", "digest", "using", "the", "specified", "array", "of", "bytes", "starting", "at", "an", "offset", "of", "0", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/hashing/DataHasher.java#L161-L165
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/hashing/DataHasher.java
DataHasher.addData
public final DataHasher addData(InputStream inStream, int bufferSize) { Util.notNull(inStream, "Input stream"); try { byte[] buffer = new byte[bufferSize]; while (true) { int bytesRead = inStream.read(buffer); if (bytesRead == -1) { return this; } addData(buffer, 0, bytesRead); } } catch (IOException e) { throw new HashException("Exception occurred when reading input stream while calculating hash", e); } }
java
public final DataHasher addData(InputStream inStream, int bufferSize) { Util.notNull(inStream, "Input stream"); try { byte[] buffer = new byte[bufferSize]; while (true) { int bytesRead = inStream.read(buffer); if (bytesRead == -1) { return this; } addData(buffer, 0, bytesRead); } } catch (IOException e) { throw new HashException("Exception occurred when reading input stream while calculating hash", e); } }
[ "public", "final", "DataHasher", "addData", "(", "InputStream", "inStream", ",", "int", "bufferSize", ")", "{", "Util", ".", "notNull", "(", "inStream", ",", "\"Input stream\"", ")", ";", "try", "{", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "...
Adds data to the digest using the specified input stream of bytes, starting at an offset of 0. @param inStream input stream of bytes. @param bufferSize maximum allowed buffer size for reading data. @return The same {@link DataHasher} object for chaining calls. @throws HashException when hash calculation fails. @throws NullPointerException when input stream is null.
[ "Adds", "data", "to", "the", "digest", "using", "the", "specified", "input", "stream", "of", "bytes", "starting", "at", "an", "offset", "of", "0", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/hashing/DataHasher.java#L218-L233
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/hashing/DataHasher.java
DataHasher.addData
public final DataHasher addData(File file, int bufferSize) { Util.notNull(file, "File"); FileInputStream inStream = null; try { inStream = new FileInputStream(file); return addData(inStream, bufferSize); } catch (FileNotFoundException e) { throw new IllegalArgumentException("File not found, when calculating data hash", e); } finally { Util.closeQuietly(inStream); } }
java
public final DataHasher addData(File file, int bufferSize) { Util.notNull(file, "File"); FileInputStream inStream = null; try { inStream = new FileInputStream(file); return addData(inStream, bufferSize); } catch (FileNotFoundException e) { throw new IllegalArgumentException("File not found, when calculating data hash", e); } finally { Util.closeQuietly(inStream); } }
[ "public", "final", "DataHasher", "addData", "(", "File", "file", ",", "int", "bufferSize", ")", "{", "Util", ".", "notNull", "(", "file", ",", "\"File\"", ")", ";", "FileInputStream", "inStream", "=", "null", ";", "try", "{", "inStream", "=", "new", "Fil...
Adds data to the digest using the specified file, starting at the offset 0. @param file input file. @param bufferSize size of buffer for reading data. @return The same {@link DataHasher} object for chaining calls. @throws HashException when hash calculation fails. @throws NullPointerException when input file is null.
[ "Adds", "data", "to", "the", "digest", "using", "the", "specified", "file", "starting", "at", "the", "offset", "0", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/hashing/DataHasher.java#L246-L257
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/BaseX.java
BaseX.addChars
private void addChars(String chars) { for (int i = 0; i < chars.length(); i++) { int c = chars.codePointAt(i) - min; if (values[c] != -1 && values[c] != i) { throw new IllegalArgumentException("Duplicate characters in the encoding alphabet"); } values[c] = i; } }
java
private void addChars(String chars) { for (int i = 0; i < chars.length(); i++) { int c = chars.codePointAt(i) - min; if (values[c] != -1 && values[c] != i) { throw new IllegalArgumentException("Duplicate characters in the encoding alphabet"); } values[c] = i; } }
[ "private", "void", "addChars", "(", "String", "chars", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", "(", ")", ";", "i", "++", ")", "{", "int", "c", "=", "chars", ".", "codePointAt", "(", "i", ")", "-", "m...
Adds the values for the given characters to the value lookup table. @param chars the list of characters to process.
[ "Adds", "the", "values", "for", "the", "given", "characters", "to", "the", "value", "lookup", "table", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/BaseX.java#L149-L157
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/BaseX.java
BaseX.encode
public final StringBuffer encode(byte[] in, int off, int len, String sep, int freq) { // sanitize the parameters if (in == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off + len < 0 || off + len > in.length) { throw new ArrayIndexOutOfBoundsException(); } if (sep == null) { freq = 0; } else { for (int i = 0; i < sep.length(); i++) { int c = sep.codePointAt(i); if (c >= min && c <= max && values[c - min] != -1) { throw new IllegalArgumentException("The separator contains characters from the encoding alphabet"); } } } // create the output buffer int outLen = (8 * len + bits - 1) / bits; outLen = (outLen + block - 1) / block * block; if (freq > 0) { outLen += (outLen - 1) / freq * sep.length(); } StringBuffer out = new StringBuffer(outLen); // encode int outCount = 0; // number of output characters produced int inCount = 0; // number of input bytes consumed int buf = 0; // buffer of input bits not yet sent to output int bufBits = 0; // number of bits in the bit buffer int bufMask = (1 << bits) - 1; while (bits * outCount < 8 * len) { if (freq > 0 && outCount > 0 && outCount % freq == 0) { out.append(sep); } // fetch the next byte(s), padding with zero bits as needed while (bufBits < bits) { int next = (inCount < len ? in[off + inCount] : 0); inCount++; buf = (buf << 8) | (next & 0xff); // we want unsigned bytes bufBits += 8; } // output the top bits from the bit buffer out.append(chars[(buf >>> (bufBits - bits)) & bufMask]); bufBits -= bits; outCount++; } // pad while (outCount % block != 0) { if (freq > 0 && outCount > 0 && outCount % freq == 0) { out.append(sep); } out.append(pad); outCount++; } return out; }
java
public final StringBuffer encode(byte[] in, int off, int len, String sep, int freq) { // sanitize the parameters if (in == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off + len < 0 || off + len > in.length) { throw new ArrayIndexOutOfBoundsException(); } if (sep == null) { freq = 0; } else { for (int i = 0; i < sep.length(); i++) { int c = sep.codePointAt(i); if (c >= min && c <= max && values[c - min] != -1) { throw new IllegalArgumentException("The separator contains characters from the encoding alphabet"); } } } // create the output buffer int outLen = (8 * len + bits - 1) / bits; outLen = (outLen + block - 1) / block * block; if (freq > 0) { outLen += (outLen - 1) / freq * sep.length(); } StringBuffer out = new StringBuffer(outLen); // encode int outCount = 0; // number of output characters produced int inCount = 0; // number of input bytes consumed int buf = 0; // buffer of input bits not yet sent to output int bufBits = 0; // number of bits in the bit buffer int bufMask = (1 << bits) - 1; while (bits * outCount < 8 * len) { if (freq > 0 && outCount > 0 && outCount % freq == 0) { out.append(sep); } // fetch the next byte(s), padding with zero bits as needed while (bufBits < bits) { int next = (inCount < len ? in[off + inCount] : 0); inCount++; buf = (buf << 8) | (next & 0xff); // we want unsigned bytes bufBits += 8; } // output the top bits from the bit buffer out.append(chars[(buf >>> (bufBits - bits)) & bufMask]); bufBits -= bits; outCount++; } // pad while (outCount % block != 0) { if (freq > 0 && outCount > 0 && outCount % freq == 0) { out.append(sep); } out.append(pad); outCount++; } return out; }
[ "public", "final", "StringBuffer", "encode", "(", "byte", "[", "]", "in", ",", "int", "off", ",", "int", "len", ",", "String", "sep", ",", "int", "freq", ")", "{", "// sanitize the parameters", "if", "(", "in", "==", "null", ")", "{", "throw", "new", ...
Encodes the given bytes into a base-X string, optionally inserting a separator into the result with given frequency. @param in an array containing the bytes to encode. @param off the start offset of the data within {@code in}. @param len the number of bytes to encode. @param sep if {@code sep} is not {@code null} and {@code freq} is positive, the {@code sep} is inserted into the result between blocks of {@code freq} normal characters. @param freq if {@code sep} is not {@code null} and {@code freq} is positive, the {@code sep} is inserted into the result between blocks of {@code freq} normal characters. @return A newly allocated buffer containing the encoded data.
[ "Encodes", "the", "given", "bytes", "into", "a", "base", "-", "X", "string", "optionally", "inserting", "a", "separator", "into", "the", "result", "with", "given", "frequency", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/BaseX.java#L180-L241
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/util/BaseX.java
BaseX.decode
public final byte[] decode(String in) { // sanitize the parameters if (in == null) { throw new NullPointerException(); } // create the result buffer byte[] out = new byte[in.length() * bits / 8]; // decode int outCount = 0; // number of output bytes produced int inCount = 0; // number of input characters consumed int buf = 0; // buffer of input bits not yet sent to output int bufBits = 0; // number of bits in the bit buffer while (inCount < in.length()) { int next = in.codePointAt(inCount); inCount++; if (next < min || next > max) { continue; } next = values[next - min]; if (next == -1) { continue; } buf = (buf << bits) | next; bufBits += bits; while (bufBits >= 8) { out[outCount] = (byte) ((buf >>> (bufBits - 8)) & 0xff); bufBits -= 8; outCount++; } } // trim the result if there were any skipped characters if (outCount < out.length) { byte[] tmp = out; out = new byte[outCount]; System.arraycopy(tmp, 0, out, 0, outCount); } return out; }
java
public final byte[] decode(String in) { // sanitize the parameters if (in == null) { throw new NullPointerException(); } // create the result buffer byte[] out = new byte[in.length() * bits / 8]; // decode int outCount = 0; // number of output bytes produced int inCount = 0; // number of input characters consumed int buf = 0; // buffer of input bits not yet sent to output int bufBits = 0; // number of bits in the bit buffer while (inCount < in.length()) { int next = in.codePointAt(inCount); inCount++; if (next < min || next > max) { continue; } next = values[next - min]; if (next == -1) { continue; } buf = (buf << bits) | next; bufBits += bits; while (bufBits >= 8) { out[outCount] = (byte) ((buf >>> (bufBits - 8)) & 0xff); bufBits -= 8; outCount++; } } // trim the result if there were any skipped characters if (outCount < out.length) { byte[] tmp = out; out = new byte[outCount]; System.arraycopy(tmp, 0, out, 0, outCount); } return out; }
[ "public", "final", "byte", "[", "]", "decode", "(", "String", "in", ")", "{", "// sanitize the parameters", "if", "(", "in", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "// create the result buffer", "byte", "[", "]", ...
Decodes the given base-X string into bytes, silently ignoring any non-base-X characters. @param in the string to decode. @return The decoded bytes.
[ "Decodes", "the", "given", "base", "-", "X", "string", "into", "bytes", "silently", "ignoring", "any", "non", "-", "base", "-", "X", "characters", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/util/BaseX.java#L252-L293
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java
InMemoryPublicationsFile.decodePublicationsFile
private void decodePublicationsFile(TLVInputStream input) throws KSIException, IOException { while (input.hasNextElement()) { TLVElement element = input.readElement(); switch (element.getType()) { case PublicationsFileHeader.ELEMENT_TYPE: if (header != null) { throw new InvalidPublicationsFileException("Publications file contains multiple header components"); } this.header = new PublicationsFileHeader(element); break; case InMemoryCertificateRecord.ELEMENT_TYPE: certificateRecords.add(new InMemoryCertificateRecord(element)); break; case PublicationsFilePublicationRecord.ELEMENT_TYPE: publicationRecords.add(new PublicationsFilePublicationRecord(element)); break; case ELEMENT_TYPE_CMS_SIGNATURE: cmsSignature = element.getContent(); break; default: throw new InvalidPublicationsFileException("Invalid publications file element type=0x" + Integer.toHexString(element.getType())); } verifyElementOrder(element); elements.add(element); } }
java
private void decodePublicationsFile(TLVInputStream input) throws KSIException, IOException { while (input.hasNextElement()) { TLVElement element = input.readElement(); switch (element.getType()) { case PublicationsFileHeader.ELEMENT_TYPE: if (header != null) { throw new InvalidPublicationsFileException("Publications file contains multiple header components"); } this.header = new PublicationsFileHeader(element); break; case InMemoryCertificateRecord.ELEMENT_TYPE: certificateRecords.add(new InMemoryCertificateRecord(element)); break; case PublicationsFilePublicationRecord.ELEMENT_TYPE: publicationRecords.add(new PublicationsFilePublicationRecord(element)); break; case ELEMENT_TYPE_CMS_SIGNATURE: cmsSignature = element.getContent(); break; default: throw new InvalidPublicationsFileException("Invalid publications file element type=0x" + Integer.toHexString(element.getType())); } verifyElementOrder(element); elements.add(element); } }
[ "private", "void", "decodePublicationsFile", "(", "TLVInputStream", "input", ")", "throws", "KSIException", ",", "IOException", "{", "while", "(", "input", ".", "hasNextElement", "(", ")", ")", "{", "TLVElement", "element", "=", "input", ".", "readElement", "(",...
Decodes publications file. Reads publications data from given input stream. @param input input stream to createSignature. not null. @throws InvalidPublicationsFileException @throws IOException
[ "Decodes", "publications", "file", ".", "Reads", "publications", "data", "from", "given", "input", "stream", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java#L112-L137
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java
InMemoryPublicationsFile.verifyMagicBytes
private void verifyMagicBytes(TLVInputStream input) throws InvalidPublicationsFileException { try { byte[] magicBytes = new byte[PUBLICATIONS_FILE_MAGIC_BYTES_LENGTH]; input.read(magicBytes); if (!Arrays.equals(magicBytes, FILE_BEGINNING_MAGIC_BYTES)) { throw new InvalidPublicationsFileException("Invalid publications file magic bytes"); } } catch (IOException e) { throw new InvalidPublicationsFileException("Checking publications file magic bytes failed", e); } }
java
private void verifyMagicBytes(TLVInputStream input) throws InvalidPublicationsFileException { try { byte[] magicBytes = new byte[PUBLICATIONS_FILE_MAGIC_BYTES_LENGTH]; input.read(magicBytes); if (!Arrays.equals(magicBytes, FILE_BEGINNING_MAGIC_BYTES)) { throw new InvalidPublicationsFileException("Invalid publications file magic bytes"); } } catch (IOException e) { throw new InvalidPublicationsFileException("Checking publications file magic bytes failed", e); } }
[ "private", "void", "verifyMagicBytes", "(", "TLVInputStream", "input", ")", "throws", "InvalidPublicationsFileException", "{", "try", "{", "byte", "[", "]", "magicBytes", "=", "new", "byte", "[", "PUBLICATIONS_FILE_MAGIC_BYTES_LENGTH", "]", ";", "input", ".", "read"...
Verifies that input stream starts with publications file magic bytes. @param input instance of input stream to check. not null.
[ "Verifies", "that", "input", "stream", "starts", "with", "publications", "file", "magic", "bytes", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java#L155-L165
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java
InMemoryPublicationsFile.findCertificateById
public Certificate findCertificateById(byte[] certificateId) throws CertificateNotFoundException { if (certificateId == null) { throw new CertificateNotFoundException("Certificate with id null not found from pubFile='" + this.toString() + "'"); } for (InMemoryCertificateRecord record : certificateRecords) { if (Arrays.equals(certificateId, record.getCertificateId())) { return X509CertUtil.toCert(record.getCertificate()); } } throw new CertificateNotFoundException("Certificate with id " + Base64.encode(certificateId) + " not found from pubFile='" + this.toString() + "'"); }
java
public Certificate findCertificateById(byte[] certificateId) throws CertificateNotFoundException { if (certificateId == null) { throw new CertificateNotFoundException("Certificate with id null not found from pubFile='" + this.toString() + "'"); } for (InMemoryCertificateRecord record : certificateRecords) { if (Arrays.equals(certificateId, record.getCertificateId())) { return X509CertUtil.toCert(record.getCertificate()); } } throw new CertificateNotFoundException("Certificate with id " + Base64.encode(certificateId) + " not found from pubFile='" + this.toString() + "'"); }
[ "public", "Certificate", "findCertificateById", "(", "byte", "[", "]", "certificateId", ")", "throws", "CertificateNotFoundException", "{", "if", "(", "certificateId", "==", "null", ")", "{", "throw", "new", "CertificateNotFoundException", "(", "\"Certificate with id nu...
Finds a certificate by certificate id. @param certificateId certificate id bytes @return certificate or null, if certificate is not found @throws CertificateNotFoundException if certificate with given id isn't found
[ "Finds", "a", "certificate", "by", "certificate", "id", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java#L201-L211
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java
InMemoryPublicationsFile.getPublicationRecord
public PublicationRecord getPublicationRecord(Date time) { PublicationRecord nearest = null; for (PublicationRecord publicationRecord : publicationRecords) { Date publicationTime = publicationRecord.getPublicationData().getPublicationTime(); if (publicationTime.equals(time) || publicationTime.after(time)) { if (nearest == null) { nearest = publicationRecord; } else if (publicationTime.before(nearest.getPublicationData().getPublicationTime())) { nearest = publicationRecord; } } } return nearest; }
java
public PublicationRecord getPublicationRecord(Date time) { PublicationRecord nearest = null; for (PublicationRecord publicationRecord : publicationRecords) { Date publicationTime = publicationRecord.getPublicationData().getPublicationTime(); if (publicationTime.equals(time) || publicationTime.after(time)) { if (nearest == null) { nearest = publicationRecord; } else if (publicationTime.before(nearest.getPublicationData().getPublicationTime())) { nearest = publicationRecord; } } } return nearest; }
[ "public", "PublicationRecord", "getPublicationRecord", "(", "Date", "time", ")", "{", "PublicationRecord", "nearest", "=", "null", ";", "for", "(", "PublicationRecord", "publicationRecord", ":", "publicationRecords", ")", "{", "Date", "publicationTime", "=", "publicat...
Returns the closest publication record to given time.
[ "Returns", "the", "closest", "publication", "record", "to", "given", "time", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java#L245-L258
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java
InMemoryPublicationsFile.getSignedData
protected byte[] getSignedData() throws KSIException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); try { byteStream.write(FILE_BEGINNING_MAGIC_BYTES); for (TLVElement element : elements) { if (ELEMENT_TYPE_CMS_SIGNATURE != element.getType()) { element.writeTo(byteStream); } } } catch (IOException e) { return new byte[]{}; } return byteStream.toByteArray(); }
java
protected byte[] getSignedData() throws KSIException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); try { byteStream.write(FILE_BEGINNING_MAGIC_BYTES); for (TLVElement element : elements) { if (ELEMENT_TYPE_CMS_SIGNATURE != element.getType()) { element.writeTo(byteStream); } } } catch (IOException e) { return new byte[]{}; } return byteStream.toByteArray(); }
[ "protected", "byte", "[", "]", "getSignedData", "(", ")", "throws", "KSIException", "{", "ByteArrayOutputStream", "byteStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "try", "{", "byteStream", ".", "write", "(", "FILE_BEGINNING_MAGIC_BYTES", ")", ";",...
Get publications file bytes without signature. @return byte array of publication file bytes without signature
[ "Get", "publications", "file", "bytes", "without", "signature", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/publication/inmemory/InMemoryPublicationsFile.java#L265-L279
train
guardtime/ksi-java-sdk
ksi-api/src/main/java/com/guardtime/ksi/unisignature/AggregationHashChainUtil.java
AggregationHashChainUtil.calculateIndex
public static long calculateIndex(List<AggregationChainLink> links) { notNull(links, "Aggregation chain links"); long chainIndex = 0; for (int i = 0; i < links.size(); i++) { if (links.get(i).isLeft()) { chainIndex |= 1L << i; } } chainIndex |= 1L << links.size(); return chainIndex; }
java
public static long calculateIndex(List<AggregationChainLink> links) { notNull(links, "Aggregation chain links"); long chainIndex = 0; for (int i = 0; i < links.size(); i++) { if (links.get(i).isLeft()) { chainIndex |= 1L << i; } } chainIndex |= 1L << links.size(); return chainIndex; }
[ "public", "static", "long", "calculateIndex", "(", "List", "<", "AggregationChainLink", ">", "links", ")", "{", "notNull", "(", "links", ",", "\"Aggregation chain links\"", ")", ";", "long", "chainIndex", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";...
Calculates chain index @param links Chain links for which to calculate the index @return Index of the chain
[ "Calculates", "chain", "index" ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-api/src/main/java/com/guardtime/ksi/unisignature/AggregationHashChainUtil.java#L35-L45
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.create
public static TLVElement create(byte[] bytes) throws TLVParserException { Util.notNull(bytes, "Byte array"); TLVInputStream input = null; try { input = new TLVInputStream(new ByteArrayInputStream(bytes)); TLVElement element = input.readElement(); if (input.hasNextElement()) { throw new MultipleTLVElementException(); } return element; } catch (IOException e) { throw new TLVParserException("Reading TLV bytes failed", e); } finally { Util.closeQuietly(input); } }
java
public static TLVElement create(byte[] bytes) throws TLVParserException { Util.notNull(bytes, "Byte array"); TLVInputStream input = null; try { input = new TLVInputStream(new ByteArrayInputStream(bytes)); TLVElement element = input.readElement(); if (input.hasNextElement()) { throw new MultipleTLVElementException(); } return element; } catch (IOException e) { throw new TLVParserException("Reading TLV bytes failed", e); } finally { Util.closeQuietly(input); } }
[ "public", "static", "TLVElement", "create", "(", "byte", "[", "]", "bytes", ")", "throws", "TLVParserException", "{", "Util", ".", "notNull", "(", "bytes", ",", "\"Byte array\"", ")", ";", "TLVInputStream", "input", "=", "null", ";", "try", "{", "input", "...
Creates TLVElement form byte array. @param bytes byte array to create the TLV element from. @return {@link TLVElement} @throws TLVParserException
[ "Creates", "TLVElement", "form", "byte", "array", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L103-L118
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.create
public static TLVElement create(int type, byte[] value) throws TLVParserException { TLVElement element = create(type); element.setContent(value); return element; }
java
public static TLVElement create(int type, byte[] value) throws TLVParserException { TLVElement element = create(type); element.setContent(value); return element; }
[ "public", "static", "TLVElement", "create", "(", "int", "type", ",", "byte", "[", "]", "value", ")", "throws", "TLVParserException", "{", "TLVElement", "element", "=", "create", "(", "type", ")", ";", "element", ".", "setContent", "(", "value", ")", ";", ...
Creates TLV element with byte array content. TLV element nonCritical and forwarded flags are set to false. @param type TLV element type. @param value value to be the content of the TLV element. @return {@link TLVElement} @throws TLVParserException
[ "Creates", "TLV", "element", "with", "byte", "array", "content", ".", "TLV", "element", "nonCritical", "and", "forwarded", "flags", "are", "set", "to", "false", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L199-L203
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.getDecodedString
public final String getDecodedString() throws TLVParserException { byte[] data = getContent(); if (!(data.length > 0 && data[data.length - 1] == '\0')) { throw new TLVParserException("String must be null terminated"); } try { return Util.decodeString(data, 0, data.length - 1); } catch (CharacterCodingException e) { throw new TLVParserException("Malformed UTF-8 data", e); } }
java
public final String getDecodedString() throws TLVParserException { byte[] data = getContent(); if (!(data.length > 0 && data[data.length - 1] == '\0')) { throw new TLVParserException("String must be null terminated"); } try { return Util.decodeString(data, 0, data.length - 1); } catch (CharacterCodingException e) { throw new TLVParserException("Malformed UTF-8 data", e); } }
[ "public", "final", "String", "getDecodedString", "(", ")", "throws", "TLVParserException", "{", "byte", "[", "]", "data", "=", "getContent", "(", ")", ";", "if", "(", "!", "(", "data", ".", "length", ">", "0", "&&", "data", "[", "data", ".", "length", ...
Converts the TLV element content data to UTF-8 string. @return Decoded instance of string. @throws TLVParserException when content string isn't null terminated or is malformed UTF-8 data.
[ "Converts", "the", "TLV", "element", "content", "data", "to", "UTF", "-", "8", "string", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L257-L267
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.getDecodedHashAlgorithm
public HashAlgorithm getDecodedHashAlgorithm() throws TLVParserException { int algorithmId = getDecodedLong().intValue(); if (HashAlgorithm.isHashAlgorithmId(algorithmId)) { return HashAlgorithm.getById(algorithmId); } throw new TLVParserException("Unknown hash algorithm with id " + algorithmId); }
java
public HashAlgorithm getDecodedHashAlgorithm() throws TLVParserException { int algorithmId = getDecodedLong().intValue(); if (HashAlgorithm.isHashAlgorithmId(algorithmId)) { return HashAlgorithm.getById(algorithmId); } throw new TLVParserException("Unknown hash algorithm with id " + algorithmId); }
[ "public", "HashAlgorithm", "getDecodedHashAlgorithm", "(", ")", "throws", "TLVParserException", "{", "int", "algorithmId", "=", "getDecodedLong", "(", ")", ".", "intValue", "(", ")", ";", "if", "(", "HashAlgorithm", ".", "isHashAlgorithmId", "(", "algorithmId", ")...
Gets HashAlgorithm form TLV element. @return Instance of {@link HashAlgorithm}. @throws TLVParserException
[ "Gets", "HashAlgorithm", "form", "TLV", "element", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L304-L310
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.getContent
public byte[] getContent() throws TLVParserException { byte[] content = this.content; if (!children.isEmpty()) { for (TLVElement child : children) { content = Util.join(content, child.encodeHeader()); content = Util.join(content, child.getContent()); } } return content; }
java
public byte[] getContent() throws TLVParserException { byte[] content = this.content; if (!children.isEmpty()) { for (TLVElement child : children) { content = Util.join(content, child.encodeHeader()); content = Util.join(content, child.getContent()); } } return content; }
[ "public", "byte", "[", "]", "getContent", "(", ")", "throws", "TLVParserException", "{", "byte", "[", "]", "content", "=", "this", ".", "content", ";", "if", "(", "!", "children", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "TLVElement", "child", ...
Returns the TLV content. If TLV does not include content then empty array is returned. @return Byte array including TLV element content. @throws TLVParserException
[ "Returns", "the", "TLV", "content", ".", "If", "TLV", "does", "not", "include", "content", "then", "empty", "array", "is", "returned", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L319-L328
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.setContent
public void setContent(byte[] content) throws TLVParserException { Util.notNull(content, "Content"); assertActualContentLengthIsInTLVLimits(content.length); this.content = content; }
java
public void setContent(byte[] content) throws TLVParserException { Util.notNull(content, "Content"); assertActualContentLengthIsInTLVLimits(content.length); this.content = content; }
[ "public", "void", "setContent", "(", "byte", "[", "]", "content", ")", "throws", "TLVParserException", "{", "Util", ".", "notNull", "(", "content", ",", "\"Content\"", ")", ";", "assertActualContentLengthIsInTLVLimits", "(", "content", ".", "length", ")", ";", ...
Sets the value to TLV element content. @param content value to set. @throws TLVParserException
[ "Sets", "the", "value", "to", "TLV", "element", "content", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L338-L342
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.getFirstChildElement
public TLVElement getFirstChildElement(int tag) { for (TLVElement element : children) { if (tag == element.getType()) { return element; } } return null; }
java
public TLVElement getFirstChildElement(int tag) { for (TLVElement element : children) { if (tag == element.getType()) { return element; } } return null; }
[ "public", "TLVElement", "getFirstChildElement", "(", "int", "tag", ")", "{", "for", "(", "TLVElement", "element", ":", "children", ")", "{", "if", "(", "tag", "==", "element", ".", "getType", "(", ")", ")", "{", "return", "element", ";", "}", "}", "ret...
Returns the first child element with specified tag. If tag doesn't exist then null is returned. @param tag tag to search. @return The first instance of {@link TLVElement} with specified tag, or null when the child element with specified tag doesn't exist.
[ "Returns", "the", "first", "child", "element", "with", "specified", "tag", ".", "If", "tag", "doesn", "t", "exist", "then", "null", "is", "returned", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L388-L395
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.getChildElements
public List<TLVElement> getChildElements(int tag) { List<TLVElement> elements = new LinkedList<>(); for (TLVElement element : children) { if (tag == element.getType()) { elements.add(element); } } return elements; }
java
public List<TLVElement> getChildElements(int tag) { List<TLVElement> elements = new LinkedList<>(); for (TLVElement element : children) { if (tag == element.getType()) { elements.add(element); } } return elements; }
[ "public", "List", "<", "TLVElement", ">", "getChildElements", "(", "int", "tag", ")", "{", "List", "<", "TLVElement", ">", "elements", "=", "new", "LinkedList", "<>", "(", ")", ";", "for", "(", "TLVElement", "element", ":", "children", ")", "{", "if", ...
Returns all the tags with the specified tag. @param tag tag to search. @return The list of {@link TLVElement}'s with specified tag or empty list.
[ "Returns", "all", "the", "tags", "with", "the", "specified", "tag", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L426-L434
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.encodeHeader
public byte[] encodeHeader() throws TLVParserException { DataOutputStream out = null; try { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); out = new DataOutputStream(byteArrayOutputStream); int dataLength = getContentLength(); boolean tlv16 = isOutputTlv16(); int firstByte = (tlv16 ? TLVInputStream.TLV16_FLAG : 0) + (isNonCritical() ? TLVInputStream.NON_CRITICAL_FLAG : 0) + (isForwarded() ? TLVInputStream.FORWARD_FLAG : 0); if (tlv16) { firstByte = firstByte | (getType() >>> TLVInputStream.BYTE_BITS) & TLVInputStream.TYPE_MASK; out.writeByte(firstByte); out.writeByte(getType()); if (dataLength < 1) { out.writeShort(0); } else { out.writeShort(dataLength); } } else { firstByte = firstByte | getType() & TLVInputStream.TYPE_MASK; out.writeByte(firstByte); if (dataLength < 1) { out.writeByte(0); } else { out.writeByte(dataLength); } } return byteArrayOutputStream.toByteArray(); } catch (IOException e) { throw new TLVParserException("TLV header encoding failed", e); } finally { Util.closeQuietly(out); } }
java
public byte[] encodeHeader() throws TLVParserException { DataOutputStream out = null; try { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); out = new DataOutputStream(byteArrayOutputStream); int dataLength = getContentLength(); boolean tlv16 = isOutputTlv16(); int firstByte = (tlv16 ? TLVInputStream.TLV16_FLAG : 0) + (isNonCritical() ? TLVInputStream.NON_CRITICAL_FLAG : 0) + (isForwarded() ? TLVInputStream.FORWARD_FLAG : 0); if (tlv16) { firstByte = firstByte | (getType() >>> TLVInputStream.BYTE_BITS) & TLVInputStream.TYPE_MASK; out.writeByte(firstByte); out.writeByte(getType()); if (dataLength < 1) { out.writeShort(0); } else { out.writeShort(dataLength); } } else { firstByte = firstByte | getType() & TLVInputStream.TYPE_MASK; out.writeByte(firstByte); if (dataLength < 1) { out.writeByte(0); } else { out.writeByte(dataLength); } } return byteArrayOutputStream.toByteArray(); } catch (IOException e) { throw new TLVParserException("TLV header encoding failed", e); } finally { Util.closeQuietly(out); } }
[ "public", "byte", "[", "]", "encodeHeader", "(", ")", "throws", "TLVParserException", "{", "DataOutputStream", "out", "=", "null", ";", "try", "{", "ByteArrayOutputStream", "byteArrayOutputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "out", "=", ...
Encodes TLV header. @return Byte array containing encoded TLV header. @throws TLVParserException when TLV header encoding fails or I/O error occurs.
[ "Encodes", "TLV", "header", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L484-L520
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.replace
public void replace(TLVElement childToBeReplaced, TLVElement newChild) { for (int i = 0; i < children.size(); i++) { if (children.get(i).equals(childToBeReplaced)) { children.set(i, newChild); return; } } }
java
public void replace(TLVElement childToBeReplaced, TLVElement newChild) { for (int i = 0; i < children.size(); i++) { if (children.get(i).equals(childToBeReplaced)) { children.set(i, newChild); return; } } }
[ "public", "void", "replace", "(", "TLVElement", "childToBeReplaced", ",", "TLVElement", "newChild", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "children", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "children", ".", ...
Replaces first element with given one. @param childToBeReplaced TLV element to be replaced. @param newChild new TLV element.
[ "Replaces", "first", "element", "with", "given", "one", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L548-L555
train
guardtime/ksi-java-sdk
ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java
TLVElement.writeTo
public void writeTo(OutputStream out) throws TLVParserException { Util.notNull(out, "Output stream"); try { assertActualContentLengthIsInTLVLimits(getContentLength()); out.write(encodeHeader()); out.write(getContent()); } catch (IOException e) { throw new TLVParserException("Writing TLV element (" + convertHeader() + ") to output stream failed", e); } }
java
public void writeTo(OutputStream out) throws TLVParserException { Util.notNull(out, "Output stream"); try { assertActualContentLengthIsInTLVLimits(getContentLength()); out.write(encodeHeader()); out.write(getContent()); } catch (IOException e) { throw new TLVParserException("Writing TLV element (" + convertHeader() + ") to output stream failed", e); } }
[ "public", "void", "writeTo", "(", "OutputStream", "out", ")", "throws", "TLVParserException", "{", "Util", ".", "notNull", "(", "out", ",", "\"Output stream\"", ")", ";", "try", "{", "assertActualContentLengthIsInTLVLimits", "(", "getContentLength", "(", ")", ")",...
Writes the encoded TLV element to the specified output stream. @param out the output stream to which to write the TLV element data. @throws TLVParserException when I/O error occurred or TLV encoding failed.
[ "Writes", "the", "encoded", "TLV", "element", "to", "the", "specified", "output", "stream", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/tlv/TLVElement.java#L582-L591
train
guardtime/ksi-java-sdk
ksi-service-client-tcp/src/main/java/com/guardtime/ksi/service/tcp/TransactionDecoder.java
TransactionDecoder.extractNextTlvElementLength
private int extractNextTlvElementLength(IoBuffer in) { if (!hasRemainingData(in, 2)) { return NOT_ENOUGH_DATA; } try { in.mark(); int firstByte = in.getUnsigned(); boolean tlv8 = (firstByte & TLV16_MASK) == 0; if (tlv8) { // 8 bit length. NB! Reads one unsigned byte as an integer return in.getUnsigned() + TLV8_HEADER_LENGTH; } // skip tlv16 LSB byte in.skip(1); if (!hasRemainingData(in, 2)) { return NOT_ENOUGH_DATA; } // 16 bit length. NB! Reads two bytes unsigned integer return in.getUnsignedShort() + TLV16_HEADER_LENGTH; } finally { in.reset(); } }
java
private int extractNextTlvElementLength(IoBuffer in) { if (!hasRemainingData(in, 2)) { return NOT_ENOUGH_DATA; } try { in.mark(); int firstByte = in.getUnsigned(); boolean tlv8 = (firstByte & TLV16_MASK) == 0; if (tlv8) { // 8 bit length. NB! Reads one unsigned byte as an integer return in.getUnsigned() + TLV8_HEADER_LENGTH; } // skip tlv16 LSB byte in.skip(1); if (!hasRemainingData(in, 2)) { return NOT_ENOUGH_DATA; } // 16 bit length. NB! Reads two bytes unsigned integer return in.getUnsignedShort() + TLV16_HEADER_LENGTH; } finally { in.reset(); } }
[ "private", "int", "extractNextTlvElementLength", "(", "IoBuffer", "in", ")", "{", "if", "(", "!", "hasRemainingData", "(", "in", ",", "2", ")", ")", "{", "return", "NOT_ENOUGH_DATA", ";", "}", "try", "{", "in", ".", "mark", "(", ")", ";", "int", "first...
Returns the length of the next TLV element. Returns -1 when buffer doesn't contain enough data for next TLV element. @return The length of the TLV element.
[ "Returns", "the", "length", "of", "the", "next", "TLV", "element", ".", "Returns", "-", "1", "when", "buffer", "doesn", "t", "contain", "enough", "data", "for", "next", "TLV", "element", "." ]
b2cd877050f0f392657c724452318d10a1002171
https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-service-client-tcp/src/main/java/com/guardtime/ksi/service/tcp/TransactionDecoder.java#L69-L91
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Servers.java
Servers.create
public Server create(ServerCreateOptions serverCreateOptions) throws IOException, MailosaurException { return client.request("POST", "api/servers", serverCreateOptions).parseAs(Server.class); }
java
public Server create(ServerCreateOptions serverCreateOptions) throws IOException, MailosaurException { return client.request("POST", "api/servers", serverCreateOptions).parseAs(Server.class); }
[ "public", "Server", "create", "(", "ServerCreateOptions", "serverCreateOptions", ")", "throws", "IOException", ",", "MailosaurException", "{", "return", "client", ".", "request", "(", "\"POST\"", ",", "\"api/servers\"", ",", "serverCreateOptions", ")", ".", "parseAs",...
Create a server. Creates a new virtual SMTP server and returns it. @param serverCreateOptions the ServerCreateOptions value @throws MailosaurException thrown if the request is rejected by server @throws IOException @return the Server object if successful.
[ "Create", "a", "server", ".", "Creates", "a", "new", "virtual", "SMTP", "server", "and", "returns", "it", "." ]
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Servers.java#L48-L50
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Servers.java
Servers.get
public Server get(String id) throws IOException, MailosaurException { return client.request("GET", "api/servers/" + id).parseAs(Server.class); }
java
public Server get(String id) throws IOException, MailosaurException { return client.request("GET", "api/servers/" + id).parseAs(Server.class); }
[ "public", "Server", "get", "(", "String", "id", ")", "throws", "IOException", ",", "MailosaurException", "{", "return", "client", ".", "request", "(", "\"GET\"", ",", "\"api/servers/\"", "+", "id", ")", ".", "parseAs", "(", "Server", ".", "class", ")", ";"...
Retrieve a server. Retrieves the detail for a single server. Simply supply the unique identifier for the required server. @param id The identifier of the server to be retrieved. @throws MailosaurException thrown if the request is rejected by server @throws IOException @return the Server object if successful.
[ "Retrieve", "a", "server", ".", "Retrieves", "the", "detail", "for", "a", "single", "server", ".", "Simply", "supply", "the", "unique", "identifier", "for", "the", "required", "server", "." ]
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Servers.java#L61-L63
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Servers.java
Servers.update
public Server update(String id, Server server) throws IOException, MailosaurException { return client.request("PUT", "api/servers/" + id, server).parseAs(Server.class); }
java
public Server update(String id, Server server) throws IOException, MailosaurException { return client.request("PUT", "api/servers/" + id, server).parseAs(Server.class); }
[ "public", "Server", "update", "(", "String", "id", ",", "Server", "server", ")", "throws", "IOException", ",", "MailosaurException", "{", "return", "client", ".", "request", "(", "\"PUT\"", ",", "\"api/servers/\"", "+", "id", ",", "server", ")", ".", "parseA...
Update a server. Updats a single server and returns it. @param id The identifier of the server to be updated. @param server the Server value @throws MailosaurException thrown if the request is rejected by server @throws IOException @return the Server object if successful.
[ "Update", "a", "server", ".", "Updats", "a", "single", "server", "and", "returns", "it", "." ]
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Servers.java#L75-L77
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Messages.java
Messages.get
public Message get(String id) throws IOException, MailosaurException { return client.request("GET", "api/messages/" + id).parseAs(Message.class); }
java
public Message get(String id) throws IOException, MailosaurException { return client.request("GET", "api/messages/" + id).parseAs(Message.class); }
[ "public", "Message", "get", "(", "String", "id", ")", "throws", "IOException", ",", "MailosaurException", "{", "return", "client", ".", "request", "(", "\"GET\"", ",", "\"api/messages/\"", "+", "id", ")", ".", "parseAs", "(", "Message", ".", "class", ")", ...
Retrieve an message. Retrieves the detail for a single message. Simply supply the unique identifier for the required message. @param id The identifier of the message to be retrieved. @throws MailosaurException thrown if the request is rejected by server @throws IOException @return the Message object if successful.
[ "Retrieve", "an", "message", ".", "Retrieves", "the", "detail", "for", "a", "single", "message", ".", "Simply", "supply", "the", "unique", "identifier", "for", "the", "required", "message", "." ]
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Messages.java#L36-L38
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Messages.java
Messages.deleteAll
public void deleteAll(String server) throws MailosaurException { HashMap<String, String> query = new HashMap<String, String>(); query.put("server", server); client.request("DELETE", "api/messages", query); }
java
public void deleteAll(String server) throws MailosaurException { HashMap<String, String> query = new HashMap<String, String>(); query.put("server", server); client.request("DELETE", "api/messages", query); }
[ "public", "void", "deleteAll", "(", "String", "server", ")", "throws", "MailosaurException", "{", "HashMap", "<", "String", ",", "String", ">", "query", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "query", ".", "put", "(", ...
Delete all messages. Permanently deletes all messages held by the specified server. This operation cannot be undone. Also deletes any attachments related to each message. @param server The identifier of the server to be emptied. @throws MailosaurException thrown if the request is rejected by server
[ "Delete", "all", "messages", ".", "Permanently", "deletes", "all", "messages", "held", "by", "the", "specified", "server", ".", "This", "operation", "cannot", "be", "undone", ".", "Also", "deletes", "any", "attachments", "related", "to", "each", "message", "."...
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Messages.java#L59-L63
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Messages.java
Messages.list
public MessageListResult list(String server) throws IOException, MailosaurException { HashMap<String, String> query = new HashMap<String, String>(); query.put("server", server); return client.request("GET", "api/messages", query).parseAs(MessageListResult.class); }
java
public MessageListResult list(String server) throws IOException, MailosaurException { HashMap<String, String> query = new HashMap<String, String>(); query.put("server", server); return client.request("GET", "api/messages", query).parseAs(MessageListResult.class); }
[ "public", "MessageListResult", "list", "(", "String", "server", ")", "throws", "IOException", ",", "MailosaurException", "{", "HashMap", "<", "String", ",", "String", ">", "query", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "q...
List all messages. Returns a list of your messages. The messages are returned sorted by received date, with the most recently-received messages appearing first. @param server The identifier of the server hosting the messages. @throws MailosaurException thrown if the request is rejected by server @throws IOException @return the MessageListResult object if successful.
[ "List", "all", "messages", ".", "Returns", "a", "list", "of", "your", "messages", ".", "The", "messages", "are", "returned", "sorted", "by", "received", "date", "with", "the", "most", "recently", "-", "received", "messages", "appearing", "first", "." ]
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Messages.java#L74-L78
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Messages.java
Messages.search
public MessageListResult search(String server, SearchCriteria criteria) throws IOException, MailosaurException { HashMap<String, String> query = new HashMap<String, String>(); query.put("server", server); return client.request("POST", "api/messages/search", criteria, query).parseAs(MessageListResult.class); }
java
public MessageListResult search(String server, SearchCriteria criteria) throws IOException, MailosaurException { HashMap<String, String> query = new HashMap<String, String>(); query.put("server", server); return client.request("POST", "api/messages/search", criteria, query).parseAs(MessageListResult.class); }
[ "public", "MessageListResult", "search", "(", "String", "server", ",", "SearchCriteria", "criteria", ")", "throws", "IOException", ",", "MailosaurException", "{", "HashMap", "<", "String", ",", "String", ">", "query", "=", "new", "HashMap", "<", "String", ",", ...
Search for messages. Returns a list of messages matching the specified search criteria. The messages are returned sorted by received date, with the most recently-received messages appearing first. @param server The identifier of the server hosting the messages. @param criteria The search criteria to match results against. @throws MailosaurException thrown if the request is rejected by server @throws IOException @return the MessageListResult object if successful.
[ "Search", "for", "messages", ".", "Returns", "a", "list", "of", "messages", "matching", "the", "specified", "search", "criteria", ".", "The", "messages", "are", "returned", "sorted", "by", "received", "date", "with", "the", "most", "recently", "-", "received",...
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Messages.java#L90-L94
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Messages.java
Messages.waitFor
public Message waitFor(String server, SearchCriteria criteria) throws IOException, MailosaurException { HashMap<String, String> query = new HashMap<String, String>(); query.put("server", server); return client.request("POST", "api/messages/await", criteria, query).parseAs(Message.class); }
java
public Message waitFor(String server, SearchCriteria criteria) throws IOException, MailosaurException { HashMap<String, String> query = new HashMap<String, String>(); query.put("server", server); return client.request("POST", "api/messages/await", criteria, query).parseAs(Message.class); }
[ "public", "Message", "waitFor", "(", "String", "server", ",", "SearchCriteria", "criteria", ")", "throws", "IOException", ",", "MailosaurException", "{", "HashMap", "<", "String", ",", "String", ">", "query", "=", "new", "HashMap", "<", "String", ",", "String"...
Wait for a specific message. Returns as soon as an message matching the specified search criteria is found. @param server The identifier of the server hosting the message. @param criteria The search criteria to use in order to find a match. @throws MailosaurException thrown if the request is rejected by server @throws IOException @return the Message object if successful.
[ "Wait", "for", "a", "specific", "message", ".", "Returns", "as", "soon", "as", "an", "message", "matching", "the", "specified", "search", "criteria", "is", "found", "." ]
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Messages.java#L106-L110
train
mailosaur/mailosaur-java
src/main/java/com/mailosaur/Analysis.java
Analysis.spam
public SpamAnalysisResult spam(String email) throws IOException, MailosaurException { return client.request("GET", "api/analysis/spam/" + email).parseAs(SpamAnalysisResult.class); }
java
public SpamAnalysisResult spam(String email) throws IOException, MailosaurException { return client.request("GET", "api/analysis/spam/" + email).parseAs(SpamAnalysisResult.class); }
[ "public", "SpamAnalysisResult", "spam", "(", "String", "email", ")", "throws", "IOException", ",", "MailosaurException", "{", "return", "client", ".", "request", "(", "\"GET\"", ",", "\"api/analysis/spam/\"", "+", "email", ")", ".", "parseAs", "(", "SpamAnalysisRe...
Perform spam analysis on the specified email. @param email The identifier of the email to be analyzed. @throws MailosaurException thrown if the request is rejected by server @throws IOException @return the SpamCheckResult object if successful.
[ "Perform", "spam", "analysis", "on", "the", "specified", "email", "." ]
a580760f2eb41e034127d93104c7050639eced97
https://github.com/mailosaur/mailosaur-java/blob/a580760f2eb41e034127d93104c7050639eced97/src/main/java/com/mailosaur/Analysis.java#L32-L34
train
BroadleafCommerce/blc-paypal
src/main/java/org/broadleafcommerce/vendor/paypal/web/controller/BroadleafPayPalCheckoutController.java
BroadleafPayPalCheckoutController.completeCheckout
@RequestMapping(value = "/checkout/complete", method = RequestMethod.POST) public String completeCheckout() throws PaymentException { paymentService.updatePayPalPaymentForFulfillment(); String paymentId = paymentService.getPayPalPaymentIdFromCurrentOrder(); String payerId = paymentService.getPayPalPayerIdFromCurrentOrder(); if (StringUtils.isBlank(paymentId)) { throw new PaymentException("Unable to complete checkout because no PayPal payment id was found on the current order"); } if (StringUtils.isBlank(payerId)) { throw new PaymentException("Unable to complete checkout because no PayPal payer id was found on the current order"); } return "redirect:/paypal-checkout/return?" + MessageConstants.HTTP_PAYMENTID + "=" + paymentId + "&" + MessageConstants.HTTP_PAYERID + "=" + payerId; }
java
@RequestMapping(value = "/checkout/complete", method = RequestMethod.POST) public String completeCheckout() throws PaymentException { paymentService.updatePayPalPaymentForFulfillment(); String paymentId = paymentService.getPayPalPaymentIdFromCurrentOrder(); String payerId = paymentService.getPayPalPayerIdFromCurrentOrder(); if (StringUtils.isBlank(paymentId)) { throw new PaymentException("Unable to complete checkout because no PayPal payment id was found on the current order"); } if (StringUtils.isBlank(payerId)) { throw new PaymentException("Unable to complete checkout because no PayPal payer id was found on the current order"); } return "redirect:/paypal-checkout/return?" + MessageConstants.HTTP_PAYMENTID + "=" + paymentId + "&" + MessageConstants.HTTP_PAYERID + "=" + payerId; }
[ "@", "RequestMapping", "(", "value", "=", "\"/checkout/complete\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "String", "completeCheckout", "(", ")", "throws", "PaymentException", "{", "paymentService", ".", "updatePayPalPaymentForFulfillment", ...
Completes checkout for a PayPal payment. If there's already a PayPal payment we go ahead and make sure the details of the payment are updated to all of the forms filled out by the customer since they could've updated shipping information, added a promotion, or other various things to the order. @return Redirect URL to either add the payment and checkout or just checkout @throws PaymentException
[ "Completes", "checkout", "for", "a", "PayPal", "payment", ".", "If", "there", "s", "already", "a", "PayPal", "payment", "we", "go", "ahead", "and", "make", "sure", "the", "details", "of", "the", "payment", "are", "updated", "to", "all", "of", "the", "for...
2b38e25722411f136f9012c030519013f6cb010a
https://github.com/BroadleafCommerce/blc-paypal/blob/2b38e25722411f136f9012c030519013f6cb010a/src/main/java/org/broadleafcommerce/vendor/paypal/web/controller/BroadleafPayPalCheckoutController.java#L161-L173
train
digipost/signature-api-client-java
src/main/java/no/digipost/signature/client/portal/PortalJobStatusChanged.java
PortalJobStatusChanged.getSignatureFrom
public Signature getSignatureFrom(SignerIdentifier signer) { return signatures.stream() .filter(signatureFrom(signer)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Unable to find signature from this signer")); }
java
public Signature getSignatureFrom(SignerIdentifier signer) { return signatures.stream() .filter(signatureFrom(signer)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Unable to find signature from this signer")); }
[ "public", "Signature", "getSignatureFrom", "(", "SignerIdentifier", "signer", ")", "{", "return", "signatures", ".", "stream", "(", ")", ".", "filter", "(", "signatureFrom", "(", "signer", ")", ")", ".", "findFirst", "(", ")", ".", "orElseThrow", "(", "(", ...
Gets the signature from a given signer. @param signer an identifier referring to a signer of the job. It may be a personal identification number or contact information, depending of how the {@link PortalSigner signer} was initially created (using {@link PortalSigner#identifiedByPersonalIdentificationNumber(String, Notifications) personal identification number}<sup>1</sup>, {@link PortalSigner#identifiedByPersonalIdentificationNumber(String, NotificationsUsingLookup) personal identification number}<sup>2</sup>, {@link PortalSigner#identifiedByEmail(String) email address}, {@link PortalSigner#identifiedByMobileNumber(String) mobile number} or {@link PortalSigner#identifiedByEmailAndMobileNumber(String, String) both email address and mobile number}). <p> <sup>1</sup>: with contact information provided.<br> <sup>2</sup>: using contact information from a lookup service. </p> @throws IllegalArgumentException if the job response doesn't contain a signature from this signer
[ "Gets", "the", "signature", "from", "a", "given", "signer", "." ]
246207571641fbac6beda5ffc585eec188825c45
https://github.com/digipost/signature-api-client-java/blob/246207571641fbac6beda5ffc585eec188825c45/src/main/java/no/digipost/signature/client/portal/PortalJobStatusChanged.java#L115-L120
train
digipost/signature-api-client-java
src/main/java/no/digipost/signature/client/direct/RedirectUrls.java
RedirectUrls.getFor
public String getFor(String personalIdentificationNumber) { for (RedirectUrl redirectUrl : urls) { if (redirectUrl.signer.equals(personalIdentificationNumber)) { return redirectUrl.url; } } throw new IllegalArgumentException("Unable to find redirect URL for this signer"); }
java
public String getFor(String personalIdentificationNumber) { for (RedirectUrl redirectUrl : urls) { if (redirectUrl.signer.equals(personalIdentificationNumber)) { return redirectUrl.url; } } throw new IllegalArgumentException("Unable to find redirect URL for this signer"); }
[ "public", "String", "getFor", "(", "String", "personalIdentificationNumber", ")", "{", "for", "(", "RedirectUrl", "redirectUrl", ":", "urls", ")", "{", "if", "(", "redirectUrl", ".", "signer", ".", "equals", "(", "personalIdentificationNumber", ")", ")", "{", ...
Gets the redirect URL for a given signer. @throws IllegalArgumentException if the job response doesn't contain a redirect URL for this signer @see DirectJobResponse#getSingleRedirectUrl()
[ "Gets", "the", "redirect", "URL", "for", "a", "given", "signer", "." ]
246207571641fbac6beda5ffc585eec188825c45
https://github.com/digipost/signature-api-client-java/blob/246207571641fbac6beda5ffc585eec188825c45/src/main/java/no/digipost/signature/client/direct/RedirectUrls.java#L27-L34
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.getMetadataFor
public <T> IMetadataDictionary getMetadataFor(T instance) { if (instance == null) { throw new IllegalArgumentException("Instance cannot be null"); } DocumentInfo documentInfo = getDocumentInfo(instance); if (documentInfo.getMetadataInstance() != null) { return documentInfo.getMetadataInstance(); } ObjectNode metadataAsJson = documentInfo.getMetadata(); MetadataAsDictionary metadata = new MetadataAsDictionary(metadataAsJson); documentInfo.setMetadataInstance(metadata); return metadata; }
java
public <T> IMetadataDictionary getMetadataFor(T instance) { if (instance == null) { throw new IllegalArgumentException("Instance cannot be null"); } DocumentInfo documentInfo = getDocumentInfo(instance); if (documentInfo.getMetadataInstance() != null) { return documentInfo.getMetadataInstance(); } ObjectNode metadataAsJson = documentInfo.getMetadata(); MetadataAsDictionary metadata = new MetadataAsDictionary(metadataAsJson); documentInfo.setMetadataInstance(metadata); return metadata; }
[ "public", "<", "T", ">", "IMetadataDictionary", "getMetadataFor", "(", "T", "instance", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Instance cannot be null\"", ")", ";", "}", "DocumentInfo", "docum...
Gets the metadata for the specified entity. @param <T> instance class @param instance Instance to get metadata from @return document metadata
[ "Gets", "the", "metadata", "for", "the", "specified", "entity", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L351-L365
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.getCountersFor
public <T> List<String> getCountersFor(T instance) { if (instance == null) { throw new IllegalArgumentException("Instance cannot be null"); } DocumentInfo documentInfo = getDocumentInfo(instance); ArrayNode countersArray = (ArrayNode) documentInfo.getMetadata().get(Constants.Documents.Metadata.COUNTERS); if (countersArray == null) { return null; } return IntStream.range(0, countersArray.size()) .mapToObj(i -> countersArray.get(i).asText()) .collect(Collectors.toList()); }
java
public <T> List<String> getCountersFor(T instance) { if (instance == null) { throw new IllegalArgumentException("Instance cannot be null"); } DocumentInfo documentInfo = getDocumentInfo(instance); ArrayNode countersArray = (ArrayNode) documentInfo.getMetadata().get(Constants.Documents.Metadata.COUNTERS); if (countersArray == null) { return null; } return IntStream.range(0, countersArray.size()) .mapToObj(i -> countersArray.get(i).asText()) .collect(Collectors.toList()); }
[ "public", "<", "T", ">", "List", "<", "String", ">", "getCountersFor", "(", "T", "instance", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Instance cannot be null\"", ")", ";", "}", "DocumentInfo...
Gets all counter names for the specified entity. @param instance Instance @param <T> Instance class @return All counters names
[ "Gets", "all", "counter", "names", "for", "the", "specified", "entity", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L373-L388
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.getChangeVectorFor
public <T> String getChangeVectorFor(T instance) { if (instance == null) { throw new IllegalArgumentException("instance cannot be null"); } DocumentInfo documentInfo = getDocumentInfo(instance); JsonNode changeVector = documentInfo.getMetadata().get(Constants.Documents.Metadata.CHANGE_VECTOR); if (changeVector != null) { return changeVector.asText(); } return null; }
java
public <T> String getChangeVectorFor(T instance) { if (instance == null) { throw new IllegalArgumentException("instance cannot be null"); } DocumentInfo documentInfo = getDocumentInfo(instance); JsonNode changeVector = documentInfo.getMetadata().get(Constants.Documents.Metadata.CHANGE_VECTOR); if (changeVector != null) { return changeVector.asText(); } return null; }
[ "public", "<", "T", ">", "String", "getChangeVectorFor", "(", "T", "instance", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"instance cannot be null\"", ")", ";", "}", "DocumentInfo", "documentInfo",...
Gets the Change Vector for the specified entity. If the entity is transient, it will load the change vector from the store and associate the current state of the entity with the change vector from the server. @param <T> instance class @param instance Instance to get change vector from @return change vector
[ "Gets", "the", "Change", "Vector", "for", "the", "specified", "entity", ".", "If", "the", "entity", "is", "transient", "it", "will", "load", "the", "change", "vector", "from", "the", "store", "and", "associate", "the", "current", "state", "of", "the", "ent...
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L399-L410
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.getDocumentId
public String getDocumentId(Object instance) { if (instance == null) { return null; } DocumentInfo value = documentsByEntity.get(instance); return value != null ? value.getId() : null; }
java
public String getDocumentId(Object instance) { if (instance == null) { return null; } DocumentInfo value = documentsByEntity.get(instance); return value != null ? value.getId() : null; }
[ "public", "String", "getDocumentId", "(", "Object", "instance", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "return", "null", ";", "}", "DocumentInfo", "value", "=", "documentsByEntity", ".", "get", "(", "instance", ")", ";", "return", "value"...
Gets the document id. @param instance instance to get document id from @return document id
[ "Gets", "the", "document", "id", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L475-L481
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.trackEntity
@SuppressWarnings("unchecked") public <T> T trackEntity(Class<T> clazz, DocumentInfo documentFound) { return (T) trackEntity(clazz, documentFound.getId(), documentFound.getDocument(), documentFound.getMetadata(), noTracking); }
java
@SuppressWarnings("unchecked") public <T> T trackEntity(Class<T> clazz, DocumentInfo documentFound) { return (T) trackEntity(clazz, documentFound.getId(), documentFound.getDocument(), documentFound.getMetadata(), noTracking); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "trackEntity", "(", "Class", "<", "T", ">", "clazz", ",", "DocumentInfo", "documentFound", ")", "{", "return", "(", "T", ")", "trackEntity", "(", "clazz", ",", "documentFound...
Tracks the entity inside the unit of work @param <T> entity class @param clazz entity class @param documentFound Document info @return tracked entity
[ "Tracks", "the", "entity", "inside", "the", "unit", "of", "work" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L501-L504
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.trackEntity
public Object trackEntity(Class entityType, String id, ObjectNode document, ObjectNode metadata, boolean noTracking) { noTracking = this.noTracking || noTracking; // if noTracking is session-wide then we want to override the passed argument if (StringUtils.isEmpty(id)) { return deserializeFromTransformer(entityType, null, document); } DocumentInfo docInfo = documentsById.getValue(id); if (docInfo != null) { // the local instance may have been changed, we adhere to the current Unit of Work // instance, and return that, ignoring anything new. if (docInfo.getEntity() == null) { docInfo.setEntity(entityToJson.convertToEntity(entityType, id, document)); } if (!noTracking) { includedDocumentsById.remove(id); documentsByEntity.put(docInfo.getEntity(), docInfo); } return docInfo.getEntity(); } docInfo = includedDocumentsById.get(id); if (docInfo != null) { if (docInfo.getEntity() == null) { docInfo.setEntity(entityToJson.convertToEntity(entityType, id, document)); } if (!noTracking) { includedDocumentsById.remove(id); documentsById.add(docInfo); documentsByEntity.put(docInfo.getEntity(), docInfo); } return docInfo.getEntity(); } Object entity = entityToJson.convertToEntity(entityType, id, document); String changeVector = metadata.get(Constants.Documents.Metadata.CHANGE_VECTOR).asText(); if (changeVector == null) { throw new IllegalStateException("Document " + id + " must have Change Vector"); } if (!noTracking) { DocumentInfo newDocumentInfo = new DocumentInfo(); newDocumentInfo.setId(id); newDocumentInfo.setDocument(document); newDocumentInfo.setMetadata(metadata); newDocumentInfo.setEntity(entity); newDocumentInfo.setChangeVector(changeVector); documentsById.add(newDocumentInfo); documentsByEntity.put(entity, newDocumentInfo); } return entity; }
java
public Object trackEntity(Class entityType, String id, ObjectNode document, ObjectNode metadata, boolean noTracking) { noTracking = this.noTracking || noTracking; // if noTracking is session-wide then we want to override the passed argument if (StringUtils.isEmpty(id)) { return deserializeFromTransformer(entityType, null, document); } DocumentInfo docInfo = documentsById.getValue(id); if (docInfo != null) { // the local instance may have been changed, we adhere to the current Unit of Work // instance, and return that, ignoring anything new. if (docInfo.getEntity() == null) { docInfo.setEntity(entityToJson.convertToEntity(entityType, id, document)); } if (!noTracking) { includedDocumentsById.remove(id); documentsByEntity.put(docInfo.getEntity(), docInfo); } return docInfo.getEntity(); } docInfo = includedDocumentsById.get(id); if (docInfo != null) { if (docInfo.getEntity() == null) { docInfo.setEntity(entityToJson.convertToEntity(entityType, id, document)); } if (!noTracking) { includedDocumentsById.remove(id); documentsById.add(docInfo); documentsByEntity.put(docInfo.getEntity(), docInfo); } return docInfo.getEntity(); } Object entity = entityToJson.convertToEntity(entityType, id, document); String changeVector = metadata.get(Constants.Documents.Metadata.CHANGE_VECTOR).asText(); if (changeVector == null) { throw new IllegalStateException("Document " + id + " must have Change Vector"); } if (!noTracking) { DocumentInfo newDocumentInfo = new DocumentInfo(); newDocumentInfo.setId(id); newDocumentInfo.setDocument(document); newDocumentInfo.setMetadata(metadata); newDocumentInfo.setEntity(entity); newDocumentInfo.setChangeVector(changeVector); documentsById.add(newDocumentInfo); documentsByEntity.put(entity, newDocumentInfo); } return entity; }
[ "public", "Object", "trackEntity", "(", "Class", "entityType", ",", "String", "id", ",", "ObjectNode", "document", ",", "ObjectNode", "metadata", ",", "boolean", "noTracking", ")", "{", "noTracking", "=", "this", ".", "noTracking", "||", "noTracking", ";", "//...
Tracks the entity. @param entityType Entity class @param id Id of document @param document raw entity @param metadata raw document metadata @param noTracking no tracking @return entity
[ "Tracks", "the", "entity", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L545-L605
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.delete
public <T> void delete(T entity) { if (entity == null) { throw new IllegalArgumentException("Entity cannot be null"); } DocumentInfo value = documentsByEntity.get(entity); if (value == null) { throw new IllegalStateException(entity + " is not associated with the session, cannot delete unknown entity instance"); } deletedEntities.add(entity); includedDocumentsById.remove(value.getId()); if (_countersByDocId != null) { _countersByDocId.remove(value.getId()); } _knownMissingIds.add(value.getId()); }
java
public <T> void delete(T entity) { if (entity == null) { throw new IllegalArgumentException("Entity cannot be null"); } DocumentInfo value = documentsByEntity.get(entity); if (value == null) { throw new IllegalStateException(entity + " is not associated with the session, cannot delete unknown entity instance"); } deletedEntities.add(entity); includedDocumentsById.remove(value.getId()); if (_countersByDocId != null) { _countersByDocId.remove(value.getId()); } _knownMissingIds.add(value.getId()); }
[ "public", "<", "T", ">", "void", "delete", "(", "T", "entity", ")", "{", "if", "(", "entity", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Entity cannot be null\"", ")", ";", "}", "DocumentInfo", "value", "=", "documentsByEntit...
Marks the specified entity for deletion. The entity will be deleted when SaveChanges is called. @param <T> entity class @param entity Entity to delete
[ "Marks", "the", "specified", "entity", "for", "deletion", ".", "The", "entity", "will", "be", "deleted", "when", "SaveChanges", "is", "called", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L624-L640
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.store
public void store(Object entity) { Reference<String> stringReference = new Reference<>(); boolean hasId = generateEntityIdOnTheClient.tryGetIdFromInstance(entity, stringReference); storeInternal(entity, null, null, !hasId ? ConcurrencyCheckMode.FORCED : ConcurrencyCheckMode.AUTO); }
java
public void store(Object entity) { Reference<String> stringReference = new Reference<>(); boolean hasId = generateEntityIdOnTheClient.tryGetIdFromInstance(entity, stringReference); storeInternal(entity, null, null, !hasId ? ConcurrencyCheckMode.FORCED : ConcurrencyCheckMode.AUTO); }
[ "public", "void", "store", "(", "Object", "entity", ")", "{", "Reference", "<", "String", ">", "stringReference", "=", "new", "Reference", "<>", "(", ")", ";", "boolean", "hasId", "=", "generateEntityIdOnTheClient", ".", "tryGetIdFromInstance", "(", "entity", ...
Stores the specified entity in the session. The entity will be saved when SaveChanges is called. @param entity Entity to store
[ "Stores", "the", "specified", "entity", "in", "the", "session", ".", "The", "entity", "will", "be", "saved", "when", "SaveChanges", "is", "called", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L686-L690
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.hasChanges
public boolean hasChanges() { for (Map.Entry<Object, DocumentInfo> entity : documentsByEntity.entrySet()) { ObjectNode document = entityToJson.convertEntityToJson(entity.getKey(), entity.getValue()); if (entityChanged(document, entity.getValue(), null)) { return true; } } return !deletedEntities.isEmpty(); }
java
public boolean hasChanges() { for (Map.Entry<Object, DocumentInfo> entity : documentsByEntity.entrySet()) { ObjectNode document = entityToJson.convertEntityToJson(entity.getKey(), entity.getValue()); if (entityChanged(document, entity.getValue(), null)) { return true; } } return !deletedEntities.isEmpty(); }
[ "public", "boolean", "hasChanges", "(", ")", "{", "for", "(", "Map", ".", "Entry", "<", "Object", ",", "DocumentInfo", ">", "entity", ":", "documentsByEntity", ".", "entrySet", "(", ")", ")", "{", "ObjectNode", "document", "=", "entityToJson", ".", "conver...
Gets a value indicating whether any of the entities tracked by the session has changes. @return true if session has changes
[ "Gets", "a", "value", "indicating", "whether", "any", "of", "the", "entities", "tracked", "by", "the", "session", "has", "changes", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L1074-L1083
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.hasChanged
public boolean hasChanged(Object entity) { DocumentInfo documentInfo = documentsByEntity.get(entity); if (documentInfo == null) { return false; } ObjectNode document = entityToJson.convertEntityToJson(entity, documentInfo); return entityChanged(document, documentInfo, null); }
java
public boolean hasChanged(Object entity) { DocumentInfo documentInfo = documentsByEntity.get(entity); if (documentInfo == null) { return false; } ObjectNode document = entityToJson.convertEntityToJson(entity, documentInfo); return entityChanged(document, documentInfo, null); }
[ "public", "boolean", "hasChanged", "(", "Object", "entity", ")", "{", "DocumentInfo", "documentInfo", "=", "documentsByEntity", ".", "get", "(", "entity", ")", ";", "if", "(", "documentInfo", "==", "null", ")", "{", "return", "false", ";", "}", "ObjectNode",...
Determines whether the specified entity has changed. @param entity Entity to check @return true if entity has changed
[ "Determines", "whether", "the", "specified", "entity", "has", "changed", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L1091-L1100
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.evict
public <T> void evict(T entity) { DocumentInfo documentInfo = documentsByEntity.get(entity); if (documentInfo != null) { documentsByEntity.remove(entity); documentsById.remove(documentInfo.getId()); } deletedEntities.remove(entity); if (_countersByDocId != null) { _countersByDocId.remove(documentInfo.getId()); } }
java
public <T> void evict(T entity) { DocumentInfo documentInfo = documentsByEntity.get(entity); if (documentInfo != null) { documentsByEntity.remove(entity); documentsById.remove(documentInfo.getId()); } deletedEntities.remove(entity); if (_countersByDocId != null) { _countersByDocId.remove(documentInfo.getId()); } }
[ "public", "<", "T", ">", "void", "evict", "(", "T", "entity", ")", "{", "DocumentInfo", "documentInfo", "=", "documentsByEntity", ".", "get", "(", "entity", ")", ";", "if", "(", "documentInfo", "!=", "null", ")", "{", "documentsByEntity", ".", "remove", ...
Evicts the specified entity from the session. Remove the entity from the delete queue and stops tracking changes for this entity. @param <T> entity class @param entity Entity to evict
[ "Evicts", "the", "specified", "entity", "from", "the", "session", ".", "Remove", "the", "entity", "from", "the", "delete", "queue", "and", "stops", "tracking", "changes", "for", "this", "entity", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L1172-L1183
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java
InMemoryDocumentSessionOperations.clear
public void clear() { documentsByEntity.clear(); deletedEntities.clear(); documentsById.clear(); _knownMissingIds.clear(); if (_countersByDocId != null) { _countersByDocId.clear(); } }
java
public void clear() { documentsByEntity.clear(); deletedEntities.clear(); documentsById.clear(); _knownMissingIds.clear(); if (_countersByDocId != null) { _countersByDocId.clear(); } }
[ "public", "void", "clear", "(", ")", "{", "documentsByEntity", ".", "clear", "(", ")", ";", "deletedEntities", ".", "clear", "(", ")", ";", "documentsById", ".", "clear", "(", ")", ";", "_knownMissingIds", ".", "clear", "(", ")", ";", "if", "(", "_coun...
Clears this instance. Remove all entities from the delete queue and stops tracking changes for all entities.
[ "Clears", "this", "instance", ".", "Remove", "all", "entities", "from", "the", "delete", "queue", "and", "stops", "tracking", "changes", "for", "all", "entities", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/InMemoryDocumentSessionOperations.java#L1189-L1197
train
wcm-io/wcm-io-wcm
ui/extjs/src/main/java/io/wcm/wcm/ui/extjs/provider/impl/servlets/TemplateFilterPageTreeProvider.java
TemplateFilterPageTreeProvider.getPagePathsForTemplate
private Set<String> getPagePathsForTemplate(String[] templates, String rootPath, SlingHttpServletRequest request) { Set<String> pagePaths = new HashSet<>(); if (templates != null && templates.length > 0) { try { NodeIterator nodes = searchNodesByTemplate(templates, rootPath, request); while (nodes.hasNext()) { Node node = nodes.nextNode(); String path = StringUtils.removeEnd(node.getPath(), "/jcr:content"); pagePaths.add(path); } } catch (RepositoryException ex) { log.warn("Seaching nodes by template failed.", ex); } } return pagePaths; }
java
private Set<String> getPagePathsForTemplate(String[] templates, String rootPath, SlingHttpServletRequest request) { Set<String> pagePaths = new HashSet<>(); if (templates != null && templates.length > 0) { try { NodeIterator nodes = searchNodesByTemplate(templates, rootPath, request); while (nodes.hasNext()) { Node node = nodes.nextNode(); String path = StringUtils.removeEnd(node.getPath(), "/jcr:content"); pagePaths.add(path); } } catch (RepositoryException ex) { log.warn("Seaching nodes by template failed.", ex); } } return pagePaths; }
[ "private", "Set", "<", "String", ">", "getPagePathsForTemplate", "(", "String", "[", "]", "templates", ",", "String", "rootPath", ",", "SlingHttpServletRequest", "request", ")", "{", "Set", "<", "String", ">", "pagePaths", "=", "new", "HashSet", "<>", "(", "...
Get paths for pages that use the given template @param templates @param rootPath @return a set of nodes that should be displayed in the tree
[ "Get", "paths", "for", "pages", "that", "use", "the", "given", "template" ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/ui/extjs/src/main/java/io/wcm/wcm/ui/extjs/provider/impl/servlets/TemplateFilterPageTreeProvider.java#L99-L117
train
wcm-io/wcm-io-wcm
parsys/src/main/java/io/wcm/wcm/parsys/controller/Parsys.java
Parsys.isParagraphValid
private Optional<@NotNull Boolean> isParagraphValid(Resource resource) { // use reflection to access the method "getModelFromResource" from ModelFactory, as it is not present in earlier version // but we want still to support earlier versions of AEM as well which do not contain this method // validation is disabled in this case Method getModelFromResourceMethod; try { getModelFromResourceMethod = ModelFactory.class.getDeclaredMethod("getModelFromResource", Resource.class); } catch (NoSuchMethodException | SecurityException ex) { // seems to be an earlier version of AEM/Sling models not supporting this method log.debug("ModelFactory does not support method 'getModelFromResource' - skip paragraph validation."); return Optional.empty(); } try { // try to get model associated with the resource, and check if it implements the ParsysItem interface Object model = getModelFromResourceMethod.invoke(modelFactory, resource); if (model instanceof ParsysItem) { return Optional.of(((ParsysItem)model).isValid()); } } catch (ModelClassException ex) { // ignore if no model was registered for this resource type } catch (InvocationTargetException ex) { if (ex.getCause() instanceof ModelClassException) { // ignore if no model was registered for this resource type } else { log.warn("Unable to invoke ModelFactory.getModelFromResource.", ex); } } catch (IllegalAccessException ex) { log.warn("Unable to access ModelFactory.getModelFromResource.", ex); } return Optional.empty(); }
java
private Optional<@NotNull Boolean> isParagraphValid(Resource resource) { // use reflection to access the method "getModelFromResource" from ModelFactory, as it is not present in earlier version // but we want still to support earlier versions of AEM as well which do not contain this method // validation is disabled in this case Method getModelFromResourceMethod; try { getModelFromResourceMethod = ModelFactory.class.getDeclaredMethod("getModelFromResource", Resource.class); } catch (NoSuchMethodException | SecurityException ex) { // seems to be an earlier version of AEM/Sling models not supporting this method log.debug("ModelFactory does not support method 'getModelFromResource' - skip paragraph validation."); return Optional.empty(); } try { // try to get model associated with the resource, and check if it implements the ParsysItem interface Object model = getModelFromResourceMethod.invoke(modelFactory, resource); if (model instanceof ParsysItem) { return Optional.of(((ParsysItem)model).isValid()); } } catch (ModelClassException ex) { // ignore if no model was registered for this resource type } catch (InvocationTargetException ex) { if (ex.getCause() instanceof ModelClassException) { // ignore if no model was registered for this resource type } else { log.warn("Unable to invoke ModelFactory.getModelFromResource.", ex); } } catch (IllegalAccessException ex) { log.warn("Unable to access ModelFactory.getModelFromResource.", ex); } return Optional.empty(); }
[ "private", "Optional", "<", "@", "NotNull", "Boolean", ">", "isParagraphValid", "(", "Resource", "resource", ")", "{", "// use reflection to access the method \"getModelFromResource\" from ModelFactory, as it is not present in earlier version", "// but we want still to support earlier ve...
Checks if the given paragraph is valid. @param resource Resource @return if the return value is empty there is no model associated with this resource, or it does not support validation via {@link ParsysItem} interface. Otherwise it contains the valid status.
[ "Checks", "if", "the", "given", "paragraph", "is", "valid", "." ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/parsys/src/main/java/io/wcm/wcm/parsys/controller/Parsys.java#L202-L237
train
wcm-io/wcm-io-wcm
parsys/src/main/java/io/wcm/wcm/parsys/controller/Parsys.java
Parsys.getComponentHtmlTagAttributes
private Map<String, String> getComponentHtmlTagAttributes(String resourceType) { if (StringUtils.isNotEmpty(resourceType)) { Component component = componentManager().getComponent(resourceType); if (component != null && component.getHtmlTagAttributes() != null) { return component.getHtmlTagAttributes(); } } return ImmutableMap.of(); }
java
private Map<String, String> getComponentHtmlTagAttributes(String resourceType) { if (StringUtils.isNotEmpty(resourceType)) { Component component = componentManager().getComponent(resourceType); if (component != null && component.getHtmlTagAttributes() != null) { return component.getHtmlTagAttributes(); } } return ImmutableMap.of(); }
[ "private", "Map", "<", "String", ",", "String", ">", "getComponentHtmlTagAttributes", "(", "String", "resourceType", ")", "{", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "resourceType", ")", ")", "{", "Component", "component", "=", "componentManager", "("...
Get HTML tag attributes from component. @param resourceType Component path @return Map (never null)
[ "Get", "HTML", "tag", "attributes", "from", "component", "." ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/parsys/src/main/java/io/wcm/wcm/parsys/controller/Parsys.java#L245-L253
train
wcm-io/wcm-io-wcm
parsys/src/main/java/io/wcm/wcm/parsys/controller/Parsys.java
Parsys.getNewAreaResourceType
private String getNewAreaResourceType(String componentPath) { Resource componentResource = resolver.getResource(componentPath); if (componentResource != null) { if (componentResource.getChild(NEWAREA_CHILD_NAME) != null) { return componentPath + "/" + NEWAREA_CHILD_NAME; } String resourceSuperType = componentResource.getResourceSuperType(); if (StringUtils.isNotEmpty(resourceSuperType)) { return getNewAreaResourceType(resourceSuperType); } } return FALLBACK_NEWAREA_RESOURCE_TYPE; }
java
private String getNewAreaResourceType(String componentPath) { Resource componentResource = resolver.getResource(componentPath); if (componentResource != null) { if (componentResource.getChild(NEWAREA_CHILD_NAME) != null) { return componentPath + "/" + NEWAREA_CHILD_NAME; } String resourceSuperType = componentResource.getResourceSuperType(); if (StringUtils.isNotEmpty(resourceSuperType)) { return getNewAreaResourceType(resourceSuperType); } } return FALLBACK_NEWAREA_RESOURCE_TYPE; }
[ "private", "String", "getNewAreaResourceType", "(", "String", "componentPath", ")", "{", "Resource", "componentResource", "=", "resolver", ".", "getResource", "(", "componentPath", ")", ";", "if", "(", "componentResource", "!=", "null", ")", "{", "if", "(", "com...
Get resource type for new area - from current parsys component or from a supertype component. @param componentPath Component path @return Resource type (never null)
[ "Get", "resource", "type", "for", "new", "area", "-", "from", "current", "parsys", "component", "or", "from", "a", "supertype", "component", "." ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/parsys/src/main/java/io/wcm/wcm/parsys/controller/Parsys.java#L287-L299
train
wcm-io/wcm-io-wcm
ui/extjs/src/main/java/io/wcm/wcm/ui/extjs/provider/impl/util/PageIterator.java
PageIterator.seek
private Page seek() { Page prev = next; next = null; while (resources.hasNext() && next == null) { Resource nextResource = resources.next(); next = nextResource.adaptTo(Page.class); if (next == null) { // handle sling:Folder and sling:OrderedFolder as "virtual pages" to allow browsing pages below them String primaryType = nextResource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class); if (StringUtils.equals(primaryType, "sling:Folder") || StringUtils.equals(primaryType, "sling:OrderedFolder")) { next = new SlingFolderVirtualPage(nextResource); } } if (next != null && pageFilter != null && !pageFilter.includes(next)) { next = null; } } return prev; }
java
private Page seek() { Page prev = next; next = null; while (resources.hasNext() && next == null) { Resource nextResource = resources.next(); next = nextResource.adaptTo(Page.class); if (next == null) { // handle sling:Folder and sling:OrderedFolder as "virtual pages" to allow browsing pages below them String primaryType = nextResource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class); if (StringUtils.equals(primaryType, "sling:Folder") || StringUtils.equals(primaryType, "sling:OrderedFolder")) { next = new SlingFolderVirtualPage(nextResource); } } if (next != null && pageFilter != null && !pageFilter.includes(next)) { next = null; } } return prev; }
[ "private", "Page", "seek", "(", ")", "{", "Page", "prev", "=", "next", ";", "next", "=", "null", ";", "while", "(", "resources", ".", "hasNext", "(", ")", "&&", "next", "==", "null", ")", "{", "Resource", "nextResource", "=", "resources", ".", "next"...
Seeks the next available page @return the previous element
[ "Seeks", "the", "next", "available", "page" ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/ui/extjs/src/main/java/io/wcm/wcm/ui/extjs/provider/impl/util/PageIterator.java#L69-L89
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/identity/GenerateEntityIdOnTheClient.java
GenerateEntityIdOnTheClient.tryGetIdFromInstance
public boolean tryGetIdFromInstance(Object entity, Reference<String> idHolder) { if (entity == null) { throw new IllegalArgumentException("Entity cannot be null"); } try { Field identityProperty = getIdentityProperty(entity.getClass()); if (identityProperty != null) { Object value = FieldUtils.readField(identityProperty, entity, true); if (value instanceof String) { idHolder.value = (String)value; return true; } } idHolder.value = null; return false; } catch (IllegalAccessException e) { throw new IllegalStateException(e); } }
java
public boolean tryGetIdFromInstance(Object entity, Reference<String> idHolder) { if (entity == null) { throw new IllegalArgumentException("Entity cannot be null"); } try { Field identityProperty = getIdentityProperty(entity.getClass()); if (identityProperty != null) { Object value = FieldUtils.readField(identityProperty, entity, true); if (value instanceof String) { idHolder.value = (String)value; return true; } } idHolder.value = null; return false; } catch (IllegalAccessException e) { throw new IllegalStateException(e); } }
[ "public", "boolean", "tryGetIdFromInstance", "(", "Object", "entity", ",", "Reference", "<", "String", ">", "idHolder", ")", "{", "if", "(", "entity", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Entity cannot be null\"", ")", ";",...
Attempts to get the document key from an instance @param entity Entity to get id from @param idHolder output parameter which holds document id @return true if id was read from entity
[ "Attempts", "to", "get", "the", "document", "key", "from", "an", "instance" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/identity/GenerateEntityIdOnTheClient.java#L30-L48
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/identity/GenerateEntityIdOnTheClient.java
GenerateEntityIdOnTheClient.getOrGenerateDocumentId
public String getOrGenerateDocumentId(Object entity) { Reference<String> idHolder = new Reference<>(); tryGetIdFromInstance(entity, idHolder); String id = idHolder.value; if (id == null) { // Generate the key up front id = _generateId.apply(entity); } if (id != null && id.startsWith("/")) { throw new IllegalStateException("Cannot use value '" + id + "' as a document id because it begins with a '/'"); } return id; }
java
public String getOrGenerateDocumentId(Object entity) { Reference<String> idHolder = new Reference<>(); tryGetIdFromInstance(entity, idHolder); String id = idHolder.value; if (id == null) { // Generate the key up front id = _generateId.apply(entity); } if (id != null && id.startsWith("/")) { throw new IllegalStateException("Cannot use value '" + id + "' as a document id because it begins with a '/'"); } return id; }
[ "public", "String", "getOrGenerateDocumentId", "(", "Object", "entity", ")", "{", "Reference", "<", "String", ">", "idHolder", "=", "new", "Reference", "<>", "(", ")", ";", "tryGetIdFromInstance", "(", "entity", ",", "idHolder", ")", ";", "String", "id", "="...
Tries to get the identity. @param entity Entity @return Document id
[ "Tries", "to", "get", "the", "identity", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/identity/GenerateEntityIdOnTheClient.java#L55-L68
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/identity/GenerateEntityIdOnTheClient.java
GenerateEntityIdOnTheClient.trySetIdentity
public void trySetIdentity(Object entity, String id) { Class<?> entityType = entity.getClass(); Field identityProperty = _conventions.getIdentityProperty(entityType); if (identityProperty == null) { return; } setPropertyOrField(identityProperty.getType(), entity, identityProperty, id); }
java
public void trySetIdentity(Object entity, String id) { Class<?> entityType = entity.getClass(); Field identityProperty = _conventions.getIdentityProperty(entityType); if (identityProperty == null) { return; } setPropertyOrField(identityProperty.getType(), entity, identityProperty, id); }
[ "public", "void", "trySetIdentity", "(", "Object", "entity", ",", "String", "id", ")", "{", "Class", "<", "?", ">", "entityType", "=", "entity", ".", "getClass", "(", ")", ";", "Field", "identityProperty", "=", "_conventions", ".", "getIdentityProperty", "("...
Tries to set the identity property @param entity Entity @param id Id to set
[ "Tries", "to", "set", "the", "identity", "property" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/identity/GenerateEntityIdOnTheClient.java#L81-L90
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java
DocumentConventions.defaultGetCollectionName
public static String defaultGetCollectionName(Class clazz) { String result = _cachedDefaultTypeCollectionNames.get(clazz); if (result != null) { return result; } // we want to reject queries and other operations on abstract types, because you usually // want to use them for polymorphic queries, and that require the conventions to be // applied properly, so we reject the behavior and hint to the user explicitly if (clazz.isInterface()) { throw new IllegalStateException("Cannot find collection name for interface " + clazz.getName() + ", only concrete classes are supported. Did you forget to customize conventions.findCollectionName?"); } if (Modifier.isAbstract(clazz.getModifiers())) { throw new IllegalStateException("Cannot find collection name for abstract class " + clazz.getName() + ", only concrete class are supported. Did you forget to customize conventions.findCollectionName?"); } result = Inflector.pluralize(clazz.getSimpleName()); _cachedDefaultTypeCollectionNames.put(clazz, result); return result; }
java
public static String defaultGetCollectionName(Class clazz) { String result = _cachedDefaultTypeCollectionNames.get(clazz); if (result != null) { return result; } // we want to reject queries and other operations on abstract types, because you usually // want to use them for polymorphic queries, and that require the conventions to be // applied properly, so we reject the behavior and hint to the user explicitly if (clazz.isInterface()) { throw new IllegalStateException("Cannot find collection name for interface " + clazz.getName() + ", only concrete classes are supported. Did you forget to customize conventions.findCollectionName?"); } if (Modifier.isAbstract(clazz.getModifiers())) { throw new IllegalStateException("Cannot find collection name for abstract class " + clazz.getName() + ", only concrete class are supported. Did you forget to customize conventions.findCollectionName?"); } result = Inflector.pluralize(clazz.getSimpleName()); _cachedDefaultTypeCollectionNames.put(clazz, result); return result; }
[ "public", "static", "String", "defaultGetCollectionName", "(", "Class", "clazz", ")", "{", "String", "result", "=", "_cachedDefaultTypeCollectionNames", ".", "get", "(", "clazz", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "return", "result", ";", ...
Default method used when finding a collection name for a type @param clazz Class @return default collection name for class
[ "Default", "method", "used", "when", "finding", "a", "collection", "name", "for", "a", "type" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java#L297-L318
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java
DocumentConventions.generateDocumentId
@SuppressWarnings("unchecked") public String generateDocumentId(String databaseName, Object entity) { Class<?> clazz = entity.getClass(); for (Tuple<Class, BiFunction<String, Object, String>> listOfRegisteredIdConvention : _listOfRegisteredIdConventions) { if (listOfRegisteredIdConvention.first.isAssignableFrom(clazz)) { return listOfRegisteredIdConvention.second.apply(databaseName, entity); } } return _documentIdGenerator.apply(databaseName, entity); }
java
@SuppressWarnings("unchecked") public String generateDocumentId(String databaseName, Object entity) { Class<?> clazz = entity.getClass(); for (Tuple<Class, BiFunction<String, Object, String>> listOfRegisteredIdConvention : _listOfRegisteredIdConventions) { if (listOfRegisteredIdConvention.first.isAssignableFrom(clazz)) { return listOfRegisteredIdConvention.second.apply(databaseName, entity); } } return _documentIdGenerator.apply(databaseName, entity); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "String", "generateDocumentId", "(", "String", "databaseName", ",", "Object", "entity", ")", "{", "Class", "<", "?", ">", "clazz", "=", "entity", ".", "getClass", "(", ")", ";", "for", "(", "Tup...
Generates the document id. @param databaseName Database name @param entity Entity @return document id
[ "Generates", "the", "document", "id", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java#L354-L365
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java
DocumentConventions.registerIdConvention
@SuppressWarnings("unchecked") public <TEntity> DocumentConventions registerIdConvention(Class<TEntity> clazz, BiFunction<String, TEntity, String> function) { assertNotFrozen(); _listOfRegisteredIdConventions.stream() .filter(x -> x.first.equals(clazz)) .findFirst() .ifPresent(x -> _listOfRegisteredIdConventions.remove(x)); int index; for (index = 0; index < _listOfRegisteredIdConventions.size(); index++) { Tuple<Class, BiFunction<String, Object, String>> entry = _listOfRegisteredIdConventions.get(index); if (entry.first.isAssignableFrom(clazz)) { break; } } _listOfRegisteredIdConventions.add(index, Tuple.create(clazz, (BiFunction<String, Object, String>) function)); return this; }
java
@SuppressWarnings("unchecked") public <TEntity> DocumentConventions registerIdConvention(Class<TEntity> clazz, BiFunction<String, TEntity, String> function) { assertNotFrozen(); _listOfRegisteredIdConventions.stream() .filter(x -> x.first.equals(clazz)) .findFirst() .ifPresent(x -> _listOfRegisteredIdConventions.remove(x)); int index; for (index = 0; index < _listOfRegisteredIdConventions.size(); index++) { Tuple<Class, BiFunction<String, Object, String>> entry = _listOfRegisteredIdConventions.get(index); if (entry.first.isAssignableFrom(clazz)) { break; } } _listOfRegisteredIdConventions.add(index, Tuple.create(clazz, (BiFunction<String, Object, String>) function)); return this; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "TEntity", ">", "DocumentConventions", "registerIdConvention", "(", "Class", "<", "TEntity", ">", "clazz", ",", "BiFunction", "<", "String", ",", "TEntity", ",", "String", ">", "function", ")", ...
Register an id convention for a single type (and all of its derived types. Note that you can still fall back to the DocumentIdGenerator if you want. @param <TEntity> Entity class @param clazz Class @param function Function to use @return document conventions
[ "Register", "an", "id", "convention", "for", "a", "single", "type", "(", "and", "all", "of", "its", "derived", "types", ".", "Note", "that", "you", "can", "still", "fall", "back", "to", "the", "DocumentIdGenerator", "if", "you", "want", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java#L375-L395
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java
DocumentConventions.getIdentityProperty
public Field getIdentityProperty(Class clazz) { Field info = _idPropertyCache.get(clazz); if (info != null) { return info; } try { Field idField = Arrays.stream(Introspector.getBeanInfo(clazz).getPropertyDescriptors()) .filter(x -> _findIdentityProperty.apply(x)) .findFirst() .map(x -> getField(clazz, x.getName())) .orElse(null); _idPropertyCache.put(clazz, idField); return idField; } catch (IntrospectionException e) { throw new RuntimeException(e); } }
java
public Field getIdentityProperty(Class clazz) { Field info = _idPropertyCache.get(clazz); if (info != null) { return info; } try { Field idField = Arrays.stream(Introspector.getBeanInfo(clazz).getPropertyDescriptors()) .filter(x -> _findIdentityProperty.apply(x)) .findFirst() .map(x -> getField(clazz, x.getName())) .orElse(null); _idPropertyCache.put(clazz, idField); return idField; } catch (IntrospectionException e) { throw new RuntimeException(e); } }
[ "public", "Field", "getIdentityProperty", "(", "Class", "clazz", ")", "{", "Field", "info", "=", "_idPropertyCache", ".", "get", "(", "clazz", ")", ";", "if", "(", "info", "!=", "null", ")", "{", "return", "info", ";", "}", "try", "{", "Field", "idFiel...
Gets the identity property. @param clazz Class of entity @return Identity property (field)
[ "Gets", "the", "identity", "property", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java#L462-L481
train
wcm-io/wcm-io-wcm
ui/granite/src/main/java/io/wcm/wcm/ui/granite/components/pathfield/ColumnView.java
ColumnView.getDataSource
private DataSource getDataSource(ComponentHelper cmp, Resource resource) { try { /* * by default the path is read from request "path" parameter * here we overwrite it via a synthetic resource because the path may be overwritten by validation logic * to ensure the path is not beyond the configured root path */ ValueMap overwriteProperties = new ValueMapDecorator(ImmutableMap.<String, Object>of("path", resource.getPath())); Resource dataSourceResourceWrapper = GraniteUiSyntheticResource.wrapMerge(request.getResource(), overwriteProperties); return cmp.getItemDataSource(dataSourceResourceWrapper); } catch (ServletException | IOException ex) { throw new RuntimeException("Unable to get data source.", ex); } }
java
private DataSource getDataSource(ComponentHelper cmp, Resource resource) { try { /* * by default the path is read from request "path" parameter * here we overwrite it via a synthetic resource because the path may be overwritten by validation logic * to ensure the path is not beyond the configured root path */ ValueMap overwriteProperties = new ValueMapDecorator(ImmutableMap.<String, Object>of("path", resource.getPath())); Resource dataSourceResourceWrapper = GraniteUiSyntheticResource.wrapMerge(request.getResource(), overwriteProperties); return cmp.getItemDataSource(dataSourceResourceWrapper); } catch (ServletException | IOException ex) { throw new RuntimeException("Unable to get data source.", ex); } }
[ "private", "DataSource", "getDataSource", "(", "ComponentHelper", "cmp", ",", "Resource", "resource", ")", "{", "try", "{", "/*\n * by default the path is read from request \"path\" parameter\n * here we overwrite it via a synthetic resource because the path may be overwritten ...
Get data source to list children of given resource. @param cmp Component helper @param resource Given resource @return Data source
[ "Get", "data", "source", "to", "list", "children", "of", "given", "resource", "." ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/ui/granite/src/main/java/io/wcm/wcm/ui/granite/components/pathfield/ColumnView.java#L132-L146
train
wcm-io/wcm-io-wcm
ui/granite/src/main/java/io/wcm/wcm/ui/granite/components/pathfield/ColumnView.java
ColumnView.getCurrentResourceColumn
private static Column getCurrentResourceColumn(DataSource dataSource, Integer size, Resource currentResource, String itemResourceType) { Iterator<Resource> items = dataSource.iterator(); boolean hasMore = false; if (size != null) { List<Resource> list = new ArrayList<Resource>(); while (items.hasNext() && list.size() < size) { list.add(items.next()); } hasMore = items.hasNext(); items = list.iterator(); } Column column = new Column() .columnId(currentResource.getPath()) .hasMore(hasMore) .metaElement(true); while (items.hasNext()) { Resource item = items.next(); column.addItem(new ColumnItem(item) .resourceType(itemResourceType)); } return column; }
java
private static Column getCurrentResourceColumn(DataSource dataSource, Integer size, Resource currentResource, String itemResourceType) { Iterator<Resource> items = dataSource.iterator(); boolean hasMore = false; if (size != null) { List<Resource> list = new ArrayList<Resource>(); while (items.hasNext() && list.size() < size) { list.add(items.next()); } hasMore = items.hasNext(); items = list.iterator(); } Column column = new Column() .columnId(currentResource.getPath()) .hasMore(hasMore) .metaElement(true); while (items.hasNext()) { Resource item = items.next(); column.addItem(new ColumnItem(item) .resourceType(itemResourceType)); } return column; }
[ "private", "static", "Column", "getCurrentResourceColumn", "(", "DataSource", "dataSource", ",", "Integer", "size", ",", "Resource", "currentResource", ",", "String", "itemResourceType", ")", "{", "Iterator", "<", "Resource", ">", "items", "=", "dataSource", ".", ...
Generate column for data source items for current resource. @param dataSource Data source @param size Size limit @param currentResource Current resource @param itemResourceType Item resource type @return Column
[ "Generate", "column", "for", "data", "source", "items", "for", "current", "resource", "." ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/ui/granite/src/main/java/io/wcm/wcm/ui/granite/components/pathfield/ColumnView.java#L156-L182
train
wcm-io/wcm-io-wcm
ui/granite/src/main/java/io/wcm/wcm/ui/granite/components/pathfield/ColumnView.java
ColumnView.getRootColumn
private static Column getRootColumn(Resource rootResource, String itemResourceType) { /* * Put a special path for columnId to avoid having the same columnId with the next column to avoid breaking the contract of columnId. * The contract of columnId is that it should be a path of the current column, i.e. the path should be a path representing a parent. * e.g. When columnId = "/", then the column will show the children of this path, such as "/a", "/b". * So for showRoot scenario, if we want to show the item with path = "/", we need to generate the column having a columnId with value of the parent of "/". * Since the cannot have a parent of "/", then we decide to just use a special convention ("parentof:<path>") to indicate this. * Other component (e.g. `.granite-collection-navigator`) reading the columnId can then understand this convention and handle it accordingly. */ String columnId = "parentof:" + rootResource.getPath(); Column column = new Column() .columnId(columnId) .hasMore(false); column.addItem(new ColumnItem(rootResource) .resourceType(itemResourceType) .active(true)); return column; }
java
private static Column getRootColumn(Resource rootResource, String itemResourceType) { /* * Put a special path for columnId to avoid having the same columnId with the next column to avoid breaking the contract of columnId. * The contract of columnId is that it should be a path of the current column, i.e. the path should be a path representing a parent. * e.g. When columnId = "/", then the column will show the children of this path, such as "/a", "/b". * So for showRoot scenario, if we want to show the item with path = "/", we need to generate the column having a columnId with value of the parent of "/". * Since the cannot have a parent of "/", then we decide to just use a special convention ("parentof:<path>") to indicate this. * Other component (e.g. `.granite-collection-navigator`) reading the columnId can then understand this convention and handle it accordingly. */ String columnId = "parentof:" + rootResource.getPath(); Column column = new Column() .columnId(columnId) .hasMore(false); column.addItem(new ColumnItem(rootResource) .resourceType(itemResourceType) .active(true)); return column; }
[ "private", "static", "Column", "getRootColumn", "(", "Resource", "rootResource", ",", "String", "itemResourceType", ")", "{", "/*\n * Put a special path for columnId to avoid having the same columnId with the next column to avoid breaking the contract of columnId.\n * The contract of...
Generate extra column representing the root resource. @param rootResource Root resource @param itemResourceType Item resource type @return Column
[ "Generate", "extra", "column", "representing", "the", "root", "resource", "." ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/ui/granite/src/main/java/io/wcm/wcm/ui/granite/components/pathfield/ColumnView.java#L190-L208
train
wcm-io/wcm-io-wcm
ui/granite/src/main/java/io/wcm/wcm/ui/granite/components/pathfield/ColumnView.java
ColumnView.getAncestorColumns
private static List<Column> getAncestorColumns(Resource currentResource, Resource rootResource) { List<Column> columns = new ArrayList<>(); List<Resource> ancestors = getAncestors(currentResource, rootResource); for (int i = 0; i < ancestors.size(); i++) { Resource r = ancestors.get(i); String activeId; if (i < ancestors.size() - 1) { activeId = ancestors.get(i + 1).getPath(); } else { activeId = currentResource.getPath(); } Column column = new Column() .columnId(r.getPath()) .lazy(true) .activeId(activeId); columns.add(column); } return columns; }
java
private static List<Column> getAncestorColumns(Resource currentResource, Resource rootResource) { List<Column> columns = new ArrayList<>(); List<Resource> ancestors = getAncestors(currentResource, rootResource); for (int i = 0; i < ancestors.size(); i++) { Resource r = ancestors.get(i); String activeId; if (i < ancestors.size() - 1) { activeId = ancestors.get(i + 1).getPath(); } else { activeId = currentResource.getPath(); } Column column = new Column() .columnId(r.getPath()) .lazy(true) .activeId(activeId); columns.add(column); } return columns; }
[ "private", "static", "List", "<", "Column", ">", "getAncestorColumns", "(", "Resource", "currentResource", ",", "Resource", "rootResource", ")", "{", "List", "<", "Column", ">", "columns", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "Resource"...
Generate column for each ancestor. @param currentResource Current resource @param rootResource Root resource @return Columns
[ "Generate", "column", "for", "each", "ancestor", "." ]
8eff9434f2f4b6462fdb718f8769ad793c55b8d7
https://github.com/wcm-io/wcm-io-wcm/blob/8eff9434f2f4b6462fdb718f8769ad793c55b8d7/ui/granite/src/main/java/io/wcm/wcm/ui/granite/components/pathfield/ColumnView.java#L216-L237
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery._waitForNonStaleResults
@Override public void _waitForNonStaleResults(Duration waitTimeout) { theWaitForNonStaleResults = true; timeout = ObjectUtils.firstNonNull(waitTimeout, getDefaultTimeout()); }
java
@Override public void _waitForNonStaleResults(Duration waitTimeout) { theWaitForNonStaleResults = true; timeout = ObjectUtils.firstNonNull(waitTimeout, getDefaultTimeout()); }
[ "@", "Override", "public", "void", "_waitForNonStaleResults", "(", "Duration", "waitTimeout", ")", "{", "theWaitForNonStaleResults", "=", "true", ";", "timeout", "=", "ObjectUtils", ".", "firstNonNull", "(", "waitTimeout", ",", "getDefaultTimeout", "(", ")", ")", ...
Instruct the query to wait for non stale result for the specified wait timeout. This shouldn't be used outside of unit tests unless you are well aware of the implications @param waitTimeout Wait timeout
[ "Instruct", "the", "query", "to", "wait", "for", "non", "stale", "result", "for", "the", "specified", "wait", "timeout", ".", "This", "shouldn", "t", "be", "used", "outside", "of", "unit", "tests", "unless", "you", "are", "well", "aware", "of", "the", "i...
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L190-L194
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery.getProjectionFields
@Override public List<String> getProjectionFields() { return fieldsToFetchToken != null && fieldsToFetchToken.projections != null ? Arrays.asList(fieldsToFetchToken.projections) : Collections.emptyList(); }
java
@Override public List<String> getProjectionFields() { return fieldsToFetchToken != null && fieldsToFetchToken.projections != null ? Arrays.asList(fieldsToFetchToken.projections) : Collections.emptyList(); }
[ "@", "Override", "public", "List", "<", "String", ">", "getProjectionFields", "(", ")", "{", "return", "fieldsToFetchToken", "!=", "null", "&&", "fieldsToFetchToken", ".", "projections", "!=", "null", "?", "Arrays", ".", "asList", "(", "fieldsToFetchToken", ".",...
Gets the fields for projection @return list of projected fields
[ "Gets", "the", "fields", "for", "projection" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L213-L216
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery._randomOrdering
@Override public void _randomOrdering(String seed) { assertNoRawQuery(); if (StringUtils.isBlank(seed)) { _randomOrdering(); return; } _noCaching(); orderByTokens.add(OrderByToken.createRandom(seed)); }
java
@Override public void _randomOrdering(String seed) { assertNoRawQuery(); if (StringUtils.isBlank(seed)) { _randomOrdering(); return; } _noCaching(); orderByTokens.add(OrderByToken.createRandom(seed)); }
[ "@", "Override", "public", "void", "_randomOrdering", "(", "String", "seed", ")", "{", "assertNoRawQuery", "(", ")", ";", "if", "(", "StringUtils", ".", "isBlank", "(", "seed", ")", ")", "{", "_randomOrdering", "(", ")", ";", "return", ";", "}", "_noCach...
Order the search results randomly using the specified seed this is useful if you want to have repeatable random queries @param seed Seed to use
[ "Order", "the", "search", "results", "randomly", "using", "the", "specified", "seed", "this", "is", "useful", "if", "you", "want", "to", "have", "repeatable", "random", "queries" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L234-L245
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery._whereLucene
@SuppressWarnings("ConstantConditions") public void _whereLucene(String fieldName, String whereClause, boolean exact) { fieldName = ensureValidFieldName(fieldName, false); List<QueryToken> tokens = getCurrentWhereTokens(); appendOperatorIfNeeded(tokens); negateIfNeeded(tokens, fieldName); WhereToken.WhereOptions options = exact ? new WhereToken.WhereOptions(exact) : null; WhereToken whereToken = WhereToken.create(WhereOperator.LUCENE, fieldName, addQueryParameter(whereClause), options); tokens.add(whereToken); }
java
@SuppressWarnings("ConstantConditions") public void _whereLucene(String fieldName, String whereClause, boolean exact) { fieldName = ensureValidFieldName(fieldName, false); List<QueryToken> tokens = getCurrentWhereTokens(); appendOperatorIfNeeded(tokens); negateIfNeeded(tokens, fieldName); WhereToken.WhereOptions options = exact ? new WhereToken.WhereOptions(exact) : null; WhereToken whereToken = WhereToken.create(WhereOperator.LUCENE, fieldName, addQueryParameter(whereClause), options); tokens.add(whereToken); }
[ "@", "SuppressWarnings", "(", "\"ConstantConditions\"", ")", "public", "void", "_whereLucene", "(", "String", "fieldName", ",", "String", "whereClause", ",", "boolean", "exact", ")", "{", "fieldName", "=", "ensureValidFieldName", "(", "fieldName", ",", "false", ")...
Filter the results from the index using the specified where clause. @param fieldName Field name @param whereClause Where clause @param exact Use exact matcher
[ "Filter", "the", "results", "from", "the", "index", "using", "the", "specified", "where", "clause", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L413-L424
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery._openSubclause
@Override public void _openSubclause() { _currentClauseDepth++; List<QueryToken> tokens = getCurrentWhereTokens(); appendOperatorIfNeeded(tokens); negateIfNeeded(tokens, null); tokens.add(OpenSubclauseToken.INSTANCE); }
java
@Override public void _openSubclause() { _currentClauseDepth++; List<QueryToken> tokens = getCurrentWhereTokens(); appendOperatorIfNeeded(tokens); negateIfNeeded(tokens, null); tokens.add(OpenSubclauseToken.INSTANCE); }
[ "@", "Override", "public", "void", "_openSubclause", "(", ")", "{", "_currentClauseDepth", "++", ";", "List", "<", "QueryToken", ">", "tokens", "=", "getCurrentWhereTokens", "(", ")", ";", "appendOperatorIfNeeded", "(", "tokens", ")", ";", "negateIfNeeded", "(",...
Simplified method for opening a new clause within the query
[ "Simplified", "method", "for", "opening", "a", "new", "clause", "within", "the", "query" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L429-L438
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery._closeSubclause
@Override public void _closeSubclause() { _currentClauseDepth--; List<QueryToken> tokens = getCurrentWhereTokens(); tokens.add(CloseSubclauseToken.INSTANCE); }
java
@Override public void _closeSubclause() { _currentClauseDepth--; List<QueryToken> tokens = getCurrentWhereTokens(); tokens.add(CloseSubclauseToken.INSTANCE); }
[ "@", "Override", "public", "void", "_closeSubclause", "(", ")", "{", "_currentClauseDepth", "--", ";", "List", "<", "QueryToken", ">", "tokens", "=", "getCurrentWhereTokens", "(", ")", ";", "tokens", ".", "add", "(", "CloseSubclauseToken", ".", "INSTANCE", ")"...
Simplified method for closing a clause within the query
[ "Simplified", "method", "for", "closing", "a", "clause", "within", "the", "query" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L443-L449
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery._whereIn
@Override public void _whereIn(String fieldName, Collection<Object> values) { _whereIn(fieldName, values, false); }
java
@Override public void _whereIn(String fieldName, Collection<Object> values) { _whereIn(fieldName, values, false); }
[ "@", "Override", "public", "void", "_whereIn", "(", "String", "fieldName", ",", "Collection", "<", "Object", ">", "values", ")", "{", "_whereIn", "(", "fieldName", ",", "values", ",", "false", ")", ";", "}" ]
Check that the field has one of the specified value @param fieldName Field name to use @param values Values to find
[ "Check", "that", "the", "field", "has", "one", "of", "the", "specified", "value" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L577-L580
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery._whereEndsWith
public void _whereEndsWith(String fieldName, Object value, boolean exact) { WhereParams whereParams = new WhereParams(); whereParams.setFieldName(fieldName); whereParams.setValue(value); whereParams.setAllowWildcards(true); Object transformToEqualValue = transformValue(whereParams); List<QueryToken> tokens = getCurrentWhereTokens(); appendOperatorIfNeeded(tokens); whereParams.setFieldName(ensureValidFieldName(whereParams.getFieldName(), whereParams.isNestedPath())); negateIfNeeded(tokens, whereParams.getFieldName()); WhereToken whereToken = WhereToken.create(WhereOperator.ENDS_WITH, whereParams.getFieldName(), addQueryParameter(transformToEqualValue), new WhereToken.WhereOptions(exact)); tokens.add(whereToken); }
java
public void _whereEndsWith(String fieldName, Object value, boolean exact) { WhereParams whereParams = new WhereParams(); whereParams.setFieldName(fieldName); whereParams.setValue(value); whereParams.setAllowWildcards(true); Object transformToEqualValue = transformValue(whereParams); List<QueryToken> tokens = getCurrentWhereTokens(); appendOperatorIfNeeded(tokens); whereParams.setFieldName(ensureValidFieldName(whereParams.getFieldName(), whereParams.isNestedPath())); negateIfNeeded(tokens, whereParams.getFieldName()); WhereToken whereToken = WhereToken.create(WhereOperator.ENDS_WITH, whereParams.getFieldName(), addQueryParameter(transformToEqualValue), new WhereToken.WhereOptions(exact)); tokens.add(whereToken); }
[ "public", "void", "_whereEndsWith", "(", "String", "fieldName", ",", "Object", "value", ",", "boolean", "exact", ")", "{", "WhereParams", "whereParams", "=", "new", "WhereParams", "(", ")", ";", "whereParams", ".", "setFieldName", "(", "fieldName", ")", ";", ...
Matches fields which ends with the specified value. @param fieldName Field name to use @param value Values to find
[ "Matches", "fields", "which", "ends", "with", "the", "specified", "value", "." ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L631-L647
train
ravendb/ravendb-jvm-client
src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java
AbstractDocumentQuery._whereBetween
@Override public void _whereBetween(String fieldName, Object start, Object end, boolean exact) { fieldName = ensureValidFieldName(fieldName, false); List<QueryToken> tokens = getCurrentWhereTokens(); appendOperatorIfNeeded(tokens); negateIfNeeded(tokens, fieldName); WhereParams startParams = new WhereParams(); startParams.setValue(start); startParams.setFieldName(fieldName); WhereParams endParams = new WhereParams(); endParams.setValue(end); endParams.setFieldName(fieldName); String fromParameterName = addQueryParameter(start == null ? "*" : transformValue(startParams, true)); String toParameterName = addQueryParameter(end == null ? "NULL" : transformValue(endParams, true)); WhereToken whereToken = WhereToken.create(WhereOperator.BETWEEN, fieldName, null, new WhereToken.WhereOptions(exact, fromParameterName, toParameterName)); tokens.add(whereToken); }
java
@Override public void _whereBetween(String fieldName, Object start, Object end, boolean exact) { fieldName = ensureValidFieldName(fieldName, false); List<QueryToken> tokens = getCurrentWhereTokens(); appendOperatorIfNeeded(tokens); negateIfNeeded(tokens, fieldName); WhereParams startParams = new WhereParams(); startParams.setValue(start); startParams.setFieldName(fieldName); WhereParams endParams = new WhereParams(); endParams.setValue(end); endParams.setFieldName(fieldName); String fromParameterName = addQueryParameter(start == null ? "*" : transformValue(startParams, true)); String toParameterName = addQueryParameter(end == null ? "NULL" : transformValue(endParams, true)); WhereToken whereToken = WhereToken.create(WhereOperator.BETWEEN, fieldName, null, new WhereToken.WhereOptions(exact, fromParameterName, toParameterName)); tokens.add(whereToken); }
[ "@", "Override", "public", "void", "_whereBetween", "(", "String", "fieldName", ",", "Object", "start", ",", "Object", "end", ",", "boolean", "exact", ")", "{", "fieldName", "=", "ensureValidFieldName", "(", "fieldName", ",", "false", ")", ";", "List", "<", ...
Matches fields where the value is between the specified start and end, inclusive @param fieldName Field name to use @param start Range start @param end Range end @param exact Use exact matcher
[ "Matches", "fields", "where", "the", "value", "is", "between", "the", "specified", "start", "and", "end", "inclusive" ]
5a45727de507b541d1571e79ddd97c7d88bee787
https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/session/AbstractDocumentQuery.java#L661-L682
train