idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
12,500
private boolean isPresent ( CobolOptionalType optionalType ) { if ( optionalType . getDependingOn ( ) != null ) { return getOdoValue ( optionalType . getDependingOn ( ) ) > 0 ; } return true ; }
Check if an optional type is present .
12,501
public boolean isCustomVariable ( CobolPrimitiveType < ? > type , String name ) { if ( type . isCustomVariable ( ) ) { return true ; } if ( customVariables != null && customVariables . contains ( name ) ) { return true ; } if ( customChoiceStrategy != null && customChoiceStrategy . getVariableNames ( ) != null && customChoiceStrategy . getVariableNames ( ) . contains ( name ) ) { return true ; } return false ; }
A primitive type is a custom variable if it has been marked as so via one of the available mechanisms or is needed to make choice decisions .
12,502
public String getAuditRepositoryTransport ( ) { String transport = getOption ( AUDITOR_AUDIT_REPOSITORY_TRANSPORT_KEY ) ; return ( transport != null ) ? transport : AUDITOR_AUDIT_REPOSITORY_DEFAULT_TRANSPORT ; }
Get the port of the target audit repository
12,503
public void setAuditRepositoryUri ( URI uri ) { setAuditRepositoryHost ( uri . getHost ( ) ) ; setAuditRepositoryPort ( uri . getPort ( ) ) ; setAuditRepositoryTransport ( uri . getScheme ( ) ) ; }
Set the hostname and port of the target audit repository from a well - formed URI
12,504
public static PIXSourceAuditor getAuditor ( ) { AuditorModuleContext ctx = AuditorModuleContext . getContext ( ) ; return ( PIXSourceAuditor ) ctx . getAuditor ( PIXSourceAuditor . class ) ; }
Get an instance of the PIX Source Auditor from the global context
12,505
public void auditCreatePatientRecordV3Event ( RFC3881EventOutcomeCodes eventOutcome , String pixManagerUri , String receivingFacility , String receivingApp , String sendingFacility , String sendingApp , String hl7MessageId , String patientId , List < CodedValueType > purposesOfUse , List < CodedValueType > userRoles ) { if ( ! isAuditorEnabled ( ) ) { return ; } auditPatientRecordEvent ( true , new IHETransactionEventTypeCodes . PatientIdentityFeedV3 ( ) , eventOutcome , RFC3881EventCodes . RFC3881EventActionCodes . CREATE , sendingFacility , sendingApp , getSystemAltUserId ( ) , getSystemNetworkId ( ) , receivingFacility , receivingApp , null , EventUtils . getAddressForUrl ( pixManagerUri , false ) , getHumanRequestor ( ) , hl7MessageId , new String [ ] { patientId } , purposesOfUse , userRoles ) ; }
Audits an ITI - 44 Patient Identity Feed CREATE PATIENT RECORD event for Patient Identity Source actors .
12,506
public void auditDeletePatientRecordEvent ( RFC3881EventOutcomeCodes eventOutcome , String pixManagerUri , String receivingFacility , String receivingApp , String sendingFacility , String sendingApp , String hl7MessageControlId , String patientId ) { if ( ! isAuditorEnabled ( ) ) { return ; } auditPatientRecordEvent ( true , new IHETransactionEventTypeCodes . PatientIdentityFeed ( ) , eventOutcome , RFC3881EventCodes . RFC3881EventActionCodes . DELETE , sendingFacility , sendingApp , getSystemAltUserId ( ) , getSystemNetworkId ( ) , receivingFacility , receivingApp , null , EventUtils . getAddressForUrl ( pixManagerUri , false ) , getHumanRequestor ( ) , hl7MessageControlId , new String [ ] { patientId } , null , null ) ; }
Audits an ITI - 8 Patient Identity Feed DELETE PATIENT RECORD event for Patient Identity Source actors .
12,507
public static NodeAuthModuleContext getContext ( ) { SecurityContext securityContext = SecurityContextFactory . getSecurityContext ( ) ; if ( ! securityContext . isInitialized ( ) ) { securityContext . initialize ( ) ; } AbstractModuleContext moduleContext = securityContext . getModuleContext ( CONTEXT_ID ) ; if ( ! ( moduleContext instanceof NodeAuthModuleContext ) ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Initializing the NodeAuthModuleContext" ) ; } moduleContext = ContextInitializer . defaultInitialize ( ) ; securityContext . registerModuleContext ( CONTEXT_ID , moduleContext ) ; } return ( NodeAuthModuleContext ) moduleContext ; }
Returns the current singleton instance of the Node Authentication Module Context from the ThreadLocal cache . If the ThreadLocal cache has not been initialized or does not contain this context then create and initialize module context register in the ThreadLocal and return the new instance .
12,508
protected AddressArray createAddressArray ( File homeDir , int batchSize , int numSyncBatches , boolean indexesCached ) throws Exception { AddressArrayFactory factory = new AddressArrayFactory ( indexesCached ) ; AddressArray addrArray = factory . createDynamicAddressArray ( homeDir , batchSize , numSyncBatches ) ; return addrArray ; }
Creates an address array file under the specified home directory .
12,509
protected boolean canSplitOnCapacity ( ) { if ( 0 < _split ) { int splitTo = _levelCapacity + _split ; if ( capacity ( ) > splitTo && splitTo >= _levelCapacity ) { return true ; } } return false ; }
Perform split on the current capacity .
12,510
@ SuppressWarnings ( "unchecked" ) public void load ( File propertiesFile ) throws IOException { String paramName ; String paramValue ; Reader reader = new FileReader ( propertiesFile ) ; _properties . load ( reader ) ; reader . close ( ) ; paramName = StoreParams . PARAM_INDEXES_CACHED ; paramValue = _properties . getProperty ( paramName ) ; setIndexesCached ( parseBoolean ( paramName , paramValue , StoreParams . INDEXES_CACHED_DEFAULT ) ) ; paramName = StoreParams . PARAM_BATCH_SIZE ; paramValue = _properties . getProperty ( paramName ) ; setBatchSize ( parseInt ( paramName , paramValue , StoreParams . BATCH_SIZE_DEFAULT ) ) ; paramName = StoreParams . PARAM_NUM_SYNC_BATCHES ; paramValue = _properties . getProperty ( paramName ) ; setNumSyncBatches ( parseInt ( paramName , paramValue , StoreParams . NUM_SYNC_BATCHES_DEFAULT ) ) ; paramName = StoreParams . PARAM_SEGMENT_FILE_SIZE_MB ; paramValue = _properties . getProperty ( paramName ) ; setSegmentFileSizeMB ( parseInt ( paramName , paramValue , StoreParams . SEGMENT_FILE_SIZE_MB_DEFAULT ) ) ; paramName = StoreParams . PARAM_SEGMENT_COMPACT_FACTOR ; paramValue = _properties . getProperty ( paramName ) ; setSegmentCompactFactor ( parseDouble ( paramName , paramValue , StoreParams . SEGMENT_COMPACT_FACTOR_DEFAULT ) ) ; paramName = StoreParams . PARAM_HASH_LOAD_FACTOR ; paramValue = _properties . getProperty ( paramName ) ; setHashLoadFactor ( parseDouble ( paramName , paramValue , StoreParams . HASH_LOAD_FACTOR_DEFAULT ) ) ; paramName = StoreParams . PARAM_SEGMENT_FACTORY_CLASS ; paramValue = _properties . getProperty ( paramName ) ; SegmentFactory segmentFactory = null ; if ( paramValue != null ) { try { segmentFactory = Class . forName ( paramValue ) . asSubclass ( SegmentFactory . class ) . newInstance ( ) ; } catch ( Exception e ) { _logger . warn ( "Invalid SegmentFactory class: " + paramValue ) ; } } if ( segmentFactory == null ) { segmentFactory = new MappedSegmentFactory ( ) ; } setSegmentFactory ( segmentFactory ) ; paramName = StoreParams . PARAM_HASH_FUNCTION_CLASS ; paramValue = _properties . getProperty ( paramName ) ; HashFunction < byte [ ] > hashFunction = null ; if ( paramValue != null ) { try { hashFunction = ( HashFunction < byte [ ] > ) Class . forName ( paramValue ) . newInstance ( ) ; } catch ( Exception e ) { _logger . warn ( "Invalid HashFunction<byte[]> class: " + paramValue ) ; } } if ( hashFunction == null ) { hashFunction = new FnvHashFunction ( ) ; } setHashFunction ( hashFunction ) ; paramName = StoreParams . PARAM_DATA_HANDLER_CLASS ; paramValue = _properties . getProperty ( paramName ) ; DataHandler dataHandler = null ; if ( paramValue != null ) { try { dataHandler = ( DataHandler ) Class . forName ( paramValue ) . newInstance ( ) ; } catch ( Exception e ) { _logger . warn ( "Invalid DataHandler class: " + paramValue ) ; } } if ( dataHandler != null ) { setDataHandler ( dataHandler ) ; } }
Loads configuration from a properties file .
12,511
public void validate ( ) throws InvalidStoreConfigException { if ( getSegmentFactory ( ) == null ) { throw new InvalidStoreConfigException ( "Segment factory not found" ) ; } if ( getHashFunction ( ) == null ) { throw new InvalidStoreConfigException ( "Store hash function not found" ) ; } if ( getBatchSize ( ) < StoreParams . BATCH_SIZE_MIN ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_BATCH_SIZE + "=" + getBatchSize ( ) ) ; } if ( getNumSyncBatches ( ) < StoreParams . NUM_SYNC_BATCHES_MIN ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_NUM_SYNC_BATCHES + "=" + getNumSyncBatches ( ) ) ; } if ( getHashLoadFactor ( ) < StoreParams . HASH_LOAD_FACTOR_MIN || getHashLoadFactor ( ) > StoreParams . HASH_LOAD_FACTOR_MAX ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_HASH_LOAD_FACTOR + "=" + getHashLoadFactor ( ) ) ; } if ( getSegmentFileSizeMB ( ) < StoreParams . SEGMENT_FILE_SIZE_MB_MIN || getSegmentFileSizeMB ( ) > StoreParams . SEGMENT_FILE_SIZE_MB_MAX ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_SEGMENT_FILE_SIZE_MB + "=" + getSegmentFileSizeMB ( ) ) ; } if ( getSegmentCompactFactor ( ) < StoreParams . SEGMENT_COMPACT_FACTOR_MIN || getSegmentCompactFactor ( ) > StoreParams . SEGMENT_COMPACT_FACTOR_MAX ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_SEGMENT_COMPACT_FACTOR + "=" + getSegmentCompactFactor ( ) ) ; } }
Checks the validity of this StoreConfig .
12,512
public boolean setProperty ( String pName , String pValue ) { if ( pName == null ) return false ; _properties . setProperty ( pName , pValue ) ; return true ; }
Sets a store configuration property via its name and value .
12,513
public boolean setClass ( String pName , Class < ? > pValue ) { if ( pName == null ) return false ; _properties . setProperty ( pName , pValue . getName ( ) + "" ) ; return true ; }
Sets a class property via a string property name .
12,514
public int getInt ( String pName , int defaultValue ) { String pValue = _properties . getProperty ( pName ) ; return parseInt ( pName , pValue , defaultValue ) ; }
Gets an integer property via a string property name .
12,515
public float getFloat ( String pName , float defaultValue ) { String pValue = _properties . getProperty ( pName ) ; return parseFloat ( pName , pValue , defaultValue ) ; }
Gets a float property via a string property name .
12,516
public double getDouble ( String pName , double defaultValue ) { String pValue = _properties . getProperty ( pName ) ; return parseDouble ( pName , pValue , defaultValue ) ; }
Gets a double property via a string property name .
12,517
public boolean getBoolean ( String pName , boolean defaultValue ) { String pValue = _properties . getProperty ( pName ) ; return parseBoolean ( pName , pValue , defaultValue ) ; }
Gets a boolean property via a string property name .
12,518
public Class < ? > getClass ( String pName , Class < ? > defaultValue ) { String pValue = _properties . getProperty ( pName ) ; return parseClass ( pName , pValue , defaultValue ) ; }
Gets a class property via a string property name .
12,519
public void setSegmentFactory ( SegmentFactory segmentFactory ) { if ( segmentFactory == null ) { throw new IllegalArgumentException ( "Invalid segmentFactory: " + segmentFactory ) ; } this . _segmentFactory = segmentFactory ; this . _properties . setProperty ( PARAM_SEGMENT_FACTORY_CLASS , segmentFactory . getClass ( ) . getName ( ) ) ; }
Sets the segment factory of the target store .
12,520
public static StoreConfig newInstance ( File filePath ) throws IOException { File homeDir ; Properties p = new Properties ( ) ; if ( filePath . exists ( ) ) { if ( filePath . isDirectory ( ) ) { homeDir = filePath ; File propertiesFile = new File ( filePath , CONFIG_PROPERTIES_FILE ) ; if ( propertiesFile . exists ( ) ) { FileReader reader = new FileReader ( propertiesFile ) ; p . load ( reader ) ; reader . close ( ) ; } else { throw new FileNotFoundException ( propertiesFile . toString ( ) ) ; } } else { homeDir = filePath . getParentFile ( ) ; FileReader reader = new FileReader ( filePath ) ; p . load ( reader ) ; reader . close ( ) ; } } else { throw new FileNotFoundException ( filePath . toString ( ) ) ; } int initialCapacity = - 1 ; String initialCapacityStr = p . getProperty ( StoreParams . PARAM_INITIAL_CAPACITY ) ; if ( initialCapacityStr == null ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_INITIAL_CAPACITY + " not found" ) ; } else if ( ( initialCapacity = parseInt ( StoreParams . PARAM_INITIAL_CAPACITY , initialCapacityStr , - 1 ) ) < 1 ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_INITIAL_CAPACITY + "=" + initialCapacityStr ) ; } int partitionStart = - 1 ; int partitionCount = - 1 ; String partitionStartStr = p . getProperty ( StoreParams . PARAM_PARTITION_START ) ; String partitionCountStr = p . getProperty ( StoreParams . PARAM_PARTITION_COUNT ) ; if ( partitionStartStr != null && partitionCountStr != null ) { if ( ( partitionStart = parseInt ( StoreParams . PARAM_PARTITION_START , partitionStartStr , - 1 ) ) < 0 ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_PARTITION_START + "=" + partitionStartStr ) ; } if ( ( partitionCount = parseInt ( StoreParams . PARAM_PARTITION_COUNT , partitionCountStr , - 1 ) ) < 1 ) { throw new InvalidStoreConfigException ( StoreParams . PARAM_PARTITION_COUNT + "=" + partitionCountStr ) ; } } else { return new StoreConfig ( homeDir , initialCapacity ) ; } return new StorePartitionConfig ( homeDir , partitionStart , partitionCount ) ; }
Creates a new instance of StoreConfig .
12,521
private void setAttributesFromUsage ( final Usage usage ) { switch ( usage ) { case BINARY : _cobolType = CobolTypes . BINARY_ITEM ; _xsdType = XsdType . INTEGER ; break ; case NATIVEBINARY : _cobolType = CobolTypes . NATIVE_BINARY_ITEM ; _xsdType = XsdType . INTEGER ; break ; case SINGLEFLOAT : _cobolType = CobolTypes . SINGLE_FLOAT_ITEM ; _xsdType = XsdType . FLOAT ; _minStorageLength = 4 ; break ; case DOUBLEFLOAT : _cobolType = CobolTypes . DOUBLE_FLOAT_ITEM ; _xsdType = XsdType . DOUBLE ; _minStorageLength = 8 ; break ; case PACKEDDECIMAL : _cobolType = CobolTypes . PACKED_DECIMAL_ITEM ; _xsdType = XsdType . DECIMAL ; break ; case INDEX : _cobolType = CobolTypes . INDEX_ITEM ; _xsdType = XsdType . HEXBINARY ; _minStorageLength = 4 ; break ; case POINTER : _cobolType = CobolTypes . POINTER_ITEM ; _xsdType = XsdType . HEXBINARY ; _minStorageLength = 4 ; break ; case PROCEDUREPOINTER : _cobolType = CobolTypes . PROC_POINTER_ITEM ; _xsdType = XsdType . HEXBINARY ; _minStorageLength = 8 ; break ; case FUNCTIONPOINTER : _cobolType = CobolTypes . FUNC_POINTER_ITEM ; _xsdType = XsdType . HEXBINARY ; _minStorageLength = 4 ; break ; case DISPLAY : _cobolType = CobolTypes . ALPHANUMERIC_ITEM ; _xsdType = XsdType . STRING ; break ; case DISPLAY1 : _cobolType = CobolTypes . DBCS_ITEM ; _xsdType = XsdType . STRING ; break ; case NATIONAL : _cobolType = CobolTypes . NATIONAL_ITEM ; _xsdType = XsdType . STRING ; break ; default : _log . error ( "Unrecognized usage clause " + toString ( ) ) ; } }
Derive XML schema attributes from a COBOL usage clause . This gives a rough approximation of the XSD type because the picture clause usually carries info that needs to be further analyzed to determine a more precise type . If no usage clause we assume there will be a picture clause .
12,522
public static String getXmlCompatibleCobolName ( final String cobolName ) { if ( cobolName != null && cobolName . length ( ) > 0 && Character . isDigit ( cobolName . charAt ( 0 ) ) ) { return SAFE_NAME_PREFIX + cobolName ; } else { return cobolName ; } }
Transform the COBOL name to a valid XML Name . Does not do any beautification other than strictly complying with XML specifications .
12,523
protected void entryRemoved ( boolean evicted , String key , Bitmap oldValue , Bitmap newValue ) { if ( Utils . hasHoneycomb ( ) ) { addToPool ( oldValue ) ; } else { } }
Notify the removed entry that is no longer being cached
12,524
protected int sizeOf ( String key , Bitmap value ) { final int bitmapSize = BitmapLruPool . getBitmapSize ( value ) ; return bitmapSize == 0 ? 1 : bitmapSize ; }
Measure item size in kilobytes rather than units which is more practical for a bitmap cache
12,525
public void saveHWMark ( long endOfPeriod ) { if ( getHWMark ( ) < endOfPeriod ) { try { set ( 0 , get ( 0 ) , endOfPeriod ) ; } catch ( Exception e ) { _logger . error ( "Failed to saveHWMark " + endOfPeriod , e ) ; } } else if ( 0 < endOfPeriod && endOfPeriod < getLWMark ( ) ) { try { _entryManager . sync ( ) ; } catch ( Exception e ) { _logger . error ( "Failed to saveHWMark" + endOfPeriod , e ) ; } _entryManager . setWaterMarks ( endOfPeriod , endOfPeriod ) ; } }
Sync - up the high water mark to a given value .
12,526
public void addNodeActiveParticipant ( String userId , String altUserId , String userName , String networkId ) { addActiveParticipant ( userId , altUserId , userName , false , null , networkId ) ; }
Add an Active Participant to this message representing the node doing the network entry
12,527
public SearchFeed search ( String query , int limit , int offset ) throws GiphyException { SearchFeed feed = null ; HashMap < String , String > params = new HashMap < String , String > ( ) ; params . put ( "api_key" , apiKey ) ; params . put ( "q" , query ) ; if ( limit > 100 ) { params . put ( "limit" , "100" ) ; } else { params . put ( "limit" , limit + "" ) ; } params . put ( "offset" , offset + "" ) ; Request request = new Request ( UrlUtil . buildUrlQuery ( SearchEndpoint , params ) ) ; try { Response response = sender . sendRequest ( request ) ; feed = gson . fromJson ( response . getBody ( ) , SearchFeed . class ) ; } catch ( JsonSyntaxException | IOException e ) { log . error ( e . getMessage ( ) , e ) ; throw new GiphyException ( e ) ; } return feed ; }
Search all Giphy GIFs for a word or phrase and returns a SearchFeed object .
12,528
public SearchGiphy searchByID ( String id ) throws GiphyException { SearchGiphy giphy = null ; HashMap < String , String > params = new HashMap < String , String > ( ) ; params . put ( "api_key" , apiKey ) ; Request request = new Request ( UrlUtil . buildUrlQuery ( IDEndpoint + id , params ) ) ; try { Response response = sender . sendRequest ( request ) ; giphy = gson . fromJson ( response . getBody ( ) , SearchGiphy . class ) ; } catch ( JsonSyntaxException | IOException e ) { log . error ( e . getMessage ( ) , e ) ; throw new GiphyException ( e ) ; } return giphy ; }
Returns a SerachGiphy object .
12,529
public SearchFeed trendSticker ( ) throws GiphyException { SearchFeed feed = null ; HashMap < String , String > params = new HashMap < String , String > ( ) ; params . put ( "api_key" , apiKey ) ; Request request = new Request ( UrlUtil . buildUrlQuery ( TrendingStickerEndpoint , params ) ) ; try { Response response = sender . sendRequest ( request ) ; feed = gson . fromJson ( response . getBody ( ) , SearchFeed . class ) ; } catch ( JsonSyntaxException | IOException e ) { log . error ( e . getMessage ( ) , e ) ; throw new GiphyException ( e ) ; } return feed ; }
Fetch GIFs currently trending online . Hand curated by the Giphy editorial team . The data returned mirrors the GIFs showcased on the Giphy homepage . Returns 25 results by default .
12,530
public SearchRandom searchRandomSticker ( String tag ) throws GiphyException { SearchRandom random = null ; HashMap < String , String > params = new HashMap < String , String > ( ) ; params . put ( "api_key" , apiKey ) ; params . put ( "tag" , tag ) ; Request request = new Request ( UrlUtil . buildUrlQuery ( RandomEndpointSticker , params ) ) ; try { Response response = sender . sendRequest ( request ) ; random = gson . fromJson ( response . getBody ( ) , SearchRandom . class ) ; } catch ( JsonSyntaxException | IOException e ) { log . error ( e . getMessage ( ) , e ) ; throw new GiphyException ( e ) ; } return random ; }
Returns a random GIF limited by tag .
12,531
private static int getResizedDimension ( int maxPrimary , int maxSecondary , int actualPrimary , int actualSecondary , ScaleType scaleType ) { if ( ( maxPrimary == 0 ) && ( maxSecondary == 0 ) ) { return actualPrimary ; } if ( scaleType == ScaleType . FIT_XY ) { if ( maxPrimary == 0 ) { return actualPrimary ; } return maxPrimary ; } if ( maxPrimary == 0 ) { double ratio = ( double ) maxSecondary / ( double ) actualSecondary ; return ( int ) ( actualPrimary * ratio ) ; } if ( maxSecondary == 0 ) { return maxPrimary ; } double ratio = ( double ) actualSecondary / ( double ) actualPrimary ; int resized = maxPrimary ; if ( scaleType == ScaleType . CENTER_CROP ) { if ( ( resized * ratio ) < maxSecondary ) { resized = ( int ) ( maxSecondary / ratio ) ; } return resized ; } if ( ( resized * ratio ) > maxSecondary ) { resized = ( int ) ( maxSecondary / ratio ) ; } return resized ; }
Scales one side of a rectangle to fit aspect ratio .
12,532
protected boolean isValidString ( CobolContext cobolContext , byte [ ] hostData , int start ) { int length = start + getBytesLen ( ) ; for ( int i = start ; i < length ; i ++ ) { int code = hostData [ i ] & 0xFF ; if ( code != 0 && code < cobolContext . getHostSpaceCharCode ( ) ) { return false ; } } return true ; }
Relatively naive implementation that assumes content is either low - value or a code point greater or equal to the space character .
12,533
private FromHostPrimitiveResult < String > fromHostString ( CobolContext cobolContext , byte [ ] hostData , int start , int bytesLen ) { int spaceCode = cobolContext . getHostSpaceCharCode ( ) ; boolean checkSpace = cobolContext . isTruncateHostStringsTrailingSpaces ( ) ; int end = start + bytesLen ; while ( end > start ) { int code = hostData [ end - 1 ] & 0xFF ; if ( code != 0 && ( ( checkSpace && code != spaceCode ) || ! checkSpace ) ) { break ; } end -- ; } if ( start == end ) { return new FromHostPrimitiveResult < String > ( "" ) ; } boolean isDirty = false ; for ( int i = start ; i < end ; i ++ ) { if ( hostData [ i ] == 0 ) { isDirty = true ; break ; } } String result = null ; try { if ( isDirty ) { byte [ ] work = new byte [ end - start ] ; for ( int i = start ; i < end ; i ++ ) { work [ i - start ] = hostData [ i ] == 0 ? ( byte ) cobolContext . getHostSpaceCharCode ( ) : hostData [ i ] ; } result = new String ( work , cobolContext . getHostCharsetName ( ) ) ; } else { result = new String ( hostData , start , end - start , cobolContext . getHostCharsetName ( ) ) ; } } catch ( UnsupportedEncodingException e ) { return new FromHostPrimitiveResult < String > ( "Failed to use host character set " + cobolContext . getHostCharsetName ( ) , hostData , start , bytesLen ) ; } return new FromHostPrimitiveResult < String > ( result ) ; }
Convert host data to a java String .
12,534
public final static DataReader createDataReader ( File file , IOType type ) { if ( type == IOType . MAPPED ) { if ( file . length ( ) <= Integer . MAX_VALUE ) { return new MappedReader ( file ) ; } else { return new MultiMappedReader ( file ) ; } } else { return new ChannelReader ( file ) ; } }
Creates a new DataReader to read from a file .
12,535
public final static DataWriter createDataWriter ( File file , IOType type ) { if ( type == IOType . MAPPED ) { if ( file . length ( ) <= Integer . MAX_VALUE ) { return new MappedWriter ( file ) ; } else { return new MultiMappedWriter ( file ) ; } } else { return new ChannelWriter ( file ) ; } }
Creates a new DataWriter to write to a file .
12,536
public static XDSConsumerAuditor getAuditor ( ) { AuditorModuleContext ctx = AuditorModuleContext . getContext ( ) ; return ( XDSConsumerAuditor ) ctx . getAuditor ( XDSConsumerAuditor . class ) ; }
Get an instance of the XDS Document Consumer Auditor from the global context
12,537
public void auditRegistryQueryEvent ( RFC3881EventOutcomeCodes eventOutcome , String registryEndpointUri , String consumerUserName , String adhocQueryRequestPayload , String patientId ) { if ( ! isAuditorEnabled ( ) ) { return ; } auditQueryEvent ( true , new IHETransactionEventTypeCodes . RegistrySQLQuery ( ) , eventOutcome , getAuditSourceId ( ) , getAuditEnterpriseSiteId ( ) , getSystemUserId ( ) , getSystemAltUserId ( ) , getSystemUserName ( ) , getSystemNetworkId ( ) , consumerUserName , consumerUserName , true , registryEndpointUri , null , "" , adhocQueryRequestPayload , "" , patientId , null , null ) ; }
Audits an ITI - 16 Registry Query event for XDS . a Document Consumer actors .
12,538
public void auditRegistryStoredQueryEvent ( RFC3881EventOutcomeCodes eventOutcome , String registryEndpointUri , String consumerUserName , String storedQueryUUID , String adhocQueryRequestPayload , String homeCommunityId , String patientId , List < CodedValueType > purposesOfUse , List < CodedValueType > userRoles ) { if ( ! isAuditorEnabled ( ) ) { return ; } String replyToUri = "http://www.w3.org/2005/08/addressing/anonymous" ; auditQueryEvent ( true , new IHETransactionEventTypeCodes . RegistryStoredQuery ( ) , eventOutcome , getAuditSourceId ( ) , getAuditEnterpriseSiteId ( ) , replyToUri , getSystemAltUserId ( ) , getSystemUserName ( ) , getSystemNetworkId ( ) , consumerUserName , consumerUserName , false , registryEndpointUri , null , storedQueryUUID , adhocQueryRequestPayload , homeCommunityId , patientId , purposesOfUse , userRoles ) ; }
Audits an ITI - 18 Registry Stored Query event for XDS . a and XDS . b Document Consumer actors .
12,539
public void auditRetrieveDocumentEvent ( RFC3881EventOutcomeCodes eventOutcome , String repositoryRetrieveUri , String userName , String documentUniqueId , String patientId ) { if ( ! isAuditorEnabled ( ) ) { return ; } ImportEvent importEvent = new ImportEvent ( false , eventOutcome , new IHETransactionEventTypeCodes . RetrieveDocument ( ) , null ) ; importEvent . setAuditSourceId ( getAuditSourceId ( ) , getAuditEnterpriseSiteId ( ) ) ; importEvent . addSourceActiveParticipant ( repositoryRetrieveUri , null , null , EventUtils . getAddressForUrl ( repositoryRetrieveUri , false ) , false ) ; importEvent . addDestinationActiveParticipant ( getSystemUserId ( ) , getSystemAltUserId ( ) , getSystemUserName ( ) , getSystemNetworkId ( ) , true ) ; if ( ! EventUtils . isEmptyOrNull ( userName ) ) { importEvent . addHumanRequestorActiveParticipant ( userName , null , userName , ( List < CodedValueType > ) null ) ; } if ( ! EventUtils . isEmptyOrNull ( patientId ) ) { importEvent . addPatientParticipantObject ( patientId ) ; } importEvent . addDocumentUriParticipantObject ( repositoryRetrieveUri , documentUniqueId ) ; audit ( importEvent ) ; }
Audits an ITI - 17 Retrieve Document event for XDS . a Document Consumer actors .
12,540
public void auditRetrieveDocumentSetEvent ( RFC3881EventOutcomeCodes eventOutcome , String repositoryEndpointUri , String userName , String [ ] documentUniqueIds , String repositoryUniqueId , String homeCommunityId , String patientId , List < CodedValueType > purposesOfUse , List < CodedValueType > userRoles ) { if ( ! isAuditorEnabled ( ) ) { return ; } String [ ] repositoryUniqueIds = null ; String [ ] homeCommunityIds = null ; if ( ! EventUtils . isEmptyOrNull ( documentUniqueIds ) ) { repositoryUniqueIds = new String [ documentUniqueIds . length ] ; Arrays . fill ( repositoryUniqueIds , repositoryUniqueId ) ; homeCommunityIds = new String [ documentUniqueIds . length ] ; Arrays . fill ( homeCommunityIds , homeCommunityId ) ; } auditRetrieveDocumentSetEvent ( eventOutcome , repositoryEndpointUri , userName , documentUniqueIds , repositoryUniqueIds , homeCommunityIds , patientId , purposesOfUse , userRoles ) ; }
Audits an ITI - 43 Retrieve Document Set event for XDS . b Document Consumer actors . Sends audit messages for situations when exactly one repository and zero or one community are specified in the transaction .
12,541
public void auditRetrieveDocumentSetEvent ( RFC3881EventOutcomeCodes eventOutcome , String repositoryEndpointUri , String userName , String [ ] documentUniqueIds , String [ ] repositoryUniqueIds , String [ ] homeCommunityIds , String patientId , List < CodedValueType > purposesOfUse , List < CodedValueType > userRoles ) { if ( ! isAuditorEnabled ( ) ) { return ; } ImportEvent importEvent = new ImportEvent ( false , eventOutcome , new IHETransactionEventTypeCodes . RetrieveDocumentSet ( ) , purposesOfUse ) ; importEvent . setAuditSourceId ( getAuditSourceId ( ) , getAuditEnterpriseSiteId ( ) ) ; importEvent . addSourceActiveParticipant ( repositoryEndpointUri , null , null , EventUtils . getAddressForUrl ( repositoryEndpointUri , false ) , false ) ; String replyToUri = "http://www.w3.org/2005/08/addressing/anonymous" ; importEvent . addDestinationActiveParticipant ( replyToUri , getSystemAltUserId ( ) , getSystemUserName ( ) , getSystemNetworkId ( ) , true ) ; if ( ! EventUtils . isEmptyOrNull ( userName ) ) { importEvent . addHumanRequestorActiveParticipant ( userName , null , userName , userRoles ) ; } if ( ! EventUtils . isEmptyOrNull ( patientId ) ) { importEvent . addPatientParticipantObject ( patientId ) ; } if ( ! EventUtils . isEmptyOrNull ( documentUniqueIds ) ) { for ( int i = 0 ; i < documentUniqueIds . length ; i ++ ) { importEvent . addDocumentParticipantObject ( documentUniqueIds [ i ] , repositoryUniqueIds [ i ] , homeCommunityIds [ i ] ) ; } } audit ( importEvent ) ; }
Audits an ITI - 43 Retrieve Document Set event for XDS . b Document Consumer actors . Sends audit messages for situations when more than one repository and more than one community are specified in the transaction .
12,542
public void addAccessingParticipant ( String userId , String altUserId , String userName , String networkId ) { addActiveParticipant ( userId , altUserId , userName , true , null , networkId ) ; }
Adds the Active Participant of the User or System that accessed the log
12,543
public void addAuditLogIdentity ( String auditLogUri ) { addParticipantObjectIdentification ( new RFC3881ParticipantObjectCodes . RFC3881ParticipantObjectIDTypeCodes . URI ( ) , "Security Audit Log" , null , null , auditLogUri , RFC3881ParticipantObjectTypeCodes . SYSTEM , RFC3881ParticipantObjectTypeRoleCodes . SECURITY_RESOURCE , null , null ) ; }
Adds the Participant Object block representing the audit log accessed
12,544
public static XDSRepositoryAuditor getAuditor ( ) { AuditorModuleContext ctx = AuditorModuleContext . getContext ( ) ; return ( XDSRepositoryAuditor ) ctx . getAuditor ( XDSRepositoryAuditor . class ) ; }
Get an instance of the XDS Document Repository Auditor from the global context
12,545
public void auditRegisterDocumentSetEvent ( RFC3881EventOutcomeCodes eventOutcome , String repositoryUserId , String userName , String registryEndpointUri , String submissionSetUniqueId , String patientId ) { if ( ! isAuditorEnabled ( ) ) { return ; } auditRegisterEvent ( new IHETransactionEventTypeCodes . RegisterDocumentSet ( ) , eventOutcome , repositoryUserId , userName , registryEndpointUri , submissionSetUniqueId , patientId , null , null ) ; }
Audits an ITI - 14 Register Document Set event for XDS . a Document Repository actors .
12,546
public void auditRegisterDocumentSetBEvent ( RFC3881EventOutcomeCodes eventOutcome , String repositoryUserId , String userName , String registryEndpointUri , String submissionSetUniqueId , String patientId , List < CodedValueType > purposesOfUse , List < CodedValueType > userRoles ) { if ( ! isAuditorEnabled ( ) ) { return ; } auditRegisterEvent ( new IHETransactionEventTypeCodes . RegisterDocumentSetB ( ) , eventOutcome , repositoryUserId , userName , registryEndpointUri , submissionSetUniqueId , patientId , purposesOfUse , userRoles ) ; }
Audits an ITI - 42 Register Document Set - b event for XDS . b Document Repository actors .
12,547
public void auditRetrieveDocumentEvent ( RFC3881EventOutcomeCodes eventOutcome , String consumerIpAddress , String userName , String repositoryRetrieveUri , String documentUniqueId ) { if ( ! isAuditorEnabled ( ) ) { return ; } ExportEvent exportEvent = new ExportEvent ( true , eventOutcome , new IHETransactionEventTypeCodes . RetrieveDocument ( ) , null ) ; exportEvent . setAuditSourceId ( getAuditSourceId ( ) , getAuditEnterpriseSiteId ( ) ) ; exportEvent . addSourceActiveParticipant ( repositoryRetrieveUri , getSystemAltUserId ( ) , null , EventUtils . getAddressForUrl ( repositoryRetrieveUri , false ) , false ) ; if ( ! EventUtils . isEmptyOrNull ( userName ) ) { exportEvent . addHumanRequestorActiveParticipant ( userName , null , userName , ( List < CodedValueType > ) null ) ; } exportEvent . addDestinationActiveParticipant ( consumerIpAddress , null , null , consumerIpAddress , true ) ; exportEvent . addDocumentUriParticipantObject ( repositoryRetrieveUri , documentUniqueId ) ; audit ( exportEvent ) ; }
Audits an ITI - 17 Retrieve Document event for XDS . a Document Repository actors .
12,548
public void auditRetrieveDocumentSetEvent ( RFC3881EventOutcomeCodes eventOutcome , String consumerUserId , String consumerUserName , String consumerIpAddress , String repositoryEndpointUri , String [ ] documentUniqueIds , String repositoryUniqueId , String homeCommunityId , List < CodedValueType > purposesOfUse , List < CodedValueType > userRoles ) { if ( ! isAuditorEnabled ( ) ) { return ; } String [ ] repositoryUniqueIds = null ; if ( ! EventUtils . isEmptyOrNull ( documentUniqueIds ) ) { repositoryUniqueIds = new String [ documentUniqueIds . length ] ; Arrays . fill ( repositoryUniqueIds , repositoryUniqueId ) ; } auditRetrieveDocumentSetEvent ( eventOutcome , consumerUserId , consumerUserName , consumerIpAddress , repositoryEndpointUri , documentUniqueIds , repositoryUniqueIds , homeCommunityId , purposesOfUse , userRoles ) ; }
Audits an ITI - 43 Retrieve Document Set - b event for XDS . b Document Repository actors . Sends audit messages for situations when exactly one repository and zero or one community are specified in the transaction .
12,549
public void auditRetrieveDocumentSetEvent ( RFC3881EventOutcomeCodes eventOutcome , String consumerUserId , String consumerUserName , String consumerIpAddress , String repositoryEndpointUri , String [ ] documentUniqueIds , String [ ] repositoryUniqueIds , String [ ] homeCommunityIds , List < CodedValueType > purposesOfUse , List < CodedValueType > userRoles ) { if ( ! isAuditorEnabled ( ) ) { return ; } ExportEvent exportEvent = new ExportEvent ( true , eventOutcome , new IHETransactionEventTypeCodes . RetrieveDocumentSet ( ) , purposesOfUse ) ; exportEvent . setAuditSourceId ( getAuditSourceId ( ) , getAuditEnterpriseSiteId ( ) ) ; exportEvent . addSourceActiveParticipant ( repositoryEndpointUri , getSystemAltUserId ( ) , null , EventUtils . getAddressForUrl ( repositoryEndpointUri , false ) , false ) ; exportEvent . addDestinationActiveParticipant ( consumerUserId , null , consumerUserName , consumerIpAddress , true ) ; if ( ! EventUtils . isEmptyOrNull ( consumerUserName ) ) { exportEvent . addHumanRequestorActiveParticipant ( consumerUserName , null , consumerUserName , userRoles ) ; } if ( ! EventUtils . isEmptyOrNull ( documentUniqueIds ) ) { for ( int i = 0 ; i < documentUniqueIds . length ; i ++ ) { exportEvent . addDocumentParticipantObject ( documentUniqueIds [ i ] , repositoryUniqueIds [ i ] , homeCommunityIds [ i ] ) ; } } audit ( exportEvent ) ; }
Audits an ITI - 43 Retrieve Document Set - b event for XDS . b Document Repository actors . Sends audit messages for situations when more than one repository and more than one community are specified in the transaction .
12,550
protected void auditProvideAndRegisterEvent ( IHETransactionEventTypeCodes transaction , RFC3881EventOutcomeCodes eventOutcome , String sourceUserId , String sourceIpAddress , String userName , String repositoryEndpointUri , String submissionSetUniqueId , String patientId , List < CodedValueType > purposesOfUse , List < CodedValueType > userRoles ) { ImportEvent importEvent = new ImportEvent ( false , eventOutcome , transaction , purposesOfUse ) ; importEvent . setAuditSourceId ( getAuditSourceId ( ) , getAuditEnterpriseSiteId ( ) ) ; importEvent . addSourceActiveParticipant ( sourceUserId , null , null , sourceIpAddress , true ) ; if ( ! EventUtils . isEmptyOrNull ( userName ) ) { importEvent . addHumanRequestorActiveParticipant ( userName , null , userName , userRoles ) ; } importEvent . addDestinationActiveParticipant ( repositoryEndpointUri , getSystemAltUserId ( ) , null , EventUtils . getAddressForUrl ( repositoryEndpointUri , false ) , false ) ; if ( ! EventUtils . isEmptyOrNull ( patientId ) ) { importEvent . addPatientParticipantObject ( patientId ) ; } importEvent . addSubmissionSetParticipantObject ( submissionSetUniqueId ) ; audit ( importEvent ) ; }
Generically sends audit messages for XDS Document Repository Provide And Register Document Set events
12,551
public final int getLiveSegmentCount ( ) { int num = 0 ; for ( int i = 0 ; i < _segList . size ( ) ; i ++ ) { if ( _segList . get ( i ) != null ) num ++ ; } return num ; }
Gets the count of live segments managed by this SegmentManager .
12,552
public synchronized boolean freeSegment ( Segment seg ) throws IOException { if ( seg == null ) return false ; int segId = seg . getSegmentId ( ) ; if ( segId < _segList . size ( ) && _segList . get ( segId ) == seg ) { _segList . set ( segId , null ) ; seg . close ( false ) ; if ( segId == ( _segList . size ( ) - 1 ) ) { try { _segList . remove ( segId ) ; File segFile = seg . getSegmentFile ( ) ; if ( segFile . exists ( ) ) segFile . delete ( ) ; File sibFile = getSegmentIndexBufferFile ( segId ) ; if ( sibFile . exists ( ) ) sibFile . delete ( ) ; _log . info ( "Segment " + seg . getSegmentId ( ) + " deleted" ) ; } catch ( Exception e ) { _log . warn ( "Segment " + seg . getSegmentId ( ) + " not deleted" , e ) ; } } else { if ( seg . isRecyclable ( ) && recycle ( seg ) ) { _log . info ( "Segment " + seg . getSegmentId ( ) + " recycled" ) ; } else { _log . info ( "Segment " + seg . getSegmentId ( ) + " freed" ) ; } } return true ; } return false ; }
Frees the specified segment .
12,553
public synchronized Segment nextSegment ( ) throws IOException { Segment seg = nextSegment ( false ) ; File sibFile = getSegmentIndexBufferFile ( seg . getSegmentId ( ) ) ; if ( sibFile . exists ( ) ) { sibFile . delete ( ) ; } return seg ; }
Opens the next segment available for read and write .
12,554
public void flushSegmentIndexBuffers ( ) { SegmentIndexBuffer sib = null ; while ( ( sib = _sibManager . poll ( ) ) != null ) { File sibFile = getSegmentIndexBufferFile ( sib . getSegmentId ( ) ) ; try { _sibManager . getSegmentIndexBufferIO ( ) . write ( sib , sibFile ) ; } catch ( Exception e ) { _log . warn ( "failed to write " + sibFile . getAbsolutePath ( ) ) ; sibFile . delete ( ) ; } } }
Flushes accumulated segment index buffers to disk .
12,555
private Segment nextSegment ( boolean newOnly ) throws IOException { int index ; Segment seg ; if ( newOnly ) { index = _segList . size ( ) ; } else { if ( _recycleList . size ( ) > 0 ) { seg = _recycleList . remove ( ) ; seg . reinit ( ) ; _segList . set ( seg . getSegmentId ( ) , seg ) ; _log . info ( "reinit Segment " + seg . getSegmentId ( ) ) ; return seg ; } for ( index = 0 ; index < _segList . size ( ) ; index ++ ) { if ( _segList . get ( index ) == null ) break ; } } File segFile = getSegmentFile ( index ) ; seg = getSegmentFactory ( ) . createSegment ( index , segFile , _segFileSizeMB , Segment . Mode . READ_WRITE ) ; if ( index < _segList . size ( ) ) _segList . set ( index , seg ) ; else _segList . add ( seg ) ; return seg ; }
Gets the next segment available for read and write .
12,556
private void initSegs ( ) throws IOException { int loaded = 0 ; File [ ] segFiles = listSegmentFiles ( ) ; if ( segFiles . length == 0 ) { return ; } try { for ( int i = 0 ; i < segFiles . length ; i ++ ) { File segFile = segFiles [ i ] ; int segId = Integer . parseInt ( segFile . getName ( ) . substring ( 0 , segFile . getName ( ) . indexOf ( '.' ) ) ) ; if ( segId != i ) { throw new IOException ( "Segment file " + i + ".seg missing" ) ; } if ( getMeta ( ) . hasSegmentInService ( segId ) ) { Segment s = getSegmentFactory ( ) . createSegment ( segId , segFile , _segFileSizeMB , Segment . Mode . READ_ONLY ) ; s . incrLoadSize ( getMeta ( ) . getSegmentLoadSize ( segId ) ) ; _segList . add ( s ) ; loaded ++ ; } else { _segList . add ( null ) ; } } } catch ( IOException e ) { _log . error ( e . getMessage ( ) ) ; clearInternal ( false ) ; throw e ; } _log . info ( "loaded: " + loaded + "/" + segFiles . length ) ; }
Initializes the segments managed by this SegmentManager
12,557
private void clearInternal ( boolean clearMeta ) { for ( int segId = 0 , cnt = _segList . size ( ) ; segId < cnt ; segId ++ ) { Segment seg = _segList . get ( segId ) ; if ( seg != null ) { try { if ( seg . getMode ( ) == Segment . Mode . READ_WRITE ) { seg . force ( ) ; } seg . close ( false ) ; } catch ( IOException e ) { _log . warn ( "failed to close segment " + seg . getSegmentId ( ) ) ; } finally { _segList . set ( segId , null ) ; } } } if ( clearMeta ) { try { updateMeta ( ) ; } catch ( IOException e ) { _log . warn ( "failed to clear segment meta" ) ; } } _segList . clear ( ) ; _recycleList . clear ( ) ; }
Clears this SegmentManager .
12,558
protected File [ ] listSegmentFiles ( ) { File segDir = new File ( _segHomePath ) ; File [ ] segFiles = segDir . listFiles ( new FileFilter ( ) { public boolean accept ( File filePath ) { String fileName = filePath . getName ( ) ; if ( fileName . matches ( "^[0-9]+\\.seg$" ) ) { return true ; } return false ; } } ) ; if ( segFiles == null ) { segFiles = new File [ 0 ] ; } else if ( segFiles . length > 0 ) { Arrays . sort ( segFiles , new Comparator < File > ( ) { public int compare ( File f1 , File f2 ) { int segId1 = Integer . parseInt ( f1 . getName ( ) . substring ( 0 , f1 . getName ( ) . indexOf ( '.' ) ) ) ; int segId2 = Integer . parseInt ( f2 . getName ( ) . substring ( 0 , f2 . getName ( ) . indexOf ( '.' ) ) ) ; return ( segId1 < segId2 ) ? - 1 : ( ( segId1 == segId2 ) ? 0 : 1 ) ; } } ) ; } return segFiles ; }
Lists all the segment files managed by this SegmentManager .
12,559
private CharSequence hashContext ( final Object context , final Options options ) throws IOException { Set < Entry < String , Object > > propertySet = options . propertySet ( context ) ; StringBuilder buffer = new StringBuilder ( ) ; Context parent = options . context ; boolean first = true ; for ( Entry < String , Object > entry : propertySet ) { Context current = Context . newBuilder ( parent , entry . getValue ( ) ) . combine ( "@key" , entry . getKey ( ) ) . combine ( "@first" , first ? "first" : "" ) . build ( ) ; buffer . append ( options . fn ( current ) ) ; current . destroy ( ) ; first = false ; } return buffer . toString ( ) ; }
Iterate over a hash like object .
12,560
private CharSequence iterableContext ( final Iterable < Object > context , final Options options ) throws IOException { StringBuilder buffer = new StringBuilder ( ) ; if ( options . isFalsy ( context ) ) { buffer . append ( options . inverse ( ) ) ; } else { Iterator < Object > iterator = context . iterator ( ) ; int index = - 1 ; Context parent = options . context ; while ( iterator . hasNext ( ) ) { index += 1 ; Object element = iterator . next ( ) ; boolean first = index == 0 ; boolean even = index % 2 == 0 ; boolean last = ! iterator . hasNext ( ) ; Context current = Context . newBuilder ( parent , element ) . combine ( "@index" , index ) . combine ( "@first" , first ? "first" : "" ) . combine ( "@last" , last ? "last" : "" ) . combine ( "@odd" , even ? "" : "odd" ) . combine ( "@even" , even ? "even" : "" ) . build ( ) ; buffer . append ( options . fn ( current ) ) ; current . destroy ( ) ; } } return buffer . toString ( ) ; }
Iterate over an iterable object .
12,561
protected synchronized void switchEntry ( boolean blocking ) throws IOException { if ( ! _entryCompaction . isEmpty ( ) ) { File file = new File ( getDirectory ( ) , getEntryLogName ( _entryCompaction ) ) ; _entryCompaction . save ( file ) ; _entryPool . addToServiceQueue ( _entryCompaction ) ; _entryCompaction = _entryPool . next ( ) ; } if ( ! _entry . isEmpty ( ) ) { if ( _persistListener != null ) { _persistListener . beforePersist ( _entry ) ; } File file = new File ( getDirectory ( ) , getEntryLogName ( _entry ) ) ; _entry . save ( file ) ; if ( _persistListener != null ) { _persistListener . afterPersist ( _entry ) ; } _lwmScn = Math . max ( _lwmScn , _entry . getMaxScn ( ) ) ; _entryPool . addToServiceQueue ( _entry ) ; _entry = _entryPool . next ( ) ; } if ( _autoApplyEntries ) { if ( _entryPool . getServiceQueueSize ( ) >= _maxEntries ) { applyEntries ( blocking ) ; } } }
Switches to a new entry if the current _entry is not empty .
12,562
protected synchronized void applyEntries ( boolean blocking ) throws IOException { if ( blocking ) { synchronized ( _entryApply ) { List < Entry < V > > entryList = new ArrayList < Entry < V > > ( ) ; while ( _entryPool . getServiceQueueSize ( ) > 0 ) { Entry < V > entry = _entryPool . pollFromService ( ) ; if ( entry != null ) entryList . add ( entry ) ; } applyEntries ( entryList ) ; } } else { synchronized ( _entryApply ) { for ( int i = 0 ; i < _maxEntries ; i ++ ) { Entry < V > entry = _entryPool . pollFromService ( ) ; if ( entry != null ) _entryApply . add ( entry ) ; } } new Thread ( _entryApply ) . start ( ) ; } }
Apply accumulated entries to the array file .
12,563
protected List < Entry < V > > loadEntryFiles ( ) { File [ ] files = getDirectory ( ) . listFiles ( ) ; String prefix = getEntryLogPrefix ( ) ; String suffix = getEntryLogSuffix ( ) ; List < Entry < V > > entryList = new ArrayList < Entry < V > > ( ) ; if ( files == null ) return entryList ; for ( File file : files ) { String fileName = file . getName ( ) ; if ( fileName . startsWith ( prefix ) && fileName . endsWith ( suffix ) ) { try { Entry < V > entry = _entryPool . next ( ) ; entry . load ( file ) ; entryList . add ( entry ) ; } catch ( Exception e ) { String filePath = file . getAbsolutePath ( ) ; _log . warn ( filePath + " corrupted: length=" + file . length ( ) , e ) ; if ( file . delete ( ) ) { _log . warn ( filePath + " deleted" ) ; } } } } return entryList ; }
Load entry log files from disk into _entryList .
12,564
private List < Entry < V > > filterEntryList ( List < Entry < V > > entryList , long minScn , long maxScn ) { List < Entry < V > > result = new ArrayList < Entry < V > > ( entryList . size ( ) ) ; for ( Entry < V > e : entryList ) { if ( minScn <= e . getMinScn ( ) && e . getMaxScn ( ) <= maxScn ) { result . add ( e ) ; } } return result ; }
Filter and select entries from an entry list that only have SCNs no less than the specified lower bound minScn and that only have SCNs no greater than the specified upper bound maxScn .
12,565
private List < Entry < V > > filterEntryListLowerBound ( List < Entry < V > > entryList , long scn ) { List < Entry < V > > result = new ArrayList < Entry < V > > ( entryList . size ( ) ) ; for ( Entry < V > e : entryList ) { if ( scn <= e . getMinScn ( ) ) { result . add ( e ) ; } } return result ; }
Filter and select entries from an entry list that only have SCNs no less than the specified lower bound .
12,566
@ SuppressWarnings ( "unused" ) private List < Entry < V > > filterEntryListUpperBound ( List < Entry < V > > entryList , long scn ) { List < Entry < V > > result = new ArrayList < Entry < V > > ( entryList . size ( ) ) ; for ( Entry < V > e : entryList ) { if ( e . getMaxScn ( ) <= scn ) { result . add ( e ) ; } } return result ; }
Filter and select entries from an entry list that only have SCNs no greater than the specified upper bound .
12,567
protected void execute ( final File input , final String cobolFileEncoding , final File target , final String targetNamespacePrefix , final String xsltFileName ) throws XsdGenerationException { try { _log . info ( "Started translation from COBOL to XML Schema" ) ; _log . info ( "Taking COBOL from : " + input ) ; _log . info ( "COBOL encoding : " + cobolFileEncoding == null ? "default" : cobolFileEncoding ) ; _log . info ( "Output XML Schema to : " + target ) ; _log . info ( "XML Schema namespace prefix : " + targetNamespacePrefix ) ; _log . info ( "XSLT transform to apply : " + xsltFileName ) ; _log . info ( "Options in effect : " + getConfig ( ) . toString ( ) ) ; if ( input . isFile ( ) ) { if ( FilenameUtils . getExtension ( target . getPath ( ) ) . length ( ) == 0 ) { FileUtils . forceMkdir ( target ) ; } translate ( input , cobolFileEncoding , target , targetNamespacePrefix , xsltFileName ) ; } else { FileUtils . forceMkdir ( target ) ; for ( File cobolFile : input . listFiles ( ) ) { if ( cobolFile . isFile ( ) ) { translate ( cobolFile , cobolFileEncoding , target , targetNamespacePrefix , xsltFileName ) ; } } } _log . info ( "Finished translation" ) ; } catch ( IOException e ) { throw new XsdGenerationException ( e ) ; } }
Translate a single file or all files from an input folder . Place results in the output folder .
12,568
protected String getVersion ( ) throws IOException { InputStream stream = null ; try { Properties version = new Properties ( ) ; stream = Cob2XsdMain . class . getResourceAsStream ( VERSION_FILE_NAME ) ; version . load ( stream ) ; return version . getProperty ( "version" ) ; } finally { if ( stream != null ) { stream . close ( ) ; } } }
Pick up the version from the properties file .
12,569
public void setConfigFile ( final String config ) { if ( config == null ) { throw ( new IllegalArgumentException ( "Configuration file parameter is null" ) ) ; } File file = new File ( config ) ; if ( file . exists ( ) ) { if ( file . isDirectory ( ) ) { throw new IllegalArgumentException ( "Folder " + config + " is not a configuration file" ) ; } } else { throw new IllegalArgumentException ( "Configuration file " + config + " not found" ) ; } setConfigFile ( file ) ; }
Check the config parameter and keep it only if it is valid .
12,570
public static PIXConsumerAuditor getAuditor ( ) { AuditorModuleContext ctx = AuditorModuleContext . getContext ( ) ; return ( PIXConsumerAuditor ) ctx . getAuditor ( PIXConsumerAuditor . class ) ; }
Get an instance of the PIX Consumer Auditor from the global context
12,571
private static String buildMessage ( String format , Object ... args ) { String msg = ( args == null ) ? format : String . format ( Locale . US , format , args ) ; StackTraceElement [ ] trace = new Throwable ( ) . fillInStackTrace ( ) . getStackTrace ( ) ; String caller = "<unknown>" ; for ( int i = 2 ; i < trace . length ; i ++ ) { Class < ? > clazz = trace [ i ] . getClass ( ) ; if ( ! clazz . equals ( VolleyLog . class ) ) { String callingClass = trace [ i ] . getClassName ( ) ; callingClass = callingClass . substring ( callingClass . lastIndexOf ( '.' ) + 1 ) ; callingClass = callingClass . substring ( callingClass . lastIndexOf ( '$' ) + 1 ) ; caller = callingClass + "." + trace [ i ] . getMethodName ( ) ; break ; } } return String . format ( Locale . US , "[%d] %s: %s" , Thread . currentThread ( ) . getId ( ) , caller , msg ) ; }
Formats the caller s provided message and prepends useful info like calling thread ID and method name .
12,572
public V get ( K key ) { if ( key == null ) { return null ; } byte [ ] bytes = _store . get ( _keySerializer . serialize ( key ) ) ; return bytes == null ? null : _valSerializer . deserialize ( bytes ) ; }
Gets an object based on its key from the store .
12,573
public byte [ ] getBytes ( K key ) { if ( key == null ) { return null ; } return _store . get ( _keySerializer . serialize ( key ) ) ; }
Gets an object in the form of byte array from the store .
12,574
public boolean put ( K key , V value ) throws Exception { if ( key == null ) { throw new NullPointerException ( "key" ) ; } if ( value == null ) { return _store . delete ( _keySerializer . serialize ( key ) ) ; } else { return _store . put ( _keySerializer . serialize ( key ) , _valSerializer . serialize ( value ) ) ; } }
Puts an serializable object into the store .
12,575
public boolean delete ( K key ) throws Exception { if ( key == null ) { throw new NullPointerException ( "key" ) ; } return _store . delete ( _keySerializer . serialize ( key ) ) ; }
Deletes an object from the store based on its key .
12,576
public < R extends Request < T > > R setRetryPolicy ( RetryPolicy retryPolicy ) { checkIfActive ( ) ; this . retryPolicy = retryPolicy ; return ( R ) this ; }
Sets the retry policy for this request .
12,577
public < R extends Request < T > > R setRedirectPolicy ( RedirectPolicy redirectPolicy ) { checkIfActive ( ) ; this . redirectPolicy = redirectPolicy ; return ( R ) this ; }
Sets the redirect policy for this request .
12,578
< R extends Request < T > > R setRequestQueue ( RequestQueue requestQueue ) { checkIfActive ( ) ; java . lang . reflect . Method m = null ; if ( ! ( this . getClass ( ) . equals ( Request . class ) ) ) { try { m = this . getClass ( ) . getDeclaredMethod ( "parseNetworkResponse" , NetworkResponse . class ) ; } catch ( NoSuchMethodException e ) { } } if ( converterFromResponse == null ) { Type t ; if ( responseType != null ) { t = responseType ; } else { t = tryIdentifyResultType ( this ) ; } if ( t == null ) { throw new IllegalArgumentException ( "Cannot resolve Response type in order to " + "identify Response Converter for Request : " + this ) ; } try { this . converterFromResponse = ( Converter < NetworkResponse , T > ) requestQueue . getResponseConverter ( t , new Annotation [ 0 ] ) ; } catch ( IllegalArgumentException ex ) { if ( m == null ) { throw ex ; } } } if ( retryPolicy == null ) { setRetryPolicy ( new DefaultRetryPolicy ( this ) ) ; } this . requestQueue = requestQueue ; return ( R ) this ; }
Associates this request with the given queue . The request queue will be notified when this request has finished .
12,579
public < R extends Request < T > > R setCacheEntry ( Cache . Entry entry ) { cacheEntry = entry ; return ( R ) this ; }
Annotates this request with an entry retrieved for it from cache . Used for cache coherency support .
12,580
public final Map < String , String > getHeadersMap ( ) { if ( networkRequest != null && networkRequest . headers != null ) { return networkRequest . headers . toMap ( ) ; } return Collections . emptyMap ( ) ; }
Returns a list of extra HTTP headers to go along with this request
12,581
public String getBodyContentType ( ) { if ( networkRequest != null && networkRequest . contentType != null ) { return networkRequest . contentType . toString ( ) ; } return null ; }
Returns the content type of the POST or PUT body .
12,582
public final < R extends Request < T > > R setShouldCache ( boolean shouldCache ) { checkIfActive ( ) ; this . shouldCache = shouldCache ; return ( R ) this ; }
Set whether or not responses to this request should be cached .
12,583
protected Response < T > parseNetworkResponse ( NetworkResponse response ) { T parsed = null ; try { parsed = converterFromResponse . convert ( response ) ; } catch ( Exception e ) { return Response . error ( new ParseError ( e ) ) ; } return Response . success ( parsed , HttpHeaderParser . parseCacheHeaders ( response ) ) ; }
Subclasses can implement this to parse the raw network response and return an appropriate response type . This method will be called from a worker threadId . The response will not be delivered if you return null .
12,584
protected void deliverResponse ( T response ) { synchronized ( responseListeners ) { for ( RequestListener . ResponseListener responseListener : responseListeners ) { responseListener . onResponse ( response ) ; } if ( ! this . response . intermediate ) { responseListeners . clear ( ) ; } } if ( ! this . response . intermediate ) { synchronized ( errorListeners ) { errorListeners . clear ( ) ; } } }
Subclasses must implement this to perform delivery of the parsed response to their listeners . The given response is guaranteed to be non - null ; responses that fail to parse are not delivered .
12,585
public void deliverError ( JusError error ) { synchronized ( errorListeners ) { for ( RequestListener . ErrorListener errorListener : errorListeners ) { errorListener . onError ( error ) ; } errorListeners . clear ( ) ; } synchronized ( responseListeners ) { responseListeners . clear ( ) ; } }
Delivers error message to the ErrorListener that the Request was initialized with .
12,586
public int compareTo ( Request < T > other ) { Priority left = this . getPriority ( ) ; Priority right = other . getPriority ( ) ; return left == right ? this . sequence - other . sequence : right . ordinal ( ) - left . ordinal ( ) ; }
Our comparator sorts from high to low priority and secondarily by sequence number to provide FIFO ordering .
12,587
public String getSystemAltUserId ( ) { if ( ! EventUtils . isEmptyOrNull ( systemAltUserId ) ) { return systemAltUserId ; } systemAltUserId = getConfig ( ) . getSystemAltUserId ( ) ; if ( ! EventUtils . isEmptyOrNull ( systemAltUserId ) ) { return systemAltUserId ; } String processId = null ; try { RuntimeMXBean mx = ManagementFactory . getRuntimeMXBean ( ) ; processId = mx . getName ( ) ; int pointer ; if ( ( pointer = processId . indexOf ( '@' ) ) != - 1 ) { processId = processId . substring ( 0 , pointer ) ; } } catch ( Throwable t ) { } if ( EventUtils . isEmptyOrNull ( processId ) ) { processId = String . valueOf ( ( int ) ( Math . random ( ) * 1000 ) ) ; } systemAltUserId = processId ; return systemAltUserId ; }
Get alternate user id for the system s ActiveParticipant in audit messages . This is either set in configuration or the the auditor will attempt to determine it from the JVM s process id .
12,588
public String getSystemNetworkId ( ) { String ipAddress = getConfig ( ) . getSystemIpAddress ( ) ; if ( ! EventUtils . isEmptyOrNull ( ipAddress ) ) { return ipAddress ; } if ( EventUtils . isEmptyOrNull ( systemNetworkAccessPointId ) ) { try { InetAddress localAddress = InetAddress . getLocalHost ( ) ; systemNetworkAccessPointId = localAddress . getHostAddress ( ) ; } catch ( Exception e ) { LOGGER . error ( "Unable to get system IP address, defaulting to localhost" ) ; systemNetworkAccessPointId = "localhost" ; } } return systemNetworkAccessPointId ; }
Get the system s ActiveParticipant Network ID for use in audit messages . Configuration is the default value used . If no value is set in configuration then Java will attempt to determine your system s IP address . If Java cannot determine your system s IP address then localhost is used .
12,589
public boolean isAuditorEnabled ( ) { if ( ! getConfig ( ) . isAuditorEnabled ( ) ) { return false ; } if ( getConfig ( ) . getDisabledAuditors ( ) . contains ( this . getClass ( ) ) ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Auditor " + this . getClass ( ) . getName ( ) + " is disabled by configuration" ) ; } return false ; } return true ; }
Determines whether this auditor instance is enabled . Checks if global auditing is enabled in configuration and if the auditor instance s class is in the list of auditors specifically disabled by configuration
12,590
public boolean isAuditorEnabledForEventId ( AuditEventMessage msg ) { CodedValueType eventIdCode = msg . getAuditMessage ( ) . getEventIdentification ( ) . getEventID ( ) ; if ( EventUtils . containsCode ( eventIdCode , getConfig ( ) . getDisabledEvents ( ) ) ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Auditor is disabled by configuration for event " + eventIdCode . getOriginalText ( ) + " (" + eventIdCode . getCode ( ) + ")" ) ; } return false ; } return true ; }
Determines if the event that this audit message represents should be audited or if the auditor is disabled by configuration . Examples of events that may be disabled include Export Import Patient Record Security Alert etc .
12,591
public void auditUserAuthenticationLoginEvent ( RFC3881EventOutcomeCodes outcome , boolean isAuthenticatedSystem , String remoteUserId , String remoteIpAddress , String remoteUserNodeIpAddress ) { auditUserAuthenticationEvent ( outcome , new DICOMEventTypeCodes . Login ( ) , isAuthenticatedSystem , remoteUserId , remoteIpAddress , remoteUserNodeIpAddress ) ; }
Audit a User Authentication - Login Event
12,592
public void auditUserAuthenticationLogoutEvent ( RFC3881EventOutcomeCodes outcome , boolean isAuthenticatedSystem , String remoteUserId , String remoteIpAddress , String remoteUserNodeIpAddress ) { auditUserAuthenticationEvent ( outcome , new DICOMEventTypeCodes . Logout ( ) , isAuthenticatedSystem , remoteUserId , remoteIpAddress , remoteUserNodeIpAddress ) ; }
Audit a User Authentication - Logout Event
12,593
private void addField ( int fieldIndex , XmlSchemaObjectBase xsdSchemaObject , Map < String , Object > fields , RootCompositeType compositeTypes ) { if ( xsdSchemaObject instanceof XmlSchemaElement ) { XmlSchemaElement xsdElement = ( XmlSchemaElement ) xsdSchemaObject ; fields . put ( getFieldName ( xsdElement ) , getProps ( fieldIndex , xsdElement , compositeTypes ) ) ; } else if ( xsdSchemaObject instanceof XmlSchemaChoice ) { XmlSchemaChoice xsdChoice = ( XmlSchemaChoice ) xsdSchemaObject ; fields . put ( getFieldName ( xsdChoice ) , getProps ( fieldIndex , xsdChoice , compositeTypes ) ) ; } }
Add a field with associated properties to a complex type .
12,594
private void addOptionalProps ( XmlSchemaElement xsdElement , CobolAnnotations cobolAnnotations , Map < String , Object > props ) { String dependingOn = cobolAnnotations . getDependingOn ( ) ; if ( dependingOn != null ) { props . put ( IS_OPTIONAL_PROP_NAME , true ) ; props . put ( DEPENDING_ON_PROP_NAME , odoObjectNames . get ( dependingOn ) ) ; } }
Optional items are declared with a minOccurs of 0 and a maxOccurs of one . Usually there is a depending on clause .
12,595
private Map < String , Object > getProps ( XmlSchemaSimpleType xsdSimpleType , final CobolAnnotations cobolAnnotations ) { XmlSchemaSimpleTypeRestriction restriction = ( XmlSchemaSimpleTypeRestriction ) xsdSimpleType . getContent ( ) ; if ( restriction != null && restriction . getBaseTypeName ( ) != null ) { QName xsdTypeName = restriction . getBaseTypeName ( ) ; List < XmlSchemaFacet > facets = restriction . getFacets ( ) ; if ( xsdTypeName . equals ( Constants . XSD_STRING ) ) { return getCobolAlphanumType ( facets ) ; } else if ( xsdTypeName . equals ( Constants . XSD_HEXBIN ) ) { return getCobolOctetStreamType ( facets ) ; } else if ( xsdTypeName . equals ( Constants . XSD_INT ) ) { return getCobolDecimalType ( cobolAnnotations , Integer . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_LONG ) ) { return getCobolDecimalType ( cobolAnnotations , Long . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_SHORT ) ) { return getCobolDecimalType ( cobolAnnotations , Short . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_DECIMAL ) ) { return getCobolDecimalType ( cobolAnnotations , BigDecimal . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_FLOAT ) ) { return getCobolDecimalType ( cobolAnnotations , Float . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_DOUBLE ) ) { return getCobolDecimalType ( cobolAnnotations , Double . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_UNSIGNEDINT ) ) { return getCobolDecimalType ( cobolAnnotations , Long . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_UNSIGNEDSHORT ) ) { return getCobolDecimalType ( cobolAnnotations , Integer . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_UNSIGNEDLONG ) ) { return getCobolDecimalType ( cobolAnnotations , BigInteger . class ) ; } else if ( xsdTypeName . equals ( Constants . XSD_INTEGER ) ) { return getCobolDecimalType ( cobolAnnotations , BigInteger . class ) ; } else { throw new Xsd2ConverterException ( "Unsupported xsd type " + xsdTypeName ) ; } } else { throw new Xsd2ConverterException ( "Simple type without restriction " + xsdSimpleType . getQName ( ) ) ; } }
Retrieve the properties of a primitive type .
12,596
private < T extends Number > Map < String , Object > getCobolAlphanumType ( List < XmlSchemaFacet > facets ) { Map < String , Object > props = new LinkedHashMap < String , Object > ( ) ; props . put ( COBOL_TYPE_NAME_PROP_NAME , "CobolStringType" ) ; props . put ( CHAR_NUM_PROP_NAME , getMaxLength ( facets ) ) ; props . put ( JAVA_TYPE_NAME_PROP_NAME , getShortTypeName ( String . class ) ) ; return props ; }
Retrieve the properties of an alphanumeric type .
12,597
private int getMaxLength ( List < XmlSchemaFacet > facets ) { for ( XmlSchemaFacet facet : facets ) { if ( facet instanceof XmlSchemaMaxLengthFacet ) { return Integer . parseInt ( ( String ) ( ( XmlSchemaMaxLengthFacet ) facet ) . getValue ( ) ) ; } } return - 1 ; }
Retrieve the maxLength facet if it exists .
12,598
private < T extends Number > Map < String , Object > getCobolDecimalType ( CobolAnnotations cobolAnnotations , Class < T > clazz ) { String cobolType = cobolAnnotations . getCobolType ( ) ; Map < String , Object > props = new LinkedHashMap < String , Object > ( ) ; switch ( CobolTypes . valueOf ( cobolType ) ) { case ZONED_DECIMAL_ITEM : props . put ( COBOL_TYPE_NAME_PROP_NAME , "CobolZonedDecimalType" ) ; props . put ( SIGN_LEADING_PROP_NAME , cobolAnnotations . signLeading ( ) ) ; props . put ( SIGN_SEPARATE_PROP_NAME , cobolAnnotations . signSeparate ( ) ) ; break ; case PACKED_DECIMAL_ITEM : props . put ( COBOL_TYPE_NAME_PROP_NAME , "CobolPackedDecimalType" ) ; break ; case BINARY_ITEM : props . put ( COBOL_TYPE_NAME_PROP_NAME , "CobolBinaryType" ) ; break ; case NATIVE_BINARY_ITEM : props . put ( COBOL_TYPE_NAME_PROP_NAME , "CobolBinaryType" ) ; break ; case SINGLE_FLOAT_ITEM : props . put ( COBOL_TYPE_NAME_PROP_NAME , "CobolFloatType" ) ; break ; case DOUBLE_FLOAT_ITEM : props . put ( COBOL_TYPE_NAME_PROP_NAME , "CobolDoubleType" ) ; break ; default : throw new Xsd2ConverterException ( "Unsupported COBOL numeric type " + cobolType ) ; } props . put ( SIGNED_PROP_NAME , cobolAnnotations . signed ( ) ) ; props . put ( TOTAL_DIGITS_PROP_NAME , cobolAnnotations . totalDigits ( ) ) ; props . put ( FRACTION_DIGITS_PROP_NAME , cobolAnnotations . fractionDigits ( ) ) ; props . put ( JAVA_TYPE_NAME_PROP_NAME , getShortTypeName ( clazz ) ) ; if ( cobolAnnotations . odoObject ( ) ) { props . put ( ODO_OBJECT_PROP_NAME , true ) ; odoObjects . put ( cobolAnnotations . getCobolName ( ) , props ) ; } return props ; }
Retrieve the properties of a decimal type .
12,599
private static String getShortTypeName ( Class < ? > javaType ) { String javaTypeName = javaType . getName ( ) ; if ( javaTypeName . startsWith ( "java.lang." ) ) { return javaTypeName . substring ( "java.lang." . length ( ) ) ; } else { return javaTypeName ; } }
For java . lang types strips the package which is not needed in generated java classes .