idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
131,500
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 .
131,501
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 ...
Calculates the height of the hash tree in case a new node would be added .
131,502
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 .
131,503
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 .
131,504
public KSIBuilder setKsiProtocolSignerClient ( KSISigningClient signingClient ) { Util . notNull ( signingClient , "KSI Signing Client" ) ; return setKsiProtocolSigningService ( new KSISigningClientServiceAdapter ( signingClient ) ) ; }
Sets the signer client to be used in signing process .
131,505
public KSIBuilder setKsiProtocolExtenderClient ( KSIExtenderClient extenderClient ) { Util . notNull ( extenderClient , "KSI Extender Client" ) ; return setKsiProtocolExtendingService ( new KSIExtendingClientServiceAdapter ( extenderClient ) ) ; }
Sets the extender client to be used in verification and extending process .
131,506
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 . getSubjec...
This method is used to check if certificate is trusted or not .
131,507
@ 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 ...
This method is used to find file from disk or classpath .
131,508
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 ) ; re...
Returns a publication string that is a base - 32 encoded value that is meant published to print media as human readable text
131,509
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 ) { thro...
Calculates the MAC based on header and payload TLVs .
131,510
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 .
131,511
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 c...
Builds the verification context .
131,512
private String getIdentityFromLegacyId ( ) throws CharacterCodingException { byte [ ] data = legacyId ; int len = Util . toShort ( data , 1 ) ; return Util . decodeString ( data , 3 , len ) ; }
Decodes link identity from legacy id .
131,513
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 ( ) + "...
Hash two hashes together .
131,514
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 ( ele...
Reads the next TLV element from the stream .
131,515
private byte [ ] readTlvContent ( TlvHeader header ) throws IOException { byte [ ] data = new byte [ header . getDataLength ( ) ] ; in . readFully ( data ) ; return data ; }
Reads the TLV content bytes from the underlying stream .
131,516
public static ContextAwarePolicy createPolicy ( Policy policy , PublicationsHandler handler , KSIExtendingService extendingService ) { if ( policy instanceof UserProvidedPublicationBasedVerificationPolicy ) { throw new IllegalArgumentException ( "Unsupported verification policy." ) ; } Util . notNull ( handler , "Publi...
Method creating context aware policy using user provided policy with needed components .
131,517
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 . setFallbackPoli...
Sets a fallback policy to be used when signature does not verify with given policy .
131,518
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 ( Codin...
Decodes UTF - 8 string from the given buffer .
131,519
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 ( CharBu...
Encodes the given string in UTF - 8 .
131,520
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 ...
Creates a copy of a section of the given byte array .
131,521
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 ; }
Joins two byte arrays into one .
131,522
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...
Decodes an unsigned integer from the given buffer .
131,523
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 ( ) . replace...
Calculates the RFC 2104 compatible HMAC for the given message key and algorithm .
131,524
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 ) ) ; }
Checks if two collections are equal ignoring the order of components . It s safe to pass collections that might be null .
131,525
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" ) ; } }
Checks if the TLV element is critical or not .
131,526
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 subserv...
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 .
131,527
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 .
131,528
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 ) ; } } ca...
Adds data to the digest using the specified input stream of bytes starting at an offset of 0 .
131,529
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, whe...
Adds data to the digest using the specified file starting at the offset 0 .
131,530
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 ; } }
Adds the values for the given characters to the value lookup table .
131,531
public final StringBuffer encode ( byte [ ] in , int off , int len , String sep , int freq ) { 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 ...
Encodes the given bytes into a base - X string optionally inserting a separator into the result with given frequency .
131,532
public final byte [ ] decode ( String in ) { if ( in == null ) { throw new NullPointerException ( ) ; } byte [ ] out = new byte [ in . length ( ) * bits / 8 ] ; int outCount = 0 ; int inCount = 0 ; int buf = 0 ; int bufBits = 0 ; while ( inCount < in . length ( ) ) { int next = in . codePointAt ( inCount ) ; inCount ++...
Decodes the given base - X string into bytes silently ignoring any non - base - X characters .
131,533
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 InvalidPublicationsFile...
Decodes publications file . Reads publications data from given input stream .
131,534
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...
Verifies that input stream starts with publications file magic bytes .
131,535
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 : certificateRecord...
Finds a certificate by certificate id .
131,536
public PublicationRecord getPublicationRecord ( Date time ) { PublicationRecord nearest = null ; for ( PublicationRecord publicationRecord : publicationRecords ) { Date publicationTime = publicationRecord . getPublicationData ( ) . getPublicationTime ( ) ; if ( publicationTime . equals ( time ) || publicationTime . aft...
Returns the closest publication record to given time .
131,537
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 ) ; ...
Get publications file bytes without signature .
131,538
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...
Calculates chain index
131,539
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 Mu...
Creates TLVElement form byte array .
131,540
public static TLVElement create ( int type , byte [ ] value ) throws TLVParserException { TLVElement element = create ( type ) ; element . setContent ( value ) ; return element ; }
Creates TLV element with byte array content . TLV element nonCritical and forwarded flags are set to false .
131,541
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 (...
Converts the TLV element content data to UTF - 8 string .
131,542
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 ...
Gets HashAlgorithm form TLV element .
131,543
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 ; }
Returns the TLV content . If TLV does not include content then empty array is returned .
131,544
public void setContent ( byte [ ] content ) throws TLVParserException { Util . notNull ( content , "Content" ) ; assertActualContentLengthIsInTLVLimits ( content . length ) ; this . content = content ; }
Sets the value to TLV element content .
131,545
public TLVElement getFirstChildElement ( int tag ) { for ( TLVElement element : children ) { if ( tag == element . getType ( ) ) { return element ; } } return null ; }
Returns the first child element with specified tag . If tag doesn t exist then null is returned .
131,546
public List < TLVElement > getChildElements ( int tag ) { List < TLVElement > elements = new LinkedList < > ( ) ; for ( TLVElement element : children ) { if ( tag == element . getType ( ) ) { elements . add ( element ) ; } } return elements ; }
Returns all the tags with the specified tag .
131,547
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 ...
Encodes TLV header .
131,548
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 ; } } }
Replaces first element with given one .
131,549
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 ...
Writes the encoded TLV element to the specified output stream .
131,550
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 ) { return in . getUnsigned ( ) + TLV8_HEADER_LENGTH ; } in . skip ( 1 ) ; i...
Returns the length of the next TLV element . Returns - 1 when buffer doesn t contain enough data for next TLV element .
131,551
public Server create ( ServerCreateOptions serverCreateOptions ) throws IOException , MailosaurException { return client . request ( "POST" , "api/servers" , serverCreateOptions ) . parseAs ( Server . class ) ; }
Create a server . Creates a new virtual SMTP server and returns it .
131,552
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 .
131,553
public Server update ( String id , Server server ) throws IOException , MailosaurException { return client . request ( "PUT" , "api/servers/" + id , server ) . parseAs ( Server . class ) ; }
Update a server . Updats a single server and returns it .
131,554
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 .
131,555
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 ) ; }
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 .
131,556
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 ) ; }
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 .
131,557
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 ( Me...
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 .
131,558
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 . cl...
Wait for a specific message . Returns as soon as an message matching the specified search criteria is found .
131,559
public SpamAnalysisResult spam ( String email ) throws IOException , MailosaurException { return client . request ( "GET" , "api/analysis/spam/" + email ) . parseAs ( SpamAnalysisResult . class ) ; }
Perform spam analysis on the specified email .
131,560
@ RequestMapping ( value = "/checkout/complete" , method = RequestMethod . POST ) public String completeCheckout ( ) throws PaymentException { paymentService . updatePayPalPaymentForFulfillment ( ) ; String paymentId = paymentService . getPayPalPaymentIdFromCurrentOrder ( ) ; String payerId = paymentService . getPayPal...
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 .
131,561
public Signature getSignatureFrom ( SignerIdentifier signer ) { return signatures . stream ( ) . filter ( signatureFrom ( signer ) ) . findFirst ( ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "Unable to find signature from this signer" ) ) ; }
Gets the signature from a given signer .
131,562
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" ) ; }
Gets the redirect URL for a given signer .
131,563
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 ( )...
Gets the metadata for the specified entity .
131,564
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 . Me...
Gets all counter names for the specified entity .
131,565
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_VECTO...
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 .
131,566
public String getDocumentId ( Object instance ) { if ( instance == null ) { return null ; } DocumentInfo value = documentsByEntity . get ( instance ) ; return value != null ? value . getId ( ) : null ; }
Gets the document id .
131,567
@ SuppressWarnings ( "unchecked" ) public < T > T trackEntity ( Class < T > clazz , DocumentInfo documentFound ) { return ( T ) trackEntity ( clazz , documentFound . getId ( ) , documentFound . getDocument ( ) , documentFound . getMetadata ( ) , noTracking ) ; }
Tracks the entity inside the unit of work
131,568
public Object trackEntity ( Class entityType , String id , ObjectNode document , ObjectNode metadata , boolean noTracking ) { noTracking = this . noTracking || noTracking ; if ( StringUtils . isEmpty ( id ) ) { return deserializeFromTransformer ( entityType , null , document ) ; } DocumentInfo docInfo = documentsById ....
Tracks the entity .
131,569
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 entit...
Marks the specified entity for deletion . The entity will be deleted when SaveChanges is called .
131,570
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 ) ; }
Stores the specified entity in the session . The entity will be saved when SaveChanges is called .
131,571
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...
Gets a value indicating whether any of the entities tracked by the session has changes .
131,572
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 ) ; }
Determines whether the specified entity has changed .
131,573
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 ....
Evicts the specified entity from the session . Remove the entity from the delete queue and stops tracking changes for this entity .
131,574
public void clear ( ) { documentsByEntity . clear ( ) ; deletedEntities . clear ( ) ; documentsById . clear ( ) ; _knownMissingIds . clear ( ) ; if ( _countersByDocId != null ) { _countersByDocId . clear ( ) ; } }
Clears this instance . Remove all entities from the delete queue and stops tracking changes for all entities .
131,575
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 ...
Get paths for pages that use the given template
131,576
private Optional < Boolean > isParagraphValid ( Resource resource ) { Method getModelFromResourceMethod ; try { getModelFromResourceMethod = ModelFactory . class . getDeclaredMethod ( "getModelFromResource" , Resource . class ) ; } catch ( NoSuchMethodException | SecurityException ex ) { log . debug ( "ModelFactory doe...
Checks if the given paragraph is valid .
131,577
private Map < String , String > getComponentHtmlTagAttributes ( String resourceType ) { if ( StringUtils . isNotEmpty ( resourceType ) ) { Component component = componentManager ( ) . getComponent ( resourceType ) ; if ( component != null && component . getHtmlTagAttributes ( ) != null ) { return component . getHtmlTag...
Get HTML tag attributes from component .
131,578
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 = ...
Get resource type for new area - from current parsys component or from a supertype component .
131,579
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 ) { String primaryType = nextResource . getValueMap ( ) . get ( JcrConstants . JCR_PRIMARYTYPE , ...
Seeks the next available page
131,580
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 . ...
Attempts to get the document key from an instance
131,581
public String getOrGenerateDocumentId ( Object entity ) { Reference < String > idHolder = new Reference < > ( ) ; tryGetIdFromInstance ( entity , idHolder ) ; String id = idHolder . value ; if ( id == null ) { id = _generateId . apply ( entity ) ; } if ( id != null && id . startsWith ( "/" ) ) { throw new IllegalStateE...
Tries to get the identity .
131,582
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 ) ; }
Tries to set the identity property
131,583
public static String defaultGetCollectionName ( Class clazz ) { String result = _cachedDefaultTypeCollectionNames . get ( clazz ) ; if ( result != null ) { return result ; } if ( clazz . isInterface ( ) ) { throw new IllegalStateException ( "Cannot find collection name for interface " + clazz . getName ( ) + ", only co...
Default method used when finding a collection name for a type
131,584
@ SuppressWarnings ( "unchecked" ) public String generateDocumentId ( String databaseName , Object entity ) { Class < ? > clazz = entity . getClass ( ) ; for ( Tuple < Class , BiFunction < String , Object , String > > listOfRegisteredIdConvention : _listOfRegisteredIdConventions ) { if ( listOfRegisteredIdConvention . ...
Generates the document id .
131,585
@ 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 ( ...
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 .
131,586
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...
Gets the identity property .
131,587
private DataSource getDataSource ( ComponentHelper cmp , Resource resource ) { try { ValueMap overwriteProperties = new ValueMapDecorator ( ImmutableMap . < String , Object > of ( "path" , resource . getPath ( ) ) ) ; Resource dataSourceResourceWrapper = GraniteUiSyntheticResource . wrapMerge ( request . getResource ( ...
Get data source to list children of given resource .
131,588
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...
Generate column for data source items for current resource .
131,589
private static Column getRootColumn ( Resource rootResource , String itemResourceType ) { String columnId = "parentof:" + rootResource . getPath ( ) ; Column column = new Column ( ) . columnId ( columnId ) . hasMore ( false ) ; column . addItem ( new ColumnItem ( rootResource ) . resourceType ( itemResourceType ) . act...
Generate extra column representing the root resource .
131,590
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 ( ...
Generate column for each ancestor .
131,591
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
131,592
public List < String > getProjectionFields ( ) { return fieldsToFetchToken != null && fieldsToFetchToken . projections != null ? Arrays . asList ( fieldsToFetchToken . projections ) : Collections . emptyList ( ) ; }
Gets the fields for projection
131,593
public void _randomOrdering ( String seed ) { assertNoRawQuery ( ) ; if ( StringUtils . isBlank ( seed ) ) { _randomOrdering ( ) ; return ; } _noCaching ( ) ; orderByTokens . add ( OrderByToken . createRandom ( seed ) ) ; }
Order the search results randomly using the specified seed this is useful if you want to have repeatable random queries
131,594
@ SuppressWarnings ( "ConstantConditions" ) public void _whereLucene ( String fieldName , String whereClause , boolean exact ) { fieldName = ensureValidFieldName ( fieldName , false ) ; List < QueryToken > tokens = getCurrentWhereTokens ( ) ; appendOperatorIfNeeded ( tokens ) ; negateIfNeeded ( tokens , fieldName ) ; W...
Filter the results from the index using the specified where clause .
131,595
public void _openSubclause ( ) { _currentClauseDepth ++ ; List < QueryToken > tokens = getCurrentWhereTokens ( ) ; appendOperatorIfNeeded ( tokens ) ; negateIfNeeded ( tokens , null ) ; tokens . add ( OpenSubclauseToken . INSTANCE ) ; }
Simplified method for opening a new clause within the query
131,596
public void _closeSubclause ( ) { _currentClauseDepth -- ; List < QueryToken > tokens = getCurrentWhereTokens ( ) ; tokens . add ( CloseSubclauseToken . INSTANCE ) ; }
Simplified method for closing a clause within the query
131,597
public void _whereIn ( String fieldName , Collection < Object > values ) { _whereIn ( fieldName , values , false ) ; }
Check that the field has one of the specified value
131,598
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 <...
Matches fields which ends with the specified value .
131,599
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 WherePa...
Matches fields where the value is between the specified start and end inclusive