idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
36,200 | public DiscriminatorJdbcSubBuilder when ( Predicate < String > predicate , Type type ) { final DiscriminatorJdbcSubBuilder subBuilder = new DiscriminatorJdbcSubBuilder ( predicate , type ) ; builders . add ( subBuilder ) ; return subBuilder ; } | Add a discriminator matching predicate with its associated type . |
36,201 | public DiscriminatorJdbcSubBuilder when ( String value , Class < ? extends T > type ) { return when ( value , ( Type ) type ) ; } | Add a discriminator value with its associated class . |
36,202 | public DiscriminatorJdbcSubBuilder when ( String value , TypeReference < ? extends T > type ) { return when ( value , type . getType ( ) ) ; } | Add a discriminator value with its associated type specified by the type reference . |
36,203 | public JdbcMapperBuilder < T > addMapping ( final String column , final int index , final int sqlType ) { addMapping ( column , index , sqlType , FieldMapperColumnDefinition . < JdbcColumnKey > identity ( ) ) ; return this ; } | add a new mapping to the specified property with the specified index and the specified type . |
36,204 | private int getNonEmptyParentIndex ( ) { return parent == null ? - 1 : parent . effectiveKeys ( ) . isEmpty ( ) ? parent . getNonEmptyParentIndex ( ) : parent . currentIndex ; } | ignore empty parent useful to skip root keys |
36,205 | public static int parseInt ( char [ ] s , int beginIndex , int endIndex ) throws NumberFormatException { s = Objects . requireNonNull ( s ) ; if ( beginIndex < 0 || beginIndex > endIndex || endIndex > s . length ) { throw new IndexOutOfBoundsException ( ) ; } if ( radix < Character . MIN_RADIX ) { throw new NumberForma... | copy of Integer . parseInt |
36,206 | public SheetMapperFactory getterFactory ( GetterFactory < Row , CsvColumnKey > getterFactory ) { return super . addGetterFactory ( new ContextualGetterFactoryAdapter < Row , CsvColumnKey > ( getterFactory ) ) ; } | set a new getterFactory . |
36,207 | public void update ( final Collection < T > values ) throws DataAccessException { jdbcTemplate . execute ( new ConnectionCallback < Object > ( ) { public Object doInConnection ( Connection connection ) throws SQLException , DataAccessException { crud . update ( connection , values ) ; return null ; } } ) ; } | update the objects . |
36,208 | public void delete ( final K key ) throws DataAccessException { jdbcTemplate . execute ( new ConnectionCallback < Object > ( ) { public Object doInConnection ( Connection connection ) throws SQLException , DataAccessException { crud . delete ( connection , key ) ; return null ; } } ) ; } | delete the object with the specified key . |
36,209 | private static boolean _areParameterNamePresent ( Type target ) { Class < ? > targetClass = TypeHelper . toClass ( target ) ; for ( Method m : targetClass . getDeclaredMethods ( ) ) { final java . lang . reflect . Parameter [ ] parameters = m . getParameters ( ) ; if ( parameters . length > 0 ) { return parameters [ 0 ... | assume parameter name are either present or not for the type |
36,210 | public < T > CsvMapperBuilder < T > newBuilder ( final Class < T > target ) { return newBuilder ( ( Type ) target ) ; } | Will create a newInstance of ResultSetMapperBuilder |
36,211 | private int _hashCode ( Object values ) { int valueHash = 0 ; if ( values instanceof Object [ ] ) valueHash = Arrays . deepHashCode ( ( Object [ ] ) values ) ; else if ( values instanceof byte [ ] ) valueHash = Arrays . hashCode ( ( byte [ ] ) values ) ; else if ( values instanceof short [ ] ) valueHash = Arrays . hash... | copy from Array . deepHashCode0 |
36,212 | public Crud < T , K > table ( String table ) { return new LazyCrud < T , K > ( this , table ) ; } | Create a crud against the specified table that will validate on the first interaction with a connection . |
36,213 | public Crud < T , K > table ( Connection connection , String table ) throws SQLException { CrudMeta crudMeta = CrudMeta . of ( connection , table , jdbcMapperFactory . columnDefinitions ( ) ) ; return CrudFactory . < T , K > newInstance ( target , keyTarget , crudMeta , jdbcMapperFactory ) ; } | Create a crud against the specified table validating it against the specified connection . |
36,214 | public ConnectedCrud < T , K > table ( DataSource dataSource , String table ) throws SQLException { Connection connection = dataSource . getConnection ( ) ; try { return new ConnectedCrud < T , K > ( new DataSourceTransactionTemplate ( dataSource ) , table ( connection , table ) ) ; } finally { connection . close ( ) ;... | Create a connected crud against the specified table validating it against the specified datasource . |
36,215 | public ConnectedCrud < T , K > to ( DataSource dataSource ) throws SQLException { Connection connection = dataSource . getConnection ( ) ; try { return new ConnectedCrud < T , K > ( new DataSourceTransactionTemplate ( dataSource ) , to ( connection ) ) ; } finally { connection . close ( ) ; } } | Create a connected crud validating it against the specified datasource . The table name is derived from the jpa annotation or from the class name . |
36,216 | public Crud < T , K > to ( Connection connection ) throws SQLException { return table ( connection , getTable ( connection , target ) ) ; } | Create a connected crud validating it against the specified connection . The table name is derived from the jpa annotation or from the class name . |
36,217 | private void precomputeSlope ( ) { float invDirX = 1.0f / dirX ; float invDirY = 1.0f / dirY ; float invDirZ = 1.0f / dirZ ; s_yx = dirX * invDirY ; s_xy = dirY * invDirX ; s_zy = dirY * invDirZ ; s_yz = dirZ * invDirY ; s_xz = dirZ * invDirX ; s_zx = dirX * invDirZ ; c_xy = originY - s_xy * originX ; c_yx = originX - ... | Precompute the values necessary for the ray slope algorithm . |
36,218 | public Quaterniond rotationX ( double angle ) { double sin = Math . sin ( angle * 0.5 ) ; double cos = Math . cosFromSin ( sin , angle * 0.5 ) ; w = cos ; x = sin ; y = 0.0 ; z = 0.0 ; return this ; } | Set this quaternion to represent a rotation of the given radians about the x axis . |
36,219 | public Vector3f div ( Vector3fc v ) { return div ( v . x ( ) , v . y ( ) , v . z ( ) , thisOrNew ( ) ) ; } | Divide this Vector3f component - wise by another Vector3fc . |
36,220 | public Quaternionf normalize ( ) { float invNorm = ( float ) ( 1.0 / Math . sqrt ( x * x + y * y + z * z + w * w ) ) ; x *= invNorm ; y *= invNorm ; z *= invNorm ; w *= invNorm ; return this ; } | Normalize this quaternion . |
36,221 | public Matrix3d set ( int column , int row , double value ) { switch ( column ) { case 0 : switch ( row ) { case 0 : this . m00 = value ; return this ; case 1 : this . m01 = value ; return this ; case 2 : this . m02 = value ; return this ; default : break ; } break ; case 1 : switch ( row ) { case 0 : this . m10 = valu... | Set the matrix element at the given column and row to the specified value . |
36,222 | public AABBd correctBounds ( ) { double tmp ; if ( this . minX > this . maxX ) { tmp = this . minX ; this . minX = this . maxX ; this . maxX = tmp ; } if ( this . minY > this . maxY ) { tmp = this . minY ; this . minY = this . maxY ; this . maxY = tmp ; } if ( this . minZ > this . maxZ ) { tmp = this . minZ ; this . mi... | Ensure that the minimum coordinates are strictly less than or equal to the maximum coordinates by swapping them if necessary . |
36,223 | public Vector3i add ( Vector3ic v ) { return add ( v . x ( ) , v . y ( ) , v . z ( ) , thisOrNew ( ) ) ; } | Add the supplied vector to this one . |
36,224 | public Vector3i mul ( int x , int y , int z ) { return mul ( x , y , z , thisOrNew ( ) ) ; } | Multiply the components of this vector by the given values . |
36,225 | public static double lengthSquared ( double x , double y , double z ) { return x * x + y * y + z * z ; } | Get the length squared of a 3 - dimensional double - precision vector . |
36,226 | public static double length ( int x , int y , int z , int w ) { return Math . sqrt ( lengthSquared ( x , y , z , w ) ) ; } | Get the length of a 4 - dimensional single - precision vector . |
36,227 | public void onResume ( final Context context ) { new Handler ( ) . post ( new Runnable ( ) { public void run ( ) { checkLocaleChange ( context ) ; checkAfterLocaleChanging ( ) ; } } ) ; } | If activity is run to back stack . So we have to check if this activity is resume working . |
36,228 | public final void setLanguage ( Context context , String language ) { Locale locale = new Locale ( language ) ; setLanguage ( context , locale ) ; } | Provide method to set application language by country name . |
36,229 | private void checkBeforeLocaleChanging ( ) { boolean isLocalizationChanged = activity . getIntent ( ) . getBooleanExtra ( KEY_ACTIVITY_LOCALE_CHANGED , false ) ; if ( isLocalizationChanged ) { this . isLocalizationChanged = true ; activity . getIntent ( ) . removeExtra ( KEY_ACTIVITY_LOCALE_CHANGED ) ; } } | If yes bundle will obe remove and set boolean flag to true . |
36,230 | private void setupLanguage ( ) { Locale locale = LanguageSetting . getLanguage ( activity ) ; setupLocale ( locale ) ; currentLanguage = locale ; LanguageSetting . setLanguage ( activity , locale ) ; } | This method will called before onCreate . |
36,231 | private boolean isCurrentLanguageSetting ( Context context , Locale locale ) { return locale . toString ( ) . equals ( LanguageSetting . getLanguage ( context ) . toString ( ) ) ; } | Avoid duplicated setup |
36,232 | private void notifyLanguageChanged ( ) { sendOnBeforeLocaleChangedEvent ( ) ; activity . getIntent ( ) . putExtra ( KEY_ACTIVITY_LOCALE_CHANGED , true ) ; callDummyActivity ( ) ; activity . recreate ( ) ; } | Let s take it change! ( Using recreate method that available on API 11 or more . |
36,233 | private void checkLocaleChange ( Context context ) { if ( ! isCurrentLanguageSetting ( context , currentLanguage ) ) { sendOnBeforeLocaleChangedEvent ( ) ; isLocalizationChanged = true ; callDummyActivity ( ) ; activity . recreate ( ) ; } } | Check if locale has change while this activity was run to back stack . |
36,234 | public List < File > scan ( List < Resource > resources ) { List < File > files = new ArrayList < File > ( ) ; for ( Resource resource : resources ) { files . addAll ( scan ( resource ) ) ; } return files ; } | Scans a list of resources returning all AsciiDoc documents found . |
36,235 | public List < LogRecord > filter ( Severity severity ) { final List < LogRecord > records = new ArrayList < > ( ) ; for ( LogRecord record : this . records ) { if ( record . getSeverity ( ) . ordinal ( ) >= severity . ordinal ( ) ) records . add ( record ) ; } return records ; } | Returns LogRecords that are equal or above the severity level . |
36,236 | public List < LogRecord > filter ( String text ) { final List < LogRecord > records = new ArrayList < > ( ) ; for ( LogRecord record : this . records ) { if ( record . getMessage ( ) . contains ( text ) ) records . add ( record ) ; } return records ; } | Returns LogRecords whose message contains text . |
36,237 | public List < LogRecord > filter ( Severity severity , String text ) { final List < LogRecord > records = new ArrayList < > ( ) ; for ( LogRecord record : this . records ) { if ( record . getSeverity ( ) . ordinal ( ) >= severity . ordinal ( ) && record . getMessage ( ) . contains ( text ) ) records . add ( record ) ; ... | Returns LogRecords that are equal or above the severity level and whose message contains text . |
36,238 | public static SwipeBack attach ( Activity activity , Type type , Position position , int dragMode ) { return attach ( activity , type , position , dragMode , new DefaultSwipeBackTransformer ( ) ) ; } | Attaches the SwipeBack to the Activity |
36,239 | private static SwipeBack createSwipeBack ( Activity activity , int dragMode , Position position , Type type , SwipeBackTransformer transformer ) { SwipeBack drawerHelper ; if ( type == Type . OVERLAY ) { drawerHelper = new OverlaySwipeBack ( activity , dragMode ) ; } else { drawerHelper = new SlidingSwipeBack ( activit... | Constructs the appropriate SwipeBack based on the position . |
36,240 | @ SuppressLint ( "NewApi" ) protected boolean isActivitiyDestroyed ( ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN_MR1 ) { return mActivity . isFinishing ( ) || mActivity . isDestroyed ( ) ; } else { return mActivity . isFinishing ( ) ; } } | Determines if the activity has been destroyed or finished . This is useful to dertermine if a |
36,241 | private static void attachToContent ( Activity activity , SwipeBack swipeBack ) { ViewGroup content = ( ViewGroup ) activity . findViewById ( android . R . id . content ) ; content . removeAllViews ( ) ; content . addView ( swipeBack , LayoutParams . MATCH_PARENT , LayoutParams . MATCH_PARENT ) ; } | Attaches the swipe back to the content view . |
36,242 | private static void attachToDecor ( Activity activity , SwipeBack swipeBack ) { ViewGroup decorView = ( ViewGroup ) activity . getWindow ( ) . getDecorView ( ) ; ViewGroup decorChild = ( ViewGroup ) decorView . getChildAt ( 0 ) ; decorView . removeAllViews ( ) ; decorView . addView ( swipeBack , LayoutParams . MATCH_PA... | Attaches the swipe back drawer to the window . |
36,243 | protected void updateTouchAreaSize ( ) { if ( mTouchMode == TOUCH_MODE_BEZEL ) { mTouchSize = mTouchBezelSize ; } else if ( mTouchMode == TOUCH_MODE_FULLSCREEN ) { mTouchSize = getMeasuredWidth ( ) ; } else { mTouchSize = 0 ; } } | Compute the touch area based on the touch mode . |
36,244 | public SwipeBack setDividerAsShadowColor ( int color ) { GradientDrawable . Orientation orientation = getDividerOrientation ( ) ; final int endColor = color & 0x00FFFFFF ; GradientDrawable gradient = new GradientDrawable ( orientation , new int [ ] { color , endColor , } ) ; setDivider ( gradient ) ; return this ; } | Sets the color of the divider if you have set the option to use a shadow gradient as divider |
36,245 | public SwipeBack setSwipeBackView ( int layoutResId ) { mSwipeBackContainer . removeAllViews ( ) ; mSwipeBackView = LayoutInflater . from ( getContext ( ) ) . inflate ( layoutResId , mSwipeBackContainer , false ) ; mSwipeBackContainer . addView ( mSwipeBackView ) ; notifySwipeBackViewCreated ( mSwipeBackView ) ; return... | Set the swipe back view from a layout resource . |
36,246 | private void completeAnimation ( ) { mScroller . abortAnimation ( ) ; final int finalX = mScroller . getFinalX ( ) ; setOffsetPixels ( finalX ) ; setDrawerState ( finalX == 0 ? STATE_CLOSED : STATE_OPEN ) ; stopLayerTranslation ( ) ; } | Called when a drawer animation has successfully completed . |
36,247 | @ SuppressLint ( "NewApi" ) private void postAnimationInvalidate ( ) { if ( mScroller . computeScrollOffset ( ) ) { final int oldX = ( int ) mOffsetPixels ; final int x = mScroller . getCurrX ( ) ; if ( x != oldX ) { setOffsetPixels ( x ) ; } if ( x != mScroller . getFinalX ( ) ) { postOnAnimation ( mDragRunnable ) ; r... | Callback when each frame in the drawer animation should be drawn . |
36,248 | @ SuppressLint ( "NewApi" ) private void peekDrawerInvalidate ( ) { if ( mPeekScroller . computeScrollOffset ( ) ) { final int oldX = ( int ) mOffsetPixels ; final int x = mPeekScroller . getCurrX ( ) ; if ( x != oldX ) { setOffsetPixels ( x ) ; } if ( ! mPeekScroller . isFinished ( ) ) { postOnAnimation ( mPeekRunnabl... | Callback when each frame in the peek drawer animation should be drawn . |
36,249 | public boolean computeScrollOffset ( ) { if ( mFinished ) { return false ; } int timePassed = ( int ) ( AnimationUtils . currentAnimationTimeMillis ( ) - mStartTime ) ; if ( timePassed < mDuration ) { switch ( mMode ) { case SCROLL_MODE : float x = timePassed * mDurationReciprocal ; if ( mInterpolator == null ) x = vis... | Call this when you want to know the new location . If it returns true the animation is not yet finished . loc will be altered to provide the new location . |
36,250 | public void startScroll ( int startX , int startY , int dx , int dy ) { startScroll ( startX , startY , dx , dy , DEFAULT_DURATION ) ; } | Start scrolling by providing a starting point and the distance to travel . The scroll will use the default value of 250 milliseconds for the duration . |
36,251 | private Object marshallParameterAsPrimitive ( Object parameter ) { Map < String , Object > primitiveWrapper = Collections . singletonMap ( "wrapped" , parameter ) ; BsonDocument document = marshaller . marshall ( primitiveWrapper ) ; return document . toDBObject ( ) . get ( "wrapped" ) ; } | The object may have been serialized to a primitive type with a custom serializer so try again after wrapping as an object property . We do this trick only as a falllback since it causes Jackson to consider the parameter as Object and thus ignore any annotations that may exist on its actual class . |
36,252 | public static AmazonDynamoDB getClient ( ) { if ( ddbClient != null ) { return ddbClient ; } if ( Config . IN_PRODUCTION ) { ddbClient = AmazonDynamoDBClientBuilder . standard ( ) . build ( ) ; } else { ddbClient = AmazonDynamoDBClientBuilder . standard ( ) . withCredentials ( new AWSStaticCredentialsProvider ( new Bas... | Returns a client instance for AWS DynamoDB . |
36,253 | public static boolean existsTable ( String appid ) { if ( StringUtils . isBlank ( appid ) ) { return false ; } try { DescribeTableResult res = getClient ( ) . describeTable ( getTableNameForAppid ( appid ) ) ; return res != null ; } catch ( Exception e ) { return false ; } } | Checks if the main table exists in the database . |
36,254 | public static boolean createTable ( String appid , long readCapacity , long writeCapacity ) { if ( StringUtils . isBlank ( appid ) ) { return false ; } else if ( StringUtils . containsWhitespace ( appid ) ) { logger . warn ( "DynamoDB table name contains whitespace. The name '{}' is invalid." , appid ) ; return false ;... | Creates a table in AWS DynamoDB . |
36,255 | public static boolean deleteTable ( String appid ) { if ( StringUtils . isBlank ( appid ) || ! existsTable ( appid ) ) { return false ; } try { String table = getTableNameForAppid ( appid ) ; getClient ( ) . deleteTable ( new DeleteTableRequest ( ) . withTableName ( table ) ) ; logger . info ( "Deleted DynamoDB table '... | Deletes the main table from AWS DynamoDB . |
36,256 | public static boolean createSharedTable ( long readCapacity , long writeCapacity ) { if ( StringUtils . isBlank ( SHARED_TABLE ) || StringUtils . containsWhitespace ( SHARED_TABLE ) || existsTable ( SHARED_TABLE ) ) { return false ; } try { GlobalSecondaryIndex secIndex = new GlobalSecondaryIndex ( ) . withIndexName ( ... | Creates a table in AWS DynamoDB which will be shared between apps . |
36,257 | public static List < String > listAllTables ( ) { int items = 100 ; ListTablesResult ltr = getClient ( ) . listTables ( items ) ; List < String > tables = new LinkedList < > ( ) ; String lastKey ; do { tables . addAll ( ltr . getTableNames ( ) ) ; lastKey = ltr . getLastEvaluatedTableName ( ) ; logger . info ( "Found {... | Lists all table names for this account . |
36,258 | public static String getTableNameForAppid ( String appIdentifier ) { if ( StringUtils . isBlank ( appIdentifier ) ) { return null ; } else { if ( isSharedAppid ( appIdentifier ) ) { appIdentifier = SHARED_TABLE ; } return ( App . isRoot ( appIdentifier ) || appIdentifier . startsWith ( Config . PARA . concat ( "-" ) ) ... | Returns the table name for a given app id . Table names are usually in the form prefix - appid . |
36,259 | protected static < P extends ParaObject > void batchGet ( Map < String , KeysAndAttributes > kna , Map < String , P > results ) { if ( kna == null || kna . isEmpty ( ) || results == null ) { return ; } try { BatchGetItemResult result = getClient ( ) . batchGetItem ( new BatchGetItemRequest ( ) . withReturnConsumedCapac... | Reads multiple items from DynamoDB in batch . |
36,260 | protected static void batchWrite ( Map < String , List < WriteRequest > > items , int backoff ) { if ( items == null || items . isEmpty ( ) ) { return ; } try { BatchWriteItemResult result = getClient ( ) . batchWriteItem ( new BatchWriteItemRequest ( ) . withReturnConsumedCapacity ( ReturnConsumedCapacity . TOTAL ) . ... | Writes multiple items in batch . |
36,261 | public static < P extends ParaObject > List < P > readPageFromTable ( String appid , Pager p ) { Pager pager = ( p != null ) ? p : new Pager ( ) ; ScanRequest scanRequest = new ScanRequest ( ) . withTableName ( getTableNameForAppid ( appid ) ) . withLimit ( pager . getLimit ( ) ) . withReturnConsumedCapacity ( ReturnCo... | Reads a page from a standard DynamoDB table . |
36,262 | public static < P extends ParaObject > List < P > readPageFromSharedTable ( String appid , Pager pager ) { LinkedList < P > results = new LinkedList < > ( ) ; if ( StringUtils . isBlank ( appid ) ) { return results ; } PageIterable < Item , QueryOutcome > pages = queryGSI ( appid , pager ) ; if ( pages != null ) { for ... | Reads a page from a shared DynamoDB table . Shared tables are tables that have global secondary indexes and can contain the objects of multiple apps . |
36,263 | public static void deleteAllFromSharedTable ( String appid ) { if ( StringUtils . isBlank ( appid ) || ! isSharedAppid ( appid ) ) { return ; } Pager pager = new Pager ( 25 ) ; PageIterable < Item , QueryOutcome > pages ; Map < String , AttributeValue > lastKey = null ; do { pages = queryGSI ( appid , pager ) ; if ( pa... | Deletes all objects in a shared table which belong to a given appid by scanning the GSI . |
36,264 | public static Index getSharedIndex ( ) { if ( ddb == null ) { getClient ( ) ; } try { Table t = ddb . getTable ( getTableNameForAppid ( SHARED_TABLE ) ) ; if ( t != null ) { return t . getIndex ( getSharedIndexName ( ) ) ; } } catch ( Exception e ) { logger . info ( "Could not get shared index: {}." , e . getMessage ( ... | Returns the Index object for the shared table . |
36,265 | public void setCurrency ( String currency ) { currency = StringUtils . upperCase ( currency ) ; if ( ! CurrencyUtils . getInstance ( ) . isValidCurrency ( currency ) ) { currency = "EUR" ; } this . currency = currency ; } | Sets a preferred currency . Default is EUR . |
36,266 | public void detachIdentifier ( String identifier ) { if ( ! StringUtils . equals ( identifier , getIdentifier ( ) ) ) { Sysprop s = CoreUtils . getInstance ( ) . getDao ( ) . read ( getAppid ( ) , identifier ) ; if ( s != null && StringUtils . equals ( getId ( ) , s . getCreatorid ( ) ) ) { deleteIdentifier ( identifie... | Detaches a secondary identifier which is not already used by this user . |
36,267 | public boolean isModerator ( ) { return isAdmin ( ) ? true : StringUtils . equalsIgnoreCase ( this . groups , Groups . MODS . toString ( ) ) ; } | Checks for moderator rights . |
36,268 | public String getIdentityProvider ( ) { if ( isFacebookUser ( ) ) { return "facebook" ; } else if ( isGooglePlusUser ( ) ) { return "google" ; } else if ( isGitHubUser ( ) ) { return "github" ; } else if ( isTwitterUser ( ) ) { return "twitter" ; } else if ( isLinkedInUser ( ) ) { return "linkedin" ; } else if ( isMicr... | Returns the name of the identity provider . |
36,269 | public static final User readUserForIdentifier ( final User u ) { if ( u == null || StringUtils . isBlank ( u . getIdentifier ( ) ) ) { return null ; } User user = null ; String password = null ; String identifier = u . getIdentifier ( ) ; Sysprop s = CoreUtils . getInstance ( ) . getDao ( ) . read ( u . getAppid ( ) ,... | Returns a user object for a given identifier . |
36,270 | public static final boolean passwordMatches ( User u ) { if ( u == null ) { return false ; } String password = u . getPassword ( ) ; String identifier = u . getIdentifier ( ) ; if ( StringUtils . isBlank ( password ) || StringUtils . isBlank ( identifier ) ) { return false ; } ParaObject s = CoreUtils . getInstance ( )... | Checks if a user has entered the correct password . Compares password hashes . |
36,271 | public final String generatePasswordResetToken ( ) { if ( StringUtils . isBlank ( identifier ) ) { return "" ; } Sysprop s = CoreUtils . getInstance ( ) . getDao ( ) . read ( getAppid ( ) , identifier ) ; if ( s != null ) { String token = Utils . generateSecurityToken ( 42 , true ) ; s . addProperty ( Config . _RESET_T... | Generates a new password reset token . Sent via email for pass reset . |
36,272 | public final boolean resetPassword ( String token , String newpass ) { if ( StringUtils . isBlank ( newpass ) || StringUtils . isBlank ( token ) || newpass . length ( ) < Config . MIN_PASS_LENGTH ) { return false ; } Sysprop s = CoreUtils . getInstance ( ) . getDao ( ) . read ( getAppid ( ) , identifier ) ; if ( isVali... | Changes the user password permanently . |
36,273 | private void deleteIdentifier ( String ident ) { if ( ! StringUtils . isBlank ( ident ) ) { CoreUtils . getInstance ( ) . getDao ( ) . delete ( getAppid ( ) , new Sysprop ( ident ) ) ; } } | Deletes the identifier and the user can no longer sign in with it . |
36,274 | public String generateEmailConfirmationToken ( ) { if ( StringUtils . isBlank ( identifier ) ) { return "" ; } Sysprop s = CoreUtils . getInstance ( ) . getDao ( ) . read ( getAppid ( ) , identifier ) ; if ( s != null ) { String token = Utils . base64encURL ( Utils . generateSecurityToken ( ) . getBytes ( ) ) ; s . add... | Generates a new email confirmation token . Sent via email for user activation . |
36,275 | public final boolean activateWithEmailToken ( String token ) { Sysprop s = CoreUtils . getInstance ( ) . getDao ( ) . read ( getAppid ( ) , identifier ) ; if ( isValidToken ( s , Config . _EMAIL_TOKEN , token ) ) { s . removeProperty ( Config . _EMAIL_TOKEN ) ; CoreUtils . getInstance ( ) . getDao ( ) . update ( getApp... | Activates a user if a given token matches the one stored . |
36,276 | public final boolean isValidPasswordResetToken ( String token ) { Sysprop s = CoreUtils . getInstance ( ) . getDao ( ) . read ( getAppid ( ) , identifier ) ; return isValidToken ( s , Config . _RESET_TOKEN , token ) ; } | Validates a token sent via email for password reset . |
36,277 | public final boolean isValidEmailConfirmationToken ( String token ) { Sysprop s = CoreUtils . getInstance ( ) . getDao ( ) . read ( getAppid ( ) , identifier ) ; return isValidToken ( s , Config . _EMAIL_TOKEN , token ) ; } | Validates a token sent for email confirmation . |
36,278 | private void setGravatarPicture ( ) { if ( StringUtils . isBlank ( picture ) ) { if ( email != null ) { String emailHash = Utils . md5 ( email . toLowerCase ( ) ) ; setPicture ( "https://www.gravatar.com/avatar/" + emailHash + "?size=400&d=mm&r=pg" ) ; } else { setPicture ( "https://www.gravatar.com/avatar?d=mm&size=40... | Sets the profile picture using the Gravatar service . |
36,279 | public static String extractAccessKey ( HttpServletRequest request ) { if ( request == null ) { return "" ; } String accessKey = "" ; String auth = request . getHeader ( HttpHeaders . AUTHORIZATION ) ; boolean isAnonymousRequest = isAnonymousRequest ( request ) ; if ( StringUtils . isBlank ( auth ) ) { auth = request .... | Extracts the access key from a request . It can be a header or a parameter . |
36,280 | public static boolean isAnonymousRequest ( HttpServletRequest request ) { return request != null && ( StringUtils . startsWith ( request . getHeader ( HttpHeaders . AUTHORIZATION ) , "Anonymous" ) || StringUtils . isBlank ( request . getHeader ( HttpHeaders . AUTHORIZATION ) ) ) ; } | Check if Authorization header starts with Anonymous . Used for guest access . |
36,281 | public static String extractDate ( HttpServletRequest request ) { if ( request == null ) { return "" ; } String date = request . getHeader ( "X-Amz-Date" ) ; if ( StringUtils . isBlank ( date ) ) { return request . getParameter ( "X-Amz-Date" ) ; } else { return date ; } } | Extracts the date field from a request . It can be a header or a parameter . |
36,282 | public static Response getEntity ( InputStream is , Class < ? > type ) { Object entity ; try { if ( is != null && is . available ( ) > 0 ) { if ( is . available ( ) > Config . MAX_ENTITY_SIZE_BYTES ) { return getStatusResponse ( Response . Status . BAD_REQUEST , "Request is too large - the maximum is " + ( Config . MAX... | Returns a Response with the entity object inside it and 200 status code . If there was and error the status code is different than 200 . |
36,283 | public static byte [ ] readEntityBytes ( InputStream in ) { byte [ ] jsonEntity = null ; try { if ( in != null && in . available ( ) > 0 ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; byte [ ] buf = new byte [ 1024 ] ; int length ; while ( ( length = in . read ( buf ) ) > 0 ) { baos . write ( buf , 0 ... | Reads the bytes from an InputStream . |
36,284 | public static Response getVotingResponse ( ParaObject object , Map < String , Object > entity ) { boolean voteSuccess = false ; if ( object != null && entity != null ) { String upvoterId = ( String ) entity . get ( "_voteup" ) ; String downvoterId = ( String ) entity . get ( "_votedown" ) ; if ( ! StringUtils . isBlank... | Process voting request and create vote object . |
36,285 | public static Response getReadResponse ( App app , ParaObject content ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "crud" , "read" ) ) { if ( app != null && content != null && checkImplicitAppPermissions ( app , content ) && checkIfUserCanMod... | Read response as JSON . |
36,286 | public static Response getCreateResponse ( App app , String type , InputStream is ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "crud" , "create" ) ) { ParaObject content ; Response entityRes = getEntity ( is , Map . class ) ; if ( entityRes .... | Create response as JSON . |
36,287 | public static Response getOverwriteResponse ( App app , String id , String type , InputStream is ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "crud" , "overwrite" ) ) { ParaObject content ; Response entityRes = getEntity ( is , Map . class ) ... | Overwrite response as JSON . |
36,288 | public static Response getUpdateResponse ( App app , ParaObject object , InputStream is ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "crud" , "update" ) ) { if ( app != null && object != null ) { Map < String , Object > newContent ; Response ... | Update response as JSON . |
36,289 | public static Response getDeleteResponse ( App app , ParaObject content ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "crud" , "delete" ) ) { if ( app != null && content != null && content . getId ( ) != null && content . getAppid ( ) != null ... | Delete response as JSON . |
36,290 | public static Response getBatchReadResponse ( App app , List < String > ids ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "batch" , "read" ) ) { if ( app != null && ids != null && ! ids . isEmpty ( ) ) { ArrayList < ParaObject > results = new ... | Batch read response as JSON . |
36,291 | public static Response getBatchCreateResponse ( final App app , InputStream is ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "batch" , "create" ) ) { if ( app != null ) { final LinkedList < ParaObject > newObjects = new LinkedList < > ( ) ; Re... | Batch create response as JSON . |
36,292 | public static Response getBatchUpdateResponse ( App app , Map < String , ParaObject > oldObjects , List < Map < String , Object > > newProperties ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "batch" , "update" ) ) { if ( app != null && oldObj... | Batch update response as JSON . |
36,293 | public static Response getBatchDeleteResponse ( App app , List < String > ids ) { try ( final Metrics . Context context = Metrics . time ( app == null ? null : app . getAppid ( ) , RestUtils . class , "batch" , "delete" ) ) { LinkedList < ParaObject > objects = new LinkedList < > ( ) ; if ( app != null && ids != null &... | Batch delete response as JSON . |
36,294 | public static Response readLinksHandler ( ParaObject pobj , String id2 , String type2 , MultivaluedMap < String , String > params , Pager pager , boolean childrenOnly ) { try ( final Metrics . Context context = Metrics . time ( null , RestUtils . class , "links" , "read" ) ) { String query = params . getFirst ( "q" ) ;... | Handles requests to search for linked objects . |
36,295 | public static Response deleteLinksHandler ( ParaObject pobj , String id2 , String type2 , boolean childrenOnly ) { try ( final Metrics . Context context = Metrics . time ( null , RestUtils . class , "links" , "delete" ) ) { if ( type2 == null && id2 == null ) { pobj . unlinkAll ( ) ; } else if ( type2 != null ) { if ( ... | Handles requests to delete linked objects . |
36,296 | public static Response createLinksHandler ( ParaObject pobj , String id2 ) { try ( final Metrics . Context context = Metrics . time ( null , RestUtils . class , "links" , "create" ) ) { if ( id2 != null && pobj != null ) { String linkid = pobj . link ( id2 ) ; if ( linkid == null ) { return getStatusResponse ( Response... | Handles requests to link an object to other objects . |
36,297 | public static Response getStatusResponse ( Response . Status status , String ... messages ) { if ( status == null ) { return Response . status ( Response . Status . BAD_REQUEST ) . build ( ) ; } String msg = StringUtils . join ( messages , ". " ) ; if ( StringUtils . isBlank ( msg ) ) { msg = status . getReasonPhrase (... | A generic JSON response handler . |
36,298 | public static void returnStatusResponse ( HttpServletResponse response , int status , String message ) { if ( response == null ) { return ; } PrintWriter out = null ; try { response . setStatus ( status ) ; response . setContentType ( MediaType . APPLICATION_JSON ) ; out = response . getWriter ( ) ; ParaObjectUtils . g... | A generic JSON response handler . Returns a message and response code . |
36,299 | public static String pathParam ( String param , ContainerRequestContext ctx ) { return ctx . getUriInfo ( ) . getPathParameters ( ) . getFirst ( param ) ; } | Returns the path parameter value . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.