idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
15,900
public static boolean useSequenceForOrderNumber ( WorkspaceEntry wsConfig , String dbDialect ) throws RepositoryConfigurationException { try { if ( wsConfig . getContainer ( ) . getParameterValue ( JDBCWorkspaceDataContainer . USE_SEQUENCE_FOR_ORDER_NUMBER , JDBCWorkspaceDataContainer . USE_SEQUENCE_AUTO ) . equalsIgno...
Use sequence for order number .
15,901
SessionImpl createSession ( ConversationState user ) throws RepositoryException , LoginException { if ( IdentityConstants . SYSTEM . equals ( user . getIdentity ( ) . getUserId ( ) ) ) { SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( JCRRuntimePermiss...
Creates Session object by given Credentials
15,902
public synchronized void retain ( ) throws RepositoryException { try { if ( ! isRetainable ( ) ) throw new RepositoryException ( "Unsupported configuration place " + configurationService . getURL ( param . getValue ( ) ) + " If you want to save configuration, start repository from standalone file." + " Or persister-cl...
Retain configuration of JCR If configurationPersister is configured it write data in to the persister otherwise it try to save configuration in file
15,903
protected void doRestore ( File backupFile ) throws BackupException { if ( ! PrivilegedFileHelper . exists ( backupFile ) ) { LOG . warn ( "Nothing to restore for quotas" ) ; return ; } ZipObjectReader in = null ; try { in = new ZipObjectReader ( PrivilegedFileHelper . zipInputStream ( backupFile ) ) ; quotaPersister ....
Restores content .
15,904
private void repairDataSize ( ) { try { long dataSize = quotaPersister . getWorkspaceDataSize ( rName , wsName ) ; ChangesItem changesItem = new ChangesItem ( ) ; changesItem . updateWorkspaceChangedSize ( dataSize ) ; quotaPersister . setWorkspaceDataSize ( rName , wsName , 0 ) ; Runnable task = new ApplyPersistedChan...
After workspace data size being restored need also to update repository and global data size on respective value .
15,905
protected void doBackup ( File backupFile ) throws BackupException { ZipObjectWriter out = null ; try { out = new ZipObjectWriter ( PrivilegedFileHelper . zipOutputStream ( backupFile ) ) ; quotaPersister . backupWorkspaceData ( rName , wsName , out ) ; } catch ( IOException e ) { throw new BackupException ( e ) ; } fi...
Backups data to define file .
15,906
private void importResource ( Node parentNode , InputStream file_in , String resourceType , ArtifactDescriptor artifact ) throws RepositoryException { String filename ; if ( resourceType . equals ( "metadata" ) ) { filename = "maven-metadata.xml" ; } else { filename = String . format ( "%s-%s.%s" , artifact . getArtifa...
this method used for writing to repo jars poms and their checksums
15,907
private IndexInfos createIndexInfos ( Boolean system , IndexerIoModeHandler modeHandler , QueryHandlerEntry config , QueryHandler handler ) throws RepositoryConfigurationException { try { RSyncConfiguration rSyncConfiguration = new RSyncConfiguration ( config ) ; if ( rSyncConfiguration . getRsyncEntryName ( ) != null ...
Factory method for creating corresponding IndexInfos class . RSyncIndexInfos created if RSync configured and ISPNIndexInfos otherwise
15,908
@ ManagedDescription ( "The number of active locks" ) public int getNumLocks ( ) { try { return getNumLocks . run ( ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return - 1 ; }
Returns the number of active locks .
15,909
protected boolean hasLocks ( ) { try { return hasLocks . run ( ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return true ; }
Indicates if some locks have already been created .
15,910
public boolean isLockLive ( String nodeId ) throws LockException { try { return isLockLive . run ( nodeId ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return false ; }
Check is LockManager contains lock . No matter it is in pending or persistent state .
15,911
protected LockData getLockDataById ( String nodeId ) { try { return getLockDataById . run ( nodeId ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return null ; }
Returns lock data by node identifier .
15,912
protected synchronized List < LockData > getLockList ( ) { try { return getLockList . run ( ) ; } catch ( LockException e ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "An exception occurred: " + e . getMessage ( ) ) ; } } return null ; }
Returns all locks .
15,913
public SessionLockManager getSessionLockManager ( String sessionId , SessionDataManager transientManager ) { CacheableSessionLockManager sessionManager = new CacheableSessionLockManager ( sessionId , this , transientManager ) ; sessionLockManagers . put ( sessionId , sessionManager ) ; return sessionManager ; }
Return new instance of session lock manager .
15,914
public synchronized void removeExpired ( ) { final List < String > removeLockList = new ArrayList < String > ( ) ; for ( LockData lock : getLockList ( ) ) { if ( ! lock . isSessionScoped ( ) && lock . getTimeToDeath ( ) < 0 ) { removeLockList . add ( lock . getNodeIdentifier ( ) ) ; } } Collections . sort ( removeLockL...
Remove expired locks . Used from LockRemover .
15,915
protected void removeLock ( String nodeIdentifier ) { try { NodeData nData = ( NodeData ) dataManager . getItemData ( nodeIdentifier ) ; if ( nData == null ) { return ; } PlainChangesLog changesLog = new PlainChangesLogImpl ( new ArrayList < ItemState > ( ) , IdentityConstants . SYSTEM , ExtendedEvent . UNLOCK ) ; Item...
Remove lock used by Lock remover .
15,916
protected void removeAll ( ) { List < LockData > locks = getLockList ( ) ; for ( LockData lockData : locks ) { removeLock ( lockData . getNodeIdentifier ( ) ) ; } }
Remove all locks .
15,917
public static byte [ ] getAsByteArray ( TransactionChangesLog dataChangesLog ) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( os ) ; oos . writeObject ( dataChangesLog ) ; byte [ ] bArray = os . toByteArray ( ) ; return bArray ; }
getAsByteArray . Make the array of bytes from ChangesLog .
15,918
public static TransactionChangesLog getAsItemDataChangesLog ( byte [ ] byteArray ) throws IOException , ClassNotFoundException { ByteArrayInputStream is = new ByteArrayInputStream ( byteArray ) ; ObjectInputStream ois = new ObjectInputStream ( is ) ; TransactionChangesLog objRead = ( TransactionChangesLog ) ois . readO...
getAsItemDataChangesLog . Make the ChangesLog from array of bytes .
15,919
public PlainChangesLog read ( ObjectReader in ) throws UnknownClassIdException , IOException { int key ; if ( ( key = in . readInt ( ) ) != SerializationConstants . PLAIN_CHANGES_LOG_IMPL ) { throw new UnknownClassIdException ( "There is unexpected class [" + key + "]" ) ; } int eventType = in . readInt ( ) ; String se...
Read and set PlainChangesLog data .
15,920
public void write ( ObjectWriter out , PlainChangesLog pcl ) throws IOException { out . writeInt ( SerializationConstants . PLAIN_CHANGES_LOG_IMPL ) ; out . writeInt ( pcl . getEventType ( ) ) ; out . writeString ( pcl . getSessionId ( ) ) ; List < ItemState > list = pcl . getAllStates ( ) ; int listSize = list . size ...
Write PlainChangesLog data .
15,921
private ExtendedNode getUsersStorageNode ( ) throws RepositoryException { Session session = service . getStorageSession ( ) ; try { return ( ExtendedNode ) utils . getUsersStorageNode ( service . getStorageSession ( ) ) ; } finally { session . logout ( ) ; } }
Returns users storage node .
15,922
protected void closeStatements ( ) { try { if ( findItemById != null ) { findItemById . close ( ) ; } if ( findItemByPath != null ) { findItemByPath . close ( ) ; } if ( findItemByName != null ) { findItemByName . close ( ) ; } if ( findChildPropertyByPath != null ) { findChildPropertyByPath . close ( ) ; } if ( findPr...
Close all statements .
15,923
public List < NodeDataIndexing > getNodesAndProperties ( String lastNodeId , int offset , int limit ) throws RepositoryException , IllegalStateException { List < NodeDataIndexing > result = new ArrayList < NodeDataIndexing > ( ) ; checkIfOpened ( ) ; try { startTxIfNeeded ( ) ; ResultSet resultSet = findNodesAndPropert...
Returns from storage the next page of nodes and its properties .
15,924
public long getNodesCount ( ) throws RepositoryException { try { ResultSet countNodes = findNodesCount ( ) ; try { if ( countNodes . next ( ) ) { return countNodes . getLong ( 1 ) ; } else { throw new SQLException ( "ResultSet has't records." ) ; } } finally { JDBCUtils . freeResources ( countNodes , null , null ) ; } ...
Reads count of nodes in workspace .
15,925
public long getWorkspaceDataSize ( ) throws RepositoryException { long dataSize = 0 ; ResultSet result = null ; try { result = findWorkspaceDataSize ( ) ; try { if ( result . next ( ) ) { dataSize += result . getLong ( 1 ) ; } } finally { JDBCUtils . freeResources ( result , null , null ) ; } result = findWorkspaceProp...
Calculates workspace data size .
15,926
public long getNodeDataSize ( String nodeIdentifier ) throws RepositoryException { long dataSize = 0 ; ResultSet result = null ; try { result = findNodeDataSize ( getInternalId ( nodeIdentifier ) ) ; try { if ( result . next ( ) ) { dataSize += result . getLong ( 1 ) ; } } finally { JDBCUtils . freeResources ( result ,...
Calculates node data size .
15,927
protected ItemData getItemByIdentifier ( String cid ) throws RepositoryException , IllegalStateException { checkIfOpened ( ) ; try { ResultSet item = findItemByIdentifier ( cid ) ; try { if ( item . next ( ) ) { return itemData ( null , item , item . getInt ( COLUMN_CLASS ) , null ) ; } return null ; } finally { try { ...
Get Item By Identifier .
15,928
protected ItemData getItemByName ( NodeData parent , String parentId , QPathEntry name , ItemType itemType ) throws RepositoryException , IllegalStateException { checkIfOpened ( ) ; try { ResultSet item = null ; try { item = findItemByName ( parentId , name . getAsString ( ) , name . getIndex ( ) ) ; while ( item . nex...
Gets an item data from database .
15,929
private ItemData itemData ( QPath parentPath , ResultSet item , int itemClass , AccessControlList parentACL ) throws RepositoryException , SQLException , IOException { String cid = item . getString ( COLUMN_ID ) ; String cname = item . getString ( COLUMN_NAME ) ; int cversion = item . getInt ( COLUMN_VERSION ) ; String...
Build ItemData .
15,930
protected MixinInfo readMixins ( String cid ) throws SQLException , IllegalNameException { ResultSet mtrs = findPropertyByName ( cid , Constants . JCR_MIXINTYPES . getAsString ( ) ) ; try { List < InternalQName > mts = null ; boolean owneable = false ; boolean privilegeable = false ; if ( mtrs . next ( ) ) { mts = new ...
Read mixins from database .
15,931
protected PersistedPropertyData loadPropertyRecord ( QPath parentPath , String cname , String cid , String cpid , int cversion , int cptype , boolean cpmultivalued ) throws RepositoryException , SQLException , IOException { try { QPath qpath = QPath . makeChildPath ( parentPath == null ? traverseQPath ( cpid ) : parent...
Load PropertyData record .
15,932
private void deleteValues ( String cid , PropertyData pdata , boolean update , ChangedSizeHandler sizeHandler ) throws IOException , SQLException , RepositoryException , InvalidItemStateException { Set < String > storages = new HashSet < String > ( ) ; final ResultSet valueRecords = findValueStorageDescAndSize ( cid ) ...
Delete Property Values .
15,933
private List < ValueDataWrapper > readValues ( String cid , int cptype , String identifier , int cversion ) throws IOException , SQLException , ValueStorageNotFoundException { List < ValueDataWrapper > data = new ArrayList < ValueDataWrapper > ( ) ; final ResultSet valueRecords = findValuesByPropertyId ( cid ) ; try { ...
Read Property Values .
15,934
protected ValueDataWrapper readValueData ( String identifier , int orderNumber , int type , String storageId ) throws SQLException , IOException , ValueStorageNotFoundException { ValueIOChannel channel = this . containerConfig . valueStorageProvider . getChannel ( storageId ) ; try { return channel . read ( identifier ...
Read ValueData from External Storage .
15,935
public IndexerIoModeHandler getModeHandler ( ) { if ( modeHandler == null ) { if ( ctx . getCache ( ) . getStatus ( ) != ComponentStatus . RUNNING ) { throw new IllegalStateException ( "The cache should be started first" ) ; } synchronized ( this ) { if ( modeHandler == null ) { this . modeHandler = new IndexerIoModeHa...
Get the mode handler
15,936
@ SuppressWarnings ( "rawtypes" ) protected void doPushState ( ) { final boolean debugEnabled = LOG . isDebugEnabled ( ) ; if ( debugEnabled ) { LOG . debug ( "start pushing in-memory state to cache cacheLoader collection" ) ; } Map < String , ChangesFilterListsWrapper > changesMap = new HashMap < String , ChangesFilte...
Flushes all cache content to underlying CacheStore
15,937
public static String getStatusDescription ( int status ) { String description = "" ; Integer statusKey = new Integer ( status ) ; if ( statusDescriptions . containsKey ( statusKey ) ) { description = statusDescriptions . get ( statusKey ) ; } return String . format ( "%s %d %s" , WebDavConst . HTTPVER , status , descri...
Returns status description by it s code .
15,938
private void spoolContent ( InputStream is ) throws IOException , FileNotFoundException { SwapFile swapFile = SwapFile . get ( spoolConfig . tempDirectory , System . currentTimeMillis ( ) + "_" + SEQUENCE . incrementAndGet ( ) , spoolConfig . fileCleaner ) ; try { OutputStream os = PrivilegedFileHelper . fileOutputStre...
Spools the content extracted from the URL
15,939
public MatchResult match ( QPath input ) { try { return match ( new Context ( input ) ) . getMatchResult ( ) ; } catch ( RepositoryException e ) { throw ( IllegalArgumentException ) new IllegalArgumentException ( "QPath not normalized" ) . initCause ( e ) ; } }
Matches this pattern against the input .
15,940
private void addPathsWithUnknownChangedSize ( ChangesItem changesItem , ItemState state ) { if ( ! state . isPersisted ( ) && ( state . isDeleted ( ) || state . isRenamed ( ) ) ) { String itemPath = getPath ( state . getData ( ) . getQPath ( ) ) ; for ( String trackedPath : quotaPersister . getAllTrackedNodes ( rName ,...
Checks if changes were made but changed size is unknown . If so determinate for which nodes data size should be recalculated at all and put those paths into respective collection .
15,941
private void behaveWhenQuotaExceeded ( String message ) throws ExceededQuotaLimitException { switch ( exceededQuotaBehavior ) { case EXCEPTION : throw new ExceededQuotaLimitException ( message ) ; case WARNING : LOG . warn ( message ) ; break ; } }
What to do if data size exceeded quota limit . Throwing exception or logging only . Depends on preconfigured parameter .
15,942
protected void pushChangesToCoordinator ( ChangesItem changesItem ) throws SecurityException , RPCException { if ( ! changesItem . isEmpty ( ) ) { rpcService . executeCommandOnCoordinator ( applyPersistedChangesTask , true , changesItem ) ; } }
Push changes to coordinator to apply .
15,943
private String getPath ( QPath path ) { try { return lFactory . createJCRPath ( path ) . getAsString ( false ) ; } catch ( RepositoryException e ) { throw new IllegalStateException ( e . getMessage ( ) , e ) ; } }
Returns item absolute path .
15,944
private Serializable executeCommand ( RemoteCommand command , Serializable ... args ) throws RPCException { try { return command . execute ( args ) ; } catch ( Throwable e ) { throw new RPCException ( e . getMessage ( ) , e ) ; } }
Command executing .
15,945
public ItemState read ( ObjectReader in ) throws UnknownClassIdException , IOException { int key ; if ( ( key = in . readInt ( ) ) != SerializationConstants . ITEM_STATE ) { throw new UnknownClassIdException ( "There is unexpected class [" + key + "]" ) ; } ItemState is = null ; try { int state = in . readInt ( ) ; boo...
Read and set ItemState data .
15,946
public Response search ( Session session , HierarchicalProperty body , String baseURI ) { try { SearchRequestEntity requestEntity = new SearchRequestEntity ( body ) ; Query query = session . getWorkspace ( ) . getQueryManager ( ) . createQuery ( requestEntity . getQuery ( ) , requestEntity . getQueryLanguage ( ) ) ; Qu...
Webdav search method implementation .
15,947
public int getDoc ( IndexReader reader ) throws IOException { if ( doc == - 1 ) { TermDocs docs = reader . termDocs ( new Term ( FieldNames . UUID , id . toString ( ) ) ) ; try { if ( docs . next ( ) ) { return docs . doc ( ) ; } else { throw new IOException ( "Node with id " + id + " not found in index" ) ; } } finall...
Returns the document number for this score node .
15,948
private String [ ] safeListToArray ( List < String > v ) { return v != null ? v . toArray ( new String [ v . size ( ) ] ) : new String [ 0 ] ; }
Convert list to array .
15,949
public void removeWorkspaceIndex ( WorkspaceEntry wsConfig , boolean isSystem ) throws RepositoryConfigurationException , IOException { String indexDirName = wsConfig . getQueryHandler ( ) . getParameterValue ( QueryHandlerParams . PARAM_INDEX_DIR ) ; File indexDir = new File ( indexDirName ) ; if ( PrivilegedFileHelpe...
Remove all file of workspace index .
15,950
public PlainChangesLog pushLog ( QPath rootPath ) { PlainChangesLog cLog = new PlainChangesLogImpl ( getDescendantsChanges ( rootPath ) , session ) ; if ( rootPath . equals ( Constants . ROOT_PATH ) ) { clear ( ) ; } else { remove ( rootPath ) ; } return cLog ; }
Creates new changes log with rootPath and its descendants of this one and removes those entries .
15,951
protected void doRestore ( ) throws Throwable { PlainChangesLog changes = read ( ) ; TransactionChangesLog tLog = new TransactionChangesLog ( changes ) ; tLog . setSystemId ( Constants . JCR_CORE_RESTORE_WORKSPACE_INITIALIZER_SYSTEM_ID ) ; dataManager . save ( tLog ) ; }
Perform restore operation .
15,952
private String removeAsterisk ( String str ) { if ( str . startsWith ( "*" ) ) { str = str . substring ( 1 ) ; } if ( str . endsWith ( "*" ) ) { str = str . substring ( 0 , str . length ( ) - 1 ) ; } return str ; }
Removes asterisk from beginning and from end of statement .
15,953
public Set < VersionResource > getVersions ( ) throws RepositoryException , IllegalResourceTypeException { Set < VersionResource > resources = new HashSet < VersionResource > ( ) ; VersionIterator versions = versionHistory . getAllVersions ( ) ; while ( versions . hasNext ( ) ) { Version version = versions . nextVersio...
Returns all versions of a resource .
15,954
public VersionResource getVersion ( String name ) throws RepositoryException , IllegalResourceTypeException { return new VersionResource ( versionURI ( name ) , versionedResource , versionHistory . getVersion ( name ) , namespaceContext ) ; }
Returns the version of resouce by name .
15,955
protected final URI versionURI ( String versionName ) { return URI . create ( versionedResource . getIdentifier ( ) . toASCIIString ( ) + "?version=" + versionName ) ; }
Returns URI of the resource version .
15,956
protected String buildPathX8 ( String fileName ) { final int xLength = 8 ; char [ ] chs = fileName . toCharArray ( ) ; StringBuilder path = new StringBuilder ( ) ; for ( int i = 0 ; i < xLength ; i ++ ) { path . append ( File . separator ) . append ( chs [ i ] ) ; } path . append ( fileName . substring ( xLength ) ) ; ...
best for now 12 . 07 . 07
15,957
private void load ( ) throws IOException { if ( PrivilegedFileHelper . exists ( storage ) ) { InputStream in = PrivilegedFileHelper . fileInputStream ( storage ) ; try { Properties props = new Properties ( ) ; log . debug ( "loading namespace mappings..." ) ; props . load ( in ) ; Iterator < Object > iter = props . key...
Loads currently known mappings from a . properties file .
15,958
private void store ( ) throws IOException { Properties props = new Properties ( ) ; Iterator < String > iter = prefixToURI . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { String prefix = iter . next ( ) ; String uri = prefixToURI . get ( prefix ) ; props . setProperty ( prefix , uri ) ; } OutputStream out ...
Writes the currently known mappings into a . properties file .
15,959
public static RegistryEntry parse ( final byte [ ] bytes ) throws IOException , SAXException , ParserConfigurationException { try { return SecurityHelper . doPrivilegedExceptionAction ( new PrivilegedExceptionAction < RegistryEntry > ( ) { public RegistryEntry run ( ) throws Exception { return new RegistryEntry ( Docum...
Factory method to create RegistryEntry from serialized XML
15,960
public void addClassTag ( String tag , Class type ) { tagToClass . put ( tag , type ) ; classToTag . put ( type , tag ) ; }
Sets a tag to use instead of the fully qualifier class name . This can make the JSON easier to read .
15,961
public < T > void setSerializer ( Class < T > type , JsonSerializer < T > serializer ) { classToSerializer . put ( type , serializer ) ; }
Registers a serializer to use for the specified type instead of the default behavior of serializing all of an objects fields .
15,962
public void setElementType ( Class type , String fieldName , Class elementType ) { ObjectMap < String , FieldMetadata > fields = getFields ( type ) ; FieldMetadata metadata = fields . get ( fieldName ) ; if ( metadata == null ) throw new JsonException ( "Field not found: " + fieldName + " (" + type . getName ( ) + ")" ...
Sets the type of elements in a collection . When the element type is known the class for each element in the collection does not need to be written unless different from the element type .
15,963
public void setWriter ( Writer writer ) { if ( ! ( writer instanceof JsonWriter ) ) writer = new JsonWriter ( writer ) ; this . writer = ( JsonWriter ) writer ; this . writer . setOutputType ( outputType ) ; this . writer . setQuoteLongValues ( quoteLongValues ) ; }
Sets the writer where JSON output will be written . This is only necessary when not using the toJson methods .
15,964
public void writeFields ( Object object ) { Class type = object . getClass ( ) ; Object [ ] defaultValues = getDefaultValues ( type ) ; OrderedMap < String , FieldMetadata > fields = getFields ( type ) ; int i = 0 ; for ( FieldMetadata metadata : new OrderedMapValues < FieldMetadata > ( fields ) ) { Field field = metad...
Writes all fields of the specified object to the current JSON object .
15,965
public void writeField ( Object object , String fieldName , String jsonName , Class elementType ) { Class type = object . getClass ( ) ; ObjectMap < String , FieldMetadata > fields = getFields ( type ) ; FieldMetadata metadata = fields . get ( fieldName ) ; if ( metadata == null ) throw new JsonException ( "Field not f...
Writes the specified field to the current JSON object .
15,966
public void writeValue ( String name , Object value ) { try { writer . name ( name ) ; } catch ( IOException ex ) { throw new JsonException ( ex ) ; } if ( value == null ) writeValue ( value , null , null ) ; else writeValue ( value , value . getClass ( ) , null ) ; }
Writes the value as a field on the current JSON object without writing the actual class .
15,967
public void writeValue ( String name , Object value , Class knownType ) { try { writer . name ( name ) ; } catch ( IOException ex ) { throw new JsonException ( ex ) ; } writeValue ( value , knownType , null ) ; }
Writes the value as a field on the current JSON object writing the class of the object if it differs from the specified known type .
15,968
public void writeValue ( Object value ) { if ( value == null ) writeValue ( value , null , null ) ; else writeValue ( value , value . getClass ( ) , null ) ; }
Writes the value without writing the class of the object .
15,969
boolean detectLongRunningJob ( long currentTime , Job job ) { if ( job . status ( ) == JobStatus . RUNNING && ! longRunningJobs . containsKey ( job ) ) { int jobExecutionsCount = job . executionsCount ( ) ; Long jobStartedtimeInMillis = job . lastExecutionStartedTimeInMillis ( ) ; Thread threadRunningJob = job . thread...
Check whether a job is running for too long or not .
15,970
public Job schedule ( Runnable runnable , Schedule when ) { return schedule ( null , runnable , when ) ; }
Schedule the executions of a process .
15,971
public Optional < Job > findJob ( String name ) { return Optional . ofNullable ( indexedJobsByName . get ( name ) ) ; }
Find a job by its name
15,972
public void gracefullyShutdown ( Duration timeout ) { logger . info ( "Shutting down..." ) ; if ( ! shuttingDown ) { synchronized ( this ) { shuttingDown = true ; threadPoolExecutor . shutdown ( ) ; } for ( Job job : jobStatus ( ) ) { Runnable runningJob = job . runningJob ( ) ; if ( runningJob != null ) { threadPoolEx...
Wait until the current running jobs are executed and cancel jobs that are planned to be executed .
15,973
private void launcher ( ) { while ( ! shuttingDown ) { Long timeBeforeNextExecution = null ; synchronized ( this ) { if ( nextExecutionsOrder . size ( ) > 0 ) { timeBeforeNextExecution = nextExecutionsOrder . get ( 0 ) . nextExecutionTimeInMillis ( ) - timeProvider . currentTime ( ) ; } } if ( timeBeforeNextExecution =...
The daemon that will be in charge of placing the jobs in the thread pool when they are ready to be executed .
15,974
private void runJob ( Job jobToRun ) { long startExecutionTime = timeProvider . currentTime ( ) ; long timeBeforeNextExecution = jobToRun . nextExecutionTimeInMillis ( ) - startExecutionTime ; if ( timeBeforeNextExecution < 0 ) { logger . debug ( "Job '{}' execution is {}ms late" , jobToRun . name ( ) , - timeBeforeNex...
The wrapper around a job that will be executed in the thread pool . It is especially in charge of logging changing the job status and checking for the next job to be executed .
15,975
private HttpURLConnection configureURLConnection ( HttpMethod method , String urlString , Map < String , String > httpHeaders , int contentLength ) throws IOException { preconditionNotNull ( method , "method cannot be null" ) ; preconditionNotNull ( urlString , "urlString cannot be null" ) ; preconditionNotNull ( httpH...
Provides an internal convenience method to allow easy overriding by test classes
15,976
String getResponseEncoding ( URLConnection connection ) { String charset = null ; String contentType = connection . getHeaderField ( "Content-Type" ) ; if ( contentType != null ) { for ( String param : contentType . replace ( " " , "" ) . split ( ";" ) ) { if ( param . startsWith ( "charset=" ) ) { charset = param . sp...
Determine the response encoding if specified
15,977
public static PDFont mapDefaultFonts ( Font font ) { if ( fontNameEqualsAnyOf ( font , Font . SANS_SERIF , Font . DIALOG , Font . DIALOG_INPUT , "Arial" , "Helvetica" ) ) return chooseMatchingHelvetica ( font ) ; if ( fontNameEqualsAnyOf ( font , Font . MONOSPACED , "courier" , "courier new" ) ) return chooseMatchingCo...
Find a PDFont for the given font object which does not need to be embedded .
15,978
public static PDFont chooseMatchingTimes ( Font font ) { if ( ( font . getStyle ( ) & ( Font . ITALIC | Font . BOLD ) ) == ( Font . ITALIC | Font . BOLD ) ) return PDType1Font . TIMES_BOLD_ITALIC ; if ( ( font . getStyle ( ) & Font . ITALIC ) == Font . ITALIC ) return PDType1Font . TIMES_ITALIC ; if ( ( font . getStyle...
Get a PDType1Font . TIMES - variant which matches the given font
15,979
public static PDFont chooseMatchingCourier ( Font font ) { if ( ( font . getStyle ( ) & ( Font . ITALIC | Font . BOLD ) ) == ( Font . ITALIC | Font . BOLD ) ) return PDType1Font . COURIER_BOLD_OBLIQUE ; if ( ( font . getStyle ( ) & Font . ITALIC ) == Font . ITALIC ) return PDType1Font . COURIER_OBLIQUE ; if ( ( font . ...
Get a PDType1Font . COURIER - variant which matches the given font
15,980
public static PDFont chooseMatchingHelvetica ( Font font ) { if ( ( font . getStyle ( ) & ( Font . ITALIC | Font . BOLD ) ) == ( Font . ITALIC | Font . BOLD ) ) return PDType1Font . HELVETICA_BOLD_OBLIQUE ; if ( ( font . getStyle ( ) & Font . ITALIC ) == Font . ITALIC ) return PDType1Font . HELVETICA_OBLIQUE ; if ( ( f...
Get a PDType1Font . HELVETICA - variant which matches the given font
15,981
@ SuppressWarnings ( "WeakerAccess" ) public void registerFont ( String fontName , File fontFile ) { if ( ! fontFile . exists ( ) ) throw new IllegalArgumentException ( "Font " + fontFile + " does not exist!" ) ; FontEntry entry = new FontEntry ( ) ; entry . overrideName = fontName ; entry . file = fontFile ; fontFiles...
Register a font .
15,982
@ SuppressWarnings ( "WeakerAccess" ) public void registerFont ( String name , PDFont font ) { fontMap . put ( name , font ) ; }
Register a font which is already associated with the PDDocument
15,983
@ SuppressWarnings ( "WeakerAccess" ) protected PDFont mapFont ( final Font font , final IFontTextDrawerEnv env ) throws IOException , FontFormatException { for ( final FontEntry fontEntry : fontFiles ) { if ( fontEntry . overrideName == null ) { Font javaFont = Font . createFont ( Font . TRUETYPE_FONT , fontEntry . fi...
Try to map the java . awt . Font to a PDFont .
15,984
public float getPixelSize ( ) { if ( mVectorState == null && mVectorState . mVPathRenderer == null || mVectorState . mVPathRenderer . mBaseWidth == 0 || mVectorState . mVPathRenderer . mBaseHeight == 0 || mVectorState . mVPathRenderer . mViewportHeight == 0 || mVectorState . mVPathRenderer . mViewportWidth == 0 ) { ret...
The size of a pixel when scaled from the intrinsic dimension to the viewport dimension . This is used to calculate the path animation accuracy .
15,985
@ RequestMapping ( path = "/api" , method = RequestMethod . GET , produces = { "application/hal+json" , "application/json" } ) public HalRepresentation getHomeDocument ( final HttpServletRequest request ) { final String homeUrl = request . getRequestURL ( ) . toString ( ) ; return new HalRepresentation ( linkingTo ( ) ...
Entry point for the products REST API .
15,986
public static Builder copyOf ( final Link prototype ) { return new Builder ( prototype . rel , prototype . href ) . withType ( prototype . type ) . withProfile ( prototype . profile ) . withTitle ( prototype . title ) . withName ( prototype . name ) . withDeprecation ( prototype . deprecation ) . withHrefLang ( prototy...
Create a Builder instance and initialize it from a prototype Link .
15,987
public static Embedded embedded ( final String rel , final HalRepresentation embeddedItem ) { return new Embedded ( singletonMap ( rel , embeddedItem ) ) ; }
Create an Embedded instance with a single embedded HalRepresentations that will be rendered as a single item instead of an array of embedded items .
15,988
public static Embedded embedded ( final String rel , final List < ? extends HalRepresentation > embeddedRepresentations ) { return new Embedded ( singletonMap ( rel , new ArrayList < > ( embeddedRepresentations ) ) ) ; }
Create an Embedded instance with a list of nested HalRepresentations for a single link - relation type .
15,989
private int calcLastPage ( int total , int pageSize ) { if ( total == 0 ) { return firstPage ; } else { final int zeroBasedPageNo = total % pageSize > 0 ? total / pageSize : total / pageSize - 1 ; return firstPage + zeroBasedPageNo ; } }
Returns the number of the last page if the total number of items is known .
15,990
private String pageUri ( final UriTemplate uriTemplate , final int pageNumber , final int pageSize ) { if ( pageSize == MAX_VALUE ) { return uriTemplate . expand ( ) ; } return uriTemplate . set ( pageNumberVar ( ) , pageNumber ) . set ( pageSizeVar ( ) , pageSize ) . expand ( ) ; }
Return the HREF of the page specified by UriTemplate pageNumber and pageSize .
15,991
@ SuppressWarnings ( "rawtypes" ) public Stream < Link > stream ( ) { return links . values ( ) . stream ( ) . map ( obj -> { if ( obj instanceof List ) { return ( List ) obj ; } else { return singletonList ( obj ) ; } } ) . flatMap ( Collection :: stream ) ; }
Returns a Stream of links .
15,992
private int calcLastPageSkip ( int total , int skip , int limit ) { if ( skip > total - limit ) { return skip ; } if ( total % limit > 0 ) { return total - total % limit ; } return total - limit ; }
Calculate the number of items to skip for the last page .
15,993
private String pageUri ( final UriTemplate uriTemplate , final int skip , final int limit ) { if ( limit == MAX_VALUE ) { return uriTemplate . expand ( ) ; } return uriTemplate . set ( skipVar ( ) , skip ) . set ( limitVar ( ) , limit ) . expand ( ) ; }
Return the URI of the page with N skipped items and a page limitted to pages of size M .
15,994
public List < Product > searchFor ( final Optional < String > searchTerm ) { if ( searchTerm . isPresent ( ) ) { return products . stream ( ) . filter ( matchingProductsFor ( searchTerm . get ( ) ) ) . collect ( toList ( ) ) ; } else { return products ; } }
Searches for products using a case - insensitive search term .
15,995
HalRepresentation mergeWithEmbedding ( final Curies curies ) { this . curies = this . curies . mergeWith ( curies ) ; if ( this . links != null ) { removeDuplicateCuriesFromEmbedding ( curies ) ; this . links = this . links . using ( this . curies ) ; if ( embedded != null ) { embedded = embedded . using ( this . curie...
Merges the Curies of an embedded resource with the Curies of this resource and updates link - relation types in _links and _embedded items .
15,996
public < T extends HalRepresentation > T as ( final Class < T > type ) throws IOException { return objectMapper . readValue ( json , type ) ; }
Specify the type that is used to parse and map the json .
15,997
private Optional < JsonNode > findPossiblyCuriedEmbeddedNode ( final HalRepresentation halRepresentation , final JsonNode jsonNode , final String rel ) { final JsonNode embedded = jsonNode . get ( "_embedded" ) ; if ( embedded != null ) { final Curies curies = halRepresentation . getCuries ( ) ; final JsonNode curiedNo...
Returns the JsonNode of the embedded items by link - relation type and resolves possibly curied rels .
15,998
public void register ( final Link curi ) { if ( ! curi . getRel ( ) . equals ( "curies" ) ) { throw new IllegalArgumentException ( "Link must be a CURI" ) ; } final boolean alreadyRegistered = curies . stream ( ) . anyMatch ( link -> link . getHref ( ) . equals ( curi . getHref ( ) ) ) ; if ( alreadyRegistered ) { curi...
Registers a CURI link in the Curies instance .
15,999
public Curies mergeWith ( final Curies other ) { final Curies merged = copyOf ( this ) ; other . curies . forEach ( merged :: register ) ; return merged ; }
Merges this Curies with another instance of Curies and returns the merged instance .