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 " + raml . getTitle ( ) ) ; try { File output = getRamlOutputFile ( source ) ; FileUtils . write ( output , ramlEmitter . dump ( raml ) ) ; getLog ( ) . info ( "Created the RAML description for " + source . getName ( ) + " => " + output . getAbsolutePath ( ) ) ; } catch ( IOException ie ) { throw new WatchingException ( "Cannot create raml file" , source , ie ) ; } catch ( IllegalArgumentException e ) { throw new WatchingException ( "Cannot create Controller Element from" , e ) ; } }
|
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 ( basedir , outputDirectory ) ; } return new File ( outDir , ramlFileName ) ; }
|
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 ( ) ) ; } return result ; }
|
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 ( ) ; } else { try { addTemplate ( bundle , templateFile . toURI ( ) . toURL ( ) ) ; } catch ( MalformedURLException e ) { } } }
|
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 , assets , bundle ) ; } ServiceRegistration < Template > reg = context . registerService ( Template . class , template , template . getServiceProperties ( ) ) ; registrations . put ( template , reg ) ; LOGGER . debug ( "Thymeleaf template added for {}" , templateURL . toExternalForm ( ) ) ; return template ; }
|
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 configuration: mode={}, ttl={}" , mode , ttl ) ; final ClassLoader orig = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( this . getClass ( ) . getClassLoader ( ) ) ; engine = new WisdomTemplateEngine ( dialects ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( orig ) ; } TemplateResolver resolver = new TemplateResolver ( ) ; resolver . setResourceResolver ( new WisdomURLResourceResolver ( this ) ) ; resolver . setTemplateMode ( mode ) ; resolver . setCacheTTLMs ( ( long ) ttl ) ; engine . setTemplateResolver ( resolver ) ; engine . setMessageResolver ( messageResolver ) ; engine . initialize ( ) ; }
|
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 template : getTemplates ( ) ) { ( ( ThymeLeafTemplateImplementation ) template ) . updateEngine ( engine ) ; } } }
|
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 ( ) ) { ( ( ThymeLeafTemplateImplementation ) template ) . updateEngine ( engine ) ; } } }
|
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 ( ) . endsWith ( resourceName + "." + extension ( ) ) ) { return template ; } if ( template . name ( ) . equals ( resourceName ) ) { return template ; } } return null ; }
|
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 ( ) ; clearMethodCaches ( ) ; }
|
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 = populatePropertiesWithDefaults ( basedir , instructions , scanner ) ; } else { String noDefaultValue = fromBnd . getProperty ( "-no-default" ) ; if ( ! "true" . equalsIgnoreCase ( noDefaultValue ) ) { instructions = Instructions . mergeAndOverrideExisting ( instructions , populatePropertiesWithDefaults ( basedir , fromBnd , scanner ) ) ; } else { instructions = Instructions . mergeAndOverrideExisting ( instructions , fromBnd ) ; } } DependencyEmbedder ed = new DependencyEmbedder ( instructions , reporter ) ; instructions = ed . generate ( instructions , org . wisdom . maven . osgi . Classpath . load ( basedir ) ) ; instructions = mergeExtraHeaders ( basedir , instructions ) ; FileOutputStream fos = null ; try { File out = new File ( basedir , "target/osgi/instructions.properties" ) ; fos = new FileOutputStream ( out ) ; instructions . store ( fos , "Wisdom BND Instructions" ) ; } catch ( IOException e ) { } finally { IOUtils . closeQuietly ( fos ) ; } final Jar [ ] jars = org . wisdom . maven . osgi . Classpath . computeClassPath ( basedir ) ; File bnd ; File ipojo ; Builder builder = null ; try { builder = getOSGiBuilder ( basedir , instructions , jars ) ; builder . build ( ) ; builder . analyze ( ) ; builder . build ( ) ; reportErrors ( builder . getWarnings ( ) , builder . getErrors ( ) , reporter ) ; bnd = File . createTempFile ( "bnd-" , ".jar" ) ; ipojo = File . createTempFile ( "ipojo-" , ".jar" ) ; builder . getJar ( ) . write ( bnd ) ; } catch ( Exception e ) { throw new IOException ( "Cannot build the OSGi bundle" , e ) ; } finally { if ( builder != null ) { builder . close ( ) ; } } final Set < String > elements = org . wisdom . maven . osgi . Classpath . computeClassPathElement ( basedir ) ; Classpath classpath = new Classpath ( elements ) ; Pojoization pojoization = new Pojoization ( ) ; pojoization . pojoization ( bnd , ipojo , new File ( basedir , "src/main/resources" ) , classpath . createClassLoader ( ) ) ; reportErrors ( pojoization . getWarnings ( ) , pojoization . getErrors ( ) , reporter ) ; Files . move ( Paths . get ( ipojo . getPath ( ) ) , Paths . get ( output . getPath ( ) ) , StandardCopyOption . REPLACE_EXISTING ) ; }
|
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 != null ) { props . setProperty ( header , value ) ; } else { props . remove ( header ) ; } FileOutputStream fos = null ; try { fos = new FileOutputStream ( extra ) ; props . store ( fos , "" ) ; } finally { IOUtils . closeQuietly ( fos ) ; } }
|
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 > pathSet = new LinkedHashSet < > ( ) ; for ( String name : files ) { String path = target + '/' + name ; if ( path . startsWith ( basePath ) ) { if ( path . length ( ) == basePath . length ( ) ) { path = "." ; } else { path = path . substring ( basePath . length ( ) + 1 ) ; } } if ( File . separatorChar != '/' ) { name = name . replace ( File . separatorChar , '/' ) ; path = path . replace ( File . separatorChar , '/' ) ; } path = name + '=' + path ; pathSet . add ( path ) ; } return Joiner . on ( ", " ) . join ( pathSet ) ; }
|
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 . UTF_8 ) ; } return new ByteArrayInputStream ( bytes ) ; }
|
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 == null ) { token = context . session ( ) . get ( getTokenName ( ) ) ; } if ( token != null && isSignedToken ( ) ) { return crypto . signToken ( crypto . extractSignedToken ( token ) ) ; } else { return 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 ( getCookieName ( ) ) ; if ( cookie != null ) { return result . with ( Cookie . builder ( cookie ) . setValue ( newToken ) . build ( ) ) ; } else { return result . with ( Cookie . cookie ( getCookieName ( ) , newToken ) . setSecure ( isSecureCookie ( ) ) . setPath ( getCookiePath ( ) ) . setDomain ( getCookieDomain ( ) ) . setMaxAge ( 3600 ) . build ( ) ) ; } } else { context . session ( ) . put ( getTokenName ( ) , newToken ) ; return result ; } }
|
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 . request ( ) . contentType ( ) . startsWith ( MimeTypes . MULTIPART ) ) { List < String > list = context . form ( ) . get ( getTokenName ( ) ) ; if ( list != null && ! list . isEmpty ( ) ) { return list . get ( 0 ) ; } } } return token ; }
|
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 { context . session ( ) . remove ( getTokenName ( ) ) ; } return error ; }
|
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 ; default : return "UNKNOWN (" + Integer . toString ( state ) + ")" ; } }
|
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 Bundle . UNINSTALLED ; default : return - 1 ; } }
|
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 == NONNUMERIC ) { localt1 = DOUBLE ; } if ( localt2 == NONNUMERIC ) { localt2 = DOUBLE ; } if ( localt1 >= MIN_REAL_TYPE ) { if ( localt2 >= MIN_REAL_TYPE ) return Math . max ( localt1 , localt2 ) ; if ( localt2 < INT ) return localt1 ; if ( localt2 == BIGINT ) return BIGDEC ; return Math . max ( DOUBLE , localt1 ) ; } else if ( localt2 >= MIN_REAL_TYPE ) { if ( localt1 < INT ) return localt2 ; if ( localt1 == BIGINT ) return BIGDEC ; return Math . max ( DOUBLE , localt2 ) ; } else return Math . max ( localt1 , localt2 ) ; }
|
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 ServiceModel ( ref ) ) ; } } } catch ( InvalidSyntaxException e ) { } return services ; }
|
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 ) ; } } catch ( IOException e ) { throw new MojoExecutionException ( "Error while processing a Markdown file" , e ) ; } }
|
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 ( FileUtils . readFileToString ( filtered ) ) ; FileUtils . write ( getOutputFile ( input , "html" ) , result ) ; }
|
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 ? conf . getConfiguration ( "schedulers." + ManagedScheduledExecutorService . SYSTEM ) : null ) ; if ( conf != null ) { createOtherExecutors ( conf . getConfiguration ( "executors" ) ) ; createOtherSchedulers ( conf . getConfiguration ( "schedulers" ) ) ; } }
|
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 ( logger ) ) ; } return ok ( loggers ) . json ( ) ; }
|
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 ( logger != null ) { logger ( ) . info ( "Setting the log level of {} to {}" , loggerName , level ) ; ( ( ch . qos . logback . classic . Logger ) logger ) . setLevel ( Level . toLevel ( level ) ) ; return loggers ( ) ; } else { logger ( ) . warn ( "Cannot set the level of logger {} - the logger does not exist" , loggerName ) ; return notFound ( ) ; } }
|
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 ( controller ) ; newRoutes . addAll ( annotatedNewRoutes ) ; newRoutes . addAll ( controller . routes ( ) ) ; ensureNoConflicts ( newRoutes ) ; } catch ( RoutingException e ) { LOGGER . error ( "The controller {} declares routes conflicting with existing routes, " + "the controller is ignored, reason: {}" , controller , e . getMessage ( ) , e ) ; routes . removeAll ( newRoutes ) ; } catch ( Exception e ) { LOGGER . error ( "The controller {} declares invalid routes, " + "the controller is ignored, reason: {}" , controller , e . getMessage ( ) , e ) ; routes . removeAll ( newRoutes ) ; } }
|
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 ) ) { routes . remove ( r ) ; } } }
|
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 , params ) ; } } return null ; }
|
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 . getExtends ( ) != null ) { hierarchy . addAll ( declaration . getExtends ( ) ) ; } if ( declaration . getImplements ( ) != null ) { hierarchy . addAll ( declaration . getImplements ( ) ) ; } return containsClassName ( hierarchy , CONTROL_CLASSNAMES ) ; }
|
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 . equalsIgnoreCase ( connection ) ; } else { return KEEP_ALIVE . equalsIgnoreCase ( connection ) ; } }
|
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 ( ) . getContentSerializerForContentType ( result . getContentType ( ) ) ; } if ( serializer == null ) { serializer = accessor . getContentEngines ( ) . getBestSerializer ( context . request ( ) . mediaTypes ( ) ) ; if ( serializer != null ) { result . with ( HeaderNames . CONTENT_TYPE , serializer . getContentType ( ) ) ; } } if ( serializer != null ) { serializer . serialize ( renderable ) ; } else { LoggerFactory . getLogger ( HttpHandler . class ) . error ( "Cannot find a serializer to handle the request (explicit content type: {}, " + "accept media types: {}), returning content as String" , result . getContentType ( ) , context . request ( ) . mediaTypes ( ) ) ; if ( renderable . content ( ) != null ) { renderable . setSerializedForm ( renderable . content ( ) . toString ( ) ) ; result . with ( HeaderNames . CONTENT_TYPE , "text/plain" ) ; } else { renderable = NoHttpBody . INSTANCE ; result . with ( HeaderNames . CONTENT_TYPE , "text/plain" ) ; } } } return renderable . render ( context , result ) ; }
|
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 ( ) ; String sign = value . substring ( 0 , value . indexOf ( '-' ) ) ; String payload = value . substring ( value . indexOf ( '-' ) + 1 ) ; if ( CookieDataCodec . safeEquals ( sign , crypto . sign ( payload ) ) ) { CookieDataCodec . decode ( data , payload ) ; } else { LOGGER . warn ( "Invalid session cookie - signature check failed" ) ; } if ( ! data . containsKey ( TIMESTAMP_KEY ) ) { data . clear ( ) ; } else { if ( Long . parseLong ( data . get ( TIMESTAMP_KEY ) ) + sessionExpireTimeInMs < System . currentTimeMillis ( ) ) { sessionDataHasBeenChanged = true ; data . clear ( ) ; } } data . put ( TIMESTAMP_KEY , Long . toString ( System . currentTimeMillis ( ) ) ) ; } } catch ( UnsupportedEncodingException unsupportedEncodingException ) { LOGGER . error ( "Encoding exception - this must not happen" , unsupportedEncodingException ) ; } }
|
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 ( ) ; async . exceptionHandler ( new Handler < Throwable > ( ) { public void handle ( Throwable event ) { LoggerFactory . getLogger ( this . getClass ( ) . getName ( ) ) . error ( "Cannot write into {}" , file . getAbsolutePath ( ) , event ) ; } } ) ; async . write ( buffer ) ; Pump . pump ( upload , async ) . start ( ) ; upload . resume ( ) ; } } ) ; } }
|
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 . getMimeTypeByExtension ( ext ) ; if ( mime == null ) { return BINARY ; } else { return mime ; } } }
|
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 . class . getName ( ) ) ; } VertxOptions options = new VertxOptions ( ) ; boolean clustered = false ; if ( configuration != null ) { clustered = configuration . getBooleanWithDefault ( "clustered" , false ) ; options = new VertxOptions ( new JsonObject ( configuration . asMap ( ) ) ) ; if ( clustered ) { options . setClustered ( true ) . setClusterHost ( configuration . getOrDie ( "cluster-host" ) ) ; String clusterConfig = configuration . getWithDefault ( "cluster-config" , "conf/cluster.xml" ) ; System . setProperty ( "hazelcast.config" , new File ( clusterConfig ) . getAbsolutePath ( ) ) ; } } final ClassLoader tccl = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( this . getClass ( ) . getClassLoader ( ) ) ; Hashtable < String , Object > properties = new Hashtable < > ( ) ; if ( clustered ) { options . setClusterManager ( new HazelcastClusterManager ( ) ) ; String host = options . getClusterHost ( ) ; properties . put ( "eventbus.host" , host ) ; Vertx . clusteredVertx ( options , ar -> { if ( ar . failed ( ) ) { throw new IllegalStateException ( "Cannot join cluster" , ar . cause ( ) ) ; } vertx = ar . result ( ) ; vertxRegistration = context . registerService ( Vertx . class , vertx , properties ) ; busRegistration = context . registerService ( EventBus . class , vertx . eventBus ( ) , properties ) ; } ) ; } else { vertx = Vertx . vertx ( options ) ; vertxRegistration = context . registerService ( Vertx . class , vertx , properties ) ; busRegistration = context . registerService ( EventBus . class , vertx . eventBus ( ) , properties ) ; } } finally { Thread . currentThread ( ) . setContextClassLoader ( tccl ) ; } }
|
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 key = sanitize ( entry . getKey ( ) ) ; if ( ! properties . containsKey ( key ) ) { sanitizedEntries . setProperty ( key , sanitize ( entry . getValue ( ) ) ) ; } itr . remove ( ) ; } else if ( ! ( entry . getValue ( ) instanceof String ) ) { entry . setValue ( sanitize ( entry . getValue ( ) ) ) ; } } properties . putAll ( sanitizedEntries ) ; return properties ; }
|
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 " + pid . getName ( ) + " file still exists after having stopped the " + "Wisdom instance - check log" ) ; } }
|
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 { Thread . currentThread ( ) . setContextClassLoader ( this . getClass ( ) . getClassLoader ( ) ) ; if ( config . isFile ( ) ) { manager = CacheManager . create ( config . getAbsolutePath ( ) ) ; } else { URL url = EhCacheService . class . getClassLoader ( ) . getResource ( INTERNAL_CONFIGURATION ) ; if ( url != null ) { manager = CacheManager . create ( url ) ; } else { throw new ExceptionInInitializerError ( "Cannot instantiate EhCache, " + "cannot load " + INTERNAL_CONFIGURATION + " file" ) ; } } manager . addCache ( WISDOM_KEY ) ; cache = manager . getCache ( WISDOM_KEY ) ; registration = context . registerService ( Cache . class , this , new Hashtable < String , Object > ( ) ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( original ) ; } }
|
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 ( ) , extensions ) ) ; return files ; }
|
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 ( ) ) ; } setDependencyFilter ( new ExcludesArtifactFilter ( ids ) ) ; } }
|
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 runtimeDirectory = new File ( mojo . getWisdomRootDirectory ( ) , "runtime" ) ; File coreDirectory = new File ( mojo . getWisdomRootDirectory ( ) , "core" ) ; Set < Artifact > artifacts = getArtifactsToConsider ( mojo , graph , transitive , null ) ; for ( Artifact artifact : artifacts ) { if ( ! disableDefaultExclusions && BundleExclusions . isExcluded ( artifact ) ) { mojo . getLog ( ) . info ( "Dependency " + artifact + " not copied - the artifact is on the exclusion list" ) ; continue ; } if ( SCOPE_COMPILE . equalsIgnoreCase ( artifact . getScope ( ) ) || deployTestDependencies && SCOPE_TEST . equalsIgnoreCase ( artifact . getScope ( ) ) ) { File file = artifact . getFile ( ) ; if ( file == null || ! file . getName ( ) . endsWith ( ".jar" ) ) { mojo . getLog ( ) . info ( "Dependency " + artifact + " not copied - it does not look like a jar " + "file" ) ; continue ; } File test = new File ( coreDirectory , file . getName ( ) ) ; if ( test . exists ( ) ) { mojo . getLog ( ) . info ( "Dependency " + file . getName ( ) + " not copied - already existing in `core`" ) ; continue ; } test = new File ( runtimeDirectory , file . getName ( ) ) ; if ( test . exists ( ) ) { mojo . getLog ( ) . info ( "Dependency " + file . getName ( ) + " not copied - already existing in `runtime`" ) ; continue ; } if ( libraries != null && libraries . hasLibraries ( ) && libraries . isExcludeFromApplication ( ) ) { if ( ! libraries . getReverseFilter ( ) . include ( artifact ) ) { mojo . getLog ( ) . info ( "Dependency " + file . getName ( ) + " not copied - excluded from the " + "libraries settings" ) ; continue ; } } if ( isBundle ( file ) ) { File destination = new File ( applicationDirectory , DefaultMaven2OsgiConverter . getBundleFileName ( artifact ) ) ; mojo . getLog ( ) . info ( "Dependency " + file . getName ( ) + " is a bundle, " + "artifact copied to " + destination . getAbsolutePath ( ) ) ; FileUtils . copyFile ( file , destination , true ) ; } else { mojo . getLog ( ) . debug ( "Dependency " + file . getName ( ) + " is not a bundle" ) ; } } } }
|
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 ( mojo , graph , filter ) ; } return artifacts ; }
|
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 . buildDependencyGraph ( mojo . project , filter ) ; node . accept ( new ArtifactVisitor ( mojo , transitives ) ) ; mojo . getLog ( ) . debug ( transitives . size ( ) + " transitive dependencies have been collected : " + transitives ) ; Set < Artifact > resolved = mojo . project . getArtifacts ( ) ; for ( Artifact a : transitives ) { Artifact r = getArtifact ( a , resolved ) ; if ( r == null ) { mojo . getLog ( ) . warn ( "Cannot find resolved artifact for " + a ) ; } else { artifacts . add ( r ) ; } } } catch ( DependencyGraphBuilderException e ) { mojo . getLog ( ) . error ( "Cannot traverse the project's dependencies to collect transitive dependencies, " + "ignoring transitive" ) ; mojo . getLog ( ) . debug ( "Here is the thrown exception having disabled the transitive dependency collection" , e ) ; artifacts = mojo . project . getDependencyArtifacts ( ) ; } return artifacts ; }
|
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 . context ( ) ) ; return csrf . addTokenToResult ( context . context ( ) , token , context . proceed ( ) ) ; } else { return context . proceed ( ) ; } }
|
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 ( "Description" ) ; raml . setDocumentation ( singletonList ( doc ) ) ; } if ( element . getVersion ( ) != null && ! element . getVersion ( ) . isEmpty ( ) ) { raml . setVersion ( element . getVersion ( ) ) ; } navigateTheRoutes ( element . getRoutes ( ) , null , raml ) ; }
|
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.