Example #1
0
 public KieFileSystem write(String path, Resource resource) {
   try {
     return write(path, readBytesFromInputStream(resource.getInputStream()));
   } catch (IOException e) {
     throw new RuntimeException("Unable to write Resource: " + resource.toString(), e);
   }
 }
Example #2
0
 public KieFileSystem write(Resource resource) {
   try {
     String target =
         resource.getTargetPath() != null ? resource.getTargetPath() : resource.getSourcePath();
     if (target != null) {
       write(RESOURCE_PATH_PREFIX + target, readBytesFromInputStream(resource.getInputStream()));
       ResourceConfiguration conf = resource.getConfiguration();
       if (conf != null) {
         Properties prop = ResourceTypeImpl.toProperties(conf);
         ByteArrayOutputStream buff = new ByteArrayOutputStream();
         prop.store(buff, "Configuration properties for resource: " + target);
         write(RESOURCE_PATH_PREFIX + target + ".properties", buff.toByteArray());
       }
       return this;
     } else {
       throw new RuntimeException(
           "Resource does not have neither a source nor a target path. Impossible to add it to the bundle. Please set either the source or target name of the resource before adding it."
               + resource.toString());
     }
   } catch (IOException e) {
     throw new RuntimeException("Unable to write Resource: " + resource.toString(), e);
   }
 }