idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
36,300 | public static List < String > pathParams ( String param , ContainerRequestContext ctx ) { return ctx . getUriInfo ( ) . getPathParameters ( ) . get ( param ) ; } | Returns the path parameters values . |
36,301 | public static String queryParam ( String param , ContainerRequestContext ctx ) { return ctx . getUriInfo ( ) . getQueryParameters ( ) . getFirst ( param ) ; } | Returns the query parameter value . |
36,302 | public static List < String > queryParams ( String param , ContainerRequestContext ctx ) { return ctx . getUriInfo ( ) . getQueryParameters ( ) . get ( param ) ; } | Returns the query parameter values . |
36,303 | public static boolean hasQueryParam ( String param , ContainerRequestContext ctx ) { return ctx . getUriInfo ( ) . getQueryParameters ( ) . containsKey ( param ) ; } | Returns true if parameter exists . |
36,304 | public String getUrl ( ) { if ( StringUtils . isBlank ( url ) && ! StringUtils . isBlank ( name ) ) { this . url = AWSQueueUtils . createQueue ( name ) ; } return url ; } | Returns the queue URL on SQS . |
36,305 | private boolean isIncluded ( final HttpServletRequest request ) { final String uri = ( String ) request . getAttribute ( "javax.servlet.include.request_uri" ) ; final boolean includeRequest = ! ( uri == null ) ; if ( includeRequest && log . isDebugEnabled ( ) ) { log . debug ( "{} resulted in an include request. This i... | Checks if the request uri is an include . These cannot be gzipped . |
36,306 | public static Date parseAWSDate ( String date ) { if ( date == null ) { return null ; } return TIME_FORMATTER . parseDateTime ( date ) . toDate ( ) ; } | Returns a parsed Date . |
36,307 | public Map < String , String > signRequest ( String accessKey , String secretKey , String httpMethod , String endpointURL , String reqPath , Map < String , String > headers , MultivaluedMap < String , String > params , byte [ ] jsonEntity ) { if ( StringUtils . isBlank ( accessKey ) ) { logger . error ( "Blank access k... | Builds and signs a request to an API endpoint using the provided credentials . |
36,308 | public static String [ ] validateObject ( ParaObject content ) { if ( content == null ) { return new String [ ] { "Object cannot be null." } ; } LinkedList < String > list = new LinkedList < > ( ) ; try { for ( ConstraintViolation < ParaObject > constraintViolation : getValidator ( ) . validate ( content ) ) { String p... | Validates objects using Hibernate Validator . |
36,309 | public static String [ ] validateObject ( App app , ParaObject content ) { if ( content == null || app == null ) { return new String [ ] { "Object cannot be null." } ; } try { String type = content . getType ( ) ; boolean isCustomType = ( content instanceof Sysprop ) && ! type . equals ( Utils . type ( Sysprop . class ... | Validates objects . |
36,310 | public static Map < String , Map < String , Map < String , Map < String , ? > > > > getCoreValidationConstraints ( ) { if ( CORE_CONSTRAINTS . isEmpty ( ) ) { for ( Map . Entry < String , Class < ? extends ParaObject > > e : ParaObjectUtils . getCoreClassesMap ( ) . entrySet ( ) ) { String type = e . getKey ( ) ; List ... | Returns all validation constraints that are defined by Java annotation in the core classes . |
36,311 | public Object invoke ( MethodInvocation mi ) throws Throwable { if ( ! Modifier . isPublic ( mi . getMethod ( ) . getModifiers ( ) ) ) { return mi . proceed ( ) ; } Method daoMethod = mi . getMethod ( ) ; Object [ ] args = mi . getArguments ( ) ; String appid = AOPUtils . getFirstArgOfString ( args ) ; Method superMeth... | Executes code when a method is invoked . A big switch statement . |
36,312 | public static Context time ( String appid , Class < ? > clazz , String ... names ) { String className = getClassName ( clazz ) ; Timer systemTimer = getTimer ( SYSTEM_METRICS_NAME , className , names ) ; Timer appTimer = appid == null || appid . isEmpty ( ) ? null : getTimer ( appid , className , names ) ; return new C... | Instantiate timing of a particular class and method for a specific application . |
36,313 | public static Counter counter ( String appid , Class < ? > clazz , String ... names ) { String className = getClassName ( clazz ) ; return getCounter ( App . isRoot ( appid ) ? SYSTEM_METRICS_NAME : appid , className , names ) ; } | Creates a new counter for a particular class and method for a specific application . |
36,314 | @ SuppressWarnings ( "unchecked" ) public UserAuthentication getOrCreateUser ( App app , String accessToken ) throws IOException { UserAuthentication userAuth = null ; User user = new User ( ) ; if ( accessToken != null ) { String ctype = null ; HttpEntity respEntity = null ; CloseableHttpResponse resp2 = null ; try { ... | Calls the Facebook API to get the user profile using a given access token . |
36,315 | public static User getAuthenticatedUser ( Authentication auth ) { User user = null ; if ( auth != null && auth . isAuthenticated ( ) && auth . getPrincipal ( ) instanceof AuthenticatedUserDetails ) { user = ( ( AuthenticatedUserDetails ) auth . getPrincipal ( ) ) . getUser ( ) ; } return user ; } | Extracts a User object from the security context . |
36,316 | public static App getAuthenticatedApp ( ) { App app = null ; if ( SecurityContextHolder . getContext ( ) . getAuthentication ( ) != null ) { Authentication auth = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( auth . isAuthenticated ( ) && auth . getPrincipal ( ) instanceof App ) { app = ( App ) ... | Extracts a App object from the security context . |
36,317 | public static boolean checkImplicitAppPermissions ( App app , ParaObject object ) { if ( app != null && object != null ) { return isNotAnApp ( object . getType ( ) ) || app . getId ( ) . equals ( object . getId ( ) ) || app . isRootApp ( ) ; } return false ; } | An app can edit itself or delete itself . It can t read edit overwrite or delete other apps unless it is the root app . |
36,318 | public static boolean checkIfUserCanModifyObject ( App app , ParaObject object ) { User user = SecurityUtils . getAuthenticatedUser ( ) ; if ( user != null && app != null && object != null ) { if ( app . permissionsContainOwnKeyword ( user , object ) ) { return user . canModify ( object ) ; } } return true ; } | Check if a user can modify an object . If there s no user principal found this returns true . |
36,319 | public static void clearSession ( HttpServletRequest req ) { SecurityContextHolder . clearContext ( ) ; if ( req != null ) { HttpSession session = req . getSession ( false ) ; if ( session != null ) { session . invalidate ( ) ; } } } | Clears the session . Deletes cookies and clears the security context . |
36,320 | public static boolean isValidJWToken ( String secret , SignedJWT jwt ) { try { if ( secret != null && jwt != null ) { JWSVerifier verifier = new MACVerifier ( secret ) ; if ( jwt . verify ( verifier ) ) { Date referenceTime = new Date ( ) ; JWTClaimsSet claims = jwt . getJWTClaimsSet ( ) ; Date expirationTime = claims ... | Validates a JWT token . |
36,321 | public static SignedJWT generateJWToken ( User user , App app ) { if ( app != null ) { try { Date now = new Date ( ) ; JWTClaimsSet . Builder claimsSet = new JWTClaimsSet . Builder ( ) ; String userSecret = "" ; claimsSet . issueTime ( now ) ; claimsSet . expirationTime ( new Date ( now . getTime ( ) + ( app . getToken... | Generates a new JWT token . |
36,322 | private static long getNextRefresh ( long tokenValiditySec ) { long interval = Config . JWT_REFRESH_INTERVAL_SEC ; if ( tokenValiditySec < ( 2 * interval ) ) { interval = ( tokenValiditySec / 2 ) ; } return System . currentTimeMillis ( ) + ( interval * 1000 ) ; } | Decides when the next token refresh should be . |
36,323 | public static String [ ] getOAuthKeysForApp ( App app , String prefix ) { prefix = StringUtils . removeEnd ( prefix + "" , Config . SEPARATOR ) ; String appIdKey = prefix + "_app_id" ; String secretKey = prefix + "_secret" ; String [ ] keys = new String [ ] { "" , "" } ; if ( app != null ) { Map < String , Object > set... | Return the OAuth app ID and secret key for a given app by reading the app settings or the config file . |
36,324 | public static Map < String , String > getLdapSettingsForApp ( App app ) { Map < String , String > ldapSettings = new HashMap < > ( ) ; if ( app != null ) { ldapSettings . put ( "security.ldap.server_url" , "ldap://localhost:8389/" ) ; ldapSettings . put ( "security.ldap.active_directory_domain" , "" ) ; ldapSettings . ... | Returns a map of LDAP configuration properties for a given app read from app . settings or config file . |
36,325 | public static String getSettingForApp ( App app , String key , String defaultValue ) { if ( app != null ) { Map < String , Object > settings = app . getSettings ( ) ; if ( settings . containsKey ( key ) ) { return String . valueOf ( settings . getOrDefault ( key , defaultValue ) ) ; } else if ( app . isRootApp ( ) ) { ... | Returns the value of the app setting read from from app . settings or from the config file if app is root . |
36,326 | public static UserAuthentication checkIfActive ( UserAuthentication userAuth , User user , boolean throwException ) { if ( userAuth == null || user == null || user . getIdentifier ( ) == null ) { if ( throwException ) { throw new BadCredentialsException ( "Bad credentials." ) ; } else { logger . debug ( "Bad credential... | Checks if account is active . |
36,327 | public static boolean isValidSignature ( HttpServletRequest incoming , String secretKey ) { if ( incoming == null || StringUtils . isBlank ( secretKey ) ) { return false ; } String auth = incoming . getHeader ( HttpHeaders . AUTHORIZATION ) ; String givenSig = StringUtils . substringAfter ( auth , "Signature=" ) ; Stri... | Validates the signature of the request . |
36,328 | public static void initialize ( ) { if ( isInitialized ) { return ; } isInitialized = true ; printLogo ( ) ; try { logger . info ( "--- Para.initialize() [{}] ---" , Config . ENVIRONMENT ) ; for ( InitializeListener initListener : INIT_LISTENERS ) { if ( initListener != null ) { initListener . onInitialize ( ) ; logger... | Executes all initialize listeners and prints logo . Call this method first . |
36,329 | public static void destroy ( ) { try { logger . info ( "--- Para.destroy() ---" ) ; for ( DestroyListener destroyListener : DESTROY_LISTENERS ) { if ( destroyListener != null ) { destroyListener . onDestroy ( ) ; logger . debug ( "Executed {}.onDestroy()." , destroyListener . getClass ( ) . getName ( ) ) ; } } if ( ! E... | Calls all registered listeners on exit . Call this method last . |
36,330 | public static Map < String , String > setup ( ) { return newApp ( Config . getRootAppIdentifier ( ) , Config . APP_NAME , false , false ) ; } | Creates the root application and returns the credentials for it . |
36,331 | public static Map < String , String > newApp ( String appid , String name , boolean sharedTable , boolean sharedIndex ) { Map < String , String > creds = new TreeMap < > ( ) ; creds . put ( "message" , "All set!" ) ; if ( StringUtils . isBlank ( appid ) ) { return creds ; } App app = new App ( appid ) ; if ( ! app . ex... | Creates a new application and returns the credentials for it . |
36,332 | public Map < String , String > readLanguage ( String appid , String langCode ) { if ( StringUtils . isBlank ( langCode ) || langCode . equals ( getDefaultLanguageCode ( ) ) ) { return getDefaultLanguage ( appid ) ; } else if ( langCode . length ( ) > 2 && ! ALL_LOCALES . containsKey ( langCode ) ) { return readLanguage... | Returns a map of all translations for a given language . Defaults to the default language which must be set . |
36,333 | public void writeLanguage ( String appid , String langCode , Map < String , String > lang , boolean writeToDatabase ) { if ( lang == null || lang . isEmpty ( ) || StringUtils . isBlank ( langCode ) || ! ALL_LOCALES . containsKey ( langCode ) ) { return ; } writeLanguageToFile ( appid , langCode , lang ) ; if ( writeToD... | Persists the language map in the data store . Overwrites any existing maps . |
36,334 | public Locale getProperLocale ( String langCode ) { if ( StringUtils . startsWith ( langCode , "zh" ) ) { if ( "zh_tw" . equalsIgnoreCase ( langCode ) ) { return Locale . TRADITIONAL_CHINESE ; } else { return Locale . SIMPLIFIED_CHINESE ; } } String lang = StringUtils . substring ( langCode , 0 , 2 ) ; lang = ( StringU... | Returns a non - null locale for a given language code . |
36,335 | public Map < String , String > getDefaultLanguage ( String appid ) { if ( ! LANG_CACHE . containsKey ( getDefaultLanguageCode ( ) ) ) { logger . info ( "Default language map not set, loading English." ) ; Map < String , String > deflang = readLanguageFromFile ( appid , getDefaultLanguageCode ( ) ) ; if ( deflang != nul... | Returns the default language map . |
36,336 | public void setDefaultLanguage ( Map < String , String > deflang ) { if ( deflang != null && ! deflang . isEmpty ( ) ) { LANG_CACHE . put ( getDefaultLanguageCode ( ) , deflang ) ; } } | Sets the default language map . It is the basis language template which is to be translated . |
36,337 | public List < Translation > readAllTranslationsForKey ( String appid , String locale , String key , Pager pager ) { Map < String , Object > terms = new HashMap < > ( 2 ) ; terms . put ( "thekey" , key ) ; terms . put ( "locale" , locale ) ; return search . findTerms ( appid , Utils . type ( Translation . class ) , term... | Returns a list of translations for a specific string . |
36,338 | public Set < String > getApprovedTransKeys ( String appid , String langCode ) { HashSet < String > approvedTransKeys = new HashSet < > ( ) ; if ( StringUtils . isBlank ( langCode ) ) { return approvedTransKeys ; } for ( Map . Entry < String , String > entry : readLanguage ( appid , langCode ) . entrySet ( ) ) { if ( ! ... | Returns the set of all approved translations . |
36,339 | public Map < String , Integer > getTranslationProgressMap ( String appid ) { if ( dao == null ) { return Collections . emptyMap ( ) ; } Sysprop progress ; if ( langProgressCache . getProperties ( ) . isEmpty ( ) ) { progress = dao . read ( appid , progressKey ) ; if ( progress != null ) { langProgressCache = progress ;... | Returns a map of language codes and the percentage of translated string for that language . |
36,340 | public boolean approveTranslation ( String appid , String langCode , String key , String value ) { if ( StringUtils . isBlank ( langCode ) || key == null || value == null || getDefaultLanguageCode ( ) . equals ( langCode ) ) { return false ; } Sysprop s = dao . read ( appid , keyPrefix . concat ( langCode ) ) ; boolean... | Approves a translation for a given language . |
36,341 | public boolean disapproveTranslation ( String appid , String langCode , String key ) { if ( StringUtils . isBlank ( langCode ) || key == null || getDefaultLanguageCode ( ) . equals ( langCode ) ) { return false ; } Sysprop s = dao . read ( appid , keyPrefix . concat ( langCode ) ) ; if ( s != null ) { String value = ge... | Disapproves a translation for a given language . |
36,342 | private void updateTranslationProgressMap ( String appid , String langCode , int value ) { if ( dao == null || getDefaultLanguageCode ( ) . equals ( langCode ) ) { return ; } double defsize = getDefaultLanguage ( appid ) . size ( ) ; double approved = value ; Map < String , Integer > progress = getTranslationProgressMa... | Updates the progress for all languages . |
36,343 | public Collection < ? extends GrantedAuthority > getAuthorities ( ) { if ( principal == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableCollection ( principal . getAuthorities ( ) ) ; } | A list of roles for the authenticated user . |
36,344 | protected boolean isRestRequest ( HttpServletRequest request ) { return RestRequestMatcher . INSTANCE . matches ( request ) || AjaxRequestMatcher . INSTANCE . matches ( request ) ; } | Checks if it is a rest request . |
36,345 | public UserDetails loadUserByUsername ( String ident ) { User user = new User ( ) ; if ( StringUtils . contains ( ident , "/" ) ) { String [ ] parts = ident . split ( "/" ) ; user . setAppid ( parts [ 0 ] ) ; ident = parts [ 1 ] ; } user . setIdentifier ( ident ) ; user = loadUser ( user ) ; if ( user == null ) { throw... | Loads a user from the data store . |
36,346 | public UserDetails loadUserDetails ( OpenIDAuthenticationToken token ) { if ( token == null ) { return null ; } User user = new User ( ) ; user . setIdentifier ( token . getIdentityUrl ( ) ) ; user = loadUser ( user ) ; if ( user == null ) { String email = "email@domain.com" ; String firstName = null , lastName = null ... | Loads a user from the data store or creates a new user from an OpenID profile . |
36,347 | protected void configure ( AuthenticationManagerBuilder auth ) throws Exception { OpenIDAuthenticationProvider openidProvider = new OpenIDAuthenticationProvider ( ) ; openidProvider . setAuthenticationUserDetailsService ( new SimpleUserService ( ) ) ; auth . authenticationProvider ( openidProvider ) ; RememberMeAuthent... | Configures the authentication providers . |
36,348 | public void configure ( WebSecurity web ) throws Exception { web . ignoring ( ) . requestMatchers ( IgnoredRequestMatcher . INSTANCE ) ; DefaultHttpFirewall firewall = new DefaultHttpFirewall ( ) ; firewall . setAllowUrlEncodedSlash ( true ) ; web . httpFirewall ( firewall ) ; } | Configures the unsecured public resources . |
36,349 | protected void configure ( HttpSecurity http ) throws Exception { ConfigObject protectedResources = Config . getConfig ( ) . getObject ( "security.protected" ) ; ConfigValue apiSec = Config . getConfig ( ) . getValue ( "security.api_security" ) ; boolean enableRestFilter = apiSec != null && Boolean . TRUE . equals ( ap... | Configures the protected private resources . |
36,350 | public static boolean matches ( Class < ? extends Annotation > anno , String consName ) { return VALIDATORS . get ( anno ) . equals ( consName ) ; } | Verifies that the given annotation type corresponds to a known constraint . |
36,351 | public static Constraint fromAnnotation ( Annotation anno ) { if ( anno instanceof Min ) { return min ( ( ( Min ) anno ) . value ( ) ) ; } else if ( anno instanceof Max ) { return max ( ( ( Max ) anno ) . value ( ) ) ; } else if ( anno instanceof Size ) { return size ( ( ( Size ) anno ) . min ( ) , ( ( Size ) anno ) . ... | Builds a new constraint from the annotation data . |
36,352 | static Map < String , Object > simplePayload ( final String name ) { if ( name == null ) { return null ; } Map < String , Object > payload = new LinkedHashMap < > ( ) ; payload . put ( "message" , MSG_PREFIX + name ) ; return payload ; } | Creates a new map representing a simple validation constraint . |
36,353 | public static Constraint required ( ) { return new Constraint ( "required" , simplePayload ( "required" ) ) { public boolean isValid ( Object actualValue ) { return ! ( actualValue == null || StringUtils . isBlank ( actualValue . toString ( ) ) ) ; } } ; } | The required constraint - marks a field as required . |
36,354 | public static Constraint min ( final Number min ) { return new Constraint ( "min" , minPayload ( min ) ) { public boolean isValid ( Object actualValue ) { return actualValue == null || ( actualValue instanceof Number && min != null && min . longValue ( ) <= ( ( Number ) actualValue ) . longValue ( ) ) ; } } ; } | The min constraint - field must contain a number larger than or equal to min . |
36,355 | public static Constraint max ( final Number max ) { return new Constraint ( "max" , maxPayload ( max ) ) { public boolean isValid ( Object actualValue ) { return actualValue == null || ( actualValue instanceof Number && max != null && max . longValue ( ) >= ( ( Number ) actualValue ) . longValue ( ) ) ; } } ; } | The max constraint - field must contain a number smaller than or equal to max . |
36,356 | public static Constraint pattern ( final Object regex ) { return new Constraint ( "pattern" , patternPayload ( regex ) ) { public boolean isValid ( Object actualValue ) { if ( actualValue != null ) { if ( regex != null && regex instanceof String ) { if ( ! ( actualValue instanceof String ) || ! ( ( String ) actualValue... | The pattern constraint - field must contain a value matching a regular expression . |
36,357 | public static Constraint email ( ) { return new Constraint ( "email" , simplePayload ( "email" ) ) { public boolean isValid ( Object actualValue ) { if ( actualValue != null ) { if ( ! ( actualValue instanceof String ) || ! Utils . isValidEmail ( ( String ) actualValue ) ) { return false ; } } return true ; } } ; } | The email constraint - field must contain a valid email . |
36,358 | public static Constraint truthy ( ) { return new Constraint ( "true" , simplePayload ( "true" ) ) { public boolean isValid ( Object actualValue ) { if ( actualValue != null ) { if ( ( actualValue instanceof Boolean && ! ( ( Boolean ) actualValue ) ) || ( actualValue instanceof String && ! Boolean . parseBoolean ( ( Str... | The truthy constraint - field value must be equal to true . |
36,359 | public static Constraint url ( ) { return new Constraint ( "url" , simplePayload ( "url" ) ) { public boolean isValid ( Object actualValue ) { if ( actualValue != null ) { if ( ! Utils . isValidURL ( actualValue . toString ( ) ) ) { return false ; } } return true ; } } ; } | The url constraint - field value must be a valid URL . |
36,360 | public static Constraint build ( String cname , Map < String , Object > payload ) { if ( cname != null && payload != null ) { if ( "min" . equals ( cname ) && payload . containsKey ( "value" ) ) { return min ( NumberUtils . toLong ( payload . get ( "value" ) + "" , 0 ) ) ; } else if ( "max" . equals ( cname ) && payloa... | Builds a new constraint from a given name and payload . |
36,361 | public Collection < ? extends GrantedAuthority > getAuthorities ( ) { if ( user . isAdmin ( ) ) { return Collections . singleton ( new SimpleGrantedAuthority ( Roles . ADMIN . toString ( ) ) ) ; } else if ( user . isModerator ( ) ) { return Collections . singleton ( new SimpleGrantedAuthority ( Roles . MOD . toString (... | A list of roles for this user . |
36,362 | public static Map < String , String > getCoreTypes ( ) { if ( CORE_TYPES . isEmpty ( ) ) { try { for ( Class < ? extends ParaObject > clazz : getCoreClassesMap ( ) . values ( ) ) { ParaObject p = clazz . getConstructor ( ) . newInstance ( ) ; CORE_TYPES . put ( p . getPlural ( ) , p . getType ( ) ) ; } } catch ( Except... | Returns a map of the core data types . |
36,363 | public static Map < String , String > getAllTypes ( App app ) { Map < String , String > map = new LinkedHashMap < > ( getCoreTypes ( ) ) ; if ( app != null ) { map . putAll ( app . getDatatypes ( ) ) ; } return map ; } | Returns a map of all registered types . |
36,364 | public static String getAppidFromAuthHeader ( String authorization ) { if ( StringUtils . isBlank ( authorization ) ) { return "" ; } String appid = "" ; if ( StringUtils . startsWith ( authorization , "Bearer" ) ) { try { String [ ] parts = StringUtils . split ( authorization , '.' ) ; if ( parts . length > 1 ) { Map ... | Returns the app identifier by parsing the Authorization . |
36,365 | public static boolean typesMatch ( ParaObject so ) { return ( so == null ) ? false : so . getClass ( ) . equals ( toClass ( so . getType ( ) ) ) ; } | Checks if the type of an object matches its real Class name . |
36,366 | public static < P extends ParaObject > P toObject ( String type ) { try { return ( P ) toClass ( type ) . getConstructor ( ) . newInstance ( ) ; } catch ( Exception ex ) { logger . error ( null , ex ) ; return null ; } } | Constructs a new instance of a core object . |
36,367 | public static < P extends ParaObject > String toJSON ( P obj ) { if ( obj == null ) { return "{}" ; } try { return getJsonWriter ( ) . writeValueAsString ( obj ) ; } catch ( Exception e ) { logger . error ( null , e ) ; } return "{}" ; } | Converts a domain object to JSON . |
36,368 | public void flushBuffer ( ) throws IOException { if ( this . printWriter != null ) { this . printWriter . flush ( ) ; } if ( this . gzipOutputStream != null ) { this . gzipOutputStream . flush ( ) ; } if ( ! disableFlushBuffer ) { super . flushBuffer ( ) ; } } | Flush OutputStream or PrintWriter . |
36,369 | public void flush ( ) throws IOException { if ( printWriter != null ) { printWriter . flush ( ) ; } if ( gzipOutputStream != null ) { gzipOutputStream . flush ( ) ; } } | Flushes all the streams for this response . |
36,370 | public static final String id ( String id ) { if ( StringUtils . startsWith ( id , PREFIX ) ) { return PREFIX . concat ( Utils . noSpaces ( Utils . stripAndTrim ( id . replaceAll ( PREFIX , "" ) , " " ) , "-" ) ) ; } else if ( id != null ) { return PREFIX . concat ( Utils . noSpaces ( Utils . stripAndTrim ( id , " " ) ... | Returns the correct id of this app with prefix . |
36,371 | public App addSetting ( String name , Object value ) { if ( ! StringUtils . isBlank ( name ) && value != null ) { getSettings ( ) . put ( name , value ) ; for ( AppSettingAddedListener listener : ADD_SETTING_LISTENERS ) { listener . onSettingAdded ( this , name , value ) ; logger . debug ( "Executed {}.onSettingAdded()... | Adds a new setting to the map . |
36,372 | public Object getSetting ( String name ) { if ( ! StringUtils . isBlank ( name ) ) { return getSettings ( ) . get ( name ) ; } return null ; } | Returns the value of a setting for a given key . |
36,373 | public App removeSetting ( String name ) { if ( ! StringUtils . isBlank ( name ) ) { Object result = getSettings ( ) . remove ( name ) ; if ( result != null ) { for ( AppSettingRemovedListener listener : REMOVE_SETTING_LISTENERS ) { listener . onSettingRemoved ( this , name ) ; logger . debug ( "Executed {}.onSettingRe... | Removes a setting from the map . |
36,374 | public Map < String , Map < String , Map < String , Map < String , ? > > > > getValidationConstraints ( ) { if ( validationConstraints == null ) { validationConstraints = new LinkedHashMap < > ( ) ; } return validationConstraints ; } | Returns a map of user - defined data types and their validation annotations . |
36,375 | public void setValidationConstraints ( Map < String , Map < String , Map < String , Map < String , ? > > > > validationConstraints ) { this . validationConstraints = validationConstraints ; } | Sets the validation constraints map . |
36,376 | public Map < String , Map < String , List < String > > > getResourcePermissions ( ) { if ( resourcePermissions == null ) { resourcePermissions = new LinkedHashMap < > ( ) ; } return resourcePermissions ; } | Returns a map of resource permissions . |
36,377 | public void setResourcePermissions ( Map < String , Map < String , List < String > > > resourcePermissions ) { this . resourcePermissions = resourcePermissions ; } | Sets the permissions map . |
36,378 | @ SuppressWarnings ( "unchecked" ) public Map < String , String > getDatatypes ( ) { if ( datatypes == null ) { datatypes = new DualHashBidiMap ( ) ; } return datatypes ; } | Returns a set of custom data types for this app . An app can have many custom types which describe its domain . |
36,379 | public Map < String , Map < String , Map < String , Map < String , ? > > > > getAllValidationConstraints ( String ... types ) { Map < String , Map < String , Map < String , Map < String , ? > > > > allConstr = new LinkedHashMap < > ( ) ; if ( types == null || types . length == 0 ) { types = ParaObjectUtils . getAllType... | Returns all validation constraints for a list of types . |
36,380 | public boolean addValidationConstraint ( String type , String field , Constraint c ) { if ( ! StringUtils . isBlank ( type ) && ! StringUtils . isBlank ( field ) && c != null && ! c . getPayload ( ) . isEmpty ( ) && Constraint . isValidConstraintName ( c . getName ( ) ) ) { Map < String , Map < String , Map < String , ... | Adds a new constraint to the list of constraints for a given field and type . |
36,381 | public boolean removeValidationConstraint ( String type , String field , String constraintName ) { if ( ! StringUtils . isBlank ( type ) && ! StringUtils . isBlank ( field ) && constraintName != null ) { Map < String , Map < String , Map < String , ? > > > fieldsMap = getValidationConstraints ( ) . get ( type ) ; if ( ... | Removes a constraint from the map . |
36,382 | public Map < String , Map < String , List < String > > > getAllResourcePermissions ( String ... subjectids ) { Map < String , Map < String , List < String > > > allPermits = new LinkedHashMap < > ( ) ; if ( subjectids == null || subjectids . length == 0 ) { return getResourcePermissions ( ) ; } try { for ( String subje... | Returns all resource permission for a list of subjects ids . |
36,383 | public boolean revokeResourcePermission ( String subjectid , String resourcePath ) { if ( ! StringUtils . isBlank ( subjectid ) && getResourcePermissions ( ) . containsKey ( subjectid ) && ! StringUtils . isBlank ( resourcePath ) ) { resourcePath = Utils . urlDecode ( resourcePath ) ; getResourcePermissions ( ) . get (... | Revokes a permission for given subject . |
36,384 | public boolean revokeAllResourcePermissions ( String subjectid ) { if ( ! StringUtils . isBlank ( subjectid ) && getResourcePermissions ( ) . containsKey ( subjectid ) ) { getResourcePermissions ( ) . remove ( subjectid ) ; return true ; } return false ; } | Revokes all permissions for a subject id . |
36,385 | final boolean isDeniedExplicitly ( String subjectid , String resourcePath , String httpMethod ) { if ( StringUtils . isBlank ( subjectid ) || StringUtils . isBlank ( resourcePath ) || StringUtils . isBlank ( httpMethod ) || getResourcePermissions ( ) . isEmpty ( ) ) { return false ; } resourcePath = Utils . urlDecode (... | Check if a subject is explicitly denied access to a resource . |
36,386 | public boolean permissionsContainOwnKeyword ( User user , ParaObject object ) { if ( user == null || object == null ) { return false ; } String resourcePath1 = object . getType ( ) ; String resourcePath2 = object . getObjectURI ( ) . substring ( 1 ) ; String resourcePath3 = object . getPlural ( ) ; return hasOwnKeyword... | Check if the permissions map contains OWN keyword which restricts access to objects to their creators . |
36,387 | public void addDatatype ( String pluralDatatype , String datatype ) { pluralDatatype = Utils . noSpaces ( Utils . stripAndTrim ( pluralDatatype , " " ) , "-" ) ; datatype = Utils . noSpaces ( Utils . stripAndTrim ( datatype , " " ) , "-" ) ; if ( StringUtils . isBlank ( pluralDatatype ) || StringUtils . isBlank ( datat... | Adds a user - defined data type to the types map . |
36,388 | public Map < String , String > getCredentials ( ) { if ( getId ( ) == null ) { return Collections . emptyMap ( ) ; } else { Map < String , String > keys = new LinkedHashMap < String , String > ( 2 ) ; keys . put ( "accessKey" , getId ( ) ) ; keys . put ( "secretKey" , getSecret ( ) ) ; return keys ; } } | Returns the map containing the app s access key and secret key . |
36,389 | public static void init ( com . typesafe . config . Config conf ) { try { config = ConfigFactory . load ( ) . getConfig ( PARA ) ; if ( conf != null ) { config = conf . withFallback ( config ) ; } configMap = new HashMap < > ( ) ; for ( Map . Entry < String , ConfigValue > con : config . entrySet ( ) ) { if ( con . get... | Initializes the configuration class by loading the configuration file . |
36,390 | public static boolean getConfigBoolean ( String key , boolean defaultValue ) { return Boolean . parseBoolean ( getConfigParam ( key , Boolean . toString ( defaultValue ) ) ) ; } | Returns the boolean value of a configuration parameter . |
36,391 | public static int getConfigInt ( String key , int defaultValue ) { return NumberUtils . toInt ( getConfigParam ( key , Integer . toString ( defaultValue ) ) ) ; } | Returns the integer value of a configuration parameter . |
36,392 | public static double getConfigDouble ( String key , double defaultValue ) { return NumberUtils . toDouble ( getConfigParam ( key , Double . toString ( defaultValue ) ) ) ; } | Returns the double value of a configuration parameter . |
36,393 | public static com . typesafe . config . Config getConfig ( ) { if ( config == null ) { init ( null ) ; } return config ; } | Returns the Config object . |
36,394 | public void saveRequest ( HttpServletRequest request , HttpServletResponse response ) { if ( anyRequestMatcher . matches ( request ) && ! ajaxRequestMatcher . matches ( request ) ) { DefaultSavedRequest savedRequest = new DefaultSavedRequest ( request , portResolver ) ; HttpUtils . setStateParam ( Config . RETURNTO_COO... | Saves a request in cache . |
36,395 | public void removeRequest ( HttpServletRequest request , HttpServletResponse response ) { HttpUtils . removeStateParam ( Config . RETURNTO_COOKIE , request , response ) ; } | Removes a saved request from cache . |
36,396 | public Object invoke ( MethodInvocation mi ) throws Throwable { if ( ! Modifier . isPublic ( mi . getMethod ( ) . getModifiers ( ) ) ) { return mi . proceed ( ) ; } Method searchMethod = mi . getMethod ( ) ; Object [ ] args = mi . getArguments ( ) ; String appid = AOPUtils . getFirstArgOfString ( args ) ; Method superM... | Executes code when a method is invoked . |
36,397 | public static void removeStateParam ( String name , HttpServletRequest req , HttpServletResponse res ) { setRawCookie ( name , "" , req , res , false , 0 ) ; } | Deletes a cookie . |
36,398 | public static String getCookieValue ( HttpServletRequest req , String name ) { if ( StringUtils . isBlank ( name ) || req == null ) { return null ; } Cookie [ ] cookies = req . getCookies ( ) ; if ( cookies == null ) { return null ; } for ( Cookie cookie : cookies ) { if ( cookie . getName ( ) . equals ( name ) ) { ret... | Reads a cookie . |
36,399 | public List < OpenIDAttribute > createAttributeList ( String identifier ) { List < OpenIDAttribute > list = new LinkedList < > ( ) ; if ( identifier != null && identifier . matches ( "https://www.google.com/.*" ) ) { OpenIDAttribute email = new OpenIDAttribute ( "email" , "http://axschema.org/contact/email" ) ; OpenIDA... | A list of OpenID attributes to send in a request . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.