idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
9,600
public static traceroute get ( nitro_service client , traceroute resource ) throws Exception { resource . validate ( "get" ) ; return ( ( traceroute [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get the status of traceroute on a given device .
53
16
9,601
public static traceroute [ ] get_filtered ( nitro_service service , filtervalue [ ] filter ) throws Exception { traceroute obj = new traceroute ( ) ; options option = new options ( ) ; option . set_filter ( filter ) ; traceroute [ ] response = ( traceroute [ ] ) obj . getfiltered ( service , option ) ; return response ; }
Use this API to fetch filtered set of traceroute resources . set the filter parameter values in filtervalue object .
85
23
9,602
public boolean isMatching ( MouseEvent event ) { return ( event != null ) && ! event . isConsumed ( ) && ( mouseModifiers . isNone ( ) || ( ( event . isPrimaryButtonDown ( ) == mouseButtons . isPrimary ( ) ) && ( event . isMiddleButtonDown ( ) == mouseButtons . isMiddle ( ) ) && ( event . isSecondaryButtonDown ( ) == mouseButtons . isSecondary ( ) ) && ( event . isAltDown ( ) == mouseModifiers . isAlt ( ) ) && ( event . isShiftDown ( ) == mouseModifiers . isShift ( ) ) && ( event . isControlDown ( ) == mouseModifiers . isControl ( ) ) && ( event . isMetaDown ( ) == mouseModifiers . isMeta ( ) ) ) ) ; }
Check whether the given MouseEvent is matching the current properties .
179
12
9,603
private WebTarget configure ( String token , boolean debug , Logger log , int maxLog ) { Client client = ClientBuilder . newBuilder ( ) . register ( MultiPartFeature . class ) . register ( JsonProcessingFeature . class ) . build ( ) ; client . register ( HttpAuthenticationFeature . basic ( token , "" ) ) ; if ( debug ) client . register ( new LoggingFilter ( log , maxLog ) ) ; return client . target ( baseUri ) ; }
Configures this client by settings HTTP AUTH filter the REST URL and logging .
104
15
9,604
protected < JsonType extends JsonStructure , ValueType > ValueType invoke ( String operation , String id , String action , QueryClosure queryClosure , RequestClosure < JsonType > requestClosure , ResponseClosure < JsonType , ValueType > responseClosure ) { try { WebTarget ws = wsBase . path ( operation ) ; if ( id != null ) ws = ws . path ( id ) ; if ( action != null ) ws = ws . path ( action ) ; if ( queryClosure != null ) ws = queryClosure . modify ( ws ) ; Invocation . Builder request = ws . request ( MediaType . APPLICATION_JSON_TYPE ) ; request . header ( AGENT_REQHDR , getAgentRequestHeaderValue ( ) ) ; JsonType json = requestClosure . call ( request ) ; return ( responseClosure != null ) ? responseClosure . call ( json ) : null ; } catch ( WebApplicationException e ) { Response . StatusType status = e . getResponse ( ) . getStatusInfo ( ) ; switch ( status . getStatusCode ( ) ) { case 400 : throw new BadRequestException ( operation , id , action , e ) ; case 401 : throw new MissingApiTokenException ( status . getReasonPhrase ( ) ) ; case 403 : throw new UnauthorizedException ( operation , id , action ) ; case 404 : throw new NotFoundException ( operation , id ) ; case 409 : throw new ConflictException ( operation , id , action , e ) ; case 422 : throw new CoercionException ( operation , id , action , e ) ; case 427 : throw new RateLimitedException ( operation , id , action ) ; case 429 : throw new ResponseParseException ( operation , id , action , e ) ; case 500 : { String message = "" ; Response response = e . getResponse ( ) ; String contentType = response . getHeaderString ( "Content-Type" ) ; if ( contentType . equals ( "application/json" ) ) { InputStream is = ( InputStream ) response . getEntity ( ) ; JsonObject errJson = Json . createReader ( is ) . readObject ( ) ; message = errJson . getString ( "message" ) ; } else if ( contentType . startsWith ( "text/html" ) ) { InputStream is = ( InputStream ) response . getEntity ( ) ; message = StringUtils . toString ( is ) ; } throw new ServerException ( status . getReasonPhrase ( ) + ": " + message ) ; } default : throw new ApiException ( e ) ; } } catch ( ApiException e ) { throw e ; } catch ( Exception e ) { throw new ApiException ( e ) ; } }
Performs a REST API invocation .
589
7
9,605
protected void checkApiToken ( String apiToken ) { if ( StringUtils . isBlank ( apiToken ) ) throw new MissingApiTokenException ( "Empty key" ) ; if ( apiToken . length ( ) != TOKEN_LENGTH ) throw new MissingApiTokenException ( "Wrong length" ) ; if ( ! apiToken . matches ( HEX_PATTERN ) ) throw new MissingApiTokenException ( "Not a HEX value" ) ; }
Syntax checks the API Token .
104
7
9,606
public boolean isValidToken ( ) { try { // Response response = wsBase.path(TEST_CONFIGS).request(MediaType.APPLICATION_JSON_TYPE).get(); // return response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL; LoadZone zone = getLoadZone ( LoadZone . AMAZON_US_ASHBURN . uid ) ; return zone == LoadZone . AMAZON_US_ASHBURN ; } catch ( Exception e ) { log . info ( "API token validation failed: " + e ) ; } return false ; }
Returns true if we can successfully logon and fetch some data .
133
13
9,607
public LoadZone getLoadZone ( String id ) { return invoke ( LOAD_ZONES , id , null , null , new RequestClosure < JsonArray > ( ) { @ Override public JsonArray call ( Invocation . Builder request ) { return request . get ( JsonArray . class ) ; } } , new ResponseClosure < JsonArray , LoadZone > ( ) { @ Override public LoadZone call ( JsonArray json ) { return LoadZone . valueOf ( json . getJsonObject ( 0 ) ) ; } } ) ; }
Retrieves a load - zone .
119
8
9,608
public List < LoadZone > getLoadZone ( ) { return invoke ( LOAD_ZONES , new RequestClosure < JsonArray > ( ) { @ Override public JsonArray call ( Invocation . Builder request ) { return request . get ( JsonArray . class ) ; } } , new ResponseClosure < JsonArray , List < LoadZone > > ( ) { @ Override public List < LoadZone > call ( JsonArray json ) { List < LoadZone > zones = new ArrayList < LoadZone > ( json . size ( ) ) ; for ( int k = 0 ; k < json . size ( ) ; ++ k ) { zones . add ( LoadZone . valueOf ( json . getJsonObject ( k ) ) ) ; } return zones ; } } ) ; }
Retrieves all load - zones .
169
8
9,609
public DataStore getDataStore ( int id ) { return invoke ( DATA_STORES , id , new RequestClosure < JsonObject > ( ) { @ Override public JsonObject call ( Invocation . Builder request ) { return request . get ( JsonObject . class ) ; } } , new ResponseClosure < JsonObject , DataStore > ( ) { @ Override public DataStore call ( JsonObject json ) { return new DataStore ( json ) ; } } ) ; }
Retrieves a data store .
105
7
9,610
public List < DataStore > getDataStores ( ) { return invoke ( DATA_STORES , new RequestClosure < JsonArray > ( ) { @ Override public JsonArray call ( Invocation . Builder request ) { return request . get ( JsonArray . class ) ; } } , new ResponseClosure < JsonArray , List < DataStore > > ( ) { @ Override public List < DataStore > call ( JsonArray json ) { List < DataStore > ds = new ArrayList < DataStore > ( json . size ( ) ) ; for ( int k = 0 ; k < json . size ( ) ; ++ k ) { ds . add ( new DataStore ( json . getJsonObject ( k ) ) ) ; } return ds ; } } ) ; }
Retrieves all data stores .
171
7
9,611
public void deleteDataStore ( final int id ) { invoke ( DATA_STORES , id , new RequestClosure < JsonStructure > ( ) { @ Override public JsonStructure call ( Invocation . Builder request ) { Response response = request . delete ( ) ; if ( response . getStatusInfo ( ) . getFamily ( ) != Response . Status . Family . SUCCESSFUL ) { throw new ResponseParseException ( DATA_STORES , id , null , null ) ; } return null ; } } , null ) ; }
Deletes a data store .
117
6
9,612
public DataStore createDataStore ( final File file , final String name , final int fromline , final DataStore . Separator separator , final DataStore . StringDelimiter delimiter ) { return invoke ( DATA_STORES , new RequestClosure < JsonObject > ( ) { @ Override public JsonObject call ( Invocation . Builder request ) { MultiPart form = new FormDataMultiPart ( ) . field ( "name" , name ) . field ( "fromline" , Integer . toString ( fromline ) ) . field ( "separator" , separator . param ( ) ) . field ( "delimiter" , delimiter . param ( ) ) . bodyPart ( new FileDataBodyPart ( "file" , file , new MediaType ( "text" , "csv" ) ) ) ; return request . post ( Entity . entity ( form , form . getMediaType ( ) ) , JsonObject . class ) ; } } , new ResponseClosure < JsonObject , DataStore > ( ) { @ Override public DataStore call ( JsonObject json ) { return new DataStore ( json ) ; } } ) ; }
Creates a new data store .
248
7
9,613
public UserScenario getUserScenario ( int id ) { return invoke ( USER_SCENARIOS , id , new RequestClosure < JsonObject > ( ) { @ Override public JsonObject call ( Invocation . Builder request ) { return request . get ( JsonObject . class ) ; } } , new ResponseClosure < JsonObject , UserScenario > ( ) { @ Override public UserScenario call ( JsonObject json ) { return new UserScenario ( json ) ; } } ) ; }
Retrieves a user scenario .
112
7
9,614
public List < UserScenario > getUserScenarios ( ) { return invoke ( USER_SCENARIOS , new RequestClosure < JsonArray > ( ) { @ Override public JsonArray call ( Invocation . Builder request ) { return request . get ( JsonArray . class ) ; } } , new ResponseClosure < JsonArray , List < UserScenario > > ( ) { @ Override public List < UserScenario > call ( JsonArray json ) { List < UserScenario > ds = new ArrayList < UserScenario > ( json . size ( ) ) ; for ( int k = 0 ; k < json . size ( ) ; ++ k ) { ds . add ( new UserScenario ( json . getJsonObject ( k ) ) ) ; } return ds ; } } ) ; }
Retrieves all user scenarios .
180
7
9,615
public UserScenario createUserScenario ( final UserScenario scenario ) { return invoke ( USER_SCENARIOS , new RequestClosure < JsonObject > ( ) { @ Override public JsonObject call ( Invocation . Builder request ) { String json = scenario . toJSON ( ) . toString ( ) ; Entity < String > data = Entity . entity ( json , MediaType . APPLICATION_JSON_TYPE ) ; return request . post ( data , JsonObject . class ) ; } } , new ResponseClosure < JsonObject , UserScenario > ( ) { @ Override public UserScenario call ( JsonObject json ) { return new UserScenario ( json ) ; } } ) ; }
Creates a new user scenario .
153
7
9,616
public UserScenarioValidation getUserScenarioValidation ( int id ) { return invoke ( USER_SCENARIO_VALIDATIONS , id , new RequestClosure < JsonObject > ( ) { @ Override public JsonObject call ( Invocation . Builder request ) { return request . get ( JsonObject . class ) ; } } , new ResponseClosure < JsonObject , UserScenarioValidation > ( ) { @ Override public UserScenarioValidation call ( JsonObject json ) { return new UserScenarioValidation ( json ) ; } } ) ; }
Retrieves a user scenario validation .
126
8
9,617
@ Override @ SuppressWarnings ( "unchecked" ) public void setModifiedBy ( USER modifiedBy ) { this . modifiedBy = assertNotNull ( modifiedBy , ( ) -> "Modified by is required" ) ; this . lastModifiedBy = defaultIfNull ( this . lastModifiedBy , this . modifiedBy ) ; }
Sets the user responsible for modifying this object .
77
10
9,618
public static br reboot ( nitro_service client , br resource ) throws Exception { return ( ( br [ ] ) resource . perform_operation ( client , "reboot" ) ) [ 0 ] ; }
Use this operation to reboot Repeater Instance .
43
10
9,619
public static br stop ( nitro_service client , br resource ) throws Exception { return ( ( br [ ] ) resource . perform_operation ( client , "stop" ) ) [ 0 ] ; }
Use this operation to stop Repeater Instance .
42
10
9,620
public static br force_reboot ( nitro_service client , br resource ) throws Exception { return ( ( br [ ] ) resource . perform_operation ( client , "force_reboot" ) ) [ 0 ] ; }
Use this operation to force reboot Repeater Instance .
48
11
9,621
public static br force_stop ( nitro_service client , br resource ) throws Exception { return ( ( br [ ] ) resource . perform_operation ( client , "force_stop" ) ) [ 0 ] ; }
Use this operation to force stop Repeater Instance .
46
11
9,622
public static br start ( nitro_service client , br resource ) throws Exception { return ( ( br [ ] ) resource . perform_operation ( client , "start" ) ) [ 0 ] ; }
Use this operation to start Repeater Instance .
42
10
9,623
public boolean isMatching ( GestureEvent event ) { return ( event != null ) && ! event . isConsumed ( ) && ( gestureModifiers . isNone ( ) || ( ( event . isAltDown ( ) == gestureModifiers . isAlt ( ) ) && ( event . isShiftDown ( ) == gestureModifiers . isShift ( ) ) && ( event . isControlDown ( ) == gestureModifiers . isControl ( ) ) && ( event . isMetaDown ( ) == gestureModifiers . isMeta ( ) ) && ( event . isShortcutDown ( ) == gestureModifiers . isShortcut ( ) ) ) ) ; }
Check whether the given GestureEvent is matching the current properties .
139
13
9,624
public static prune_policy get ( nitro_service client , prune_policy resource ) throws Exception { resource . validate ( "get" ) ; return ( ( prune_policy [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get the prune policy to view number of days data to retain .
56
18
9,625
@ Override @ SuppressWarnings ( "unchecked" ) public < E > E search ( final Collection < E > collection ) { Assert . isInstanceOf ( collection , List . class , "The collection {0} must be an instance of java.util.List!" , ClassUtils . getClassName ( collection ) ) ; return doSearch ( ( List < E > ) collection ) ; }
Searches the Collection of elements in order to find the element or elements matching the criteria defined by the Matcher . The search operation expects the collection of elements to an instance of java . util . List an ordered collection of elements that are sorted according the natural ordering of the element s Comparable Class type .
87
62
9,626
public void close ( ) { refuseNewRequests . set ( true ) ; channel . close ( ) . awaitUninterruptibly ( ) ; channel . eventLoop ( ) . shutdownGracefully ( ) . awaitUninterruptibly ( ) ; }
Shuts down this client and releases the underlying associated resources .
53
12
9,627
protected FraggleFragment peek ( String tag ) { if ( fm != null ) { return ( FraggleFragment ) fm . findFragmentByTag ( tag ) ; } return new EmptyFragment ( ) ; }
Returns the first fragment in the stack with the tag tag .
50
12
9,628
protected void processAnimations ( FragmentAnimation animation , FragmentTransaction ft ) { if ( animation != null ) { if ( animation . isCompletedAnimation ( ) ) { ft . setCustomAnimations ( animation . getEnterAnim ( ) , animation . getExitAnim ( ) , animation . getPushInAnim ( ) , animation . getPopOutAnim ( ) ) ; } else { ft . setCustomAnimations ( animation . getEnterAnim ( ) , animation . getExitAnim ( ) ) ; } if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) for ( LollipopAnim sharedElement : animation . getSharedViews ( ) ) { ft . addSharedElement ( sharedElement . view , sharedElement . name ) ; } } }
Processes the custom animations element adding them as required
170
10
9,629
protected void configureAdditionMode ( Fragment frag , int flags , FragmentTransaction ft , int containerId ) { if ( ( flags & DO_NOT_REPLACE_FRAGMENT ) != DO_NOT_REPLACE_FRAGMENT ) { ft . replace ( containerId , frag , ( ( FraggleFragment ) frag ) . getFragmentTag ( ) ) ; } else { ft . add ( containerId , frag , ( ( FraggleFragment ) frag ) . getFragmentTag ( ) ) ; peek ( ) . onFragmentNotVisible ( ) ; } }
Configures the way to add the Fragment into the transaction . It can vary from adding a new fragment to using a previous instance and refresh it or replacing the last one .
129
35
9,630
protected void performTransaction ( Fragment frag , int flags , FragmentTransaction ft , int containerId ) { configureAdditionMode ( frag , flags , ft , containerId ) ; ft . commitAllowingStateLoss ( ) ; }
Commits the transaction to the Fragment Manager .
49
10
9,631
protected FraggleFragment peek ( ) { if ( fm . getBackStackEntryCount ( ) > 0 ) { return ( ( FraggleFragment ) fm . findFragmentByTag ( fm . getBackStackEntryAt ( fm . getBackStackEntryCount ( ) - 1 ) . getName ( ) ) ) ; } else { return new EmptyFragment ( ) ; } }
Peeks the last fragment in the Fragment stack .
87
11
9,632
public void clear ( ) { if ( fm != null ) { fm . popBackStack ( null , FragmentManager . POP_BACK_STACK_INCLUSIVE ) ; } fm = null ; }
Clears fragment manager backstack and the fragment manager itself .
46
12
9,633
public void reattach ( String tag ) { final Fragment currentFragment = ( Fragment ) peek ( tag ) ; FragmentTransaction fragTransaction = fm . beginTransaction ( ) ; fragTransaction . detach ( currentFragment ) ; fragTransaction . attach ( currentFragment ) ; fragTransaction . commit ( ) ; }
Reattaches a Fragment
67
6
9,634
public Set < String > keys ( String pattern ) { Set < String > result = new TreeSet < String > ( ) ; for ( String key : keys ( ) ) { if ( key . matches ( pattern ) ) result . add ( key ) ; } return result ; }
Returns all keys matching the given pattern .
57
8
9,635
public String get ( String key , String defaultValue ) { String value = parameters . get ( key ) ; return StringUtils . isBlank ( value ) ? defaultValue : value ; }
Returns the value associated with the key or the given default value .
40
13
9,636
public static system_settings get ( nitro_service client ) throws Exception { system_settings resource = new system_settings ( ) ; resource . validate ( "get" ) ; return ( ( system_settings [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get SDX system settings .
60
10
9,637
@ Override @ SuppressWarnings ( "unchecked" ) public < E > Comparator < E > getOrderBy ( ) { return ObjectUtils . defaultIfNull ( ComparatorHolder . get ( ) , ObjectUtils . defaultIfNull ( orderBy , ComparableComparator . INSTANCE ) ) ; }
Gets the Comparator used to order the elements in the collection .
70
14
9,638
@ Override @ SuppressWarnings ( "unchecked" ) public < E > E [ ] sort ( final E ... elements ) { sort ( new SortableArrayList ( elements ) ) ; return elements ; }
Sorts an array of elements as defined by the Comparator or as determined by the elements in the array if the elements are Comparable .
46
28
9,639
@ Override public < E > Sortable < E > sort ( final Sortable < E > sortable ) { try { sort ( configureComparator ( sortable ) . asList ( ) ) ; return sortable ; } finally { ComparatorHolder . unset ( ) ; } }
Sorts the List representation of the Sortable implementing object as defined by the orderBy Comparator or as determined by elements in the Sortable collection if the elements are Comparable .
61
36
9,640
@ SafeVarargs public static < T > @ NonNull Optional < T > first ( final @ NonNull Optional < T > ... optionals ) { return Arrays . stream ( optionals ) . filter ( Optional :: isPresent ) . findFirst ( ) . orElse ( Optional . empty ( ) ) ; }
Gets the first optional with a present value .
65
10
9,641
@ SuppressWarnings ( "unchecked" ) public static < T extends Searcher > T createSearcher ( final SearchType type ) { switch ( ObjectUtils . defaultIfNull ( type , SearchType . UNKNOWN_SEARCH ) ) { case BINARY_SEARCH : return ( T ) new BinarySearch ( ) ; case LINEAR_SEARCH : return ( T ) new LinearSearch ( ) ; default : throw new IllegalArgumentException ( String . format ( "The SearchType (%1$s) is not supported by the %2$s!" , type , SearcherFactory . class . getSimpleName ( ) ) ) ; } }
Creates an instance of the Searcher interface implementing the searching algorithm based on the SearchType .
140
19
9,642
public static < T extends Searcher > T createSearcherElseDefault ( final SearchType type , final T defaultSearcher ) { try { return createSearcher ( type ) ; } catch ( IllegalArgumentException ignore ) { return defaultSearcher ; } }
Creates an instance of the Searcher interface implementing the searching algorithm based on the SearchType otherwise returns the provided default Searcher implementation if a Searcher based on the specified SearchType is not available .
54
40
9,643
private void balance ( ) { // only try to balance when we're not terminating if ( ! isTerminated ( ) ) { Set < Map . Entry < Thread , Tracking > > threads = liveThreads . entrySet ( ) ; long liveAvgTimeTotal = 0 ; long liveAvgCpuTotal = 0 ; long liveCount = 0 ; for ( Map . Entry < Thread , Tracking > e : threads ) { if ( ! e . getKey ( ) . isAlive ( ) ) { // thread is dead or otherwise hosed threads . remove ( e ) ; } else { liveAvgTimeTotal += e . getValue ( ) . avgTotalTime ; liveAvgCpuTotal += e . getValue ( ) . avgCpuTime ; liveCount ++ ; } } long waitTime = 1 ; long cpuTime = 1 ; if ( liveCount > 0 ) { waitTime = liveAvgTimeTotal / liveCount ; cpuTime = liveAvgCpuTotal / liveCount ; } int size = 1 ; if ( cpuTime > 0 ) { size = ( int ) ceil ( ( CPUS * targetUtilization * ( 1 + ( waitTime / cpuTime ) ) ) ) ; } size = Math . min ( size , threadPoolExecutor . getMaximumPoolSize ( ) ) ; // TODO remove debugging //System.out.println(waitTime / 1000000 + " ms"); //System.out.println(cpuTime / 1000000 + " ms"); //System.out.println(size); threadPoolExecutor . setCorePoolSize ( size ) ; } }
Compute and set the optimal number of threads to use in this pool .
332
15
9,644
public void setMenu ( Menu menu ) { this . menu = menu ; RadialMenuItem . setupMenuButton ( this , radialMenuParams , ( menu != null ) ? menu . getGraphic ( ) : null , ( menu != null ) ? menu . getText ( ) : null , true ) ; }
Sets the menu model .
66
6
9,645
@ Override public < E > List < E > sort ( final List < E > elements ) { int size = elements . size ( ) ; // create the heap for ( int parentIndex = ( ( size - 2 ) / 2 ) ; parentIndex >= 0 ; parentIndex -- ) { siftDown ( elements , parentIndex , size - 1 ) ; } // swap the first and last elements in the heap of array since the first is the largest value in the heap, // and then heapify the heap again for ( int count = ( size - 1 ) ; count > 0 ; count -- ) { swap ( elements , 0 , count ) ; siftDown ( elements , 0 , count - 1 ) ; } return elements ; }
Uses the Heap Sort algorithm to sort a List of elements as defined by the Comparator or as determined by the elements in the collection if the elements are Comparable .
152
35
9,646
protected < E > void siftDown ( final List < E > elements , final int startIndex , final int endIndex ) { int rootIndex = startIndex ; while ( ( rootIndex * 2 + 1 ) <= endIndex ) { int swapIndex = rootIndex ; int leftChildIndex = ( rootIndex * 2 + 1 ) ; int rightChildIndex = ( leftChildIndex + 1 ) ; if ( getOrderBy ( ) . compare ( elements . get ( swapIndex ) , elements . get ( leftChildIndex ) ) < 0 ) { swapIndex = leftChildIndex ; } if ( rightChildIndex <= endIndex && getOrderBy ( ) . compare ( elements . get ( swapIndex ) , elements . get ( rightChildIndex ) ) < 0 ) { swapIndex = rightChildIndex ; } if ( swapIndex != rootIndex ) { swap ( elements , rootIndex , swapIndex ) ; rootIndex = swapIndex ; } else { return ; } } }
Creates a binary heap with the list of elements with the largest valued element at the root followed by the next largest valued elements as parents down to the leafs .
202
33
9,647
public void fireChangeEvent ( ) { ChangeEvent event = createChangeEvent ( getSource ( ) ) ; for ( ChangeListener listener : this ) { listener . stateChanged ( event ) ; } }
Fires a ChangeEvent for the source Object notifying each registered ChangeListener of the change .
41
19
9,648
@ Override public < E > List < E > sort ( final List < E > elements ) { int elementsSize = elements . size ( ) ; if ( elementsSize <= getSizeThreshold ( ) ) { return getSorter ( ) . sort ( elements ) ; } else { int beginIndex = 1 ; int endIndex = ( elementsSize - 1 ) ; E pivotElement = elements . get ( 0 ) ; while ( beginIndex < endIndex ) { while ( beginIndex < endIndex && getOrderBy ( ) . compare ( elements . get ( beginIndex ) , pivotElement ) <= 0 ) { beginIndex ++ ; } while ( endIndex >= beginIndex && getOrderBy ( ) . compare ( elements . get ( endIndex ) , pivotElement ) >= 0 ) { endIndex -- ; } if ( beginIndex < endIndex ) { swap ( elements , beginIndex , endIndex ) ; } } swap ( elements , 0 , endIndex ) ; sort ( elements . subList ( 0 , endIndex ) ) ; sort ( elements . subList ( endIndex + 1 , elementsSize ) ) ; return elements ; } }
Uses the Quick Sort algorithm to sort a List of elements as defined by the Comparator or as determined by the elements in the collection if the elements are Comparable .
236
34
9,649
public void onBeforeAdd ( E value ) { long freeHeapSpace = RUNTIME . freeMemory ( ) + ( RUNTIME . maxMemory ( ) - RUNTIME . totalMemory ( ) ) ; // start flow control if we cross the threshold if ( freeHeapSpace < minimumHeapSpaceBeforeFlowControl ) { // x indicates how close we are to overflowing the heap long x = minimumHeapSpaceBeforeFlowControl - freeHeapSpace ; long delay = Math . round ( x * ( x * c ) ) ; // delay = x^2 * c try { Thread . sleep ( delay ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } } }
Block for a varying amount based on how close the system is to the max heap space . Only kick in when we have passed the percentOfHeapBeforeFlowControl threshold .
147
35
9,650
public void onAfterRemove ( E value ) { if ( value != null ) { dequeued ++ ; if ( dequeued % dequeueHint == 0 ) { RUNTIME . gc ( ) ; } } }
Increment the count of removed items from the queue . Calling this will optionally request that the garbage collector run to free up heap space for every nth dequeue where n is the value set for the dequeueHint .
47
45
9,651
public void propertyChange ( final PropertyChangeEvent event ) { if ( objectStateMap . containsKey ( event . getPropertyName ( ) ) ) { if ( objectStateMap . get ( event . getPropertyName ( ) ) == ObjectUtils . hashCode ( event . getNewValue ( ) ) ) { // NOTE the state of the property identified by the event has been reverted to it's original, persisted value. objectStateMap . remove ( event . getPropertyName ( ) ) ; } } else { if ( ! ObjectUtils . equalsIgnoreNull ( event . getOldValue ( ) , event . getNewValue ( ) ) ) { objectStateMap . put ( event . getPropertyName ( ) , ObjectUtils . hashCode ( event . getOldValue ( ) ) ) ; } } }
The event handler method that gets fired when a property of the Bean tracked by this ChangeTracker has been modified . The PropertyChangeEvent encapsulates all the information pertaining to the property change including the name of the property it s old and new value and the source Bean of the targeted change .
170
57
9,652
public void setResponse ( JsonRpcResponse response ) { if ( response . isError ( ) ) { setException ( response . error ( ) ) ; return ; } try { set ( ( V ) Messages . fromJson ( method . outputBuilder ( ) , response . result ( ) ) ) ; } catch ( Exception e ) { setException ( e ) ; } }
Sets the JSON response of this promise .
79
9
9,653
@ SuppressWarnings ( "unchecked" ) protected Class [ ] getArgumentTypes ( final Object ... arguments ) { Class [ ] argumentTypes = new Class [ arguments . length ] ; int index = 0 ; for ( Object argument : arguments ) { argumentTypes [ index ++ ] = ObjectUtils . defaultIfNull ( ClassUtils . getClass ( argument ) , Object . class ) ; } return argumentTypes ; }
Determines the class types of the array of object arguments .
90
13
9,654
protected Constructor resolveConstructor ( final Class < ? > objectType , final Class ... parameterTypes ) { try { return objectType . getConstructor ( parameterTypes ) ; } catch ( NoSuchMethodException e ) { if ( ! ArrayUtils . isEmpty ( parameterTypes ) ) { Constructor constructor = resolveCompatibleConstructor ( objectType , parameterTypes ) ; // if the "compatible" constructor is null, resolve to finding the public, default no-arg constructor return ( constructor != null ? constructor : resolveConstructor ( objectType ) ) ; } throw new NoSuchConstructorException ( String . format ( "Failed to find a constructor with signature (%1$s) in Class (%2$s)" , from ( parameterTypes ) . toString ( ) , objectType . getName ( ) ) , e ) ; } }
Resolves the Class constructor with the given signature as determined by the parameter types .
176
16
9,655
@ SuppressWarnings ( "unchecked" ) protected Constructor resolveCompatibleConstructor ( final Class < ? > objectType , final Class < ? > [ ] parameterTypes ) { for ( Constructor constructor : objectType . getConstructors ( ) ) { Class [ ] constructorParameterTypes = constructor . getParameterTypes ( ) ; if ( parameterTypes . length == constructorParameterTypes . length ) { boolean match = true ; for ( int index = 0 ; index < constructorParameterTypes . length ; index ++ ) { match &= constructorParameterTypes [ index ] . isAssignableFrom ( parameterTypes [ index ] ) ; } if ( match ) { return constructor ; } } } return null ; }
Resolves the matching constructor for the specified Class type who s actual public constructor argument types are assignment compatible with the expected parameter types .
148
26
9,656
@ Override @ SuppressWarnings ( "unchecked" ) public < T > T create ( final String objectTypeName , final Object ... args ) { return ( T ) create ( ClassUtils . loadClass ( objectTypeName ) , getArgumentTypes ( args ) , args ) ; }
Creates an object given the fully qualified class name initialized with the specified constructor arguments . The parameter types of the constructor used to construct the object are determined from the arguments .
64
34
9,657
@ Override public < T > T create ( final Class < T > objectType , final Object ... args ) { return create ( objectType , getArgumentTypes ( args ) , args ) ; }
Creates an object given the class type initialized with the specified constructor arguments . The parameter types of the constructor used to construct the object are determined from the arguments .
42
32
9,658
private static int copyPathFragment ( char [ ] input , int beginIndex , StringBuilder output ) { int inputCharIndex = beginIndex ; while ( inputCharIndex < input . length ) { final char inputChar = input [ inputCharIndex ] ; if ( inputChar == ' ' ) { break ; } output . append ( inputChar ) ; inputCharIndex += 1 ; } return inputCharIndex ; }
Copy path fragment
86
3
9,659
public ListenableFuture < JsonRpcResponse > invoke ( JsonRpcRequest request ) { Service service = services . lookupByName ( request . service ( ) ) ; if ( service == null ) { JsonRpcError error = new JsonRpcError ( HttpResponseStatus . BAD_REQUEST , "Unknown service: " + request . service ( ) ) ; JsonRpcResponse response = JsonRpcResponse . error ( error ) ; return Futures . immediateFuture ( response ) ; } ServerMethod < ? extends Message , ? extends Message > method = service . lookup ( request . method ( ) ) ; serverLogger . logMethodCall ( service , method ) ; if ( method == null ) { JsonRpcError error = new JsonRpcError ( HttpResponseStatus . BAD_REQUEST , "Unknown method: " + request . service ( ) ) ; JsonRpcResponse response = JsonRpcResponse . error ( error ) ; return Futures . immediateFuture ( response ) ; } return invoke ( method , request . parameter ( ) , request . id ( ) ) ; }
Executes a request .
239
5
9,660
private < I extends Message , O extends Message > ListenableFuture < JsonRpcResponse > invoke ( ServerMethod < I , O > method , JsonObject parameter , JsonElement id ) { I request ; try { request = ( I ) Messages . fromJson ( method . inputBuilder ( ) , parameter ) ; } catch ( Exception e ) { serverLogger . logServerFailure ( method , e ) ; SettableFuture < JsonRpcResponse > future = SettableFuture . create ( ) ; future . setException ( e ) ; return future ; } ListenableFuture < O > response = method . invoke ( request ) ; return Futures . transform ( response , new JsonConverter ( id ) , TRANSFORM_EXECUTOR ) ; }
Actually invokes the server method .
163
7
9,661
protected synchronized void addContent ( Artifact record , String filename ) { if ( record != null ) { if ( filename . endsWith ( ".jar" ) ) { // this is an embedded archive embedded . add ( record ) ; } else { contents . add ( record ) ; } } }
Synchronized method for adding a new conent
59
10
9,662
protected void submitJob ( ExecutorService executor , Content file ) { // lifted from http://stackoverflow.com/a/5853198/1874604 class OneShotTask implements Runnable { Content file ; OneShotTask ( Content file ) { this . file = file ; } public void run ( ) { processContent ( file ) ; } } // we do not care about Future executor . submit ( new OneShotTask ( file ) ) ; }
Helper method to sumit a new threaded tast to a given executor .
98
15
9,663
public static < T extends Comparable < T > > ComparableValueHolder < T > withComparableValue ( final T value ) { return new ComparableValueHolder <> ( value ) ; }
Factory method to construct an instance of the ValueHolder class with a Comparable value . The ValueHolder implementation itself implements the Comparable interface .
43
30
9,664
public static < T extends Cloneable > ValueHolder < T > withImmutableValue ( final T value ) { return new ValueHolder < T > ( ObjectUtils . clone ( value ) ) { @ Override public T getValue ( ) { return ObjectUtils . clone ( super . getValue ( ) ) ; } @ Override public void setValue ( final T value ) { super . setValue ( ObjectUtils . clone ( value ) ) ; } } ; }
Factory method to construct an instance of the ValueHolder class with an immutable Object value .
101
18
9,665
public static < T > ValueHolder < T > withNonNullValue ( final T value ) { Assert . notNull ( value , "The value must not be null!" ) ; return new ValueHolder < T > ( value ) { @ Override public void setValue ( final T value ) { Assert . notNull ( value , "The value must not be null!" ) ; super . setValue ( value ) ; } } ; }
Factory method to construct an instance of the ValueHolder class with a non - null value .
94
19
9,666
public static xen reboot ( nitro_service client , xen resource ) throws Exception { return ( ( xen [ ] ) resource . perform_operation ( client , "reboot" ) ) [ 0 ] ; }
Use this operation to reboot XenServer .
43
8
9,667
public static xen stop ( nitro_service client , xen resource ) throws Exception { return ( ( xen [ ] ) resource . perform_operation ( client , "stop" ) ) [ 0 ] ; }
Use this operation to shutdown XenServer .
42
8
9,668
public static xen [ ] get_filtered ( nitro_service service , filtervalue [ ] filter ) throws Exception { xen obj = new xen ( ) ; options option = new options ( ) ; option . set_filter ( filter ) ; xen [ ] response = ( xen [ ] ) obj . getfiltered ( service , option ) ; return response ; }
Use this API to fetch filtered set of xen resources . set the filter parameter values in filtervalue object .
75
21
9,669
public static sdx_license get ( nitro_service client ) throws Exception { sdx_license resource = new sdx_license ( ) ; resource . validate ( "get" ) ; return ( ( sdx_license [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get SDX license information .
64
10
9,670
@ Override public void visit ( final Visitable visitable ) { if ( visitable instanceof Auditable ) { modified |= ( ( Auditable ) visitable ) . isModified ( ) ; } }
Visits all Auditable Visitable objects in an object graph hierarchy in search of any modified objects .
44
20
9,671
public FilterBuilder < T > addWithAnd ( final Filter < T > filter ) { filterInstance = ComposableFilter . and ( filterInstance , filter ) ; return this ; }
Adds the specified Filter to the composition of Filters joined using the AND operator .
37
16
9,672
public FilterBuilder < T > addWithOr ( final Filter < T > filter ) { filterInstance = ComposableFilter . or ( filterInstance , filter ) ; return this ; }
Adds the specified Filter to the composition of Filters joined using the OR operator .
37
16
9,673
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] filter ( T [ ] array , Filter < T > filter ) { Assert . notNull ( array , "Array is required" ) ; Assert . notNull ( filter , "Filter is required" ) ; List < T > arrayList = stream ( array ) . filter ( filter :: accept ) . collect ( Collectors . toList ( ) ) ; return arrayList . toArray ( ( T [ ] ) Array . newInstance ( array . getClass ( ) . getComponentType ( ) , arrayList . size ( ) ) ) ; }
Filters the elements in the array .
134
8
9,674
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] filterAndTransform ( T [ ] array , FilteringTransformer < T > filteringTransformer ) { return transform ( filter ( array , filteringTransformer ) , filteringTransformer ) ; }
Filters and transforms the elements in the array .
59
10
9,675
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] insert ( T element , T [ ] array , int index ) { Assert . notNull ( array , "Array is required" ) ; assertThat ( index ) . throwing ( new ArrayIndexOutOfBoundsException ( String . format ( "[%1$d] is not a valid index [0, %2$d] in the array" , index , array . length ) ) ) . isGreaterThanEqualToAndLessThanEqualTo ( 0 , array . length ) ; Class < ? > componentType = array . getClass ( ) . getComponentType ( ) ; componentType = defaultIfNull ( componentType , ObjectUtils . getClass ( element ) ) ; componentType = defaultIfNull ( componentType , Object . class ) ; T [ ] newArray = ( T [ ] ) Array . newInstance ( componentType , array . length + 1 ) ; if ( index > 0 ) { System . arraycopy ( array , 0 , newArray , 0 , index ) ; } newArray [ index ] = element ; if ( index < array . length ) { System . arraycopy ( array , index , newArray , index + 1 , array . length - index ) ; } return newArray ; }
Inserts element into the array at index .
279
9
9,676
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] remove ( T [ ] array , int index ) { Assert . notNull ( array , "Array is required" ) ; assertThat ( index ) . throwing ( new ArrayIndexOutOfBoundsException ( String . format ( "[%1$d] is not a valid index [0, %2$d] in the array" , index , array . length ) ) ) . isGreaterThanEqualToAndLessThan ( 0 , array . length ) ; Class < ? > componentType = defaultIfNull ( array . getClass ( ) . getComponentType ( ) , Object . class ) ; T [ ] newArray = ( T [ ] ) Array . newInstance ( componentType , array . length - 1 ) ; if ( index > 0 ) { System . arraycopy ( array , 0 , newArray , 0 , index ) ; } if ( index + 1 < array . length ) { System . arraycopy ( array , index + 1 , newArray , index , ( array . length - index - 1 ) ) ; } return newArray ; }
Removes the element at index from the given array .
244
11
9,677
public static < T > T [ ] sort ( T [ ] array , Comparator < T > comparator ) { Arrays . sort ( array , comparator ) ; return array ; }
Sorts the elements in the given array .
39
9
9,678
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] subArray ( T [ ] array , int ... indices ) { List < T > subArrayList = new ArrayList <> ( indices . length ) ; for ( int index : indices ) { subArrayList . add ( array [ index ] ) ; } return subArrayList . toArray ( ( T [ ] ) Array . newInstance ( array . getClass ( ) . getComponentType ( ) , subArrayList . size ( ) ) ) ; }
Creates a sub - array from the given array with elements at the specified indices in the given array .
115
21
9,679
public static < T > T [ ] swap ( T [ ] array , int indexOne , int indexTwo ) { T elementAtIndexOne = array [ indexOne ] ; array [ indexOne ] = array [ indexTwo ] ; array [ indexTwo ] = elementAtIndexOne ; return array ; }
Swaps elements in the array at indexOne and indexTwo .
63
13
9,680
public static void warnFormatted ( final Exception exception ) { logWriterInstance . warn ( exception ) ; UaiWebSocketLogManager . addLogText ( "[WARN] An exception just happened: " + exception . getMessage ( ) ) ; }
Wil log a text with the WARN level .
51
9
9,681
public static JsonObject toJson ( Message output ) { JsonObject object = new JsonObject ( ) ; for ( Map . Entry < Descriptors . FieldDescriptor , Object > field : output . getAllFields ( ) . entrySet ( ) ) { String jsonName = CaseFormat . LOWER_UNDERSCORE . to ( CaseFormat . LOWER_CAMEL , field . getKey ( ) . getName ( ) ) ; if ( field . getKey ( ) . isRepeated ( ) ) { JsonArray array = new JsonArray ( ) ; List < ? > items = ( List < ? > ) field . getValue ( ) ; for ( Object item : items ) { array . add ( serializeField ( field . getKey ( ) , item ) ) ; } object . add ( jsonName , array ) ; } else { object . add ( jsonName , serializeField ( field . getKey ( ) , field . getValue ( ) ) ) ; } } return object ; }
Converts a proto - message into an equivalent JSON representation .
221
12
9,682
public static Message fromJson ( Message . Builder builder , JsonObject input ) throws Exception { Descriptors . Descriptor descriptor = builder . getDescriptorForType ( ) ; for ( Map . Entry < String , JsonElement > entry : input . entrySet ( ) ) { String protoName = CaseFormat . LOWER_CAMEL . to ( CaseFormat . LOWER_UNDERSCORE , entry . getKey ( ) ) ; Descriptors . FieldDescriptor field = descriptor . findFieldByName ( protoName ) ; if ( field == null ) { throw new Exception ( "Can't find descriptor for field " + protoName ) ; } if ( field . isRepeated ( ) ) { if ( ! entry . getValue ( ) . isJsonArray ( ) ) { // fail } JsonArray array = entry . getValue ( ) . getAsJsonArray ( ) ; for ( JsonElement item : array ) { builder . addRepeatedField ( field , parseField ( field , item , builder ) ) ; } } else { builder . setField ( field , parseField ( field , entry . getValue ( ) , builder ) ) ; } } return builder . build ( ) ; }
Converts a JSON object to a protobuf message
263
11
9,683
public static void bind ( final Context _ctx , final String _nameStr , final Object _object ) throws NamingException { final Name names = _ctx . getNameParser ( "" ) . parse ( _nameStr ) ; if ( names . size ( ) > 0 ) { Context subCtx = _ctx ; for ( int idx = 0 ; idx < names . size ( ) - 1 ; idx ++ ) { final String name = names . get ( idx ) ; try { subCtx = ( Context ) subCtx . lookup ( name ) ; if ( Util . LOG . isDebugEnabled ( ) ) { Util . LOG . debug ( "Subcontext " + name + " already exists" ) ; } } catch ( final NameNotFoundException e ) { subCtx = subCtx . createSubcontext ( name ) ; if ( Util . LOG . isDebugEnabled ( ) ) { Util . LOG . debug ( "Subcontext " + name + " created" ) ; } } } subCtx . rebind ( names . get ( names . size ( ) - 1 ) , _object ) ; if ( Util . LOG . isDebugEnabled ( ) ) { Util . LOG . debug ( "Bound object to " + names . get ( names . size ( ) - 1 ) ) ; } } }
Bing given object at the given name path within given name context .
285
14
9,684
protected Session getSession ( ) throws EFapsException { if ( this . session == null ) { try { String username = getProperties ( ) . get ( JCRStoreResource . PROPERTY_USERNAME ) ; if ( username == null ) { username = Context . getThreadContext ( ) . getPerson ( ) . getName ( ) ; } String passwd = getProperties ( ) . get ( JCRStoreResource . PROPERTY_PASSWORD ) ; if ( passwd == null ) { passwd = "efaps" ; } this . session = this . repository . login ( new SimpleCredentials ( username , passwd . toCharArray ( ) ) , getProperties ( ) . get ( JCRStoreResource . PROPERTY_WORKSPACENAME ) ) ; } catch ( final LoginException e ) { throw new EFapsException ( JCRStoreResource . class , "initialize.LoginException" , e ) ; } catch ( final NoSuchWorkspaceException e ) { throw new EFapsException ( JCRStoreResource . class , "initialize.NoSuchWorkspaceException" , e ) ; } catch ( final RepositoryException e ) { throw new EFapsException ( JCRStoreResource . class , "initialize.RepositoryException" , e ) ; } } return this . session ; }
Gets the session for JCR access .
285
9
9,685
protected Node getFolderNode ( ) throws EFapsException , RepositoryException { Node ret = getSession ( ) . getRootNode ( ) ; if ( getProperties ( ) . containsKey ( JCRStoreResource . PROPERTY_BASEFOLDER ) ) { if ( ret . hasNode ( getProperties ( ) . get ( JCRStoreResource . PROPERTY_BASEFOLDER ) ) ) { ret = ret . getNode ( getProperties ( ) . get ( JCRStoreResource . PROPERTY_BASEFOLDER ) ) ; } else { ret = ret . addNode ( getProperties ( ) . get ( JCRStoreResource . PROPERTY_BASEFOLDER ) , NodeType . NT_FOLDER ) ; } } final String subFolder = new DateTime ( ) . toString ( "yyyy-MM" ) ; if ( ret . hasNode ( subFolder ) ) { ret = ret . getNode ( subFolder ) ; } else { ret = ret . addNode ( subFolder , NodeType . NT_FOLDER ) ; } return ret ; }
Gets the folder node .
242
6
9,686
protected Binary getBinary ( final InputStream _in ) throws EFapsException { Binary ret = null ; try { ret = SerialValueFactory . getInstance ( ) . createBinary ( _in ) ; } catch ( final RepositoryException e ) { throw new EFapsException ( "RepositoryException" , e ) ; } return ret ; }
Gets the binary .
73
5
9,687
protected void setIdentifer ( final String _identifier ) throws EFapsException { if ( ! _identifier . equals ( this . identifier ) ) { ConnectionResource res = null ; try { res = Context . getThreadContext ( ) . getConnectionResource ( ) ; final StringBuffer cmd = new StringBuffer ( ) . append ( "update " ) . append ( JCRStoreResource . TABLENAME_STORE ) . append ( " set " ) . append ( JCRStoreResource . COLNAME_IDENTIFIER ) . append ( "=? " ) . append ( "where ID =" ) . append ( getGeneralID ( ) ) ; final PreparedStatement stmt = res . prepareStatement ( cmd . toString ( ) ) ; try { stmt . setString ( 1 , _identifier ) ; stmt . execute ( ) ; } finally { stmt . close ( ) ; } this . identifier = _identifier ; } catch ( final EFapsException e ) { throw e ; } catch ( final SQLException e ) { throw new EFapsException ( JDBCStoreResource . class , "write.SQLException" , e ) ; } } }
Set the identifier in the eFaps DataBase .
253
11
9,688
@ Override public void rollback ( final Xid _xid ) throws XAException { try { getSession ( ) . logout ( ) ; } catch ( final EFapsException e ) { throw new XAException ( "EFapsException" ) ; } }
On rollback no save is send to the session ..
57
11
9,689
@ Override public final void initialize ( final Subject _subject , final CallbackHandler _callbackHandler , final Map < String , ? > _sharedState , final Map < String , ? > _options ) { XMLUserLoginModule . LOG . debug ( "Init" ) ; this . subject = _subject ; this . callbackHandler = _callbackHandler ; readPersons ( ( String ) _options . get ( "xmlFileName" ) ) ; }
Initialize this LoginModule .
94
6
9,690
@ SuppressWarnings ( "unchecked" ) private void readPersons ( final String _fileName ) { try { final File file = new File ( _fileName ) ; final Digester digester = new Digester ( ) ; digester . setValidating ( false ) ; digester . addObjectCreate ( "persons" , ArrayList . class ) ; digester . addObjectCreate ( "persons/person" , XMLPersonPrincipal . class ) ; digester . addSetNext ( "persons/person" , "add" ) ; digester . addCallMethod ( "persons/person/name" , "setName" , 1 ) ; digester . addCallParam ( "persons/person/name" , 0 ) ; digester . addCallMethod ( "persons/person/password" , "setPassword" , 1 ) ; digester . addCallParam ( "persons/person/password" , 0 ) ; digester . addCallMethod ( "persons/person/firstName" , "setFirstName" , 1 ) ; digester . addCallParam ( "persons/person/firstName" , 0 ) ; digester . addCallMethod ( "persons/person/lastName" , "setLastName" , 1 ) ; digester . addCallParam ( "persons/person/lastName" , 0 ) ; digester . addCallMethod ( "persons/person/email" , "setEmail" , 1 ) ; digester . addCallParam ( "persons/person/email" , 0 ) ; digester . addCallMethod ( "persons/person/organisation" , "setOrganisation" , 1 ) ; digester . addCallParam ( "persons/person/organisation" , 0 ) ; digester . addCallMethod ( "persons/person/url" , "setUrl" , 1 ) ; digester . addCallParam ( "persons/person/url" , 0 ) ; digester . addCallMethod ( "persons/person/phone" , "setPhone" , 1 ) ; digester . addCallParam ( "persons/person/phone" , 0 ) ; digester . addCallMethod ( "persons/person/mobile" , "setMobile" , 1 ) ; digester . addCallParam ( "persons/person/mobile" , 0 ) ; digester . addCallMethod ( "persons/person/fax" , "setFax" , 1 ) ; digester . addCallParam ( "persons/person/fax" , 0 ) ; digester . addCallMethod ( "persons/person/role" , "addRole" , 1 ) ; digester . addCallParam ( "persons/person/role" , 0 ) ; digester . addCallMethod ( "persons/person/group" , "addGroup" , 1 ) ; digester . addCallParam ( "persons/person/group" , 0 ) ; final List < XMLPersonPrincipal > personList = ( List < XMLPersonPrincipal > ) digester . parse ( file ) ; for ( final XMLPersonPrincipal personTmp : personList ) { this . allPersons . put ( personTmp . getName ( ) , personTmp ) ; } } catch ( final IOException e ) { XMLUserLoginModule . LOG . error ( "could not open file '" + _fileName + "'" , e ) ; } catch ( final SAXException e ) { XMLUserLoginModule . LOG . error ( "could not read file '" + _fileName + "'" , e ) ; } }
The name of the XML is store in this instance variable . The XML file holds all allowed persons and their related roles and groups .
786
26
9,691
private static boolean getAccessSetFromDB ( final String _sql , final Object _criteria ) throws CacheReloadException { boolean ret = false ; Connection con = null ; try { AccessSet accessSet = null ; con = Context . getConnection ( ) ; PreparedStatement stmt = null ; try { stmt = con . prepareStatement ( _sql ) ; stmt . setObject ( 1 , _criteria ) ; final ResultSet rs = stmt . executeQuery ( ) ; if ( rs . next ( ) ) { final long id = rs . getLong ( 1 ) ; final String uuid = rs . getString ( 2 ) ; final String name = rs . getString ( 3 ) ; AccessSet . LOG . debug ( "read AccessSet '{}' (id = {}, uuid ={})" , name , id , uuid ) ; accessSet = new AccessSet ( id , uuid , name ) ; } ret = true ; rs . close ( ) ; } finally { if ( stmt != null ) { stmt . close ( ) ; } } con . commit ( ) ; if ( accessSet != null ) { accessSet . readLinks2AccessTypes ( ) ; accessSet . readLinks2DMTypes ( ) ; accessSet . readLinks2Status ( ) ; accessSet . readLinks2Person ( ) ; // needed due to cluster serialization that does not update automatically AccessSet . cacheAccessSet ( accessSet ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "could not read roles" , e ) ; } catch ( final EFapsException e ) { throw new CacheReloadException ( "could not read roles" , e ) ; } finally { try { if ( con != null && ! con . isClosed ( ) ) { con . close ( ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "could not read child type ids" , e ) ; } } return ret ; }
Read the AccessSet from the DataBase .
430
9
9,692
public Table cloneTable ( ) { Table ret = null ; try { ret = ( Table ) super . clone ( ) ; } catch ( final CloneNotSupportedException e ) { e . printStackTrace ( ) ; } return ret ; }
Creates and returns a copy of this table object .
50
11
9,693
@ Override public void setIndex ( boolean b ) { if ( b ) { assert safe == null ; safe = type ; type = Typ . Int ; } else { assert type . getKind ( ) == TypeKind . INT ; assert safe != null ; type = safe ; safe = null ; } }
Set index parsing mode . In true mode we are parsing inside bracket where index type must be int .
63
20
9,694
public boolean hasEntries ( ) { return ( getCache4Id ( ) != null && ! getCache4Id ( ) . isEmpty ( ) ) || ( getCache4Name ( ) != null && ! getCache4Name ( ) . isEmpty ( ) ) || ( getCache4UUID ( ) != null && ! getCache4UUID ( ) . isEmpty ( ) ) ; }
The method tests if the cache has stored some entries .
84
11
9,695
public void initialize ( final Class < ? > _initializer ) { this . initializer = _initializer . getName ( ) ; synchronized ( this ) { try { readCache ( ) ; } catch ( final CacheReloadException e ) { AbstractCache . LOG . error ( "Unexpected error while initializing Cache for " + getClass ( ) , e ) ; } } }
The method initialize the cache .
80
6
9,696
public void clear ( ) { if ( getCache4Id ( ) != null ) { getCache4Id ( ) . clear ( ) ; } if ( getCache4Name ( ) != null ) { getCache4Name ( ) . clear ( ) ; } if ( getCache4UUID ( ) != null ) { getCache4UUID ( ) . clear ( ) ; } }
Clear all values of this Cache .
81
7
9,697
public static void clearCaches ( ) { synchronized ( AbstractCache . CACHES ) { for ( final AbstractCache < ? > cache : AbstractCache . CACHES ) { cache . getCache4Id ( ) . clear ( ) ; cache . getCache4Name ( ) . clear ( ) ; cache . getCache4UUID ( ) . clear ( ) ; } } }
The static method removes all values in all caches .
80
10
9,698
@ Override public void registerPropertyMatcher ( PropertyMatcher < ? > propertyMatcher ) { if ( propertyMatcher . getPathProvider ( ) == null ) { propertyMatcher . setPathProvider ( this ) ; } propertyMatcherList . add ( propertyMatcher ) ; }
Register a PropertyMatcher instance . Registered property matchers are used to generate the describeTo text . If a given property matcher does not have an assigned path provider this instance will be assigned .
61
39
9,699
@ Deprecated public Add add ( long projectId , String deviceId , String deviceName , String deviceType , Date created ) { return add ( projectId , new Device . Spec ( deviceId , deviceName , deviceType ) , created ) ; }
Creates an Add API request for a new Device with the provided data .
52
15