idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
2,000 | public void controllerParsed ( File source , ControllerModel < Raml > model ) throws WatchingException { Raml raml = new Raml ( ) ; raml . setBaseUri ( baseUri ) ; raml . setVersion ( project ( ) . getVersion ( ) ) ; model . accept ( controllerVisitor , raml ) ; getLog ( ) . info ( "Create raml file for controller " + ... | Generate the raml file from a given controller source file . |
2,001 | private File getRamlOutputFile ( File input ) { String ramlFileName = input . getName ( ) . substring ( 0 , input . getName ( ) . length ( ) - 4 ) + "raml" ; File outDir ; if ( outputDirectory == null ) { outDir = new File ( WatcherUtils . getExternalAssetsDestination ( basedir ) , "raml" ) ; } else { outDir = new File... | Create the . raml file from the java source file . |
2,002 | public CommandResult exec ( String commandLine ) { CommandResult result = new CommandResult ( RESULT ) ; try { Object raw = shellSession . execute ( commandLine ) ; if ( raw != null ) { result . setContent ( format ( raw ) ) ; } } catch ( Exception e ) { result . setType ( ERR ) ; result . setContent ( e . getMessage (... | Execute a command on the gogo shell . |
2,003 | private String format ( Object o ) { return shellSession . format ( o , Converter . INSPECT ) . toString ( ) ; } | Format the given object as a String . |
2,004 | private void checkSize ( long newSize , long maxSize , HttpServerFileUpload upload ) { if ( maxSize >= 0 && newSize > maxSize ) { upload . handler ( null ) ; report ( new IllegalStateException ( "Size exceed allowed maximum capacity" ) ) ; } } | Checks whether we exceed the max allowed file size . |
2,005 | public void updatedTemplate ( Bundle bundle , File templateFile ) { ThymeLeafTemplateImplementation template = getTemplateByFile ( templateFile ) ; if ( template != null ) { LOGGER . debug ( "Thymeleaf template updated for {} ({})" , templateFile . getAbsoluteFile ( ) , template . fullName ( ) ) ; updatedTemplate ( ) ;... | Updates the template object using the given file as backend . |
2,006 | private ThymeLeafTemplateImplementation getTemplateByFile ( File templateFile ) { try { return getTemplateByURL ( templateFile . toURI ( ) . toURL ( ) ) ; } catch ( MalformedURLException e ) { } return null ; } | Gets the template object using the given file as backend . |
2,007 | private ThymeLeafTemplateImplementation getTemplateByURL ( URL url ) { Collection < ThymeLeafTemplateImplementation > list = registrations . keySet ( ) ; for ( ThymeLeafTemplateImplementation template : list ) { if ( template . getURL ( ) . sameFile ( url ) ) { return template ; } } return null ; } | Gets the template object using the given url as backend . |
2,008 | public void deleteTemplate ( File templateFile ) { ThymeLeafTemplateImplementation template = getTemplateByFile ( templateFile ) ; if ( template != null ) { deleteTemplate ( template ) ; } } | Deletes the template using the given file as backend . |
2,009 | public ThymeLeafTemplateImplementation addTemplate ( Bundle bundle , URL templateURL ) { ThymeLeafTemplateImplementation template = getTemplateByURL ( templateURL ) ; if ( template != null ) { return template ; } synchronized ( this ) { template = new ThymeLeafTemplateImplementation ( engine , templateURL , router , as... | Adds a template form the given url . |
2,010 | public synchronized void configure ( ) { String mode = configuration . getWithDefault ( "application.template.thymeleaf.mode" , "HTML5" ) ; int ttl = configuration . getIntegerWithDefault ( "application.template.thymeleaf.ttl" , 60 * 1000 ) ; if ( configuration . isDev ( ) ) { ttl = 1 ; } LOGGER . debug ( "Thymeleaf co... | Initializes the thymeleaf template engine . |
2,011 | @ Bind ( optional = true , aggregate = true ) public synchronized void bindDialect ( IDialect dialect ) { LOGGER . debug ( "Binding a new dialect using the prefix '{}' and containing {}" , dialect . getPrefix ( ) , dialect . getProcessors ( ) ) ; if ( this . dialects . add ( dialect ) ) { configure ( ) ; for ( Template... | A new dialect is now available . |
2,012 | public synchronized void unbindDialect ( IDialect dialect ) { LOGGER . debug ( "Binding a new dialect {}, processors: {}" , dialect . getPrefix ( ) , dialect . getProcessors ( ) ) ; if ( this . dialects . remove ( dialect ) ) { configure ( ) ; for ( Template template : getTemplates ( ) ) { ( ( ThymeLeafTemplateImplemen... | A dialect has left . |
2,013 | public ThymeLeafTemplateImplementation getTemplateByResourceName ( String resourceName ) { Collection < ThymeLeafTemplateImplementation > list = registrations . keySet ( ) ; for ( ThymeLeafTemplateImplementation template : list ) { if ( template . fullName ( ) . endsWith ( resourceName ) || template . fullName ( ) . en... | Finds a template object from the given resource name . The first template matching the given name is returned . |
2,014 | public void deleteTemplate ( ThymeLeafTemplateImplementation template ) { try { ServiceRegistration reg = registrations . remove ( template ) ; if ( reg != null ) { reg . unregister ( ) ; } } catch ( Exception e ) { } synchronized ( this ) { engine . getCacheManager ( ) . clearAllCaches ( ) ; } OgnlRuntime . clearCache... | Deletes the given template . The service is unregistered and the cache is cleared . |
2,015 | public static void bundle ( File basedir , File output , Reporter reporter ) throws IOException { ProjectScanner scanner = new ProjectScanner ( basedir ) ; Properties instructions = readMavenProperties ( basedir ) ; Properties fromBnd = readInstructionsFromBndFile ( basedir ) ; if ( fromBnd == null ) { instructions = p... | Creates the bundle . |
2,016 | private static Properties mergeExtraHeaders ( File baseDir , Properties properties ) throws IOException { File extra = new File ( baseDir , EXTRA_HEADERS_FILE ) ; return Instructions . merge ( properties , extra ) ; } | If a bundle has added extra headers they are added to the bundle manifest . |
2,017 | public static void addExtraHeaderToBundleManifest ( File baseDir , String header , String value ) throws IOException { Properties props = new Properties ( ) ; File extra = new File ( baseDir , EXTRA_HEADERS_FILE ) ; extra . getParentFile ( ) . mkdirs ( ) ; props = Instructions . merge ( props , extra ) ; if ( value != ... | This method is used by plugin willing to add custom header to the bundle manifest . |
2,018 | public static String getLocalResources ( File basedir , boolean test , ProjectScanner scanner ) { final String basePath = basedir . getAbsolutePath ( ) ; String target = "target/classes" ; if ( test ) { target = "target/test-classes" ; } Set < String > files = scanner . getLocalResources ( test ) ; Set < String > pathS... | Gets local resources . |
2,019 | public void onFileCreate ( File file ) { try { engine . addTemplate ( context . getBundle ( 0 ) , file . toURI ( ) . toURL ( ) ) ; } catch ( MalformedURLException e ) { LOGGER . error ( "Cannot compute the url of file {}" , file . getAbsolutePath ( ) , e ) ; } } | Callback called when an accepted file is created . |
2,020 | public List < String > headers ( String name ) { return request . headers ( ) . get ( name ) ; } | Get all the request headers with the given name . |
2,021 | public String cookieValue ( String name ) { return CookieHelper . getCookieValue ( name , request ( ) . cookies ( ) ) ; } | Get the cookie value from the request if defined . |
2,022 | public BufferedReader reader ( ) throws IOException { byte [ ] raw = request . getRawBody ( ) ; if ( raw != null ) { return IOUtils . toBufferedReader ( new InputStreamReader ( new ByteArrayInputStream ( raw ) ) ) ; } return null ; } | Gets the reader to read the request . |
2,023 | public void route ( Route route ) { Preconditions . checkState ( this . route == null ) ; Preconditions . checkNotNull ( route ) ; this . route = route ; } | Sets the route associated with the current context . |
2,024 | public FileItem file ( String name ) { for ( FileItem item : request . getFiles ( ) ) { if ( item . field ( ) . equals ( name ) && ! Strings . isNullOrEmpty ( item . name ( ) ) ) { return item ; } } return null ; } | Gets the uploaded file having a form s field matching the given name . |
2,025 | public InputStream render ( Context context , Result result ) throws RenderableException { byte [ ] bytes ; if ( result != null ) { if ( result . getCharset ( ) == null ) { result . with ( Charsets . UTF_8 ) ; } bytes = rendered . getBytes ( result . getCharset ( ) ) ; } else { bytes = rendered . getBytes ( Charsets . ... | Retrieves the content . |
2,026 | public String extractTokenFromRequest ( Context context ) { String token = ( String ) context . request ( ) . data ( ) . get ( TOKEN_KEY ) ; if ( token == null && getCookieName ( ) != null ) { Cookie cookie = context . cookie ( getCookieName ( ) ) ; if ( cookie != null ) { token = cookie . value ( ) ; } } if ( token ==... | Extracts the token from the request . This implementation checks in the request data then in the CORS cookie if any and finally in the session cookie . If the token is signed it resigns it to avoid the BREACH vulnerability . |
2,027 | public Result addTokenToResult ( Context context , String newToken , Result result ) { if ( isCached ( context ) ) { LOGGER . debug ( "Not adding token to a cached result" ) ; return result ; } LOGGER . debug ( "Adding token to result" ) ; if ( getCookieName ( ) != null ) { Cookie cookie = context . cookie ( getCookieN... | Methods adding the CORS token to the given result . The effect depends on the configuration . |
2,028 | public boolean compareTokens ( String a , String b ) { if ( isSignedToken ( ) ) { return crypto . compareSignedTokens ( a , b ) ; } else { return crypto . constantTimeEquals ( a , b ) ; } } | Compares to token . |
2,029 | public String extractTokenFromContent ( Context context ) { String token = context . request ( ) . parameter ( getTokenName ( ) ) ; if ( token == null ) { token = context . header ( CSRF_TOKEN_HEADER ) ; } if ( token == null ) { if ( context . request ( ) . contentType ( ) . startsWith ( MimeTypes . FORM ) || context .... | Extracts the token from the content of the request . This implementation checks inside the headers and inside form body . |
2,030 | public Result clearTokenIfInvalid ( Context context , String msg ) { Result error = handler . onError ( context , msg ) ; final String cookieName = getCookieName ( ) ; if ( cookieName != null ) { Cookie cookie = context . cookie ( cookieName ) ; if ( cookie != null ) { return error . without ( cookieName ) ; } } else {... | Clears the token from the request |
2,031 | public static String from ( int state ) { switch ( state ) { case Bundle . ACTIVE : return ACTIVE ; case Bundle . INSTALLED : return INSTALLED ; case Bundle . RESOLVED : return RESOLVED ; case Bundle . STARTING : return STARTING ; case Bundle . STOPPING : return STOPPING ; case Bundle . UNINSTALLED : return UNINSTALLED... | Gets the String form of the given OSGi bundle state . |
2,032 | public static int from ( String state ) { switch ( state . toUpperCase ( ) ) { case ACTIVE : return Bundle . ACTIVE ; case INSTALLED : return Bundle . INSTALLED ; case RESOLVED : return Bundle . RESOLVED ; case STARTING : return Bundle . STARTING ; case STOPPING : return Bundle . STOPPING ; case UNINSTALLED : return Bu... | Gets the OSGi state from the string form . |
2,033 | public static int getNumericType ( int t1 , int t2 , boolean canBeNonNumeric ) { int localt1 = t1 ; int localt2 = t2 ; if ( localt1 == localt2 ) return localt1 ; if ( canBeNonNumeric && ( localt1 == NONNUMERIC || localt2 == NONNUMERIC || localt1 == CHAR || localt2 == CHAR ) ) return NONNUMERIC ; if ( localt1 == NONNUME... | Returns the constant from the NumericTypes interface that best expresses the type of an operation which can be either numeric or not on the two given types . |
2,034 | public void publish ( byte [ ] message , EventBus bus ) { bus . publish ( getBinaryWriteHandlerId ( ) , Buffer . buffer ( message ) ) ; } | Sends a binary frame on the socket . |
2,035 | public static List < ServiceModel > services ( BundleContext context ) { List < ServiceModel > services = new ArrayList < > ( ) ; try { ServiceReference [ ] references = context . getAllServiceReferences ( null , null ) ; if ( references != null ) { for ( ServiceReference ref : references ) { services . add ( new Servi... | Creates the list of service models from the list of the currently available services . |
2,036 | public Enumeration < String > getKeys ( ) { Set < String > handleKeys = properties . stringPropertyNames ( ) ; return Collections . enumeration ( handleKeys ) ; } | Gets the keys from the wrapped properties . |
2,037 | public Logger logger ( ) { if ( logger == null ) { logger = LoggerFactory . getLogger ( this . getClass ( ) . getName ( ) ) ; } return logger ; } | Retrieves the logger usable by the controller . If the logger does not exist yet get one . |
2,038 | public InputStream render ( Context context , Result result ) throws RenderableException { try { return FileUtils . openInputStream ( file ) ; } catch ( IOException e ) { throw new RenderableException ( "Cannot read file " + file . getAbsolutePath ( ) , e ) ; } } | Renders the file . If just returns an empty stream on the served file . |
2,039 | public boolean accept ( File file ) { return WatcherUtils . isInDirectory ( file , WatcherUtils . getJavaSource ( basedir ) ) ; } | Checks whether or not an event on the given file should trigger the Java compilation . |
2,040 | public void execute ( ) throws MojoExecutionException { if ( extensions == null || extensions . isEmpty ( ) ) { extensions = ImmutableList . of ( "md" , "markdown" ) ; } if ( instance == null ) { instance = new PegDownProcessor ( Extensions . ALL ) ; } try { for ( File f : getResources ( extensions ) ) { process ( f ) ... | Compiles all markdown files located in the internal and external asset directories . |
2,041 | public void process ( File input ) throws IOException { File filtered = getFilteredVersion ( input ) ; if ( filtered == null ) { getLog ( ) . warn ( "Cannot find the filtered version of " + input . getAbsolutePath ( ) + ", " + "using source file." ) ; filtered = input ; } String result = instance . markdownToHtml ( Fil... | Processes the given markdown file . When the filtered version of the file exists it uses it . |
2,042 | public boolean fileDeleted ( File file ) { File output = getOutputFile ( file , OUTPUT_EXTENSION ) ; FileUtils . deleteQuietly ( output ) ; return true ; } | An accepted file was deleted - deletes the output file . |
2,043 | @ Route ( method = HttpMethod . GET , uri = BROWSER_WATCH_BUNDLES ) public Result bundles ( ) { return ok ( render ( template ) ) ; } | Simple test route showing all loaded bundles and the route of the current one |
2,044 | @ Opened ( BROWSER_WATCH_SOCKET ) public void addedClient ( @ Parameter ( "client" ) String client ) { log . log ( LogService . LOG_INFO , String . format ( "added client %s" , client ) ) ; } | When a client is added we get the service it should be associated with using the route resoluton mechanism wisdom provides us |
2,045 | @ Closed ( BROWSER_WATCH_SOCKET ) public void removedClient ( @ Parameter ( "client" ) String client ) { displayedControllers . inverse ( ) . remove ( client ) ; } | And when client leaves stop notifying it |
2,046 | public void start ( ) { Configuration conf = configuration . getConfiguration ( "pools" ) ; createExecutor ( ManagedExecutorService . SYSTEM , conf != null ? conf . getConfiguration ( "executors." + ManagedExecutorService . SYSTEM ) : null ) ; createScheduler ( ManagedScheduledExecutorService . SYSTEM , conf != null ? ... | Creates the system executors and the others specified executors . |
2,047 | public void stop ( ) { for ( Map . Entry < ServiceRegistration , ExecutorService > entry : instances . entrySet ( ) ) { entry . getKey ( ) . unregister ( ) ; entry . getValue ( ) . shutdownNow ( ) ; } instances . clear ( ) ; } | Shutdown all created executors . |
2,048 | @ Route ( method = HttpMethod . GET , uri = "/monitor/logs/loggers" ) public Result loggers ( ) { LoggerContext context = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; List < LoggerModel > loggers = new ArrayList < > ( ) ; for ( Logger logger : context . getLoggerList ( ) ) { loggers . add ( new LoggerModel... | Gets a json form of the list of logger . |
2,049 | @ Route ( method = HttpMethod . PUT , uri = "/monitor/logs/{name}" ) public Result setLevel ( @ Parameter ( "name" ) String loggerName , @ Parameter ( "level" ) String level ) { LoggerContext context = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; Logger logger = context . getLogger ( loggerName ) ; if ( lo... | Changes the log level of the specified logger . |
2,050 | public void write ( int b ) throws IOException { byte [ ] bytes = new byte [ 1 ] ; bytes [ 0 ] = ( byte ) ( b & 0xff ) ; buffer = buffer + new String ( bytes ) ; if ( buffer . endsWith ( "\n" ) ) { buffer = buffer . substring ( 0 , buffer . length ( ) - 1 ) ; flush ( ) ; } } | Writes a byte to the output stream . This method flushes automatically at the end of a line . |
2,051 | public void flush ( ) { if ( useWarn ) { log . warn ( buffer ) ; } else { log . info ( buffer ) ; } if ( memory != null ) { memory += buffer + "\n" ; } buffer = "" ; } | Flushes the output stream . |
2,052 | @ Bind ( aggregate = true , optional = true ) public synchronized void bindController ( Controller controller ) { LOGGER . info ( "Adding routes from " + controller ) ; List < Route > newRoutes = new ArrayList < > ( ) ; try { List < Route > annotatedNewRoutes = RouteUtils . collectRouteFromControllerAnnotations ( contr... | Binds a new controller . |
2,053 | @ Unbind ( aggregate = true ) public synchronized void unbindController ( Controller controller ) { LOGGER . info ( "Removing routes from " + controller ) ; Collection < RouteDelegate > copy = new LinkedHashSet < > ( routes ) ; for ( RouteDelegate r : copy ) { if ( r . getControllerObject ( ) . equals ( controller ) ) ... | Unbinds a controller . |
2,054 | public String getReverseRouteFor ( String className , String method , Map < String , Object > params ) { for ( Route route : copy ( ) ) { if ( route . getControllerClass ( ) . getName ( ) . equals ( className ) && route . getControllerMethod ( ) . getName ( ) . equals ( method ) ) { return computeUrlForRoute ( route , ... | Gets the URL that would invoke the given action method . |
2,055 | @ Bind ( aggregate = true , optional = true ) public void bindFilter ( Filter filter ) { filters . add ( filter ) ; } | Binds a filter . |
2,056 | public Boolean visit ( ClassOrInterfaceDeclaration declaration , Object extra ) { if ( declaration . getAnnotations ( ) != null && containsAnnotation ( declaration . getAnnotations ( ) , CONTROL_ANNO_NAME ) ) { return true ; } List < ClassOrInterfaceType > hierarchy = new ArrayList < > ( ) ; if ( declaration . getExten... | Visit the Class declaration and return true if it corresponds to a wisdom controller . |
2,057 | private boolean containsAnnotation ( List < AnnotationExpr > annos , String annotationName ) { for ( AnnotationExpr anno : annos ) { if ( anno . getName ( ) . getName ( ) . equals ( annotationName ) ) { return true ; } } return false ; } | Check if the list of annotation contains the annotation of given name . |
2,058 | public static boolean isKeepAlive ( HttpServerRequest request ) { String connection = request . headers ( ) . get ( HeaderNames . CONNECTION ) ; if ( connection != null && connection . equalsIgnoreCase ( CLOSE ) ) { return false ; } if ( request . version ( ) == HttpVersion . HTTP_1_1 ) { return ! CLOSE . equalsIgnoreC... | Checks whether the given request should be closed or not once completed . |
2,059 | public static InputStream processResult ( ServiceAccessor accessor , Context context , Renderable renderable , Result result ) throws Exception { if ( renderable . requireSerializer ( ) ) { ContentSerializer serializer = null ; if ( result . getContentType ( ) != null ) { serializer = accessor . getContentEngines ( ) .... | Processes the given result . This method returns either the rendered renderable but also applies required serialization if any . |
2,060 | public void init ( Context context ) { try { Cookie cookie = context . request ( ) . cookie ( applicationCookiePrefix + SESSION_SUFFIX ) ; if ( cookie != null && cookie . value ( ) != null && ! "" . equals ( cookie . value ( ) . trim ( ) ) && cookie . value ( ) . contains ( "-" ) ) { String value = cookie . value ( ) ;... | Has to be called initially . |
2,061 | public void execute ( ) throws MojoExecutionException { if ( watchFilter == null ) { removeFromWatching ( ) ; } NPM . npm ( this , name , version ) . execute ( binary != null ? binary : name , arguments ) ; } | Installs and executes the NPM . |
2,062 | public boolean accept ( File file ) { WildcardFileFilter filter = new WildcardFileFilter ( watchFilter ) ; return filter . accept ( file ) ; } | If the watcher has a filter set creates a wildcard filter and test the file name against this filter . |
2,063 | public boolean fileCreated ( File file ) throws WatchingException { try { execute ( ) ; } catch ( MojoExecutionException e ) { throw new WatchingException ( "Cannot execute the NPM '" + name + "'" , e ) ; } return true ; } | An accepted file was created - executes the NPM . |
2,064 | public static String getPrimitiveDefault ( Class type ) { if ( type == Boolean . class ) { return "false" ; } if ( type == Character . class ) { return Character . toString ( ( char ) 0 ) ; } return "0" ; } | Gets the default value as String for the primitive types . |
2,065 | public String asset ( String path ) { Asset asset = assets . assetAt ( path ) ; if ( asset == null ) { if ( path . startsWith ( "/" ) ) { return asset ( path . substring ( 1 ) ) ; } throw new TemplateProcessingException ( "Cannot find the URL of the asset " + path ) ; } return asset . getPath ( ) ; } | Gets the url of the given asset . Throws an exception if the asset cannot be found . |
2,066 | public void push ( final Buffer buffer ) { if ( async == null ) { upload . pause ( ) ; vertx . fileSystem ( ) . open ( file . getAbsolutePath ( ) , new OpenOptions ( ) . setCreate ( true ) , new Handler < AsyncResult < AsyncFile > > ( ) { public void handle ( AsyncResult < AsyncFile > event ) { async = event . result (... | A new chunk has arrived save it on disk . |
2,067 | public static String getMimeTypeForFile ( URL url ) { if ( url == null ) { return null ; } String external = url . toExternalForm ( ) ; if ( external . indexOf ( '.' ) == - 1 ) { return BINARY ; } else { String ext = external . substring ( external . lastIndexOf ( '.' ) + 1 ) ; String mime = KnownMimeTypes . getMimeTyp... | Makes an educated guess of the mime type of the resource pointed by this url . It tries to extract an extension part and confronts this extension to the list of known extensions . |
2,068 | public void start ( ) { final Configuration configuration = appConfiguration . getConfiguration ( "vertx" ) ; String log = System . getProperty ( "org.vertx.logger-delegate-factory-class-name" ) ; if ( log == null ) { System . setProperty ( "org.vertx.logger-delegate-factory-class-name" , SLF4JLogDelegateFactory . clas... | Creates and exposed the instance of Vert . X . |
2,069 | public void stop ( ) throws InterruptedException { unregisterQuietly ( vertxRegistration ) ; unregisterQuietly ( busRegistration ) ; CountDownLatch latch = new CountDownLatch ( 1 ) ; vertx . close ( v -> latch . countDown ( ) ) ; latch . await ( ) ; vertx = null ; } | Unregisters and shuts down the Vert . X singleton . |
2,070 | public Asset assetAt ( String path ) { for ( AssetProvider provider : providers ) { Asset asset = provider . assetAt ( path ) ; if ( asset != null ) { return asset ; } } return null ; } | Gets the path to retrieve the asset identified by its file name . |
2,071 | public Collection < Asset < ? > > assets ( boolean useCache ) { if ( useCache && ! cache . isEmpty ( ) ) { return new ArrayList < > ( cache ) ; } return assets ( ) ; } | Retrieve the list of all asset currently available on the platform . |
2,072 | public static Properties sanitize ( Properties properties ) { Properties sanitizedEntries = new Properties ( ) ; for ( Iterator < ? > itr = properties . entrySet ( ) . iterator ( ) ; itr . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) itr . next ( ) ; if ( ! ( entry . getKey ( ) instanceof String ) ) { String k... | Utility method to sanitize the set of instructions . |
2,073 | public Result render ( Object object ) { if ( object instanceof Renderable ) { this . content = ( Renderable < ? > ) object ; } else { this . content = new RenderableObject ( object ) ; } return this ; } | Sets the content of the current result to the given object . |
2,074 | public Result with ( String headerName , String headerContent ) { headers . put ( headerName , headerContent ) ; return this ; } | Sets a header . If this header was already set the value is overridden . |
2,075 | public Result discard ( String name ) { Cookie cookie = getCookie ( name ) ; if ( cookie != null ) { cookies . remove ( cookie ) ; cookies . add ( Cookie . builder ( cookie ) . setMaxAge ( 0 ) . build ( ) ) ; } else { cookies . add ( Cookie . builder ( name , "" ) . setMaxAge ( 0 ) . build ( ) ) ; } return this ; } | Discards the given cookie . The cookie max - age is set to 0 so is going to be invalidated . |
2,076 | public Result redirect ( String url ) { status ( Status . SEE_OTHER ) ; with ( HeaderNames . LOCATION , url ) ; return this ; } | A redirect that uses 303 - SEE OTHER . |
2,077 | public Result redirectTemporary ( String url ) { status ( Status . TEMPORARY_REDIRECT ) ; with ( HeaderNames . LOCATION , url ) ; return this ; } | A redirect that uses 307 see other . |
2,078 | private Context current ( boolean fail ) { Context context = Context . CONTEXT . get ( ) ; if ( context == null && fail ) { throw new IllegalStateException ( "No context" ) ; } return context ; } | Convenient method to retrieve the current HTTP context . |
2,079 | public void execute ( ) throws MojoExecutionException { new WisdomExecutor ( ) . stop ( this ) ; File pid = new File ( getWisdomRootDirectory ( ) , "RUNNING_PID" ) ; if ( WisdomExecutor . waitForFileDeletion ( pid ) ) { getLog ( ) . info ( "Wisdom server stopped." ) ; } else { throw new MojoExecutionException ( "The " ... | Tries to stops the running Wisdom server . |
2,080 | public void start ( ) { Boolean enabled = configuration . getBooleanWithDefault ( "ehcache.enabled" , true ) ; if ( ! enabled ) { return ; } File config = new File ( configuration . getBaseDir ( ) , CUSTOM_CONFIGURATION ) ; final ClassLoader original = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thre... | Creates the EhCache - based implementation of the Cache Service . |
2,081 | public void stop ( ) { if ( registration != null ) { registration . unregister ( ) ; registration = null ; } if ( manager != null ) { manager . removeCache ( WISDOM_KEY ) ; } } | Cleans up everything . |
2,082 | public void set ( String key , Object value , int expiration ) { Element element = new Element ( key , value ) ; if ( expiration == 0 ) { element . setEternal ( true ) ; } element . setTimeToLive ( expiration ) ; cache . put ( element ) ; } | Adds an entry in the cache . |
2,083 | public Object get ( String key ) { Element element = cache . get ( key ) ; if ( element != null ) { return element . getObjectValue ( ) ; } return null ; } | Gets an entry from the cache . |
2,084 | public Collection < File > getResources ( List < String > extensions ) { List < File > files = new ArrayList < > ( ) ; files . addAll ( WatcherUtils . getAllFilesFromDirectory ( getInternalAssetsDirectory ( ) , extensions ) ) ; files . addAll ( WatcherUtils . getAllFilesFromDirectory ( getExternalAssetsDirectory ( ) , ... | Finds all resources from internal and external assets directories having one of the specified extensions . |
2,085 | public File getFilteredVersion ( File input ) { File out = getOutputFile ( input ) ; if ( ! out . isFile ( ) ) { return null ; } return out ; } | Searches if the given file has already being copied to its output directory and so may have been filtered . |
2,086 | public static boolean isValid ( Artifact artifact ) { return artifact . getGroupId ( ) != null && ! FAKE . equals ( artifact . getGroupId ( ) ) ; } | Ensures that the given artifact was correctly populated . |
2,087 | public static Collection < ? extends Artifact > filter ( Collection < Artifact > artifacts ) { LinkedHashSet < Artifact > set = new LinkedHashSet < > ( ) ; for ( Artifact artifact : artifacts ) { if ( MavenArtifact . isValid ( artifact ) ) { set . add ( artifact ) ; } } return set ; } | Removes non valid artifacts from the given list . |
2,088 | public void setDependencyFilter ( ObjectNode filter ) { if ( filter == null ) { return ; } final JsonNode patterns = filter . get ( "patterns" ) ; if ( patterns != null && patterns . isArray ( ) ) { List < String > ids = new ArrayList < > ( ) ; for ( JsonNode exclusion : patterns ) { ids . add ( exclusion . asText ( ) ... | A setter method made especially for Jackson . Artifact s dependency filter is used for the exclusion list . As the filter cannot be created directly by Jackson we do the job directly here . |
2,089 | public String get ( String key , Object ... args ) { String value = bundle . getString ( key ) ; if ( args . length != 0 ) { value = MessageFormat . format ( value , args ) ; } return value ; } | Gets the localized message for the given key . |
2,090 | public Set < String > keys ( ) { Set < String > list = new LinkedHashSet < > ( ) ; Enumeration < String > keys = bundle . getKeys ( ) ; while ( keys . hasMoreElements ( ) ) { list . add ( keys . nextElement ( ) ) ; } return list ; } | Gets the keys contained in the bundle . |
2,091 | public static void copyBundles ( AbstractWisdomMojo mojo , DependencyGraphBuilder graph , boolean transitive , boolean deployTestDependencies , boolean disableDefaultExclusions , Libraries libraries ) throws IOException { File applicationDirectory = new File ( mojo . getWisdomRootDirectory ( ) , "application" ) ; File ... | Copies dependencies that are bundles to the application directory . If the bundle is already in core or runtime the bundle is not copied . |
2,092 | public static Set < Artifact > getArtifactsToConsider ( AbstractWisdomMojo mojo , DependencyGraphBuilder graph , boolean transitive , ArtifactFilter filter ) { Set < Artifact > artifacts ; if ( ! transitive ) { artifacts = mojo . project . getDependencyArtifacts ( ) ; } else { artifacts = getTransitiveDependencies ( mo... | Gets the list of artifact to consider during the analysis . |
2,093 | private static Set < Artifact > getTransitiveDependencies ( AbstractWisdomMojo mojo , DependencyGraphBuilder graph , ArtifactFilter filter ) { Set < Artifact > artifacts ; artifacts = new LinkedHashSet < > ( ) ; try { Set < Artifact > transitives = new LinkedHashSet < > ( ) ; DependencyNode node = graph . buildDependen... | Collects the transitive dependencies of the current projects . |
2,094 | public Result call ( AddCSRFToken configuration , RequestContext context ) throws Exception { if ( csrf . eligibleForCSRF ( context . context ( ) ) && ( csrf . extractTokenFromRequest ( context . context ( ) ) == null || configuration . newTokenOnEachRequest ( ) ) ) { String token = csrf . generateToken ( context . con... | Injects a CSRF token into the result if the request is eligible . |
2,095 | public void start ( ) { if ( directory . isDirectory ( ) ) { buildFileIndex ( ) ; } if ( tracker != null ) { tracker . open ( ) ; } if ( deployer != null ) { deployer . start ( ) ; } } | Starts the controllers . |
2,096 | public void stop ( ) { if ( deployer != null ) { deployer . stop ( ) ; } if ( tracker != null ) { tracker . close ( ) ; } libraries . clear ( ) ; } | Stops the controllers . |
2,097 | public void modifiedBundle ( Bundle bundle , BundleEvent bundleEvent , List < BundleWebJarLib > webJarLibs ) { synchronized ( this ) { removedBundle ( bundle , bundleEvent , webJarLibs ) ; addingBundle ( bundle , bundleEvent ) ; } } | A bundle is updated . |
2,098 | public void removedBundle ( Bundle bundle , BundleEvent bundleEvent , List < BundleWebJarLib > webJarLibs ) { removeWebJarLibs ( webJarLibs ) ; } | A bundle is removed . |
2,099 | public void visit ( ControllerModel element , Raml raml ) { raml . setTitle ( element . getName ( ) ) ; if ( element . getDescription ( ) != null && ! element . getDescription ( ) . isEmpty ( ) ) { DocumentationItem doc = new DocumentationItem ( ) ; doc . setContent ( element . getDescription ( ) ) ; doc . setTitle ( "... | Visit the Wisdom Controller source model in order to populate the raml model . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.