idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
11,100 | public boolean covariantReturnType ( Type t , Type s , Warner warner ) { return isSameType ( t , s ) || allowCovariantReturns && ! t . isPrimitive ( ) && ! s . isPrimitive ( ) && isAssignable ( t , s , warner ) ; } | Is t an appropriate return type in an overrider for a method that returns s? | 67 | 17 |
11,101 | public ClassSymbol boxedClass ( Type t ) { return reader . enterClass ( syms . boxedName [ t . getTag ( ) . ordinal ( ) ] ) ; } | Return the class that boxes the given primitive . | 38 | 9 |
11,102 | protected String getSpace ( Request req ) { String spaceToken = req . headers ( SPACE_TOKEN_HEADER ) ; if ( StringUtils . isBlank ( spaceToken ) ) { throw new MissingSpaceTokenException ( "Missing header '" + SPACE_TOKEN_HEADER + "'." ) ; } String space = this . spacesService . getSpaceForAuthenticationToken ( spaceToken ) ; if ( space == null ) { throw new InvalidSpaceTokenException ( spaceToken ) ; } return space ; } | Extract spaceToken from request headers . | 109 | 8 |
11,103 | public WithCache . CacheState getCacheState ( ) { return new WithCache . CacheState ( size ( ) , _max , _get , _hit , _rep ) ; } | Reports the cumulative statistics of this cache . | 38 | 8 |
11,104 | static Class < ? > resolveParameterName ( String parameterName , Class < ? > target ) { Map < Type , Type > typeVariableMap = getTypeVariableMap ( target ) ; Set < Entry < Type , Type > > set = typeVariableMap . entrySet ( ) ; Type type = Object . class ; for ( Entry < Type , Type > entry : set ) { if ( entry . getKey ( ) . toString ( ) . equals ( parameterName ) ) { type = entry . getKey ( ) ; break ; } } return resolveType ( type , typeVariableMap ) ; } | Resolves the generic parameter name of a class . | 124 | 10 |
11,105 | public List < Widget > putFactories ( Iterable < ? extends IWidgetFactory > factories ) throws IndexOutOfBoundsException { List < Widget > instances = new LinkedList < Widget > ( ) ; for ( IWidgetFactory factory : factories ) { instances . add ( put ( factory ) ) ; } return instances ; } | Creates widgets instance from given iterable and adds it to this panel | 72 | 14 |
11,106 | protected List < File > getSpooledFileList ( ) { final List < File > spooledFileList = new ArrayList < File > ( ) ; for ( final File file : spoolDirectory . listFiles ( ) ) { if ( file . isFile ( ) ) { spooledFileList . add ( file ) ; } } return spooledFileList ; } | protected for overriding during unit tests | 81 | 6 |
11,107 | public void add ( Collection < Application > applications ) { for ( Application application : applications ) this . applications . put ( application . getId ( ) , application ) ; } | Adds the application list to the applications for the account . | 35 | 11 |
11,108 | public ApplicationHostCache applicationHosts ( long applicationId ) { ApplicationHostCache cache = applicationHosts . get ( applicationId ) ; if ( cache == null ) applicationHosts . put ( applicationId , cache = new ApplicationHostCache ( applicationId ) ) ; return cache ; } | Returns the cache of application hosts for the given application creating one if it doesn t exist . | 59 | 18 |
11,109 | public KeyTransactionCache keyTransactions ( long applicationId ) { KeyTransactionCache cache = keyTransactions . get ( applicationId ) ; if ( cache == null ) keyTransactions . put ( applicationId , cache = new KeyTransactionCache ( applicationId ) ) ; return cache ; } | Returns the cache of key transactions for the given application creating one if it doesn t exist . | 59 | 18 |
11,110 | public void addKeyTransactions ( Collection < KeyTransaction > keyTransactions ) { for ( KeyTransaction keyTransaction : keyTransactions ) { // Add the transaction to any applications it is associated with long applicationId = keyTransaction . getLinks ( ) . getApplication ( ) ; Application application = applications . get ( applicationId ) ; if ( application != null ) keyTransactions ( applicationId ) . add ( keyTransaction ) ; else logger . severe ( String . format ( "Unable to find application for key transaction '%s': %d" , keyTransaction . getName ( ) , applicationId ) ) ; } } | Adds the key transactions to the applications for the account . | 129 | 11 |
11,111 | public DeploymentCache deployments ( long applicationId ) { DeploymentCache cache = deployments . get ( applicationId ) ; if ( cache == null ) deployments . put ( applicationId , cache = new DeploymentCache ( applicationId ) ) ; return cache ; } | Returns the cache of deployments for the given application creating one if it doesn t exist . | 53 | 17 |
11,112 | public LabelCache labels ( long applicationId ) { LabelCache cache = labels . get ( applicationId ) ; if ( cache == null ) labels . put ( applicationId , cache = new LabelCache ( applicationId ) ) ; return cache ; } | Returns the cache of labels for the given application creating one if it doesn t exist . | 50 | 17 |
11,113 | public void addLabel ( Label label ) { // Add the label to any applications it is associated with List < Long > applicationIds = label . getLinks ( ) . getApplications ( ) ; for ( long applicationId : applicationIds ) { Application application = applications . get ( applicationId ) ; if ( application != null ) labels ( applicationId ) . add ( label ) ; else logger . severe ( String . format ( "Unable to find application for label '%s': %d" , label . getKey ( ) , applicationId ) ) ; } } | Adds the label to the applications for the account . | 118 | 10 |
11,114 | private static < T , R > Function < T , R > doThrow ( Supplier < ? extends RuntimeException > exceptionSupplier ) { return t -> { throw exceptionSupplier . get ( ) ; } ; } | Returns a function that throws the exception supplied by the given supplier . | 45 | 13 |
11,115 | @ SuppressWarnings ( "unchecked" ) public < E extends BaseException > E put ( String name , Object value ) { properties . put ( name , value ) ; return ( E ) this ; } | Put a property in this exception . | 45 | 7 |
11,116 | @ GET @ PermitAll @ Path ( "uniquetag/{uniqueTag}" ) public Response findByUniqueTag ( @ PathParam ( "uniqueTag" ) String uniqueTag ) { checkNotNull ( uniqueTag ) ; DContact contact = dao . findByUniqueTag ( null , uniqueTag ) ; return null != contact ? Response . ok ( contact ) . build ( ) : Response . status ( Response . Status . NOT_FOUND ) . build ( ) ; } | Find a contact based on its unique tag . | 102 | 9 |
11,117 | public static void generate ( ConfigurationImpl configuration ) { ProfileIndexFrameWriter profilegen ; DocPath filename = DocPaths . PROFILE_OVERVIEW_FRAME ; try { profilegen = new ProfileIndexFrameWriter ( configuration , filename ) ; profilegen . buildProfileIndexFile ( "doclet.Window_Overview" , false ) ; profilegen . close ( ) ; } catch ( IOException exc ) { configuration . standardmessage . error ( "doclet.exception_encountered" , exc . toString ( ) , filename ) ; throw new DocletAbortException ( exc ) ; } } | Generate the profile index file named profile - overview - frame . html . | 127 | 15 |
11,118 | protected Content getProfile ( String profileName ) { Content profileLinkContent ; Content profileLabel ; profileLabel = new StringContent ( profileName ) ; profileLinkContent = getHyperLink ( DocPaths . profileFrame ( profileName ) , profileLabel , "" , "packageListFrame" ) ; Content li = HtmlTree . LI ( profileLinkContent ) ; return li ; } | Gets each profile name as a separate link . | 79 | 10 |
11,119 | public void newRound ( Context context ) { this . context = context ; this . log = Log . instance ( context ) ; clearRoundState ( ) ; } | Update internal state for a new round . | 33 | 8 |
11,120 | public static GameSettings getInstance ( ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new GamePermission ( "readSettings" ) ) ; } return INSTANCE ; } | Checks if the caller has permission to read the game settings | 52 | 12 |
11,121 | public static ClassFileReader newInstance ( Path path , JarFile jf ) throws IOException { return new JarFileReader ( path , jf ) ; } | Returns a ClassFileReader instance of a given JarFile . | 33 | 12 |
11,122 | Type rawInstantiate ( Env < AttrContext > env , Type site , Symbol m , ResultInfo resultInfo , List < Type > argtypes , List < Type > typeargtypes , boolean allowBoxing , boolean useVarargs , Warner warn ) throws Infer . InferenceException { Type mt = types . memberType ( site , m ) ; // tvars is the list of formal type variables for which type arguments // need to inferred. List < Type > tvars = List . nil ( ) ; if ( typeargtypes == null ) typeargtypes = List . nil ( ) ; if ( ! mt . hasTag ( FORALL ) && typeargtypes . nonEmpty ( ) ) { // This is not a polymorphic method, but typeargs are supplied // which is fine, see JLS 15.12.2.1 } else if ( mt . hasTag ( FORALL ) && typeargtypes . nonEmpty ( ) ) { ForAll pmt = ( ForAll ) mt ; if ( typeargtypes . length ( ) != pmt . tvars . length ( ) ) throw inapplicableMethodException . setMessage ( "arg.length.mismatch" ) ; // not enough args // Check type arguments are within bounds List < Type > formals = pmt . tvars ; List < Type > actuals = typeargtypes ; while ( formals . nonEmpty ( ) && actuals . nonEmpty ( ) ) { List < Type > bounds = types . subst ( types . getBounds ( ( TypeVar ) formals . head ) , pmt . tvars , typeargtypes ) ; for ( ; bounds . nonEmpty ( ) ; bounds = bounds . tail ) if ( ! types . isSubtypeUnchecked ( actuals . head , bounds . head , warn ) ) throw inapplicableMethodException . setMessage ( "explicit.param.do.not.conform.to.bounds" , actuals . head , bounds ) ; formals = formals . tail ; actuals = actuals . tail ; } mt = types . subst ( pmt . qtype , pmt . tvars , typeargtypes ) ; } else if ( mt . hasTag ( FORALL ) ) { ForAll pmt = ( ForAll ) mt ; List < Type > tvars1 = types . newInstances ( pmt . tvars ) ; tvars = tvars . appendList ( tvars1 ) ; mt = types . subst ( pmt . qtype , pmt . tvars , tvars1 ) ; } // find out whether we need to go the slow route via infer boolean instNeeded = tvars . tail != null ; /*inlined: tvars.nonEmpty()*/ for ( List < Type > l = argtypes ; l . tail != null /*inlined: l.nonEmpty()*/ && ! instNeeded ; l = l . tail ) { if ( l . head . hasTag ( FORALL ) ) instNeeded = true ; } if ( instNeeded ) return infer . instantiateMethod ( env , tvars , ( MethodType ) mt , resultInfo , ( MethodSymbol ) m , argtypes , allowBoxing , useVarargs , currentResolutionContext , warn ) ; DeferredAttr . DeferredAttrContext dc = currentResolutionContext . deferredAttrContext ( m , infer . emptyContext , resultInfo , warn ) ; currentResolutionContext . methodCheck . argumentsAcceptable ( env , dc , argtypes , mt . getParameterTypes ( ) , warn ) ; dc . complete ( ) ; return mt ; } | Try to instantiate the type of a method so that it fits given type arguments and argument types . If successful return the method s instantiated type else return null . The instantiation will take into account an additional leading formal parameter if the method is an instance method seen as a member of an under determined site . In this case we treat site as an additional parameter and the parameters of the class containing the method as additional type variables that get instantiated . | 766 | 90 |
11,123 | @ SuppressWarnings ( "fallthrough" ) Symbol selectBest ( Env < AttrContext > env , Type site , List < Type > argtypes , List < Type > typeargtypes , Symbol sym , Symbol bestSoFar , boolean allowBoxing , boolean useVarargs , boolean operator ) { if ( sym . kind == ERR || ! sym . isInheritedIn ( site . tsym , types ) ) { return bestSoFar ; } else if ( useVarargs && ( sym . flags ( ) & VARARGS ) == 0 ) { return bestSoFar . kind >= ERRONEOUS ? new BadVarargsMethod ( ( ResolveError ) bestSoFar . baseSymbol ( ) ) : bestSoFar ; } Assert . check ( sym . kind < AMBIGUOUS ) ; try { Type mt = rawInstantiate ( env , site , sym , null , argtypes , typeargtypes , allowBoxing , useVarargs , types . noWarnings ) ; if ( ! operator || verboseResolutionMode . contains ( VerboseResolutionMode . PREDEF ) ) currentResolutionContext . addApplicableCandidate ( sym , mt ) ; } catch ( InapplicableMethodException ex ) { if ( ! operator ) currentResolutionContext . addInapplicableCandidate ( sym , ex . getDiagnostic ( ) ) ; switch ( bestSoFar . kind ) { case ABSENT_MTH : return new InapplicableSymbolError ( currentResolutionContext ) ; case WRONG_MTH : if ( operator ) return bestSoFar ; bestSoFar = new InapplicableSymbolsError ( currentResolutionContext ) ; default : return bestSoFar ; } } if ( ! isAccessible ( env , site , sym ) ) { return ( bestSoFar . kind == ABSENT_MTH ) ? new AccessError ( env , site , sym ) : bestSoFar ; } return ( bestSoFar . kind > AMBIGUOUS ) ? sym : mostSpecific ( argtypes , sym , bestSoFar , env , site , allowBoxing && operator , useVarargs ) ; } | Select the best method for a call site among two choices . | 464 | 12 |
11,124 | Symbol findMethod ( Env < AttrContext > env , Type site , Name name , List < Type > argtypes , List < Type > typeargtypes , boolean allowBoxing , boolean useVarargs , boolean operator ) { Symbol bestSoFar = methodNotFound ; bestSoFar = findMethod ( env , site , name , argtypes , typeargtypes , site . tsym . type , bestSoFar , allowBoxing , useVarargs , operator ) ; return bestSoFar ; } | Find best qualified method matching given name type and value arguments . | 106 | 12 |
11,125 | public void printscopes ( Scope s ) { while ( s != null ) { if ( s . owner != null ) System . err . print ( s . owner + ": " ) ; for ( Scope . Entry e = s . elems ; e != null ; e = e . sibling ) { if ( ( e . sym . flags ( ) & ABSTRACT ) != 0 ) System . err . print ( "abstract " ) ; System . err . print ( e . sym + " " ) ; } System . err . println ( ) ; s = s . next ; } } | print all scopes starting with scope s and proceeding outwards . used for debugging . | 124 | 17 |
11,126 | Symbol resolveBinaryOperator ( DiagnosticPosition pos , JCTree . Tag optag , Env < AttrContext > env , Type left , Type right ) { return resolveOperator ( pos , optag , env , List . of ( left , right ) ) ; } | Resolve binary operator . | 60 | 5 |
11,127 | private boolean matches ( String classname , AccessFlags flags ) { if ( options . apiOnly && ! flags . is ( AccessFlags . ACC_PUBLIC ) ) { return false ; } else if ( options . includePattern != null ) { return options . includePattern . matcher ( classname . replace ( ' ' , ' ' ) ) . matches ( ) ; } else { return true ; } } | Tests if the given class matches the pattern given in the - include option or if it s a public class if - apionly option is specified | 84 | 30 |
11,128 | private String replacementFor ( String cn ) { String name = cn ; String value = null ; while ( value == null && name != null ) { try { value = ResourceBundleHelper . jdkinternals . getString ( name ) ; } catch ( MissingResourceException e ) { // go up one subpackage level int i = name . lastIndexOf ( ' ' ) ; name = i > 0 ? name . substring ( 0 , i ) : null ; } } return value ; } | Returns the recommended replacement API for the given classname ; or return null if replacement API is not known . | 106 | 21 |
11,129 | @ Override public void setContract ( Contract c ) { super . setContract ( c ) ; for ( Field f : params ) { f . setContract ( c ) ; } if ( returns != null ) { returns . setContract ( c ) ; } } | Sets the Contract for this Function . Propegates this down to its param and return Fields | 54 | 19 |
11,130 | public Object invoke ( RpcRequest req , Object handler ) throws RpcException , IllegalAccessException , InvocationTargetException { if ( contract == null ) { throw new IllegalStateException ( "contract cannot be null" ) ; } if ( req == null ) { throw new IllegalArgumentException ( "req cannot be null" ) ; } if ( handler == null ) { throw new IllegalArgumentException ( "handler cannot be null" ) ; } Method method = getMethod ( handler ) ; Object reqParams [ ] = unmarshalParams ( req , method ) ; return marshalResult ( method . invoke ( handler , reqParams ) ) ; } | Invokes this Function against the given handler Class for the given request . This is the heart of the RPC dispatch and is where your application code gets run . | 139 | 31 |
11,131 | public Object [ ] marshalParams ( RpcRequest req ) throws RpcException { Object [ ] converted = new Object [ params . size ( ) ] ; Object [ ] reqParams = req . getParams ( ) ; if ( reqParams . length != converted . length ) { String msg = "Function '" + req . getMethod ( ) + "' expects " + params . size ( ) + " param(s). " + reqParams . length + " given." ; throw invParams ( msg ) ; } for ( int i = 0 ; i < converted . length ; i ++ ) { converted [ i ] = params . get ( i ) . getTypeConverter ( ) . marshal ( reqParams [ i ] ) ; } return converted ; } | Marshals the req . params to their RPC format equivalents . For example a Java Struct class will be converted to a Map . | 166 | 25 |
11,132 | public Object unmarshalResult ( Object respObj ) throws RpcException { if ( returns == null ) { if ( respObj != null ) { throw new IllegalArgumentException ( "Function " + name + " is a notification and should not have a result" ) ; } } return returns . getTypeConverter ( ) . unmarshal ( respObj ) ; } | Unmarshals respObj into its Java representation | 79 | 10 |
11,133 | public Object [ ] unmarshalParams ( RpcRequest req ) throws RpcException { Object reqParams [ ] = req . getParams ( ) ; if ( reqParams . length != params . size ( ) ) { String msg = "Function '" + req . getMethod ( ) + "' expects " + params . size ( ) + " param(s). " + reqParams . length + " given." ; throw invParams ( msg ) ; } Object convParams [ ] = new Object [ reqParams . length ] ; for ( int i = 0 ; i < convParams . length ; i ++ ) { convParams [ i ] = params . get ( i ) . getTypeConverter ( ) . unmarshal ( reqParams [ i ] ) ; } return convParams ; } | Unmarshals req . params into their Java representations | 178 | 11 |
11,134 | @ Nullable public static String getCompactMessage ( final String sMsg ) { UPCA . validateMessage ( sMsg ) ; final String sUPCA = UPCA . handleChecksum ( sMsg , EEANChecksumMode . AUTO ) ; final byte nNumberSystem = _extractNumberSystem ( sUPCA ) ; if ( nNumberSystem != 0 && nNumberSystem != 1 ) return null ; final byte nCheck = StringParser . parseByte ( sUPCA . substring ( 11 , 12 ) , ( byte ) - 1 ) ; if ( nCheck == ( byte ) - 1 ) return null ; final StringBuilder aSB = new StringBuilder ( ) ; aSB . append ( Byte . toString ( nNumberSystem ) ) ; final String manufacturer = sUPCA . substring ( 1 , 1 + 5 ) ; final String product = sUPCA . substring ( 6 , 6 + 5 ) ; // Rule 1 String mtemp = manufacturer . substring ( 2 , 2 + 3 ) ; String ptemp = product . substring ( 0 , 0 + 2 ) ; if ( "000|100|200" . indexOf ( mtemp ) >= 0 && "00" . equals ( ptemp ) ) { aSB . append ( manufacturer . substring ( 0 , 2 ) ) ; aSB . append ( product . substring ( 2 , 2 + 3 ) ) ; aSB . append ( mtemp . charAt ( 0 ) ) ; } else { // Rule 2 ptemp = product . substring ( 0 , 0 + 3 ) ; if ( "300|400|500|600|700|800|900" . indexOf ( mtemp ) >= 0 && "000" . equals ( ptemp ) ) { aSB . append ( manufacturer . substring ( 0 , 0 + 3 ) ) ; aSB . append ( product . substring ( 3 , 3 + 2 ) ) ; aSB . append ( ' ' ) ; } else { // Rule 3 mtemp = manufacturer . substring ( 3 , 3 + 2 ) ; ptemp = product . substring ( 0 , 0 + 4 ) ; if ( "10|20|30|40|50|60|70|80|90" . indexOf ( mtemp ) >= 0 && "0000" . equals ( ptemp ) ) { aSB . append ( manufacturer . substring ( 0 , 0 + 4 ) ) ; aSB . append ( product . substring ( 4 , 4 + 1 ) ) ; aSB . append ( ' ' ) ; } else { // Rule 4 mtemp = manufacturer . substring ( 4 , 4 + 1 ) ; ptemp = product . substring ( 4 , 4 + 1 ) ; if ( ! "0" . equals ( mtemp ) && "5|6|7|8|9" . indexOf ( ptemp ) >= 0 ) { aSB . append ( manufacturer ) ; aSB . append ( ptemp ) ; } else { return null ; } } } } aSB . append ( Byte . toString ( nCheck ) ) ; return aSB . toString ( ) ; } | Compacts an UPC - A message to an UPC - E message if possible . | 668 | 18 |
11,135 | @ Nonnull public static String getExpandedMessage ( @ Nonnull final String sMsg ) { final char cCheck = sMsg . length ( ) == 8 ? sMsg . charAt ( 7 ) : ' ' ; final String sUpce = sMsg . substring ( 0 , 0 + 7 ) ; final byte nNumberSystem = _extractNumberSystem ( sUpce ) ; if ( nNumberSystem != 0 && nNumberSystem != 1 ) throw new IllegalArgumentException ( "Invalid UPC-E message: " + sMsg ) ; final StringBuilder aSB = new StringBuilder ( ) ; aSB . append ( Byte . toString ( nNumberSystem ) ) ; final byte nMode = StringParser . parseByte ( sUpce . substring ( 6 , 6 + 1 ) , ( byte ) - 1 ) ; if ( nMode >= 0 && nMode <= 2 ) { aSB . append ( sUpce . substring ( 1 , 1 + 2 ) ) ; aSB . append ( Byte . toString ( nMode ) ) ; aSB . append ( "0000" ) ; aSB . append ( sUpce . substring ( 3 , 3 + 3 ) ) ; } else if ( nMode == 3 ) { aSB . append ( sUpce . substring ( 1 , 1 + 3 ) ) ; aSB . append ( "00000" ) ; aSB . append ( sUpce . substring ( 4 , 4 + 2 ) ) ; } else if ( nMode == 4 ) { aSB . append ( sUpce . substring ( 1 , 1 + 4 ) ) ; aSB . append ( "00000" ) ; aSB . append ( sUpce . substring ( 5 , 5 + 1 ) ) ; } else if ( nMode >= 5 && nMode <= 9 ) { aSB . append ( sUpce . substring ( 1 , 1 + 5 ) ) ; aSB . append ( "0000" ) ; aSB . append ( Byte . toString ( nMode ) ) ; } else { // Shouldn't happen throw new IllegalArgumentException ( "Internal error" ) ; } final String sUpcaFinished = aSB . toString ( ) ; final char cExpectedCheck = calcChecksumChar ( sUpcaFinished , sUpcaFinished . length ( ) ) ; if ( cCheck != ' ' && cCheck != cExpectedCheck ) throw new IllegalArgumentException ( "Invalid checksum. Expected " + cExpectedCheck + " but was " + cCheck ) ; return sUpcaFinished + cExpectedCheck ; } | Expands an UPC - E message to an UPC - A message . | 562 | 16 |
11,136 | @ Nonnull public static EValidity validateMessage ( @ Nullable final String sMsg ) { final int nLen = StringHelper . getLength ( sMsg ) ; if ( nLen >= 7 && nLen <= 8 ) { final byte nNumberSystem = _extractNumberSystem ( sMsg ) ; if ( nNumberSystem >= 0 && nNumberSystem <= 1 ) return EValidity . VALID ; } return EValidity . INVALID ; } | Validates an UPC - E message . The message can also be UPC - A in which case the message is compacted to a UPC - E message if possible . If it s not possible an IllegalArgumentException is thrown | 97 | 48 |
11,137 | public Iterable < DUser > queryByBirthInfo ( java . lang . String birthInfo ) { return queryByField ( null , DUserMapper . Field . BIRTHINFO . getFieldName ( ) , birthInfo ) ; } | query - by method for field birthInfo | 51 | 8 |
11,138 | public Iterable < DUser > queryByFriends ( java . lang . Object friends ) { return queryByField ( null , DUserMapper . Field . FRIENDS . getFieldName ( ) , friends ) ; } | query - by method for field friends | 47 | 7 |
11,139 | public Iterable < DUser > queryByPassword ( java . lang . String password ) { return queryByField ( null , DUserMapper . Field . PASSWORD . getFieldName ( ) , password ) ; } | query - by method for field password | 47 | 7 |
11,140 | public Iterable < DUser > queryByPhoneNumber1 ( java . lang . String phoneNumber1 ) { return queryByField ( null , DUserMapper . Field . PHONENUMBER1 . getFieldName ( ) , phoneNumber1 ) ; } | query - by method for field phoneNumber1 | 56 | 9 |
11,141 | public Iterable < DUser > queryByPhoneNumber2 ( java . lang . String phoneNumber2 ) { return queryByField ( null , DUserMapper . Field . PHONENUMBER2 . getFieldName ( ) , phoneNumber2 ) ; } | query - by method for field phoneNumber2 | 56 | 9 |
11,142 | public Iterable < DUser > queryByPreferredLanguage ( java . lang . String preferredLanguage ) { return queryByField ( null , DUserMapper . Field . PREFERREDLANGUAGE . getFieldName ( ) , preferredLanguage ) ; } | query - by method for field preferredLanguage | 55 | 8 |
11,143 | public Iterable < DUser > queryByTimeZoneCanonicalId ( java . lang . String timeZoneCanonicalId ) { return queryByField ( null , DUserMapper . Field . TIMEZONECANONICALID . getFieldName ( ) , timeZoneCanonicalId ) ; } | query - by method for field timeZoneCanonicalId | 67 | 12 |
11,144 | public DUser findByUsername ( java . lang . String username ) { return queryUniqueByField ( null , DUserMapper . Field . USERNAME . getFieldName ( ) , username ) ; } | find - by method for unique field username | 45 | 8 |
11,145 | public < T > T executeSelect ( Connection conn , DataObject object , ResultSetWorker < T > worker ) throws Exception { PreparedStatement statement = conn . prepareStatement ( _sql ) ; try { load ( statement , object ) ; return worker . process ( statement . executeQuery ( ) ) ; } finally { statement . close ( ) ; } } | Executes the SELECT statement passing the result set to the ResultSetWorker for processing . | 74 | 18 |
11,146 | public ClassDoc [ ] enums ( ) { ListBuffer < ClassDocImpl > ret = new ListBuffer < ClassDocImpl > ( ) ; for ( ClassDocImpl c : getClasses ( true ) ) { if ( c . isEnum ( ) ) { ret . append ( c ) ; } } return ret . toArray ( new ClassDocImpl [ ret . length ( ) ] ) ; } | Get included enum types in this package . | 85 | 8 |
11,147 | public ClassDoc [ ] interfaces ( ) { ListBuffer < ClassDocImpl > ret = new ListBuffer < ClassDocImpl > ( ) ; for ( ClassDocImpl c : getClasses ( true ) ) { if ( c . isInterface ( ) ) { ret . append ( c ) ; } } return ret . toArray ( new ClassDocImpl [ ret . length ( ) ] ) ; } | Get included interfaces in this package omitting annotation types . | 83 | 11 |
11,148 | public Rejected acquirePermits ( long number , long nanoTime ) { for ( int i = 0 ; i < backPressureList . size ( ) ; ++ i ) { BackPressure < Rejected > bp = backPressureList . get ( i ) ; Rejected rejected = bp . acquirePermit ( number , nanoTime ) ; if ( rejected != null ) { rejectedCounts . write ( rejected , number , nanoTime ) ; for ( int j = 0 ; j < i ; ++ j ) { backPressureList . get ( j ) . releasePermit ( number , nanoTime ) ; } return rejected ; } } return null ; } | Acquire permits for task execution . If the acquisition is rejected then a reason will be returned . If the acquisition is successful null will be returned . | 140 | 29 |
11,149 | public void releasePermitsWithoutResult ( long number , long nanoTime ) { for ( BackPressure < Rejected > backPressure : backPressureList ) { backPressure . releasePermit ( number , nanoTime ) ; } } | Release acquired permits without result . Since there is not a known result the result count object and latency will not be updated . | 51 | 24 |
11,150 | @ GET @ Path ( "{taskName}" ) public Response enqueueTask ( @ PathParam ( "taskName" ) String taskName ) { checkNotNull ( taskName ) ; taskQueue . enqueueTask ( taskName , requestParamsProvider . get ( ) ) ; return Response . ok ( ) . build ( ) ; } | Enqueue an admin task for processing . The request will return immediately and the task will be run in a separate thread . The execution model depending on the implementation of the queue . | 70 | 35 |
11,151 | @ POST @ Path ( "{taskName}" ) public Response processTask ( @ PathParam ( "taskName" ) String taskName ) { checkNotNull ( requestParamsProvider . get ( ) ) ; checkNotNull ( taskName ) ; LOGGER . info ( "Processing task for {}..." , taskName ) ; for ( AdminTask adminTask : adminTasks ) { final Object body = adminTask . processTask ( taskName , requestParamsProvider . get ( ) ) ; LOGGER . info ( "Processed tasks for {}: {}" , taskName , body ) ; } return Response . ok ( ) . build ( ) ; } | Process an admin task . The admin task will be processed on the requesting thread . | 137 | 16 |
11,152 | public void run ( Map < String , Object > extra ) { if ( getParameterConfig ( ) != null ) { Boolean parametersRequired = false ; List < String > requiredParameters = new ArrayList < String > ( ) ; for ( ParamConfig paramConfig : getParameterConfig ( ) ) { if ( BooleanUtils . isTrue ( paramConfig . getRequired ( ) ) ) { try { if ( StringUtils . isBlank ( ObjectUtils . toString ( PropertyUtils . getProperty ( paramConfig , "value" ) ) ) ) { parametersRequired = true ; requiredParameters . add ( paramConfig . getName ( ) ) ; } } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; } catch ( InvocationTargetException e ) { e . printStackTrace ( ) ; } catch ( NoSuchMethodException e ) { e . printStackTrace ( ) ; } } } if ( parametersRequired ) { errors . add ( "Some required parameters weren't filled in: " + StringUtils . join ( requiredParameters , ", " ) + "." ) ; return ; } } runReport ( extra ) ; } | Runs the report . | 244 | 5 |
11,153 | public static Date getDateFromString ( final String dateString , final String pattern ) { try { SimpleDateFormat df = buildDateFormat ( pattern ) ; return df . parse ( dateString ) ; } catch ( ParseException e ) { throw new DateException ( String . format ( "Could not parse %s with pattern %s." , dateString , pattern ) , e ) ; } } | Get data from data string using the given pattern and the default date format symbols for the default locale . | 82 | 20 |
11,154 | public static String getDateFormat ( final Date date , final String pattern ) { SimpleDateFormat simpleDateFormat = buildDateFormat ( pattern ) ; return simpleDateFormat . format ( date ) ; } | Format date by given pattern . | 41 | 6 |
11,155 | public static Date getDateOfSecondsBack ( final int secondsBack , final Date date ) { return dateBack ( Calendar . SECOND , secondsBack , date ) ; } | Get specify seconds back form given date . | 36 | 8 |
11,156 | public static Date getDateOfMinutesBack ( final int minutesBack , final Date date ) { return dateBack ( Calendar . MINUTE , minutesBack , date ) ; } | Get specify minutes back form given date . | 36 | 8 |
11,157 | public static Date getDateOfHoursBack ( final int hoursBack , final Date date ) { return dateBack ( Calendar . HOUR_OF_DAY , hoursBack , date ) ; } | Get specify hours back form given date . | 39 | 8 |
11,158 | public static Date getDateOfDaysBack ( final int daysBack , final Date date ) { return dateBack ( Calendar . DAY_OF_MONTH , daysBack , date ) ; } | Get specify days back from given date . | 39 | 8 |
11,159 | public static Date getDateOfWeeksBack ( final int weeksBack , final Date date ) { return dateBack ( Calendar . WEEK_OF_MONTH , weeksBack , date ) ; } | Get specify weeks back from given date . | 40 | 8 |
11,160 | public static Date getDateOfMonthsBack ( final int monthsBack , final Date date ) { return dateBack ( Calendar . MONTH , monthsBack , date ) ; } | Get specify months back from given date . | 36 | 8 |
11,161 | public static Date getDateOfYearsBack ( final int yearsBack , final Date date ) { return dateBack ( Calendar . YEAR , yearsBack , date ) ; } | Get specify years back from given date . | 34 | 8 |
11,162 | public static boolean isLastDayOfTheMonth ( final Date date ) { Date dateOfMonthsBack = getDateOfMonthsBack ( - 1 , date ) ; int dayOfMonth = getDayOfMonth ( dateOfMonthsBack ) ; Date dateOfDaysBack = getDateOfDaysBack ( dayOfMonth , dateOfMonthsBack ) ; return dateOfDaysBack . equals ( date ) ; } | Return true if the given date is the last day of the month ; false otherwise . | 87 | 17 |
11,163 | public static long subSeconds ( final Date date1 , final Date date2 ) { return subTime ( date1 , date2 , DatePeriod . SECOND ) ; } | Get how many seconds between two date . | 37 | 8 |
11,164 | public static long subMinutes ( final Date date1 , final Date date2 ) { return subTime ( date1 , date2 , DatePeriod . MINUTE ) ; } | Get how many minutes between two date . | 37 | 8 |
11,165 | public static long subHours ( final Date date1 , final Date date2 ) { return subTime ( date1 , date2 , DatePeriod . HOUR ) ; } | Get how many hours between two date . | 36 | 8 |
11,166 | public static long subDays ( final Date date1 , final Date date2 ) { return subTime ( date1 , date2 , DatePeriod . DAY ) ; } | Get how many days between two date . | 35 | 8 |
11,167 | public static long subMonths ( final String dateString1 , final String dateString2 ) { Date date1 = getDateFromString ( dateString1 , DEFAULT_DATE_SIMPLE_PATTERN ) ; Date date2 = getDateFromString ( dateString2 , DEFAULT_DATE_SIMPLE_PATTERN ) ; return subMonths ( date1 , date2 ) ; } | Get how many months between two date the date pattern is yyyy - MM - dd . | 87 | 19 |
11,168 | public static long subMonths ( final Date date1 , final Date date2 ) { Calendar calendar1 = buildCalendar ( date1 ) ; int monthOfDate1 = calendar1 . get ( Calendar . MONTH ) ; int yearOfDate1 = calendar1 . get ( Calendar . YEAR ) ; Calendar calendar2 = buildCalendar ( date2 ) ; int monthOfDate2 = calendar2 . get ( Calendar . MONTH ) ; int yearOfDate2 = calendar2 . get ( Calendar . YEAR ) ; int subMonth = Math . abs ( monthOfDate1 - monthOfDate2 ) ; int subYear = Math . abs ( yearOfDate1 - yearOfDate2 ) ; return subYear * 12 + subMonth ; } | Get how many months between two date . | 156 | 8 |
11,169 | public static long subYears ( final Date date1 , final Date date2 ) { return Math . abs ( getYear ( date1 ) - getYear ( date2 ) ) ; } | Get how many years between two date . | 38 | 8 |
11,170 | private static SimpleDateFormat buildDateFormat ( final String pattern ) { SimpleDateFormat simpleDateFormat = simpleDateFormatCache . get ( ) ; if ( simpleDateFormat == null ) { simpleDateFormat = new SimpleDateFormat ( ) ; simpleDateFormatCache . set ( simpleDateFormat ) ; } simpleDateFormat . applyPattern ( pattern ) ; return simpleDateFormat ; } | Get a SimpleDateFormat object by given pattern . | 79 | 10 |
11,171 | Type fold1 ( int opcode , Type operand ) { try { Object od = operand . constValue ( ) ; switch ( opcode ) { case nop : return operand ; case ineg : // unary - return syms . intType . constType ( - intValue ( od ) ) ; case ixor : // ~ return syms . intType . constType ( ~ intValue ( od ) ) ; case bool_not : // ! return syms . booleanType . constType ( b2i ( intValue ( od ) == 0 ) ) ; case ifeq : return syms . booleanType . constType ( b2i ( intValue ( od ) == 0 ) ) ; case ifne : return syms . booleanType . constType ( b2i ( intValue ( od ) != 0 ) ) ; case iflt : return syms . booleanType . constType ( b2i ( intValue ( od ) < 0 ) ) ; case ifgt : return syms . booleanType . constType ( b2i ( intValue ( od ) > 0 ) ) ; case ifle : return syms . booleanType . constType ( b2i ( intValue ( od ) <= 0 ) ) ; case ifge : return syms . booleanType . constType ( b2i ( intValue ( od ) >= 0 ) ) ; case lneg : // unary - return syms . longType . constType ( new Long ( - longValue ( od ) ) ) ; case lxor : // ~ return syms . longType . constType ( new Long ( ~ longValue ( od ) ) ) ; case fneg : // unary - return syms . floatType . constType ( new Float ( - floatValue ( od ) ) ) ; case dneg : // ~ return syms . doubleType . constType ( new Double ( - doubleValue ( od ) ) ) ; default : return null ; } } catch ( ArithmeticException e ) { return null ; } } | Fold unary operation . | 427 | 6 |
11,172 | public synchronized void addHandler ( Class iface , Object handler ) { try { iface . cast ( handler ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Handler: " + handler . getClass ( ) . getName ( ) + " does not implement: " + iface . getName ( ) ) ; } if ( contract . getInterfaces ( ) . get ( iface . getSimpleName ( ) ) == null ) { throw new IllegalArgumentException ( "Interface: " + iface . getName ( ) + " is not a part of this Contract" ) ; } if ( contract . getPackage ( ) == null ) { setContractPackage ( iface ) ; } handlers . put ( iface . getSimpleName ( ) , handler ) ; } | Associates the handler instance with the given IDL interface . Replaces an existing handler for this iface if one was previously registered . | 167 | 28 |
11,173 | @ SuppressWarnings ( "unchecked" ) public void call ( Serializer ser , InputStream is , OutputStream os ) throws IOException { Object obj = null ; try { obj = ser . readMapOrList ( is ) ; } catch ( Exception e ) { String msg = "Unable to deserialize request: " + e . getMessage ( ) ; ser . write ( new RpcResponse ( null , RpcException . Error . PARSE . exc ( msg ) ) . marshal ( ) , os ) ; return ; } if ( obj instanceof List ) { List list = ( List ) obj ; List respList = new ArrayList ( ) ; for ( Object o : list ) { RpcRequest rpcReq = new RpcRequest ( ( Map ) o ) ; respList . add ( call ( rpcReq ) . marshal ( ) ) ; } ser . write ( respList , os ) ; } else if ( obj instanceof Map ) { RpcRequest rpcReq = new RpcRequest ( ( Map ) obj ) ; ser . write ( call ( rpcReq ) . marshal ( ) , os ) ; } else { ser . write ( new RpcResponse ( null , RpcException . Error . INVALID_REQ . exc ( "Invalid Request" ) ) . marshal ( ) , os ) ; } } | Reads a RpcRequest from the input stream deserializes it invokes the matching handler method serializes the result and writes it to the output stream . | 294 | 32 |
11,174 | public RpcResponse call ( RpcRequest req ) { for ( Filter filter : filters ) { RpcRequest tmp = filter . alterRequest ( req ) ; if ( tmp != null ) { req = tmp ; } } RpcResponse resp = null ; for ( Filter filter : filters ) { resp = filter . preInvoke ( req ) ; if ( resp != null ) { break ; } } if ( resp == null ) { resp = callInternal ( req ) ; } for ( int i = filters . size ( ) - 1 ; i >= 0 ; i -- ) { RpcResponse tmp = filters . get ( i ) . postInvoke ( req , resp ) ; if ( tmp != null ) { resp = tmp ; } } return resp ; } | Calls the method associated with the RpcRequest and wraps the result as a RpcResponse . | 158 | 20 |
11,175 | public static String doGet ( final String url , final int retryTimes ) { try { return doGetByLoop ( url , retryTimes ) ; } catch ( HttpException e ) { throw new HttpException ( format ( "Failed to download content for url: '%s'. Tried '%s' times" , url , Math . max ( retryTimes + 1 , 1 ) ) ) ; } } | access given url by get request if get exception will retry by given retryTimes . | 90 | 18 |
11,176 | public static String doPost ( final String action , final Map < String , String > parameters , final int retryTimes ) { try { return doPostByLoop ( action , parameters , retryTimes ) ; } catch ( HttpException e ) { throw new HttpException ( format ( "Failed to download content for action url: '%s' with parameters. Tried '%s' times" , action , parameters , Math . max ( retryTimes + 1 , 1 ) ) ) ; } } | access given action with given parameters by post if get exception will retry by given retryTimes . | 107 | 20 |
11,177 | public < A extends Appendable > A document ( A output ) throws IOException { StringBuilder line = new StringBuilder ( ) ; for ( Field field : Beans . getKnownInstanceFields ( _prototype ) ) { description d = field . getAnnotation ( description . class ) ; if ( d == null ) continue ; placeholder p = field . getAnnotation ( placeholder . class ) ; String n = Strings . splitCamelCase ( field . getName ( ) , "-" ) . toLowerCase ( ) ; char key = getShortOptionKey ( field ) ; if ( ( field . getType ( ) == Boolean . class || field . getType ( ) == Boolean . TYPE ) && _booleans . containsKey ( key ) ) { line . append ( " -" ) . append ( key ) . append ( ", --" ) . append ( n ) ; } else { line . append ( " --" ) . append ( n ) . append ( ' ' ) . append ( p != null ? p . value ( ) : "value" ) ; } if ( line . length ( ) < 16 ) { for ( int i = line . length ( ) ; i < 16 ; ++ i ) line . append ( ' ' ) ; line . append ( d . value ( ) ) ; } else { line . append ( "\n\t\t" ) . append ( d . value ( ) ) ; } output . append ( line . toString ( ) ) . append ( ' ' ) ; line . setLength ( 0 ) ; } return output ; } | Writes usage documentation to an Appendable . | 331 | 10 |
11,178 | public static InetAddress getAddress ( String host ) throws UnknownHostException { if ( timeToClean ( ) ) { synchronized ( storedAddresses ) { if ( timeToClean ( ) ) { cleanOldAddresses ( ) ; } } } Pair < InetAddress , Long > cachedAddress ; synchronized ( storedAddresses ) { cachedAddress = storedAddresses . get ( host ) ; } if ( cachedAddress != null ) { //host DNS entry was cached InetAddress address = cachedAddress . getFirst ( ) ; if ( address == null ) { throw new UnknownHostException ( "Could not find host " + host + " (cached response)" ) ; } else { return address ; } } else { //host DNS entry was not cached fetchDnsAddressLock . acquireUninterruptibly ( ) ; try { InetAddress addr = InetAddress . getByName ( host ) ; synchronized ( storedAddresses ) { storedAddresses . put ( host , new Pair <> ( addr , System . currentTimeMillis ( ) ) ) ; } return addr ; } catch ( UnknownHostException exp ) { synchronized ( storedAddresses ) { storedAddresses . put ( host , new Pair < InetAddress , Long > ( null , System . currentTimeMillis ( ) ) ) ; } Log . i ( "[Dns lookup] " + host + " --> not found" ) ; throw exp ; } finally { fetchDnsAddressLock . release ( ) ; } } } | only allow 5 simultaneous DNS requests | 312 | 6 |
11,179 | private VarSymbol enterConstant ( String name , Type type ) { VarSymbol c = new VarSymbol ( PUBLIC | STATIC | FINAL , names . fromString ( name ) , type , predefClass ) ; c . setData ( type . constValue ( ) ) ; predefClass . members ( ) . enter ( c ) ; return c ; } | Enter a constant into symbol table . | 77 | 7 |
11,180 | private void enterBinop ( String name , Type left , Type right , Type res , int opcode ) { predefClass . members ( ) . enter ( new OperatorSymbol ( makeOperatorName ( name ) , new MethodType ( List . of ( left , right ) , res , List . < Type > nil ( ) , methodClass ) , opcode , predefClass ) ) ; } | Enter a binary operation into symbol table . | 85 | 8 |
11,181 | private OperatorSymbol enterUnop ( String name , Type arg , Type res , int opcode ) { OperatorSymbol sym = new OperatorSymbol ( makeOperatorName ( name ) , new MethodType ( List . of ( arg ) , res , List . < Type > nil ( ) , methodClass ) , opcode , predefClass ) ; predefClass . members ( ) . enter ( sym ) ; return sym ; } | Enter a unary operation into symbol table . | 91 | 9 |
11,182 | private Name makeOperatorName ( String name ) { Name opName = names . fromString ( name ) ; operatorNames . add ( opName ) ; return opName ; } | Create a new operator name from corresponding String representation and add the name to the set of known operator names . | 37 | 21 |
11,183 | public Widget put ( IWidgetFactory factory , String name ) { Widget widget = factory . getWidget ( ) ; put ( widget , name ) ; return widget ; } | Creates new widget and puts it to container at first free index | 36 | 13 |
11,184 | public static String getEventTypeDescription ( final XMLStreamReader reader ) { final int eventType = reader . getEventType ( ) ; if ( eventType == XMLStreamConstants . START_ELEMENT ) { final String namespace = reader . getNamespaceURI ( ) ; return "<" + reader . getLocalName ( ) + ( ! StringUtils . isEmpty ( namespace ) ? "@" + namespace : StringUtils . EMPTY ) + ">" ; } if ( eventType == XMLStreamConstants . END_ELEMENT ) { final String namespace = reader . getNamespaceURI ( ) ; return "</" + reader . getLocalName ( ) + ( ! StringUtils . isEmpty ( namespace ) ? "@" + namespace : StringUtils . EMPTY ) + ">" ; } return NAMES_OF_EVENTS [ reader . getEventType ( ) ] ; } | Returns string describing the current event . | 190 | 7 |
11,185 | public static boolean isStartElement ( final XMLStreamReader reader , final String namespace , final String localName ) { return reader . getEventType ( ) == XMLStreamConstants . START_ELEMENT && nameEquals ( reader , namespace , localName ) ; } | Method isStartElement . | 56 | 5 |
11,186 | public static boolean nameEquals ( final XMLStreamReader reader , final String namespace , final String localName ) { if ( ! reader . getLocalName ( ) . equals ( localName ) ) { return false ; } if ( namespace == null ) { return true ; } final String namespaceURI = reader . getNamespaceURI ( ) ; if ( namespaceURI == null ) { return StringUtils . isEmpty ( namespace ) ; } return namespaceURI . equals ( StringUtils . defaultString ( namespace ) ) ; } | Method nameEquals . | 108 | 5 |
11,187 | public static Class optionalClassAttribute ( final XMLStreamReader reader , final String localName , final Class defaultValue ) throws XMLStreamException { return optionalClassAttribute ( reader , null , localName , defaultValue ) ; } | Returns the value of an attribute as a Class . If the attribute is empty this method returns the default value provided . | 45 | 23 |
11,188 | public static void skipElement ( final XMLStreamReader reader ) throws XMLStreamException , IOException { if ( reader . getEventType ( ) != XMLStreamConstants . START_ELEMENT ) { return ; } final String namespace = reader . getNamespaceURI ( ) ; final String name = reader . getLocalName ( ) ; for ( ; ; ) { switch ( reader . nextTag ( ) ) { case XMLStreamConstants . START_ELEMENT : // call ourselves recursively if we encounter START_ELEMENT skipElement ( reader ) ; break ; case XMLStreamConstants . END_ELEMENT : case XMLStreamConstants . END_DOCUMENT : // discard events until we encounter matching END_ELEMENT reader . require ( XMLStreamConstants . END_ELEMENT , namespace , name ) ; reader . next ( ) ; return ; } } } | Method skipElement . | 187 | 4 |
11,189 | public UriBuilder path ( String path ) throws URISyntaxException { path = path . trim ( ) ; if ( getPath ( ) . endsWith ( "/" ) ) { return new UriBuilder ( setPath ( String . format ( "%s%s" , getPath ( ) , path ) ) ) ; } else { return new UriBuilder ( setPath ( String . format ( "%s/%s" , getPath ( ) , path ) ) ) ; } } | Appends a path to the current one | 100 | 8 |
11,190 | public < T > ApruveResponse < List < T > > index ( String path , GenericType < List < T > > resultType ) { Response response = restRequest ( path ) . get ( ) ; List < T > responseObject = null ; ApruveResponse < List < T > > result ; if ( response . getStatusInfo ( ) . getFamily ( ) == Family . SUCCESSFUL ) { responseObject = response . readEntity ( resultType ) ; result = new ApruveResponse < List < T > > ( response . getStatus ( ) , responseObject ) ; } else { result = new ApruveResponse < List < T > > ( response . getStatus ( ) , null , response . readEntity ( String . class ) ) ; } return result ; } | is kind of a pain and it duplicates processResponse . | 167 | 12 |
11,191 | public < T > ApruveResponse < T > get ( String path , Class < T > resultType ) { Response response = restRequest ( path ) . get ( ) ; return processResponse ( response , resultType ) ; } | Issues a GET request against to the Apruve REST API using the specified path . | 48 | 18 |
11,192 | public boolean sync ( NewRelicCache cache ) { if ( cache == null ) throw new IllegalArgumentException ( "null cache" ) ; checkInitialize ( cache ) ; boolean ret = isInitialized ( ) ; if ( ! ret ) throw new IllegalStateException ( "cache not initialized" ) ; clear ( cache ) ; if ( ret ) ret = syncApplications ( cache ) ; if ( ret ) ret = syncPlugins ( cache ) ; if ( ret ) ret = syncMonitors ( cache ) ; if ( ret ) ret = syncServers ( cache ) ; if ( ret ) ret = syncLabels ( cache ) ; if ( ret ) ret = syncAlerts ( cache ) ; if ( ret ) ret = syncDashboards ( cache ) ; return ret ; } | Synchronises the cache . | 162 | 6 |
11,193 | public boolean syncAlerts ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; // Get the alert configuration using the REST API if ( cache . isAlertsEnabled ( ) ) { ret = false ; // Get the alert policies logger . info ( "Getting the alert policies" ) ; Collection < AlertPolicy > policies = apiClient . alertPolicies ( ) . list ( ) ; for ( AlertPolicy policy : policies ) { cache . alertPolicies ( ) . add ( policy ) ; // Add the alert conditions if ( cache . isApmEnabled ( ) || cache . isServersEnabled ( ) || cache . isBrowserEnabled ( ) || cache . isMobileEnabled ( ) ) cache . alertPolicies ( ) . alertConditions ( policy . getId ( ) ) . add ( apiClient . alertConditions ( ) . list ( policy . getId ( ) ) ) ; cache . alertPolicies ( ) . nrqlAlertConditions ( policy . getId ( ) ) . add ( apiClient . nrqlAlertConditions ( ) . list ( policy . getId ( ) ) ) ; if ( cache . isApmEnabled ( ) || cache . isMobileEnabled ( ) ) cache . alertPolicies ( ) . externalServiceAlertConditions ( policy . getId ( ) ) . add ( apiClient . externalServiceAlertConditions ( ) . list ( policy . getId ( ) ) ) ; if ( cache . isSyntheticsEnabled ( ) ) cache . alertPolicies ( ) . syntheticsAlertConditions ( policy . getId ( ) ) . add ( apiClient . syntheticsAlertConditions ( ) . list ( policy . getId ( ) ) ) ; if ( cache . isPluginsEnabled ( ) ) cache . alertPolicies ( ) . pluginsAlertConditions ( policy . getId ( ) ) . add ( apiClient . pluginsAlertConditions ( ) . list ( policy . getId ( ) ) ) ; if ( cache . isInfrastructureEnabled ( ) ) cache . alertPolicies ( ) . infraAlertConditions ( policy . getId ( ) ) . add ( infraApiClient . infraAlertConditions ( ) . list ( policy . getId ( ) ) ) ; } // Get the alert channels logger . info ( "Getting the alert channels" ) ; Collection < AlertChannel > channels = apiClient . alertChannels ( ) . list ( ) ; cache . alertChannels ( ) . set ( channels ) ; cache . alertPolicies ( ) . setAlertChannels ( channels ) ; cache . setUpdatedAt ( ) ; ret = true ; } return ret ; } | Synchronise the alerts configuration with the cache . | 585 | 10 |
11,194 | public boolean syncApplications ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; // Get the application configuration using the REST API if ( cache . isApmEnabled ( ) || cache . isBrowserEnabled ( ) || cache . isMobileEnabled ( ) ) { ret = false ; if ( cache . isApmEnabled ( ) ) { logger . info ( "Getting the applications" ) ; Collection < Application > applications = apiClient . applications ( ) . list ( ) ; for ( Application application : applications ) { cache . applications ( ) . add ( application ) ; logger . fine ( "Getting the hosts for application: " + application . getId ( ) ) ; cache . applications ( ) . applicationHosts ( application . getId ( ) ) . add ( apiClient . applicationHosts ( ) . list ( application . getId ( ) ) ) ; logger . fine ( "Getting the instances for application: " + application . getId ( ) ) ; cache . applications ( ) . applicationHosts ( application . getId ( ) ) . addApplicationInstances ( apiClient . applicationInstances ( ) . list ( application . getId ( ) ) ) ; logger . fine ( "Getting the deployments for application: " + application . getId ( ) ) ; cache . applications ( ) . deployments ( application . getId ( ) ) . add ( apiClient . deployments ( ) . list ( application . getId ( ) ) ) ; } // Get the key transaction configuration using the REST API try { logger . info ( "Getting the key transactions" ) ; cache . applications ( ) . addKeyTransactions ( apiClient . keyTransactions ( ) . list ( ) ) ; } catch ( ErrorResponseException e ) { if ( e . getStatus ( ) == 403 ) // throws 403 if not allowed by subscription logger . warning ( "Error in get key transactions: " + e . getMessage ( ) ) ; else throw e ; } } if ( cache . isBrowserEnabled ( ) ) { logger . info ( "Getting the browser applications" ) ; cache . browserApplications ( ) . add ( apiClient . browserApplications ( ) . list ( ) ) ; } if ( cache . isBrowserEnabled ( ) ) { logger . info ( "Getting the mobile applications" ) ; cache . mobileApplications ( ) . add ( apiClient . mobileApplications ( ) . list ( ) ) ; } cache . setUpdatedAt ( ) ; ret = true ; } return ret ; } | Synchronise the application configuration with the cache . | 534 | 10 |
11,195 | public boolean syncPlugins ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; // Get the Plugins configuration using the REST API if ( cache . isPluginsEnabled ( ) ) { ret = false ; logger . info ( "Getting the plugins" ) ; Collection < Plugin > plugins = apiClient . plugins ( ) . list ( true ) ; for ( Plugin plugin : plugins ) { cache . plugins ( ) . add ( plugin ) ; logger . fine ( "Getting the components for plugin: " + plugin . getId ( ) ) ; Collection < PluginComponent > components = apiClient . pluginComponents ( ) . list ( PluginComponentService . filters ( ) . pluginId ( plugin . getId ( ) ) . build ( ) ) ; cache . plugins ( ) . components ( plugin . getId ( ) ) . add ( components ) ; } cache . setUpdatedAt ( ) ; ret = true ; } return ret ; } | Synchronise the Plugins configuration with the cache . | 215 | 11 |
11,196 | public boolean syncMonitors ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; // Get the Synthetics configuration using the REST API if ( cache . isSyntheticsEnabled ( ) ) { ret = false ; logger . info ( "Getting the monitors" ) ; cache . monitors ( ) . add ( syntheticsApiClient . monitors ( ) . list ( ) ) ; cache . setUpdatedAt ( ) ; ret = true ; } return ret ; } | Synchronise the Synthetics configuration with the cache . | 117 | 11 |
11,197 | public boolean syncServers ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; // Get the server configuration using the REST API if ( cache . isServersEnabled ( ) ) { ret = false ; logger . info ( "Getting the servers" ) ; cache . servers ( ) . add ( apiClient . servers ( ) . list ( ) ) ; cache . setUpdatedAt ( ) ; ret = true ; } return ret ; } | Synchronise the server configuration with the cache . | 112 | 10 |
11,198 | public boolean syncLabels ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; // Get the label configuration using the REST API if ( cache . isApmEnabled ( ) || cache . isSyntheticsEnabled ( ) ) { ret = false ; logger . info ( "Getting the labels" ) ; Collection < Label > labels = apiClient . labels ( ) . list ( ) ; for ( Label label : labels ) { cache . applications ( ) . addLabel ( label ) ; try { // Also check to see if this label is associated with any monitors Collection < Monitor > monitors = syntheticsApiClient . monitors ( ) . list ( label ) ; for ( Monitor monitor : monitors ) cache . monitors ( ) . labels ( monitor . getId ( ) ) . ( label ) ; } catch ( NullPointerException e ) { logger . severe ( "Unable to get monitor labels: " + e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } } cache . setUpdatedAt ( ) ; ret = true ; } return ret ; } | Synchronise the label configuration with the cache . | 252 | 10 |
11,199 | public boolean syncDashboards ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; // Get the dashboard configuration using the REST API if ( cache . isInsightsEnabled ( ) ) { ret = false ; logger . info ( "Getting the dashboards" ) ; cache . dashboards ( ) . set ( apiClient . dashboards ( ) . list ( ) ) ; cache . setUpdatedAt ( ) ; ret = true ; } return ret ; } | Synchronise the dashboard configuration with the cache . | 115 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.