final Path resource = Paths.convert( pathCollectionEntry.getKey() );
checkNotNull( "type", type );
checkNotNull( "resource", resource );
final BuildValidationHelper validator = getBuildValidationHelper( resource );
final String destinationPath = resource.toUri().toString().substring( projectPrefix.length() + 1 );
changedFilesKieBuilderPaths.add( destinationPath );
switch ( type ) {
case ADD:
case UPDATE:
//Only files can be processed
if ( !Files.isRegularFile( resource ) ) {
continue;
}
final InputStream is = ioService.newInputStream( resource );
final BufferedInputStream bis = new BufferedInputStream( is );
kieFileSystem.write( destinationPath,
KieServices.Factory.get().getResources().newInputStreamResource( bis ) );
addJavaClass( resource );
handles.put( destinationPath,
pathCollectionEntry.getKey() );
//Resource Type might require "external" validation (i.e. it's not covered by Kie)
if ( validator != null ) {
nonKieResourceValidationHelpers.put( resource,
validator );
final List<ValidationMessage> addedValidationMessages = validator.validate( Paths.convert( resource ) );
if ( !( addedValidationMessages == null || addedValidationMessages.isEmpty() ) ) {
for ( ValidationMessage validationMessage : addedValidationMessages ) {
nonKieResourceValidatorAddedMessages.add( validationMessage );
}
}