idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
9,800
public static Stream < CharSequence > split ( CharSequence seq , String regex , Option ... options ) { return StreamSupport . stream ( new SpliteratorImpl ( seq , regex , options ) , false ) ; }
Returns stream that contains subsequences delimited by given regex
45
11
9,801
public boolean checkAndIncrease ( ) { long newTimestamp = System . currentTimeMillis ( ) ; if ( isShutdown ) { if ( newTimestamp > shutdownEndTime ) { isShutdown = false ; largeLimitCalls = 0 ; smallLimitCalls = 0 ; } else { return false ; } } if ( newTimestamp - smallLimitTimestamp > smallTimeFrame ) { smallLimitCalls = 0 ; smallLimitTimestamp = newTimestamp ; } else { if ( smallLimitCalls >= smallCallLimit ) { return false ; } else { smallLimitCalls += 1 ; } } if ( newTimestamp - largeLimitTimestamp > largeTimeFrame ) { largeLimitCalls = 0 ; largeLimitTimestamp = newTimestamp ; } else { if ( largeLimitCalls >= largeCallsLimit ) { isShutdown = true ; shutdownEndTime = newTimestamp + shutdownPeriod ; return false ; } else { largeLimitCalls += 1 ; } } return true ; }
Check if next call is allowed and increase the counts .
215
11
9,802
public static Method findMethod ( String name , Class < ? > cls ) { for ( Method method : cls . getDeclaredMethods ( ) ) { if ( method . getName ( ) . equals ( name ) ) { return method ; } } throw new ExecutionException ( "invalid auto-function: no '" + name + "' method declared" , null ) ; }
Finds a named declared method on the given class .
80
11
9,803
public static Object exec ( Method method , String [ ] paramNames , Map < String , ? > params , Object instance ) throws Throwable { Object [ ] paramValues = new Object [ paramNames . length ] ; for ( int c = 0 ; c < paramNames . length ; ++ c ) { paramValues [ c ] = params . get ( paramNames [ c ] ) ; } try { return method . invoke ( instance , paramValues ) ; } catch ( IllegalAccessException e ) { //Shouldn't happen throw new RuntimeException ( e ) ; } catch ( IllegalArgumentException e ) { throw new InvocationException ( "invalid arguments" , e , null ) ; } catch ( InvocationTargetException e ) { throw e . getTargetException ( ) ; } }
Invokes the given method mapping named parameters to positions based on a given list of parameter names .
163
19
9,804
protected void setLinkProperty ( final UUID _linkTypeUUID , final long _toId , final UUID _toTypeUUID , final String _toName ) throws EFapsException { setDirty ( ) ; }
Sets the link properties for this object .
48
9
9,805
public void addEvent ( final EventType _eventtype , final EventDefinition _eventdef ) throws CacheReloadException { List < EventDefinition > evenList = this . events . get ( _eventtype ) ; if ( evenList == null ) { evenList = new ArrayList <> ( ) ; this . events . put ( _eventtype , evenList ) ; } if ( ! evenList . contains ( _eventdef ) ) { evenList . add ( _eventdef ) ; } // if there are more than one event they must be sorted by their index // position if ( evenList . size ( ) > 1 ) { Collections . sort ( evenList , new Comparator < EventDefinition > ( ) { @ Override public int compare ( final EventDefinition _eventDef0 , final EventDefinition _eventDef1 ) { return Long . compare ( _eventDef0 . getIndexPos ( ) , _eventDef1 . getIndexPos ( ) ) ; } } ) ; } setDirty ( ) ; }
Adds a new event to this AdminObject .
213
9
9,806
public List < EventDefinition > getEvents ( final EventType _eventType ) { if ( ! this . eventChecked ) { this . eventChecked = true ; try { EventDefinition . addEvents ( this ) ; } catch ( final EFapsException e ) { AbstractAdminObject . LOG . error ( "Could not read events for Name:; {}', UUID: {}" , this . name , this . uuid ) ; } } return this . events . get ( _eventType ) ; }
Returns the list of events defined for given event type .
106
11
9,807
public boolean hasEvents ( final EventType _eventtype ) { if ( ! this . eventChecked ) { this . eventChecked = true ; try { EventDefinition . addEvents ( this ) ; } catch ( final EFapsException e ) { AbstractAdminObject . LOG . error ( "Could not read events for Name:; {}', UUID: {}" , this . name , this . uuid ) ; } } return this . events . get ( _eventtype ) != null ; }
Does this instance have Event for the specified EventType ?
104
11
9,808
public Object call ( Map < String , ? > params ) throws Throwable { return AnnotatedExtensions . exec ( getCallMethod ( ) , getParameterNames ( ) , params , this ) ; }
Executes a method named doCall by mapping parameters by name to parameters annotated with the Named annotation
43
20
9,809
private Long getLanguageId ( final String _language ) { Long ret = null ; try { final QueryBuilder queryBldr = new QueryBuilder ( CIAdmin . Language ) ; queryBldr . addWhereAttrEqValue ( CIAdmin . Language . Language , _language ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { ret = query . getCurrentValue ( ) . getId ( ) ; } else { ret = insertNewLanguage ( _language ) ; } } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "getLanguageId()" , e ) ; } return ret ; }
find out the Id of the language used for this properties .
158
12
9,810
private long insertNewLanguage ( final String _language ) { Long ret = null ; try { final Insert insert = new Insert ( CIAdmin . Language ) ; insert . add ( CIAdmin . Language . Language , _language ) ; insert . executeWithoutAccessCheck ( ) ; ret = insert . getId ( ) ; insert . close ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "insertNewLanguage()" , e ) ; } return ret ; }
inserts a new language into the Database .
105
9
9,811
private Instance insertNewBundle ( ) { Instance ret = null ; try { final Insert insert = new Insert ( DBPropertiesUpdate . TYPE_PROPERTIES_BUNDLE ) ; insert . add ( "Name" , this . bundlename ) ; insert . add ( "UUID" , this . bundeluuid ) ; insert . add ( "Sequence" , this . bundlesequence ) ; insert . add ( "CacheOnStart" , this . cacheOnStart ) ; insert . executeWithoutAccessCheck ( ) ; ret = insert . getInstance ( ) ; insert . close ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "insertNewBundle()" , e ) ; } return ret ; }
Insert a new Bundle into the Database .
167
8
9,812
private void importFromProperties ( final URL _url ) { try { final InputStream propInFile = _url . openStream ( ) ; final Properties props = new Properties ( ) ; props . load ( propInFile ) ; final Iterator < Entry < Object , Object > > iter = props . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { final Entry < Object , Object > element = iter . next ( ) ; final Instance existing = getExistingKey ( element . getKey ( ) . toString ( ) ) ; if ( existing == null ) { insertNewProp ( element . getKey ( ) . toString ( ) , element . getValue ( ) . toString ( ) ) ; } else { updateDefault ( existing , element . getValue ( ) . toString ( ) ) ; } } } catch ( final IOException e ) { DBPropertiesUpdate . LOG . error ( "ImportFromProperties() - I/O failed." , e ) ; } }
Import Properties from a Properties - File as default if the key is already existing the default will be replaced with the new default .
215
25
9,813
private Instance getExistingLocale ( final long _propertyid , final String _language ) { Instance ret = null ; try { final QueryBuilder queryBldr = new QueryBuilder ( Type . get ( DBPropertiesUpdate . TYPE_PROPERTIES_LOCAL ) ) ; queryBldr . addWhereAttrEqValue ( "PropertyID" , _propertyid ) ; queryBldr . addWhereAttrEqValue ( "LanguageID" , getLanguageId ( _language ) ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { ret = query . getCurrentValue ( ) ; } } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "getExistingLocale(String)" , e ) ; } return ret ; }
Is a localized value already existing .
194
7
9,814
private void insertNewLocal ( final long _propertyid , final String _value , final String _language ) { try { final Insert insert = new Insert ( DBPropertiesUpdate . TYPE_PROPERTIES_LOCAL ) ; insert . add ( "Value" , _value ) ; insert . add ( "PropertyID" , _propertyid ) ; insert . add ( "LanguageID" , getLanguageId ( _language ) ) ; insert . executeWithoutAccessCheck ( ) ; insert . close ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "insertNewLocal(String)" , e ) ; } }
Insert a new localized Value .
139
6
9,815
private void updateLocale ( final Instance _localeInst , final String _value ) { try { final Update update = new Update ( _localeInst ) ; update . add ( "Value" , _value ) ; update . execute ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "updateLocale(String, String)" , e ) ; } }
Update a localized Value .
87
5
9,816
private Instance getExistingKey ( final String _key ) { Instance ret = null ; try { final QueryBuilder queryBldr = new QueryBuilder ( Type . get ( DBPropertiesUpdate . TYPE_PROPERTIES ) ) ; queryBldr . addWhereAttrEqValue ( "Key" , _key ) ; queryBldr . addWhereAttrEqValue ( "BundleID" , this . bundleInstance ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { ret = query . getCurrentValue ( ) ; } } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "getExisting()" , e ) ; } return ret ; }
Is a key already existing .
177
6
9,817
private void updateDefault ( final Instance _inst , final String _value ) { try { final Update update = new Update ( _inst ) ; update . add ( "Default" , _value ) ; update . execute ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "updateDefault(String, String)" , e ) ; } }
Update a Default .
81
4
9,818
private Instance insertNewProp ( final String _key , final String _value ) { Instance ret = null ; try { final Insert insert = new Insert ( DBPropertiesUpdate . TYPE_PROPERTIES ) ; insert . add ( "BundleID" , this . bundleInstance ) ; insert . add ( "Key" , _key ) ; insert . add ( "Default" , _value ) ; insert . executeWithoutAccessCheck ( ) ; ret = insert . getInstance ( ) ; insert . close ( ) ; } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "InsertNew(String, String)" , e ) ; } return ret ; }
Insert a new Property .
146
5
9,819
private Instance getExistingBundle ( final String _uuid ) { Instance ret = null ; try { final QueryBuilder queryBldr = new QueryBuilder ( Type . get ( DBPropertiesUpdate . TYPE_PROPERTIES_BUNDLE ) ) ; queryBldr . addWhereAttrEqValue ( "UUID" , _uuid ) ; final InstanceQuery query = queryBldr . getQuery ( ) ; query . executeWithoutAccessCheck ( ) ; if ( query . next ( ) ) { ret = query . getCurrentValue ( ) ; } } catch ( final EFapsException e ) { DBPropertiesUpdate . LOG . error ( "getExistingBundle(String)" , e ) ; } return ret ; }
Is the Bundle allready existing .
164
7
9,820
public boolean setPassword ( final String _name , final String _newpasswd , final String _oldpasswd ) throws LoginException { boolean ret = false ; final LoginContext login = new LoginContext ( this . application , new SetPasswordCallbackHandler ( ActionCallback . Mode . SET_PASSWORD , _name , _newpasswd , _oldpasswd ) ) ; login . login ( ) ; ret = true ; return ret ; }
Set the password .
92
4
9,821
@ Action ( invokeOn = InvokeOn . OBJECT_AND_COLLECTION ) @ ActionLayout ( describedAs = "Toggle, for testing (direct) bulk actions" ) public void toggleForBulkActions ( ) { boolean flag = getFlag ( ) != null ? getFlag ( ) : false ; setFlag ( ! flag ) ; }
region > toggleForBulkActions
75
8
9,822
public boolean addMeasureToVerb ( Map < String , Object > properties ) { String [ ] pathKeys = { "verb" } ; return addChild ( "measure" , properties , pathKeys ) ; }
Add an arbitrary map of key - value pairs as a measure to the verb
45
15
9,823
public boolean addMeasureToVerb ( String measureType , Number value , Number scaleMin , Number scaleMax , Number sampleSize ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( measureType != null ) { container . put ( "measureType" , measureType ) ; } else { return false ; } if ( value != null ) { container . put ( "value" , value ) ; } else { return false ; } if ( scaleMin != null ) { container . put ( "scaleMin" , scaleMin ) ; } if ( scaleMax != null ) { container . put ( "scaleMax" , scaleMax ) ; } if ( sampleSize != null ) { container . put ( "sampleSize" , sampleSize ) ; } return addMeasureToVerb ( container ) ; }
Add a mesure object to the verb within this activity
178
11
9,824
public boolean addContextToVerb ( String objectType , String id , String description ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( objectType != null ) { container . put ( "objectType" , objectType ) ; } if ( id != null ) { container . put ( "id" , id ) ; } if ( description != null ) { container . put ( "description" , description ) ; } String [ ] pathKeys = { "verb" } ; return addChild ( "context" , container , pathKeys ) ; }
Add a context object to the verb within this activity
125
10
9,825
public boolean addVerb ( String action , Date dateStart , Date dateEnd , String [ ] description , String comment ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( action != null ) { container . put ( "action" , action ) ; } else { return false ; } if ( dateStart != null && dateEnd != null ) { container . put ( "date" , df . format ( dateStart ) + "/" + df . format ( dateEnd ) ) ; } else if ( dateStart != null ) { container . put ( "date" , df . format ( dateStart ) ) ; } if ( description != null && description . length > 0 ) { container . put ( "description" , description ) ; } if ( comment != null ) { container . put ( "comment" , comment ) ; } return addChild ( "verb" , container , null ) ; }
Add a verb object to this activity
197
7
9,826
public boolean addActor ( String objectType , String displayName , String url , String [ ] description ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( objectType != null ) { container . put ( "objectType" , objectType ) ; } else { return false ; } if ( displayName != null ) { container . put ( "displayName" , displayName ) ; } if ( url != null ) { container . put ( "url" , url ) ; } if ( description != null && description . length > 0 ) { container . put ( "description" , description ) ; } return addChild ( "actor" , container , null ) ; }
Add an actor object to this activity
149
7
9,827
public boolean addObject ( String objectType , String id , String content ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( objectType != null ) { container . put ( "objectType" , objectType ) ; } if ( id != null ) { container . put ( "id" , id ) ; } if ( content != null ) { container . put ( "content" , content ) ; } return addChild ( "object" , container , null ) ; }
Add an object to this activity
109
6
9,828
public boolean addRelatedObject ( String objectType , String id , String content ) { Map < String , Object > container = new HashMap < String , Object > ( ) ; if ( objectType != null ) { container . put ( "objectType" , objectType ) ; } else { return false ; } if ( id != null ) { container . put ( "id" , id ) ; } if ( content != null ) { container . put ( "content" , content ) ; } related . add ( container ) ; return true ; }
Add a related object to this activity
113
7
9,829
private Map < String , Object > getMap ( String [ ] pathKeys ) { if ( pathKeys == null ) { return ( Map < String , Object > ) resourceData ; } Map < String , Object > selected = ( Map < String , Object > ) resourceData ; for ( int i = 0 ; i < pathKeys . length ; i ++ ) { if ( selected . containsKey ( pathKeys [ i ] ) && selected . get ( pathKeys [ i ] ) . getClass ( ) . equals ( resourceData . getClass ( ) ) ) { selected = ( Map < String , Object > ) selected . get ( pathKeys [ i ] ) ; } else { return null ; } } return selected ; }
Get a map embedded in the activity following a set of keys
150
12
9,830
private boolean addChild ( String name , Object value , String [ ] pathKeys ) { Map < String , Object > selected = ( Map < String , Object > ) resourceData ; if ( pathKeys != null ) { selected = getMap ( pathKeys ) ; } if ( selected != null && ! selected . containsKey ( name ) ) { selected . put ( name , value ) ; return true ; } return false ; }
Add a child object to the activity at the specified path
88
11
9,831
public void process ( TemplateImpl template , Writer out ) throws IOException { Environment env = new Environment ( template . getPath ( ) , out ) ; currentScope . declaringEnvironment = env ; Environment prevEnv = switchEnvironment ( env ) ; TemplateContext tmpl = template . getContext ( ) ; HeaderContext hdr = tmpl . hdr ; if ( hdr != null && hdr . hdrSig != null && hdr . hdrSig . callSig != null && hdr . hdrSig . callSig . paramDecls != null ) { for ( ParameterDeclContext paramDecl : hdr . hdrSig . callSig . paramDecls ) { String paramId = paramDecl . id . getText ( ) ; if ( ! currentScope . values . containsKey ( paramId ) ) { currentScope . declare ( paramId , eval ( paramDecl . expr ) ) ; } } } try { tmpl . accept ( visitor ) ; } finally { switchEnvironment ( prevEnv ) ; } }
Processes a template into its text representation
225
8
9,832
private TemplateImpl load ( String path , ParserRuleContext errCtx ) { path = Paths . resolvePath ( currentEnvironment . path , path ) ; try { return ( TemplateImpl ) engine . load ( path ) ; } catch ( IOException | ParseException e ) { throw new ExecutionException ( "error importing " + path , e , getLocation ( errCtx ) ) ; } }
Loads a template from the supplied template loader .
84
10
9,833
private Environment switchEnvironment ( Environment env ) { Environment prev = currentEnvironment ; currentEnvironment = env ; return prev ; }
Switch to a new environment
24
5
9,834
private Scope switchScope ( Scope scope ) { Scope prev = currentScope ; currentScope = scope ; return prev ; }
Switch to a completely new scope stack
24
7
9,835
private Map < String , Object > bindBlocks ( PrepareSignatureContext sig , PrepareInvocationContext inv ) { if ( inv == null ) { return Collections . emptyMap ( ) ; } BlockDeclContext allDecl = null ; BlockDeclContext unnamedDecl = null ; List < NamedOutputBlockContext > namedBlocks = new ArrayList <> ( inv . namedBlocks ) ; Map < String , Object > blocks = new HashMap <> ( ) ; for ( BlockDeclContext blockDecl : sig . blockDecls ) { if ( blockDecl . flag != null ) { if ( blockDecl . flag . getText ( ) . equals ( "*" ) ) { if ( allDecl != null ) { throw new ExecutionException ( "only a single parameter can be marked with '*'" , getLocation ( blockDecl ) ) ; } allDecl = blockDecl ; } else if ( blockDecl . flag . getText ( ) . equals ( "+" ) ) { if ( unnamedDecl != null ) { throw new ExecutionException ( "only a single parameter can be marked with '+'" , getLocation ( blockDecl ) ) ; } unnamedDecl = blockDecl ; } else { throw new ExecutionException ( "unknown block declaration flag" , getLocation ( blockDecl ) ) ; } continue ; } //Find the block ParserRuleContext paramBlock = findAndRemoveBlock ( namedBlocks , name ( blockDecl ) ) ; //Bind the block BoundParamOutputBlock boundBlock = bindBlock ( paramBlock ) ; blocks . put ( name ( blockDecl ) , boundBlock ) ; } // // Bind unnamed block (if requested) // if ( unnamedDecl != null ) { UnnamedOutputBlockContext unnamedBlock = inv . unnamedBlock ; BoundParamOutputBlock boundUnnamedBlock = bindBlock ( unnamedBlock ) ; blocks . put ( unnamedDecl . id . getText ( ) , boundUnnamedBlock ) ; } // // Bind rest of blocks (if requested) // if ( allDecl != null ) { Map < String , Block > otherBlocks = new HashMap <> ( ) ; // Add unnamed block if it wasn't bound explicitly if ( inv . unnamedBlock != null && unnamedDecl == null ) { UnnamedOutputBlockContext unnamedBlock = inv . unnamedBlock ; BoundParamOutputBlock boundUnnamedBlock = new BoundParamOutputBlock ( unnamedBlock , mode ( unnamedBlock ) , currentScope ) ; otherBlocks . put ( "" , boundUnnamedBlock ) ; } // Add all other unbound blocks for ( NamedOutputBlockContext namedBlock : namedBlocks ) { String blockName = nullToEmpty ( name ( namedBlock ) ) ; BoundParamOutputBlock boundNamedBlock = new BoundParamOutputBlock ( namedBlock , mode ( namedBlock ) , currentScope ) ; otherBlocks . put ( blockName , boundNamedBlock ) ; } blocks . put ( allDecl . id . getText ( ) , otherBlocks ) ; } return blocks ; }
Bind block values to names based on prepare signature
612
9
9,836
private NamedOutputBlockContext findAndRemoveBlock ( List < NamedOutputBlockContext > blocks , String name ) { if ( blocks == null ) { return null ; } Iterator < NamedOutputBlockContext > blockIter = blocks . iterator ( ) ; while ( blockIter . hasNext ( ) ) { NamedOutputBlockContext block = blockIter . next ( ) ; String blockName = name ( block ) ; if ( name . equals ( blockName ) ) { blockIter . remove ( ) ; return block ; } } return null ; }
Find and remove block with specific name
111
7
9,837
private ExpressionContext findAndRemoveValue ( List < NamedValueContext > namedValues , String name ) { Iterator < NamedValueContext > namedValueIter = namedValues . iterator ( ) ; while ( namedValueIter . hasNext ( ) ) { NamedValueContext namedValue = namedValueIter . next ( ) ; if ( name . equals ( value ( namedValue . name ) ) ) { namedValueIter . remove ( ) ; return namedValue . expr ; } } return null ; }
Find and remove named value with specific name
101
8
9,838
private Object eval ( ExpressionContext expr ) { Object res = expr ; while ( res instanceof ExpressionContext ) res = ( ( ExpressionContext ) res ) . accept ( visitor ) ; if ( res instanceof LValue ) res = ( ( LValue ) res ) . get ( expr ) ; return res ; }
Evaluate an expression into a value
64
8
9,839
private List < Object > eval ( Iterable < ExpressionContext > expressions ) { List < Object > results = new ArrayList < Object > ( ) ; for ( ExpressionContext expression : expressions ) { results . add ( eval ( expression ) ) ; } return results ; }
Evaluates a list of expressions into their values
55
10
9,840
private Object exec ( StatementContext statement ) { if ( statement == null ) return null ; return statement . accept ( visitor ) ; }
Execute a statement block until the first return statement is reached .
27
13
9,841
ExecutionLocation getLocation ( ParserRuleContext object ) { Token start = object . getStart ( ) ; return new ExecutionLocation ( currentScope . declaringEnvironment . path , start . getLine ( ) , start . getCharPositionInLine ( ) + 1 ) ; }
Retrieves location information for a model object
57
9
9,842
public T find ( String text ) { T match = matcher . match ( text , true ) ; if ( match != null ) { String name = match . name ( ) ; if ( name . substring ( 0 , Math . min ( name . length ( ) , text . length ( ) ) ) . equalsIgnoreCase ( text ) ) { return match ; } } return null ; }
Returns enum for text if it is unique prefix .
82
10
9,843
public static void stop ( ) throws EFapsException { for ( final QueueConnection queCon : JmsHandler . QUEUE2QUECONN . values ( ) ) { try { queCon . close ( ) ; } catch ( final JMSException e ) { throw new EFapsException ( "JMSException" , e ) ; } } for ( final TopicConnection queCon : JmsHandler . TOPIC2QUECONN . values ( ) ) { try { queCon . close ( ) ; } catch ( final JMSException e ) { throw new EFapsException ( "JMSException" , e ) ; } } JmsHandler . TOPIC2QUECONN . clear ( ) ; JmsHandler . QUEUE2QUECONN . clear ( ) ; JmsHandler . NAME2DEF . clear ( ) ; }
Stop the jms .
181
5
9,844
public static String getTimeoutMessage ( long timeout , TimeUnit unit ) { return String . format ( "Timeout of %d %s reached" , timeout , requireNonNull ( unit , "unit" ) ) ; }
Utility method that produce the message of the timeout .
45
11
9,845
protected void checkAccess ( ) throws EFapsException { for ( final Instance instance : getInstances ( ) ) { if ( ! instance . getType ( ) . hasAccess ( instance , AccessTypeEnums . DELETE . getAccessType ( ) , null ) ) { LOG . error ( "Delete not permitted for Person: {} on Instance: {}" , Context . getThreadContext ( ) . getPerson ( ) , instance ) ; throw new EFapsException ( getClass ( ) , "execute.NoAccess" , instance ) ; } } }
Check access for all Instances . If one does not have access an error will be thrown .
118
19
9,846
public void set ( double eyeX , double eyeY , double eyeZ , double centerX , double centerY , double centerZ , double upX , double upY , double upZ ) { this . eyeX = eyeX ; this . eyeY = eyeY ; this . eyeZ = eyeZ ; this . centerX = centerX ; this . centerY = centerY ; this . centerZ = centerZ ; this . upX = upX ; this . upY = upY ; this . upZ = upZ ; }
Sets the eye position the center of the scene and which axis is facing upward .
114
17
9,847
public void setEye ( double eyeX , double eyeY , double eyeZ ) { this . eyeX = eyeX ; this . eyeY = eyeY ; this . eyeZ = eyeZ ; }
Sets the eye position of this Camera .
43
9
9,848
public void setCenter ( double centerX , double centerY , double centerZ ) { this . centerX = centerX ; this . centerY = centerY ; this . centerZ = centerZ ; }
Sets the center of the scene of this Camera .
43
11
9,849
public void setOrientation ( double upX , double upY , double upZ ) { this . upX = upX ; this . upY = upY ; this . upZ = upZ ; }
Sets which axis is facing upward .
45
8
9,850
public double [ ] getCameraDirection ( ) { double [ ] cameraDirection = new double [ 3 ] ; double l = Math . sqrt ( Math . pow ( this . eyeX - this . centerX , 2.0 ) + Math . pow ( this . eyeZ - this . centerZ , 2.0 ) + Math . pow ( this . eyeZ - this . centerZ , 2.0 ) ) ; cameraDirection [ 0 ] = ( this . centerX - this . eyeX ) / l ; cameraDirection [ 1 ] = ( this . centerY - this . eyeY ) / l ; cameraDirection [ 2 ] = ( this . centerZ - this . eyeZ ) / l ; return cameraDirection ; }
Gets the eye direction of this Camera .
159
9
9,851
protected boolean hasAccess ( ) throws EFapsException { //Admin_REST return Context . getThreadContext ( ) . getPerson ( ) . isAssigned ( Role . get ( UUID . fromString ( "2d142645-140d-46ad-af67-835161a8d732" ) ) ) ; }
Check if the logged in users has access to rest . User must be assigned to the Role Admin_Rest .
74
22
9,852
protected String getJSONReply ( final Object _jsonObject ) { String ret = "" ; final ObjectMapper mapper = new ObjectMapper ( ) ; if ( LOG . isDebugEnabled ( ) ) { mapper . enable ( SerializationFeature . INDENT_OUTPUT ) ; } mapper . configure ( SerializationFeature . WRITE_DATES_AS_TIMESTAMPS , false ) ; mapper . registerModule ( new JodaModule ( ) ) ; try { ret = mapper . writeValueAsString ( _jsonObject ) ; } catch ( final JsonProcessingException e ) { LOG . error ( "Catched JsonProcessingException" , e ) ; } return ret ; }
Gets the JSON reply .
151
6
9,853
public static String login ( final String _userName , final String _passwd , final String _applicationKey ) throws EFapsException { String ret = null ; if ( JmsSession . checkLogin ( _userName , _passwd , _applicationKey ) ) { final JmsSession session = new JmsSession ( _userName ) ; JmsSession . CACHE . put ( session . getSessionKey ( ) , session ) ; ret = session . getSessionKey ( ) ; } return ret ; }
Login and create a Session .
108
6
9,854
void update ( long index , int b ) { if ( size > 0 ) { assert index <= hi ; if ( index < lo ) { throw new IllegalStateException ( "lookaheadLength() too small in ChecksumProvider implementation" ) ; } hi = index ; if ( ( lo == hi - size ) ) { checksum . update ( lookahead [ ( int ) ( lo % size ) ] ) ; lo ++ ; } lookahead [ ( int ) ( hi ++ % size ) ] = b ; } else { if ( index == hi ) { checksum . update ( b ) ; hi = index + 1 ; } else { if ( index != hi - 1 ) { throw new IllegalStateException ( "lookahead needed for checksum" ) ; } } } }
Update with character index .
161
5
9,855
public void execute ( ) throws InstallationException { Instance instance = searchInstance ( ) ; if ( instance == null ) { instance = createInstance ( ) ; } updateDB ( instance ) ; }
Import related source code into the eFaps DataBase . If the source code does not exists the source code is created in eFaps .
40
29
9,856
protected Instance createInstance ( ) throws InstallationException { final Insert insert ; try { insert = new Insert ( getCiType ( ) ) ; insert . add ( "Name" , this . programName ) ; if ( getEFapsUUID ( ) != null ) { insert . add ( "UUID" , getEFapsUUID ( ) . toString ( ) ) ; } insert . execute ( ) ; } catch ( final EFapsException e ) { throw new InstallationException ( "Could not create " + getCiType ( ) + " " + getProgramName ( ) , e ) ; } return insert . getInstance ( ) ; }
Creates an instance of a source object in eFaps for given name .
137
16
9,857
public void updateDB ( final Instance _instance ) throws InstallationException { try { final InputStream is = newCodeInputStream ( ) ; final Checkin checkin = new Checkin ( _instance ) ; checkin . executeWithoutAccessCheck ( getProgramName ( ) , is , is . available ( ) ) ; } catch ( final UnsupportedEncodingException e ) { throw new InstallationException ( "Encoding failed for " + this . programName , e ) ; } catch ( final EFapsException e ) { throw new InstallationException ( "Could not check in " + this . programName , e ) ; } catch ( final IOException e ) { throw new InstallationException ( "Reading from inoutstream faild for " + this . programName , e ) ; } }
Stores the read source code in eFaps . This is done with a check in .
163
19
9,858
public static void startup ( final String _classDBType , final String _classDSFactory , final String _propConnection , final String _classTM , final String _classTSR , final String _eFapsProps ) throws StartupException { StartupDatabaseConnection . startup ( _classDBType , _classDSFactory , StartupDatabaseConnection . convertToMap ( _propConnection ) , _classTM , _classTSR , StartupDatabaseConnection . convertToMap ( _eFapsProps ) ) ; }
Initialize the database information set for given parameter values .
107
11
9,859
protected static void configureEFapsProperties ( final Context _compCtx , final Map < String , String > _eFapsProps ) throws StartupException { try { Util . bind ( _compCtx , "env/" + INamingBinds . RESOURCE_CONFIGPROPERTIES , _eFapsProps ) ; } catch ( final NamingException e ) { throw new StartupException ( "could not bind eFaps Properties '" + _eFapsProps + "'" , e ) ; // CHECKSTYLE:OFF } catch ( final Exception e ) { // CHECKSTYLE:ON throw new StartupException ( "could not bind eFaps Properties '" + _eFapsProps + "'" , e ) ; } }
Add the eFaps Properties to the JNDI binding .
167
13
9,860
public static void shutdown ( ) throws StartupException { final Context compCtx ; try { final InitialContext context = new InitialContext ( ) ; compCtx = ( javax . naming . Context ) context . lookup ( "java:comp" ) ; } catch ( final NamingException e ) { throw new StartupException ( "Could not initialize JNDI" , e ) ; } try { Util . unbind ( compCtx , "env/" + INamingBinds . RESOURCE_DATASOURCE ) ; Util . unbind ( compCtx , "env/" + INamingBinds . RESOURCE_DBTYPE ) ; Util . unbind ( compCtx , "env/" + INamingBinds . RESOURCE_CONFIGPROPERTIES ) ; Util . unbind ( compCtx , "env/" + INamingBinds . RESOURCE_TRANSMANAG ) ; } catch ( final NamingException e ) { throw new StartupException ( "unbind of the database connection failed" , e ) ; } }
Shutdowns the connection to the database .
225
8
9,861
@ SuppressWarnings ( "unchecked" ) public STMT columnWithCurrentTimestamp ( final String _columnName ) { this . columnWithSQLValues . add ( new AbstractSQLInsertUpdate . ColumnWithSQLValue ( _columnName , Context . getDbType ( ) . getCurrentTimeStamp ( ) ) ) ; return ( STMT ) this ; }
Adds a new column which will have the current time stamp to append .
78
14
9,862
public static EQLInvoker getInvoker ( ) { final EQLInvoker ret = new EQLInvoker ( ) { @ Override protected AbstractPrintStmt getPrint ( ) { return new PrintStmt ( ) ; } @ Override protected AbstractInsertStmt getInsert ( ) { return new InsertStmt ( ) ; } @ Override protected AbstractExecStmt getExec ( ) { return new ExecStmt ( ) ; } @ Override protected AbstractUpdateStmt getUpdate ( ) { return new UpdateStmt ( ) ; } @ Override protected AbstractDeleteStmt getDelete ( ) { return new DeleteStmt ( ) ; } @ Override protected INestedQueryStmtPart getNestedQuery ( ) { return super . getNestedQuery ( ) ; } @ Override protected AbstractCIPrintStmt getCIPrint ( ) { return new CIPrintStmt ( ) ; } } ; ret . getValidator ( ) . setDiagnosticClazz ( EFapsDiagnostic . class ) ; ret . getValidator ( ) . addValidation ( "EQLJavaValidator.type" , new TypeValidation ( ) ) ; return ret ; }
Gets the invoker .
253
6
9,863
public void append2SQLSelect ( final SQLSelect _sqlSelect ) { if ( iWhere != null ) { final SQLWhere sqlWhere = _sqlSelect . getWhere ( ) ; for ( final IWhereTerm < ? > term : iWhere . getTerms ( ) ) { if ( term instanceof IWhereElementTerm ) { final IWhereElement element = ( ( IWhereElementTerm ) term ) . getElement ( ) ; if ( element . getAttribute ( ) != null ) { final String attrName = element . getAttribute ( ) ; for ( final Type type : types ) { final Attribute attr = type . getAttribute ( attrName ) ; if ( attr != null ) { addAttr ( _sqlSelect , sqlWhere , attr , term , element ) ; break ; } } } else if ( element . getSelect ( ) != null ) { final IWhereSelect select = element . getSelect ( ) ; for ( final ISelectElement ele : select . getElements ( ) ) { if ( ele instanceof IBaseSelectElement ) { switch ( ( ( IBaseSelectElement ) ele ) . getElement ( ) ) { case STATUS : for ( final Type type : types ) { final Attribute attr = type . getStatusAttribute ( ) ; if ( attr != null ) { addAttr ( _sqlSelect , sqlWhere , attr , term , element ) ; break ; } } break ; default : break ; } } else if ( ele instanceof IAttributeSelectElement ) { final String attrName = ( ( IAttributeSelectElement ) ele ) . getName ( ) ; for ( final Type type : types ) { addAttr ( _sqlSelect , sqlWhere , type . getAttribute ( attrName ) , term , element ) ; } } } } } } } if ( iOrder != null ) { final SQLOrder sqlOrder = _sqlSelect . getOrder ( ) ; for ( final IOrderElement element : iOrder . getElements ( ) ) { for ( final Type type : types ) { final Attribute attr = type . getAttribute ( element . getKey ( ) ) ; if ( attr != null ) { final SQLTable table = attr . getTable ( ) ; final String tableName = table . getSqlTable ( ) ; final TableIdx tableidx = _sqlSelect . getIndexer ( ) . getTableIdx ( tableName ) ; sqlOrder . addElement ( tableidx . getIdx ( ) , attr . getSqlColNames ( ) , element . isDesc ( ) ) ; break ; } } } } }
Append two SQL select .
559
6
9,864
void init ( ) { if ( ! isEnabled ( ) ) { loggerConfig . info ( "Ted prime instance check is disabled" ) ; return ; } this . primeTaskId = context . tedDaoExt . findPrimeTaskId ( ) ; int periodMs = context . config . intervalDriverMs ( ) ; this . postponeSec = ( int ) Math . round ( ( 1.0 * periodMs * TICK_SKIP_COUNT + 500 + 500 ) / 1000 ) ; // 500ms reserve, 500 for rounding up becomePrime ( ) ; loggerConfig . info ( "Ted prime instance check is enabled, primeTaskId={} isPrime={} postponeSec={}" , primeTaskId , isPrime , postponeSec ) ; initiated = true ; }
after configs read
159
4
9,865
@ Override public TemplateSource find ( String path ) throws IOException { return new URLTemplateSource ( new URL ( "file" , null , path ) ) ; }
Maps the given path to a file URL and builds a URLTemplateSource for it .
35
17
9,866
public static void initialize ( ) throws CacheReloadException { if ( InfinispanCache . get ( ) . exists ( BundleMaker . NAMECACHE ) ) { InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . NAMECACHE ) . clear ( ) ; InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . CACHE4BUNDLE ) . clear ( ) ; InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . CACHE4BUNDLEMAP ) . clear ( ) ; } else { InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . NAMECACHE ) . addListener ( new CacheLogListener ( BundleMaker . LOG ) ) ; InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . CACHE4BUNDLE ) . addListener ( new CacheLogListener ( BundleMaker . LOG ) ) ; InfinispanCache . get ( ) . < UUID , Type > getCache ( BundleMaker . CACHE4BUNDLEMAP ) . addListener ( new CacheLogListener ( BundleMaker . LOG ) ) ; } }
Init this class .
280
4
9,867
public static boolean containsKey ( final String _key ) { final Cache < String , BundleInterface > cache = InfinispanCache . get ( ) . < String , BundleInterface > getIgnReCache ( BundleMaker . CACHE4BUNDLE ) ; return cache . containsKey ( _key ) ; }
Does a Bundle for the Key exist .
66
8
9,868
private static String createNewKey ( final List < String > _names , final Class < ? > _bundleclass ) throws EFapsException { final StringBuilder builder = new StringBuilder ( ) ; final List < String > oids = new ArrayList <> ( ) ; String ret = null ; try { for ( final String name : _names ) { if ( builder . length ( ) > 0 ) { builder . append ( "-" ) ; } final Cache < String , StaticCompiledSource > cache = InfinispanCache . get ( ) . < String , StaticCompiledSource > getIgnReCache ( BundleMaker . NAMECACHE ) ; if ( ! cache . containsKey ( name ) ) { final QueryBuilder queryBldr = new QueryBuilder ( CIAdminProgram . StaticCompiled ) ; queryBldr . addWhereAttrEqValue ( CIAdminProgram . StaticCompiled . Name , name ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminProgram . StaticCompiled . Name ) ; multi . execute ( ) ; while ( multi . next ( ) ) { final String statName = multi . < String > getAttribute ( CIAdminProgram . StaticCompiled . Name ) ; final StaticCompiledSource source = new StaticCompiledSource ( multi . getCurrentInstance ( ) . getOid ( ) , statName ) ; cache . put ( source . getName ( ) , source ) ; } } if ( cache . containsKey ( name ) ) { final String oid = cache . get ( name ) . getOid ( ) ; builder . append ( oid ) ; oids . add ( oid ) ; } } ret = builder . toString ( ) ; final BundleInterface bundle = ( BundleInterface ) _bundleclass . newInstance ( ) ; bundle . setKey ( ret , oids ) ; final Cache < String , BundleInterface > cache = InfinispanCache . get ( ) . < String , BundleInterface > getIgnReCache ( BundleMaker . CACHE4BUNDLE ) ; cache . put ( ret , bundle ) ; } catch ( final InstantiationException e ) { throw new EFapsException ( BundleMaker . class , "createNewKey.InstantiationException" , e , _bundleclass ) ; } catch ( final IllegalAccessException e ) { throw new EFapsException ( BundleMaker . class , "createNewKey.IllegalAccessException" , e , _bundleclass ) ; } return ret ; }
Creates a new Key and instantiates the BundleInterface .
538
12
9,869
public static void init ( final String _runLevel ) throws EFapsException { RunLevel . ALL_RUNLEVELS . clear ( ) ; RunLevel . RUNLEVEL = new RunLevel ( _runLevel ) ; }
The static method first removes all values in the caches . Then the cache is initialized automatically depending on the desired RunLevel
48
23
9,870
private List < String > getAllInitializers ( ) { final List < String > ret = new ArrayList <> ( ) ; for ( final CacheMethod cacheMethod : this . cacheMethods ) { ret . add ( cacheMethod . className ) ; } if ( this . parent != null ) { ret . addAll ( this . parent . getAllInitializers ( ) ) ; } return ret ; }
Returns the list of all initializers .
84
8
9,871
protected void initialize ( final String _sql ) throws EFapsException { Connection con = null ; try { con = Context . getConnection ( ) ; Statement stmt = null ; long parentId = 0 ; try { stmt = con . createStatement ( ) ; // read run level itself ResultSet rs = stmt . executeQuery ( _sql ) ; if ( rs . next ( ) ) { this . id = rs . getLong ( 1 ) ; parentId = rs . getLong ( 2 ) ; } else { RunLevel . LOG . error ( "RunLevel not found" ) ; } rs . close ( ) ; // read all methods for one run level rs = stmt . executeQuery ( RunLevel . SELECT_DEF_PRE . getCopy ( ) . addPart ( SQLPart . WHERE ) . addColumnPart ( 0 , "RUNLEVELID" ) . addPart ( SQLPart . EQUAL ) . addValuePart ( this . id ) . addPart ( SQLPart . ORDERBY ) . addColumnPart ( 0 , "PRIORITY" ) . getSQL ( ) ) ; /** * Order part of the SQL select statement. */ //private static final String SQL_DEF_POST = " order by PRIORITY"; while ( rs . next ( ) ) { if ( rs . getString ( 3 ) != null ) { this . cacheMethods . add ( new CacheMethod ( rs . getString ( 1 ) . trim ( ) , rs . getString ( 2 ) . trim ( ) , rs . getString ( 3 ) . trim ( ) ) ) ; } else { this . cacheMethods . add ( new CacheMethod ( rs . getString ( 1 ) . trim ( ) , rs . getString ( 2 ) . trim ( ) ) ) ; } } rs . close ( ) ; } finally { if ( stmt != null ) { stmt . close ( ) ; } } con . commit ( ) ; con . close ( ) ; RunLevel . ALL_RUNLEVELS . put ( this . id , this ) ; if ( parentId != 0 ) { this . parent = RunLevel . ALL_RUNLEVELS . get ( parentId ) ; if ( this . parent == null ) { this . parent = new RunLevel ( parentId ) ; } } } catch ( final EFapsException e ) { RunLevel . LOG . error ( "initialise()" , e ) ; } catch ( final SQLException e ) { RunLevel . LOG . error ( "initialise()" , e ) ; } finally { try { if ( con != null && ! con . isClosed ( ) ) { con . close ( ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "Cannot read a type for an attribute." , e ) ; } } }
Reads the id and the parent id of this RunLevel . All defined methods for this run level are loaded . If a parent id is defined the parent is initialized .
600
34
9,872
static Integer getInteger ( Properties properties , String key , Integer defaultValue ) { if ( properties == null ) return defaultValue ; String value = properties . getProperty ( key ) ; if ( value == null || value . isEmpty ( ) ) return defaultValue ; int intVal ; try { intVal = Integer . parseInt ( value ) ; } catch ( NumberFormatException e ) { logger . warn ( "Cannot read property '" + key + "'. Expected integer, but got '" + value + "'. Setting default value = '" + defaultValue + "'" , e . getMessage ( ) ) ; return defaultValue ; } logger . trace ( "Read property '" + key + "' value '" + intVal + "'" ) ; return intVal ; }
returns int value of property or defaultValue if not found or invalid
164
14
9,873
public void execute ( T target ) throws Throwable { try { for ( Invokation invokation : queue ) { invokation . invoke ( target ) ; } } catch ( InvocationTargetException ex ) { throw ex . getCause ( ) ; } catch ( ReflectiveOperationException ex ) { throw new RuntimeException ( ex ) ; } }
Executes delayed invocations
73
5
9,874
protected Map < String , Object > getSignableData ( ) { final Map < String , Object > doc = getSendableData ( ) ; // remove node-specific data for ( int i = 0 ; i < excludedFields . length ; i ++ ) { doc . remove ( excludedFields [ i ] ) ; } return doc ; }
Builds and returns a map of the envelope data suitable for signing with the included signer
72
18
9,875
protected Map < String , Object > getSendableData ( ) { Map < String , Object > doc = new LinkedHashMap < String , Object > ( ) ; MapUtil . put ( doc , docTypeField , docType ) ; MapUtil . put ( doc , docVersionField , docVersion ) ; MapUtil . put ( doc , activeField , true ) ; MapUtil . put ( doc , resourceDataTypeField , resourceDataType ) ; Map < String , Object > docId = new HashMap < String , Object > ( ) ; MapUtil . put ( docId , submitterTypeField , submitterType ) ; MapUtil . put ( docId , submitterField , submitter ) ; MapUtil . put ( docId , curatorField , curator ) ; MapUtil . put ( docId , ownerField , owner ) ; MapUtil . put ( docId , signerField , signer ) ; MapUtil . put ( doc , identityField , docId ) ; MapUtil . put ( doc , submitterTTLField , submitterTTL ) ; Map < String , Object > docTOS = new HashMap < String , Object > ( ) ; MapUtil . put ( docTOS , submissionTOSField , submissionTOS ) ; MapUtil . put ( docTOS , submissionAttributionField , submissionAttribution ) ; MapUtil . put ( doc , TOSField , docTOS ) ; MapUtil . put ( doc , resourceLocatorField , resourceLocator ) ; MapUtil . put ( doc , payloadPlacementField , payloadPlacement ) ; MapUtil . put ( doc , payloadSchemaField , payloadSchema ) ; MapUtil . put ( doc , payloadSchemaLocatorField , payloadSchemaLocator ) ; MapUtil . put ( doc , keysField , tags ) ; MapUtil . put ( doc , resourceDataField , getEncodedResourceData ( ) ) ; MapUtil . put ( doc , replacesField , replaces ) ; if ( signed ) { Map < String , Object > sig = new HashMap < String , Object > ( ) ; String [ ] keys = { publicKeyLocation } ; MapUtil . put ( sig , keyLocationField , keys ) ; MapUtil . put ( sig , signingMethodField , signingMethod ) ; MapUtil . put ( sig , signatureField , clearSignedMessage ) ; MapUtil . put ( doc , digitalSignatureField , sig ) ; } return doc ; }
Builds and returns a map of the envelope data including any signing data suitable for sending to a Learning Registry node
544
22
9,876
public void addSigningData ( String signingMethod , String publicKeyLocation , String clearSignedMessage ) { this . signingMethod = signingMethod ; this . publicKeyLocation = publicKeyLocation ; this . clearSignedMessage = clearSignedMessage ; this . signed = true ; }
Adds signing data to the envelope
60
6
9,877
public String getUrl ( String email ) { if ( email == null ) { throw new IllegalArgumentException ( "Email can't be null." ) ; } String emailHash = DigestUtils . md5Hex ( email . trim ( ) . toLowerCase ( ) ) ; boolean firstParameter = true ; // StringBuilder standard capacity is 16 characters while the minimum // url is 63 characters long. The maximum length without // customDefaultImage // is 91. StringBuilder builder = new StringBuilder ( 91 ) . append ( https ? HTTPS_URL : URL ) . append ( emailHash ) . append ( FILE_TYPE_EXTENSION ) ; if ( size != DEFAULT_SIZE ) { addParameter ( builder , "s" , Integer . toString ( size ) , firstParameter ) ; firstParameter = false ; } if ( forceDefault ) { addParameter ( builder , "f" , "y" , firstParameter ) ; firstParameter = false ; } if ( rating != DEFAULT_RATING ) { addParameter ( builder , "r" , rating . getKey ( ) , firstParameter ) ; firstParameter = false ; } if ( customDefaultImage != null ) { addParameter ( builder , "d" , customDefaultImage , firstParameter ) ; } else if ( standardDefaultImage != null ) { addParameter ( builder , "d" , standardDefaultImage . getKey ( ) , firstParameter ) ; } return builder . toString ( ) ; }
Retrieve the gravatar URL for the given email .
306
11
9,878
private void setProperties ( final Instance _instance ) throws EFapsException { final QueryBuilder queryBldr = new QueryBuilder ( CIAdminCommon . Property ) ; queryBldr . addWhereAttrEqValue ( CIAdminCommon . Property . Abstract , _instance . getId ( ) ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; multi . addAttribute ( CIAdminCommon . Property . Name , CIAdminCommon . Property . Value ) ; multi . executeWithoutAccessCheck ( ) ; while ( multi . next ( ) ) { super . setProperty ( multi . < String > getAttribute ( CIAdminCommon . Property . Name ) , multi . < String > getAttribute ( CIAdminCommon . Property . Value ) ) ; } }
Set the properties in the superclass .
164
8
9,879
private void checkProgramInstance ( ) { try { if ( EventDefinition . LOG . isDebugEnabled ( ) ) { EventDefinition . LOG . debug ( "checking Instance: {} - {}" , this . resourceName , this . methodName ) ; } if ( ! EFapsClassLoader . getInstance ( ) . isOffline ( ) ) { final Class < ? > cls = Class . forName ( this . resourceName , true , EFapsClassLoader . getInstance ( ) ) ; final Method method = cls . getMethod ( this . methodName , new Class [ ] { Parameter . class } ) ; final Object progInstance = cls . newInstance ( ) ; if ( EventDefinition . LOG . isDebugEnabled ( ) ) { EventDefinition . LOG . debug ( "found Class: {} and method {}" , progInstance , method ) ; } } } catch ( final ClassNotFoundException e ) { EventDefinition . LOG . error ( "could not find Class: '{}'" , this . resourceName , e ) ; } catch ( final InstantiationException e ) { EventDefinition . LOG . error ( "could not instantiat Class: '{}'" , this . resourceName , e ) ; } catch ( final IllegalAccessException e ) { EventDefinition . LOG . error ( "could not access Class: '{}'" , this . resourceName , e ) ; } catch ( final SecurityException e ) { EventDefinition . LOG . error ( "could not access Class: '{}'" , this . resourceName , e ) ; } catch ( final NoSuchMethodException e ) { EventDefinition . LOG . error ( "could not find method: '{}' in class '{}'" , new Object [ ] { this . methodName , this . resourceName , e } ) ; } }
Method to check if the instance of the esjp is valid .
383
13
9,880
@ Override public Return execute ( final Parameter _parameter ) throws EFapsException { Return ret = null ; _parameter . put ( ParameterValues . PROPERTIES , new HashMap <> ( super . evalProperties ( ) ) ) ; try { EventDefinition . LOG . debug ( "Invoking method '{}' for Resource '{}'" , this . methodName , this . resourceName ) ; final Class < ? > cls = Class . forName ( this . resourceName , true , EFapsClassLoader . getInstance ( ) ) ; final Method method = cls . getMethod ( this . methodName , new Class [ ] { Parameter . class } ) ; ret = ( Return ) method . invoke ( cls . newInstance ( ) , _parameter ) ; EventDefinition . LOG . debug ( "Terminated invokation of method '{}' for Resource '{}'" , this . methodName , this . resourceName ) ; } catch ( final SecurityException e ) { EventDefinition . LOG . error ( "security wrong: '{}'" , this . resourceName , e ) ; } catch ( final IllegalArgumentException e ) { EventDefinition . LOG . error ( "arguments invalid : '{}'- '{}'" , this . resourceName , this . methodName , e ) ; } catch ( final IllegalAccessException e ) { EventDefinition . LOG . error ( "could not access class: '{}'" , this . resourceName , e ) ; } catch ( final InvocationTargetException e ) { EventDefinition . LOG . error ( "could not invoke method: '{}' in class: '{}'" , this . methodName , this . resourceName , e ) ; throw ( EFapsException ) e . getCause ( ) ; } catch ( final ClassNotFoundException e ) { EventDefinition . LOG . error ( "class not found: '{}" + this . resourceName , e ) ; } catch ( final NoSuchMethodException e ) { EventDefinition . LOG . error ( "could not find method: '{}' in class '{}'" , new Object [ ] { this . methodName , this . resourceName , e } ) ; } catch ( final InstantiationException e ) { EventDefinition . LOG . error ( "could not instantiat Class: '{}'" , this . resourceName , e ) ; } return ret ; }
Method to execute the esjp .
514
7
9,881
public String getOid ( ) { String ret = null ; if ( isValid ( ) ) { ret = getType ( ) . getId ( ) + "." + getId ( ) ; } return ret ; }
The string representation which is defined by this instance is returned .
46
12
9,882
public boolean checkEventId ( String conversationId , long conversationEventId , MissingEventsListener missingEventsListener ) { if ( ! idsPerConversation . containsKey ( conversationId ) ) { TreeSet < Long > ids = new TreeSet <> ( ) ; boolean added = ids . add ( conversationEventId ) ; idsPerConversation . put ( conversationId , ids ) ; return ! added ; } else { TreeSet < Long > ids = idsPerConversation . get ( conversationId ) ; long last = ids . last ( ) ; boolean added = ids . add ( conversationEventId ) ; if ( last < conversationEventId - 1 ) { missingEventsListener . missingEvents ( conversationId , last + 1 , ( int ) ( conversationEventId - last ) ) ; } while ( ids . size ( ) > 10 ) { ids . pollFirst ( ) ; } return ! added ; } }
Check conversation event id for duplicates or missing events .
202
11
9,883
public static < G , B > Bad < G , B > of ( B value ) { return new Bad <> ( value ) ; }
Creates a Bad of type B .
29
8
9,884
public LREnvelope sign ( LREnvelope envelope ) throws LRException { // Bencode the document String bencodedMessage = bencode ( envelope . getSignableData ( ) ) ; // Clear sign the bencoded document String clearSignedMessage = signEnvelopeData ( bencodedMessage ) ; envelope . addSigningData ( signingMethod , publicKeyLocation , clearSignedMessage ) ; return envelope ; }
Sign the specified envelope with this signer
92
8
9,885
private List < Object > normalizeList ( List < Object > list ) { List < Object > result = new ArrayList < Object > ( ) ; for ( Object o : list ) { if ( o == null ) { result . add ( nullLiteral ) ; } else if ( o instanceof Boolean ) { result . add ( ( ( Boolean ) o ) . toString ( ) ) ; } else if ( o instanceof List < ? > ) { result . add ( normalizeList ( ( List < Object > ) o ) ) ; } else if ( o instanceof Map < ? , ? > ) { result . add ( normalizeMap ( ( Map < String , Object > ) o ) ) ; } else if ( ! ( o instanceof Number ) ) { result . add ( o ) ; } } return result ; }
Helper for map normalization ; inspects list and returns a replacement list that has been normalized .
175
19
9,886
private String signEnvelopeData ( String message ) throws LRException { // Throw an exception if any of the required fields are null if ( passPhrase == null || publicKeyLocation == null || privateKey == null ) { throw new LRException ( LRException . NULL_FIELD ) ; } // Get an InputStream for the private key InputStream privateKeyStream = getPrivateKeyStream ( privateKey ) ; // Get an OutputStream for the result ByteArrayOutputStream result = new ByteArrayOutputStream ( ) ; ArmoredOutputStream aOut = new ArmoredOutputStream ( result ) ; // Get the pass phrase char [ ] privateKeyPassword = passPhrase . toCharArray ( ) ; try { // Get the private key from the InputStream PGPSecretKey sk = readSecretKey ( privateKeyStream ) ; PGPPrivateKey pk = sk . extractPrivateKey ( new JcePBESecretKeyDecryptorBuilder ( ) . setProvider ( "BC" ) . build ( privateKeyPassword ) ) ; PGPSignatureGenerator sGen = new PGPSignatureGenerator ( new JcaPGPContentSignerBuilder ( sk . getPublicKey ( ) . getAlgorithm ( ) , PGPUtil . SHA256 ) . setProvider ( "BC" ) ) ; PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator ( ) ; // Clear sign the message java . util . Iterator it = sk . getPublicKey ( ) . getUserIDs ( ) ; if ( it . hasNext ( ) ) { spGen . setSignerUserID ( false , ( String ) it . next ( ) ) ; sGen . setHashedSubpackets ( spGen . generate ( ) ) ; } aOut . beginClearText ( PGPUtil . SHA256 ) ; sGen . init ( PGPSignature . CANONICAL_TEXT_DOCUMENT , pk ) ; byte [ ] msg = message . getBytes ( ) ; sGen . update ( msg , 0 , msg . length ) ; aOut . write ( msg , 0 , msg . length ) ; BCPGOutputStream bOut = new BCPGOutputStream ( aOut ) ; aOut . endClearText ( ) ; sGen . generate ( ) . encode ( bOut ) ; aOut . close ( ) ; String strResult = result . toString ( "utf8" ) ; // for whatever reason, bouncycastle is failing to put a linebreak before "-----BEGIN PGP SIGNATURE" strResult = strResult . replaceAll ( "([a-z0-9])-----BEGIN PGP SIGNATURE-----" , "$1\n-----BEGIN PGP SIGNATURE-----" ) ; return strResult ; } catch ( Exception e ) { throw new LRException ( LRException . SIGNING_FAILED ) ; } finally { try { if ( privateKeyStream != null ) { privateKeyStream . close ( ) ; } result . close ( ) ; } catch ( IOException e ) { //Could not close the streams } } }
Encodes the provided message with the private key and pass phrase set in configuration
666
15
9,887
private PGPSecretKey readSecretKey ( InputStream input ) throws LRException { PGPSecretKeyRingCollection pgpSec ; try { pgpSec = new PGPSecretKeyRingCollection ( PGPUtil . getDecoderStream ( input ) ) ; } catch ( Exception e ) { throw new LRException ( LRException . NO_KEY ) ; } java . util . Iterator keyRingIter = pgpSec . getKeyRings ( ) ; while ( keyRingIter . hasNext ( ) ) { PGPSecretKeyRing keyRing = ( PGPSecretKeyRing ) keyRingIter . next ( ) ; java . util . Iterator keyIter = keyRing . getSecretKeys ( ) ; while ( keyIter . hasNext ( ) ) { PGPSecretKey key = ( PGPSecretKey ) keyIter . next ( ) ; if ( key . isSigningKey ( ) ) { return key ; } } } throw new LRException ( LRException . NO_KEY ) ; }
Reads private key from the provided InputStream
228
9
9,888
private InputStream getPrivateKeyStream ( String privateKey ) throws LRException { try { // If the private key matches the form of a private key string, treat it as such if ( privateKey . matches ( pgpRegex ) ) { return new ByteArrayInputStream ( privateKey . getBytes ( ) ) ; } // Otherwise, treat it as a file location on the local disk else { return new FileInputStream ( new File ( privateKey ) ) ; } } catch ( IOException e ) { throw new LRException ( LRException . NO_KEY_STREAM ) ; } }
Converts the local location or text of a private key into an input stream
129
15
9,889
@ Override public void include ( Readable in , String source ) throws IOException { if ( cursor != end ) { release ( ) ; } if ( includeStack == null ) { includeStack = new ArrayDeque <> ( ) ; } includeStack . push ( includeLevel ) ; includeLevel = new IncludeLevel ( in , source ) ; }
Include Readable at current input . Readable is read as part of input . When Readable ends input continues using current input .
73
27
9,890
private static Set < Type > getChildTypes ( final Type _type ) throws CacheReloadException { final Set < Type > ret = new HashSet < Type > ( ) ; ret . add ( _type ) ; for ( final Type child : _type . getChildTypes ( ) ) { ret . addAll ( getChildTypes ( child ) ) ; } return ret ; }
Gets the type list .
79
6
9,891
public Criteria addCriteria ( final int _idx , final List < String > _sqlColNames , final Comparison _comparison , final Set < String > _values , final boolean _escape , final Connection _connection ) { final Criteria criteria = new Criteria ( ) . tableIndex ( _idx ) . colNames ( _sqlColNames ) . comparison ( _comparison ) . values ( _values ) . escape ( _escape ) . connection ( _connection ) ; sections . add ( criteria ) ; return criteria ; }
Adds the criteria .
114
4
9,892
protected void appendSQL ( final String _tablePrefix , final StringBuilder _cmd ) { if ( sections . size ( ) > 0 ) { if ( isStarted ( ) ) { new SQLSelectPart ( SQLPart . AND ) . appendSQL ( _cmd ) ; new SQLSelectPart ( SQLPart . SPACE ) . appendSQL ( _cmd ) ; } else { new SQLSelectPart ( SQLPart . WHERE ) . appendSQL ( _cmd ) ; new SQLSelectPart ( SQLPart . SPACE ) . appendSQL ( _cmd ) ; } addSectionsSQL ( _tablePrefix , _cmd , sections ) ; } }
Append SQL .
134
4
9,893
public static InetAddress getInetAddress ( Config config , String path ) { try { return InetAddress . getByName ( config . getString ( path ) ) ; } catch ( UnknownHostException e ) { throw badValue ( e , config , path ) ; } }
Get an IP address . The configuration value can either be a hostname or a literal IP address .
59
20
9,894
public static NetworkInterface getNetworkInterface ( Config config , String path ) { NetworkInterface value = getNetworkInterfaceByName ( config , path ) ; if ( value == null ) value = getNetworkInterfaceByInetAddress ( config , path ) ; if ( value == null ) throw badValue ( "No network interface for value '" + config . getString ( path ) + "'" , config , path ) ; return value ; }
Get a network interface . The network interface can be identified by its name or its IP address .
90
19
9,895
public static int getPort ( Config config , String path ) { try { return new InetSocketAddress ( config . getInt ( path ) ) . getPort ( ) ; } catch ( IllegalArgumentException e ) { throw badValue ( e , config , path ) ; } }
Get a port number .
59
5
9,896
public List < ChatMessageStatus > adaptEvents ( List < DbOrphanedEvent > dbOrphanedEvents ) { List < ChatMessageStatus > statuses = new ArrayList <> ( ) ; Parser parser = new Parser ( ) ; for ( DbOrphanedEvent event : dbOrphanedEvents ) { OrphanedEvent orphanedEvent = parser . parse ( event . event ( ) , OrphanedEvent . class ) ; statuses . add ( ChatMessageStatus . builder ( ) . populate ( orphanedEvent . getConversationId ( ) , orphanedEvent . getMessageId ( ) , orphanedEvent . getProfileId ( ) , orphanedEvent . isEventTypeRead ( ) ? LocalMessageStatus . read : LocalMessageStatus . delivered , DateHelper . getUTCMilliseconds ( orphanedEvent . getTimestamp ( ) ) , ( long ) orphanedEvent . getConversationEventId ( ) ) . build ( ) ) ; } return statuses ; }
Translates Orphaned events to message statuses .
214
12
9,897
public List < ChatMessage > adaptMessages ( List < MessageReceived > messagesReceived ) { List < ChatMessage > chatMessages = new ArrayList <> ( ) ; if ( messagesReceived != null ) { for ( MessageReceived msg : messagesReceived ) { ChatMessage adaptedMessage = ChatMessage . builder ( ) . populate ( msg ) . build ( ) ; List < ChatMessageStatus > adaptedStatuses = adaptStatuses ( msg . getConversationId ( ) , msg . getMessageId ( ) , msg . getStatusUpdate ( ) ) ; for ( ChatMessageStatus s : adaptedStatuses ) { adaptedMessage . addStatusUpdate ( s ) ; } chatMessages . add ( adaptedMessage ) ; } } return chatMessages ; }
Translates received messages through message query to chat SDK model .
162
13
9,898
public List < ChatMessageStatus > adaptStatuses ( String conversationId , String messageId , Map < String , MessageReceived . Status > statuses ) { List < ChatMessageStatus > adapted = new ArrayList <> ( ) ; for ( String key : statuses . keySet ( ) ) { MessageReceived . Status status = statuses . get ( key ) ; adapted . add ( ChatMessageStatus . builder ( ) . populate ( conversationId , messageId , key , status . getStatus ( ) . compareTo ( MessageStatus . delivered ) == 0 ? LocalMessageStatus . delivered : LocalMessageStatus . read , DateHelper . getUTCMilliseconds ( status . getTimestamp ( ) ) , null ) . build ( ) ) ; } return adapted ; }
Translates received message statuses through message query to chat SDK model .
161
15
9,899
public List < ChatParticipant > adapt ( List < Participant > participants ) { List < ChatParticipant > result = new ArrayList <> ( ) ; if ( participants != null && ! participants . isEmpty ( ) ) { for ( Participant p : participants ) { result . add ( ChatParticipant . builder ( ) . populate ( p ) . build ( ) ) ; } } return result ; }
Translates Foundation conversation participants to Chat SDK conversation participants .
83
12