idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
131,600
public void _orElse ( ) { List < QueryToken > tokens = getCurrentWhereTokens ( ) ; if ( tokens . isEmpty ( ) ) { return ; } if ( tokens . get ( tokens . size ( ) - 1 ) instanceof QueryOperatorToken ) { throw new IllegalStateException ( "Cannot add OR, previous token was already an operator token." ) ; } tokens . add ( ...
Add an OR to the query
131,601
public void _orderBy ( String field , OrderingType ordering ) { assertNoRawQuery ( ) ; String f = ensureValidFieldName ( field , false ) ; orderByTokens . add ( OrderByToken . createAscending ( f , ordering ) ) ; }
Order the results by the specified fields The fields are the names of the fields to sort defaulting to sorting by ascending . You can prefix a field name with - to indicate sorting by descending or + to sort by ascending
131,602
public void _orderByDescending ( String field , OrderingType ordering ) { assertNoRawQuery ( ) ; String f = ensureValidFieldName ( field , false ) ; orderByTokens . add ( OrderByToken . createDescending ( f , ordering ) ) ; }
Order the results by the specified fields The fields are the names of the fields to sort defaulting to sorting by descending . You can prefix a field name with - to indicate sorting by descending or + to sort by ascending
131,603
protected IndexQuery generateIndexQuery ( String query ) { IndexQuery indexQuery = new IndexQuery ( ) ; indexQuery . setQuery ( query ) ; indexQuery . setStart ( start ) ; indexQuery . setWaitForNonStaleResults ( theWaitForNonStaleResults ) ; indexQuery . setWaitForNonStaleResultsTimeout ( timeout ) ; indexQuery . setQ...
Generates the index query .
131,604
public QueryResult createSnapshot ( ) { QueryResult queryResult = new QueryResult ( ) ; queryResult . setResults ( getResults ( ) ) ; queryResult . setIncludes ( getIncludes ( ) ) ; queryResult . setIndexName ( getIndexName ( ) ) ; queryResult . setIndexTimestamp ( getIndexTimestamp ( ) ) ; queryResult . setIncludedPat...
Creates a snapshot of the query results
131,605
public List < SubscriptionState > getSubscriptions ( int start , int take , String database ) { RequestExecutor requestExecutor = _store . getRequestExecutor ( ObjectUtils . firstNonNull ( database , _store . getDatabase ( ) ) ) ; GetSubscriptionsCommand command = new GetSubscriptionsCommand ( start , take ) ; requestE...
It downloads a list of all existing subscriptions in a database .
131,606
public void delete ( String name , String database ) { RequestExecutor requestExecutor = _store . getRequestExecutor ( ObjectUtils . firstNonNull ( database , _store . getDatabase ( ) ) ) ; DeleteSubscriptionCommand command = new DeleteSubscriptionCommand ( name ) ; requestExecutor . execute ( command ) ; }
Delete a subscription .
131,607
public SubscriptionState getSubscriptionState ( String subscriptionName , String database ) { if ( StringUtils . isEmpty ( subscriptionName ) ) { throw new IllegalArgumentException ( "SubscriptionName cannot be null" ) ; } RequestExecutor requestExecutor = _store . getRequestExecutor ( ObjectUtils . firstNonNull ( data...
Returns subscription definition and it s current state
131,608
public void dropConnection ( String name , String database ) { RequestExecutor requestExecutor = _store . getRequestExecutor ( ObjectUtils . firstNonNull ( database , _store . getDatabase ( ) ) ) ; DropSubscriptionConnectionCommand command = new DropSubscriptionConnectionCommand ( name ) ; requestExecutor . execute ( c...
Force server to close current client subscription connection to the server
131,609
private static String getContentPath ( HttpServletRequest request ) { String contentPath = ( String ) request . getAttribute ( Value . CONTENTPATH_ATTRIBUTE ) ; if ( contentPath == null ) { contentPath = ( ( SlingHttpServletRequest ) request ) . getRequestPathInfo ( ) . getSuffix ( ) ; } return contentPath ; }
Current content path
131,610
public static < T extends EventArgs > void invoke ( List < EventHandler < T > > delegates , Object sender , T event ) { for ( EventHandler < T > delegate : delegates ) { delegate . handle ( sender , event ) ; } }
Helper used for invoking event on list of delegates
131,611
private static void checkOffset ( String value , int offset , char expected ) throws IndexOutOfBoundsException { char found = value . charAt ( offset ) ; if ( found != expected ) { throw new IndexOutOfBoundsException ( "Expected '" + expected + "' character but found '" + found + "'" ) ; } }
Check if the expected character exist at the given offset of the
131,612
public void saveChanges ( ) { BatchOperation saveChangeOperation = new BatchOperation ( this ) ; try ( BatchCommand command = saveChangeOperation . createRequest ( ) ) { if ( command == null ) { return ; } if ( noTracking ) { throw new IllegalStateException ( "Cannot execute saveChanges when entity tracking is disabled...
Saves all the changes to the Raven server .
131,613
public boolean exists ( String id ) { if ( id == null ) { throw new IllegalArgumentException ( "id cannot be null" ) ; } if ( _knownMissingIds . contains ( id ) ) { return false ; } if ( documentsById . getValue ( id ) != null ) { return true ; } HeadDocumentCommand command = new HeadDocumentCommand ( id , null ) ; _re...
Check if document exists without loading it
131,614
public < T > void refresh ( T entity ) { DocumentInfo documentInfo = documentsByEntity . get ( entity ) ; if ( documentInfo == null ) { throw new IllegalStateException ( "Cannot refresh a transient instance" ) ; } incrementRequestCount ( ) ; GetDocumentsCommand command = new GetDocumentsCommand ( new String [ ] { docum...
Refreshes the specified entity from Raven server .
131,615
protected void spatial ( String field , Function < SpatialOptionsFactory , SpatialOptions > indexing ) { spatialOptionsStrings . put ( field , indexing . apply ( new SpatialOptionsFactory ( ) ) ) ; }
Register a field to be spatially indexed
131,616
@ SuppressWarnings ( "unchecked" ) public Object convertToEntity ( Class entityType , String id , ObjectNode document ) { try { if ( ObjectNode . class . equals ( entityType ) ) { return document ; } Object defaultValue = InMemoryDocumentSessionOperations . getDefaultValue ( entityType ) ; Object entity = defaultValue ...
Converts a json object to an entity .
131,617
protected final JSONArray getPages ( Iterator < Page > pages , int depth , PageFilter pageFilter ) throws JSONException { JSONArray pagesArray = new JSONArray ( ) ; while ( pages . hasNext ( ) ) { Page page = pages . next ( ) ; JSONObject pageObject = getPage ( page ) ; if ( pageObject != null ) { Iterator < Page > chi...
Generate JSON objects for pages .
131,618
protected final Iterator < Page > listChildren ( Resource parentResource , PageFilter pageFilter ) { return new PageIterator ( parentResource . listChildren ( ) , pageFilter ) ; }
Lists children using custom page iterator .
131,619
@ SuppressWarnings ( "null" ) protected final JSONObject getPage ( Page page ) throws JSONException { Resource resource = page . adaptTo ( Resource . class ) ; JSONObject pageObject = new JSONObject ( ) ; pageObject . put ( "name" , page . getName ( ) ) ; String title = page . getTitle ( ) ; if ( StringUtils . isEmpty ...
Generate JSON object for page
131,620
public String getIdentifier ( ) { if ( identifier != null ) { return identifier ; } if ( urls == null ) { return null ; } if ( database != null ) { return String . join ( "," , urls ) + " (DB: " + database + ")" ; } return String . join ( "," , urls ) ; }
Gets the identifier for this store .
131,621
public IDocumentSession openSession ( String database ) { SessionOptions sessionOptions = new SessionOptions ( ) ; sessionOptions . setDatabase ( database ) ; return openSession ( sessionOptions ) ; }
Opens the session for a particular database
131,622
public IDocumentStore initialize ( ) { if ( initialized ) { return this ; } assertValidConfiguration ( ) ; try { if ( getConventions ( ) . getDocumentIdGenerator ( ) == null ) { MultiDatabaseHiLoIdGenerator generator = new MultiDatabaseHiLoIdGenerator ( this , getConventions ( ) ) ; _multiDbHiLo = generator ; getConven...
Initializes this instance .
131,623
private static boolean isPageInTemplateDefinition ( Page page ) { Resource resource = page . adaptTo ( Resource . class ) ; if ( resource != null ) { Resource parent = resource . getParent ( ) ; if ( parent != null ) { return StringUtils . equals ( NT_TEMPLATE , parent . getValueMap ( ) . get ( JCR_PRIMARYTYPE , String...
Checks if the given page is part of the editable template definition itself .
131,624
public void execute ( IDocumentStore store , DocumentConventions conventions , String database ) { DocumentConventions oldConventions = getConventions ( ) ; try { setConventions ( ObjectUtils . firstNonNull ( conventions , getConventions ( ) , store . getConventions ( ) ) ) ; IndexDefinition indexDefinition = createInd...
Executes the index creation against the specified document database using the specified conventions
131,625
public static boolean is ( Set < String > runModes , String ... expectedRunModes ) { if ( runModes != null && expectedRunModes != null ) { for ( String expectedRunMode : expectedRunModes ) { if ( runModes . contains ( expectedRunMode ) ) { return true ; } } } return false ; }
Checks if given run mode is active .
131,626
public IndexDefinition createIndexDefinition ( ) { if ( conventions == null ) { conventions = new DocumentConventions ( ) ; } IndexDefinitionBuilder indexDefinitionBuilder = new IndexDefinitionBuilder ( getIndexName ( ) ) ; indexDefinitionBuilder . setIndexesStrings ( indexesStrings ) ; indexDefinitionBuilder . setAnal...
Creates the index definition .
131,627
protected PageFilter getPageFilter ( SlingHttpServletRequest request ) { String predicateName = RequestParam . get ( request , RP_PREDICATE ) ; if ( StringUtils . isNotEmpty ( predicateName ) ) { PredicateProvider predicateProvider = getPredicateProvider ( ) ; if ( predicateProvider == null ) { throw new RuntimeExcepti...
Can be overridden by subclasses to filter page list via page filter . If not overridden it supports defining a page filter via predicate request attribute .
131,628
private IndexedPropertyMethodMetadata < ? > getIndexedPropertyMethodMetadata ( Collection < MethodMetadata < ? , ? > > methodMetadataOfType ) { for ( MethodMetadata methodMetadata : methodMetadataOfType ) { AnnotatedMethod annotatedMethod = methodMetadata . getAnnotatedMethod ( ) ; Annotation indexedAnnotation = annota...
Determine the indexed property from a list of method metadata .
131,629
private Collection < MethodMetadata < ? , ? > > getMethodMetadataOfType ( AnnotatedType annotatedType , Collection < AnnotatedMethod > annotatedMethods ) { Collection < MethodMetadata < ? , ? > > methodMetadataOfType = new ArrayList < > ( ) ; for ( AnnotatedMethod annotatedMethod : annotatedMethods ) { MethodMetadata <...
Return the collection of method metadata from the given collection of annotated methods .
131,630
public static < T > DependencyResolver < T > newInstance ( Collection < T > elements , DependencyProvider < T > dependencyProvider ) { return new DependencyResolver < T > ( elements , dependencyProvider ) ; }
Creates an instance of the resolver .
131,631
public List < T > resolve ( ) { blockedBy = new HashMap < > ( ) ; Set < T > queue = new LinkedHashSet < > ( ) ; Set < T > allElements = new HashSet < > ( ) ; queue . addAll ( elements ) ; while ( ! queue . isEmpty ( ) ) { T element = queue . iterator ( ) . next ( ) ; Set < T > dependencies = dependencyProvider . getDep...
Resolves the dependencies to a list .
131,632
private void resolve ( T element , List < T > result ) { Set < T > dependencies = blockedBy . get ( element ) ; if ( dependencies != null ) { for ( T dependency : dependencies ) { resolve ( dependency , result ) ; } blockedBy . remove ( element ) ; result . add ( element ) ; } }
Resolves an element .
131,633
public void put ( Id id , Object value , Mode mode ) { if ( Mode . WRITE . equals ( mode ) ) { writeCache . put ( id , value ) ; } readCache . put ( new CacheKey ( id ) , value ) ; }
Put an instance into the cache .
131,634
public Object get ( Id id , Mode mode ) { Object value = writeCache . get ( id ) ; if ( value == null ) { value = readCache . get ( new CacheKey ( id ) ) ; if ( value != null && Mode . WRITE . equals ( mode ) ) { writeCache . put ( id , value ) ; } } return value ; }
Lookup an instance in the cache identified by its id .
131,635
public void remove ( Id id ) { readCache . remove ( new CacheKey ( id ) ) ; writeCache . remove ( id ) ; }
Removes an instance from the cache .
131,636
private void initializeEntity ( Collection < ? extends TypeMetadata > types , NodeState nodeState ) { for ( TypeMetadata type : types ) { Collection < TypeMetadata > superTypes = type . getSuperTypes ( ) ; initializeEntity ( superTypes , nodeState ) ; for ( MethodMetadata < ? , ? > methodMetadata : type . getProperties...
Initializes all relation properties of the given node state with empty collections .
131,637
public void log ( String message ) { switch ( level ) { case TRACE : LOGGER . trace ( message ) ; break ; case DEBUG : LOGGER . debug ( message ) ; break ; case INFO : LOGGER . info ( message ) ; break ; case WARN : LOGGER . warn ( message ) ; break ; case ERROR : LOGGER . error ( message ) ; break ; default : throw ne...
Log a message using the configured log level .
131,638
private Object convertParameter ( Object value ) { if ( entityInstanceManager . isInstance ( value ) ) { return entityInstanceManager . getDatastoreType ( value ) ; } else if ( relationInstanceManager . isInstance ( value ) ) { return relationInstanceManager . getDatastoreType ( value ) ; } else if ( value instanceof C...
Converts the given parameter value to instances which can be passed to the datastore .
131,639
public < P extends PluginRepository < ? , ? > > P getPluginManager ( Class < ? > pluginType ) { return ( P ) pluginRepositories . get ( pluginType ) ; }
Return a plugin repository identified by the plugin interface type .
131,640
private void ensureIndex ( DS session , EntityTypeMetadata < NodeMetadata < L > > entityTypeMetadata , IndexedPropertyMethodMetadata < IndexedPropertyMetadata > indexedProperty ) { if ( indexedProperty != null ) { IndexedPropertyMetadata datastoreMetadata = indexedProperty . getDatastoreMetadata ( ) ; if ( datastoreMet...
Ensures that an index exists for the given entity and property .
131,641
private void ensureIndex ( DS session , L label , PrimitivePropertyMethodMetadata < PropertyMetadata > propertyMethodMetadata , boolean unique ) { PropertyMetadata propertyMetadata = propertyMethodMetadata . getDatastoreMetadata ( ) ; String statement ; if ( unique ) { LOGGER . debug ( "Creating constraint for label {}...
Ensures that an index exists for the given label and property .
131,642
public CompositeType getCompositeType ( ) { return CompositeTypeBuilder . create ( CompositeObject . class , metadata , typeMetadata -> typeMetadata . getAnnotatedType ( ) . getAnnotatedElement ( ) ) ; }
Convert this set into a composite type .
131,643
public void registerInstanceListener ( Object instanceListener ) { for ( Method method : instanceListener . getClass ( ) . getMethods ( ) ) { evaluateMethod ( instanceListener , PostCreate . class , method , postCreateMethods ) ; evaluateMethod ( instanceListener , PreUpdate . class , method , preUpdateMethods ) ; eval...
Add an instance listener instance .
131,644
private void evaluateMethod ( Object listener , Class < ? extends Annotation > annotation , Method method , Map < Object , Set < Method > > methods ) { if ( method . isAnnotationPresent ( annotation ) ) { if ( method . getParameterTypes ( ) . length != 1 ) { throw new XOException ( "Life cycle method '" + method . toGe...
Evaluates a method if an annotation is present and if true adds to the map of life cycle methods .
131,645
private < T > void invoke ( Map < Object , Set < Method > > methods , T instance ) { for ( Map . Entry < Object , Set < Method > > entry : methods . entrySet ( ) ) { Object listener = entry . getKey ( ) ; Set < Method > listenerMethods = entry . getValue ( ) ; if ( listenerMethods != null ) { for ( Method method : list...
Invokes all registered lifecycle methods on a given instance .
131,646
public < T > T readInstance ( DatastoreType datastoreType ) { return getInstance ( datastoreType , TransactionalCache . Mode . READ ) ; }
Return the proxy instance which corresponds to the given datastore type for reading .
131,647
public < T > T createInstance ( DatastoreType datastoreType , DynamicType < ? > types ) { return newInstance ( getDatastoreId ( datastoreType ) , datastoreType , types , TransactionalCache . Mode . WRITE ) ; }
Return the proxy instance which corresponds to the given datastore type for writing .
131,648
private < T > T getInstance ( DatastoreType datastoreType , TransactionalCache . Mode cacheMode ) { DatastoreId id = getDatastoreId ( datastoreType ) ; Object instance = cache . get ( id , cacheMode ) ; if ( instance == null ) { DynamicType < ? > types = getTypes ( datastoreType ) ; instance = newInstance ( id , datast...
Return the proxy instance which corresponds to the given datastore type .
131,649
private < T > T newInstance ( DatastoreId id , DatastoreType datastoreType , DynamicType < ? > types , TransactionalCache . Mode cacheMode ) { validateType ( types ) ; InstanceInvocationHandler invocationHandler = new InstanceInvocationHandler ( datastoreType , getProxyMethodService ( ) ) ; T instance = proxyFactory . ...
Create a proxy instance which corresponds to the given datastore type .
131,650
private void validateType ( DynamicType < ? > dynamicType ) { int size = dynamicType . getMetadata ( ) . size ( ) ; if ( size == 1 ) { if ( dynamicType . isAbstract ( ) ) { throw new XOException ( "Cannot create an instance of a single abstract type " + dynamicType ) ; } } else if ( dynamicType . isFinal ( ) ) { throw ...
Validates the given types .
131,651
public < Instance > boolean isInstance ( Instance instance ) { if ( instance instanceof CompositeObject ) { Object delegate = ( ( CompositeObject ) instance ) . getDelegate ( ) ; return isDatastoreType ( delegate ) ; } return false ; }
Determine if a given instance is a datastore type handled by this manager .
131,652
public < Instance > DatastoreType getDatastoreType ( Instance instance ) { InstanceInvocationHandler < DatastoreType > invocationHandler = proxyFactory . getInvocationHandler ( instance ) ; return invocationHandler . getDatastoreType ( ) ; }
Return the datastore type represented by an instance .
131,653
public DynamicType < RelationTypeMetadata < RelationMetadata > > getRelationTypes ( Set < EntityDiscriminator > sourceDiscriminators , RelationDiscriminator discriminator , Set < EntityDiscriminator > targetDiscriminators ) { DynamicType < RelationTypeMetadata < RelationMetadata > > dynamicType = new DynamicType < > ( ...
Determine the relation type for the given source discriminators relation descriminator and target discriminators .
131,654
private < T > Map < PrimitivePropertyMethodMetadata < PropertyMetadata > , Object > prepareExample ( Example < T > example , Class < ? > type , Class < ? > ... types ) { Map < PrimitivePropertyMethodMetadata < PropertyMetadata > , Object > exampleEntity = new HashMap < > ( ) ; ExampleProxyMethodService < T > proxyMetho...
Setup an example entity .
131,655
private < T > ResultIterable < T > findByExample ( Class < ? > type , Map < PrimitivePropertyMethodMetadata < PropertyMetadata > , Object > entity ) { sessionContext . getCacheSynchronizationService ( ) . flush ( ) ; EntityTypeMetadata < EntityMetadata > entityTypeMetadata = sessionContext . getMetadataProvider ( ) . g...
Find entities according to the given example entity .
131,656
private Set < Discriminator > getAggregatedDiscriminators ( EntityTypeMetadata < EntityMetadata > typeMetadata ) { Set < Discriminator > discriminators = aggregatedDiscriminators . get ( typeMetadata ) ; if ( discriminators == null ) { discriminators = new HashSet < > ( ) ; Discriminator discriminator = typeMetadata . ...
Determine the set of discriminators for one type i . e . the discriminator of the type itself and of all it s super types .
131,657
public static Collection < Class < ? > > getTypes ( Collection < String > typeNames ) { Set < Class < ? > > types = new HashSet < > ( ) ; for ( String typeName : typeNames ) { types . add ( ClassHelper . getType ( typeName ) ) ; } return types ; }
Load a collection of classes .
131,658
public static < T > T newInstance ( Class < T > type ) { try { return type . newInstance ( ) ; } catch ( InstantiationException e ) { throw new XOException ( "Cannot create instance of type '" + type . getName ( ) + "'" , e ) ; } catch ( IllegalAccessException e ) { throw new XOException ( "Access denied to type '" + t...
Create an instance of a class .
131,659
public static Class < ? > getTypeParameter ( Class < ? > genericType , Class < ? > type ) { Type [ ] genericInterfaces = type . getGenericInterfaces ( ) ; for ( Type genericInterface : genericInterfaces ) { if ( genericInterface instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ...
Determines the type of a class implementing a generic interface with one type parameter .
131,660
public Collection < AnnotatedMethod > getMethods ( ) { for ( Method method : type . getDeclaredMethods ( ) ) { if ( ! method . isSynthetic ( ) ) { Class < ? > returnType = method . getReturnType ( ) ; Type genericReturnType = method . getGenericReturnType ( ) ; Class < ? > [ ] parameterTypes = method . getParameterType...
Return the methods of the type .
131,661
private List < Content > rewriteAnchor ( Element element ) { if ( element . getContent ( ) . isEmpty ( ) ) { element . setText ( "" ) ; } Link link = getAnchorLink ( element ) ; Element anchorElement = buildAnchorElement ( link , element ) ; List < Content > content = new ArrayList < Content > ( ) ; if ( anchorElement ...
Checks if the given anchor element has to be rewritten .
131,662
private boolean getAnchorLegacyMetadataFromSingleData ( ValueMap resourceProps , Element element ) { boolean foundAny = false ; JSONObject metadata = null ; Attribute dataAttribute = element . getAttribute ( "data" ) ; if ( dataAttribute != null ) { String metadataString = dataAttribute . getValue ( ) ; if ( StringUtil...
Support legacy data structures where link metadata is stored as JSON fragment in single HTML5 data attribute .
131,663
private void getAnchorLegacyMetadataFromRel ( ValueMap resourceProps , Element element ) { String href = element . getAttributeValue ( "href" ) ; String linkWindowTarget = element . getAttributeValue ( "target" ) ; if ( href == null || href . startsWith ( "#" ) ) { return ; } JSONObject metadata = null ; String metadat...
Support legacy data structures where link metadata is stored as JSON fragment in rel attribute .
131,664
private List < Content > rewriteImage ( Element element ) { Media media = getImageMedia ( element ) ; Element imageElement = buildImageElement ( media , element ) ; List < Content > content = new ArrayList < Content > ( ) ; if ( imageElement != null ) { content . add ( imageElement ) ; } return content ; }
Checks if the given image element has to be rewritten .
131,665
private Element buildImageElement ( Media media , Element element ) { if ( media . isValid ( ) ) { element . setAttribute ( "src" , media . getUrl ( ) ) ; } return element ; }
Builds image element for given media metadata .
131,666
private String unexternalizeImageRef ( String ref ) { String unexternalizedRef = ref ; if ( StringUtils . isNotEmpty ( unexternalizedRef ) ) { unexternalizedRef = decodeIfEncoded ( unexternalizedRef ) ; unexternalizedRef = StringUtils . removeEnd ( unexternalizedRef , "/" + JcrConstants . JCR_CONTENT + ".default" ) ; u...
Converts the RTE externalized form of media reference to internal form .
131,667
private String decodeIfEncoded ( String value ) { if ( StringUtils . contains ( value , "%" ) ) { try { return URLDecoder . decode ( value , CharEncoding . UTF_8 ) ; } catch ( UnsupportedEncodingException ex ) { throw new RuntimeException ( ex ) ; } } return value ; }
URL - decode value if required .
131,668
public static Map < String , Object > keyValuePairAsMap ( String key , Object value ) { Map < String , Object > paramMap = new HashMap < > ( ) ; paramMap . put ( key , value ) ; return paramMap ; }
Convert key value pair to map
131,669
private Rendition getInlineRendition ( MediaArgs mediaArgs ) { return new InlineRendition ( this . resource , this . media , mediaArgs , this . fileName , this . adaptable ) ; }
Get inline rendition instance .
131,670
private void addRendition ( Set < RenditionMetadata > candidates , Rendition rendition , MediaArgs mediaArgs ) { if ( ! mediaArgs . isIncludeAssetThumbnails ( ) && AssetRendition . isThumbnailRendition ( rendition ) ) { return ; } boolean isIncludeAssetWebRenditions = mediaArgs . isIncludeAssetWebRenditions ( ) != null...
adds rendition to the list of candidates if it should be available for resolving
131,671
private Set < RenditionMetadata > getRendtionsMatchingFileExtensions ( String [ ] fileExtensions , MediaArgs mediaArgs ) { Set < RenditionMetadata > allRenditions = getAvailableRenditions ( mediaArgs ) ; if ( fileExtensions == null || fileExtensions . length == 0 ) { return allRenditions ; } Set < RenditionMetadata > m...
Get all renditions that match the requested list of file extension .
131,672
private String [ ] getRequestedFileExtensions ( MediaArgs mediaArgs ) { Set < String > mediaArgsFileExtensions = new HashSet < String > ( ) ; if ( mediaArgs . getFileExtensions ( ) != null && mediaArgs . getFileExtensions ( ) . length > 0 ) { mediaArgsFileExtensions . addAll ( ImmutableList . copyOf ( mediaArgs . getFi...
Get merged list of file extensions from both media formats and media args .
131,673
private RenditionMetadata getExactMatchRendition ( final Set < RenditionMetadata > candidates , MediaArgs mediaArgs ) { if ( mediaArgs . getFixedWidth ( ) > 0 || mediaArgs . getFixedHeight ( ) > 0 ) { for ( RenditionMetadata candidate : candidates ) { if ( candidate . matches ( mediaArgs . getFixedWidth ( ) , mediaArgs...
Get rendition that matches exactly with the given media args requirements .
131,674
private RenditionMetadata getOriginalOrFirstRendition ( Set < RenditionMetadata > candidates ) { if ( this . originalRendition != null && candidates . contains ( this . originalRendition ) ) { return this . originalRendition ; } else if ( ! candidates . isEmpty ( ) ) { return candidates . iterator ( ) . next ( ) ; } el...
Returns original rendition - if it is contained in the candidate set . Otherwise first candidate is returned . If a VirtualCropRenditionMetadata is present always the first one is returned .
131,675
@ SuppressWarnings ( "null" ) private < T > T visitMediaFormats ( MediaArgs mediaArgs , MediaFormatVisitor < T > mediaFormatVisitor ) { MediaFormat [ ] mediaFormats = mediaArgs . getMediaFormats ( ) ; if ( mediaFormats != null ) { for ( MediaFormat mediaFormat : mediaFormats ) { T returnValue = mediaFormatVisitor . vis...
Iterate over all media formats defined in media args . Ignores invalid media formats . If the media format visitor returns a value that is not null iteration is stopped and the value is returned from this method .
131,676
private boolean resolveFirstMatchRenditions ( Media media , Asset asset , MediaArgs mediaArgs ) { Rendition rendition = asset . getRendition ( mediaArgs ) ; if ( rendition != null ) { media . setRenditions ( ImmutableList . of ( rendition ) ) ; media . setUrl ( rendition . getUrl ( ) ) ; return true ; } return false ; ...
Check if a matching rendition is found for any of the provided media formats and other media args . The first match is returned .
131,677
private boolean resolveAllRenditions ( Media media , Asset asset , MediaArgs mediaArgs ) { boolean allMandatory = mediaArgs . isMediaFormatsMandatory ( ) ; boolean allResolved = true ; boolean anyResolved = false ; List < Rendition > resolvedRenditions = new ArrayList < > ( ) ; for ( MediaFormat mediaFormat : mediaArgs...
Iterates over all defined media format and tries to find a matching rendition for each of them in combination with the other media args .
131,678
public Page getRelativePage ( String relativePath ) { String path = getRootPath ( ) ; if ( path == null ) { return null ; } StringBuilder sb = new StringBuilder ( path ) ; if ( ! relativePath . startsWith ( "/" ) ) { sb . append ( "/" ) ; } sb . append ( relativePath ) ; return pageManager . getPage ( sb . toString ( )...
Get page relative to site root .
131,679
protected boolean isNotModified ( Resource resource , SlingHttpServletRequest request , SlingHttpServletResponse response ) throws IOException { return CacheHeader . isNotModified ( resource , request , response , false ) ; }
Checks if the resource was modified since last request
131,680
protected void sendBinaryData ( byte [ ] binaryData , String contentType , SlingHttpServletRequest request , SlingHttpServletResponse response ) throws IOException { response . setContentType ( contentType ) ; response . setContentLength ( binaryData . length ) ; if ( RequestPath . hasSelector ( request , SELECTOR_DOWN...
Send binary data to output stream . Respect optional content disposition header handling .
131,681
protected UrlConfig getUrlConfigForTarget ( Adaptable adaptable , Page targetPage ) { Resource targetResource = null ; if ( targetPage != null ) { targetResource = targetPage . adaptTo ( Resource . class ) ; } return getUrlConfigForTarget ( adaptable , targetResource ) ; }
Get URL configuration for target page . If this is invalid or not available get it from adaptable .
131,682
protected UrlConfig getUrlConfigForTarget ( Adaptable adaptable , Resource targetResource ) { UrlConfig config = null ; if ( targetResource != null ) { config = new UrlConfig ( targetResource ) ; } if ( config == null || ! config . isValid ( ) ) { config = new UrlConfig ( adaptable ) ; } return config ; }
Get URL configuration for target resource . If this is invalid or not available get it from adaptable .
131,683
public MediaFormat build ( ) { if ( this . name == null ) { throw new IllegalArgumentException ( "Name is missing." ) ; } return new MediaFormat ( name , label , description , width , minWidth , maxWidth , height , minHeight , maxHeight , ratio , ratioWidth , ratioHeight , fileSizeMax , nonNullArray ( extensions ) , re...
Builds the media format definition .
131,684
protected Rendition getDamRendition ( MediaArgs mediaArgs ) { return new DamRendition ( this . damAsset , this . cropDimension , this . rotation , mediaArgs , adaptable ) ; }
Get DAM rendition instance .
131,685
protected HtmlElement < ? > getImageElement ( Media media ) { Image img = new Image ( ) ; Asset asset = media . getAsset ( ) ; String altText = null ; if ( asset != null ) { altText = asset . getAltText ( ) ; } if ( StringUtils . isNotEmpty ( altText ) ) { img . setAlt ( altText ) ; } return img ; }
Create an IMG element with alt text .
131,686
protected void setResponsiveImageSource ( HtmlElement < ? > mediaElement , JSONArray responsiveImageSources , Media media ) { mediaElement . setData ( PROP_RESPONSIVE_SOURCES , responsiveImageSources . toString ( ) ) ; }
Set attribute on media element for responsive image sources
131,687
protected HtmlElement < ? > getImageElement ( Media media ) { Image img = new Image ( ) . addCssClass ( MediaNameConstants . CSS_DUMMYIMAGE ) ; return img ; }
Create an IMG element .
131,688
public HtmlComment createComment ( String text ) { HtmlComment comment = new HtmlComment ( text ) ; this . addContent ( comment ) ; return comment ; }
Creates and adds html comment .
131,689
private static boolean isNt ( Resource resource , String nodeTypeName ) { if ( resource != null ) { return StringUtils . equals ( resource . getResourceType ( ) , nodeTypeName ) ; } return false ; }
Checks if the given resource is a node with the given node type name
131,690
protected List < VideoProfile > getVideoProfiles ( ) { List < VideoProfile > profiles = new ArrayList < VideoProfile > ( ) ; for ( String profileName : getVideoProfileNames ( ) ) { VideoProfile profile = VideoProfile . get ( resourceResolver , profileName ) ; if ( profile != null ) { profiles . add ( profile ) ; } else...
Return video profiles supported by this markup builder .
131,691
protected void addSources ( Video video , Media media ) { Asset asset = getDamAsset ( media ) ; if ( asset == null ) { return ; } for ( VideoProfile profile : getVideoProfiles ( ) ) { com . day . cq . dam . api . Rendition rendition = profile . getRendition ( asset ) ; if ( rendition != null ) { video . createSource ( ...
Add sources for HTML5 video player
131,692
protected HtmlElement getFlashPlayerElement ( Media media , Dimension dimension ) { Asset asset = getDamAsset ( media ) ; if ( asset == null ) { return null ; } com . day . cq . dam . api . Rendition rendition = asset . getRendition ( new PrefixRenditionPicker ( VideoConstants . RENDITION_PREFIX + H264_PROFILE ) ) ; if...
Build flash player element
131,693
protected String buildFlashVarsString ( Map < String , String > flashVars ) { try { StringBuilder flashvarsString = new StringBuilder ( ) ; Iterator < Map . Entry < String , String > > flashvarsIterator = flashVars . entrySet ( ) . iterator ( ) ; while ( flashvarsIterator . hasNext ( ) ) { Map . Entry < String , String...
Build flashvars string to be used on HTML object element for flash embedding .
131,694
protected Map < String , String > getAdditionalFlashPlayerParameters ( Media media , Dimension dimension ) { Map < String , String > parameters = new HashMap < String , String > ( ) ; parameters . put ( "allowFullScreen" , "true" ) ; parameters . put ( "wmode" , "opaque" ) ; return parameters ; }
Get additional parameters to be set as &lt ; param&gt ; elements on html object element for flash player .
131,695
protected Map < String , String > getAdditionalFlashPlayerFlashVars ( Media media , Dimension dimension ) { Map < String , String > flashvars = new HashMap < String , String > ( ) ; flashvars . put ( "autoPlay" , "false" ) ; flashvars . put ( "loop" , "false" ) ; return flashvars ; }
Get additional parameters to be set as flashvars parameter on html object element for flash player .
131,696
private boolean linksToOtherDomain ( Adaptable adaptable , Page currentPage , Resource targetResource ) { if ( currentPage == null || targetResource == null ) { return false ; } UrlHandlerConfig urlHandlerConfig = AdaptTo . notNull ( adaptable , UrlHandlerConfig . class ) ; Resource currentResource = AdaptTo . notNull ...
Checks if the target resource is located outsite the current site and if for this other resource context a valid url configuration with a specific hostname exists .
131,697
private Dimension getScaledDimension ( Dimension originalDimension ) { Dimension requestedDimension = getRequestedDimension ( ) ; boolean scaleWidth = ( requestedDimension . getWidth ( ) > 0 && requestedDimension . getWidth ( ) != originalDimension . getWidth ( ) ) ; boolean scaleHeight = ( requestedDimension . getHeig...
Checks if the current binary is an image and has to be scaled . In this case the destination dimension is returned .
131,698
private String buildMediaUrl ( Dimension scaledDimension ) { if ( ! isMatchingFileExtension ( ) ) { return null ; } if ( scaledDimension != null ) { if ( scaledDimension . equals ( SCALING_NOT_POSSIBLE_DIMENSION ) ) { return null ; } return buildScaledMediaUrl ( scaledDimension , this . media . getCropDimension ( ) ) ;...
Build media URL for this rendition - either native URL to repository or virtual url to rescaled version .
131,699
private String buildNativeMediaUrl ( ) { String path = null ; Resource parentResource = this . resource . getParent ( ) ; if ( JcrBinary . isNtFile ( parentResource ) ) { if ( StringUtils . equals ( parentResource . getName ( ) , getFileName ( ) ) ) { path = parentResource . getPath ( ) ; } else { path = parentResource...
Builds native URL that returns the binary data directly from the repository .