@Override
 public Resource createNew(
     String newName, InputStream inputStream, Long length, String contentType) throws IOException {
   log.debug("createNew");
   if (contentType.startsWith("text/calendar")) {
     TEvent e = new TEvent(this, newName);
     log.debug("created tevent: " + e.name);
     ICalFormatter formatter = new ICalFormatter();
     ByteArrayOutputStream bout = new ByteArrayOutputStream();
     StreamUtils.readTo(inputStream, bout);
     bout.close();
     String data = bout.toString();
     e.setiCalData(data);
     return e;
   } else {
     throw new RuntimeException("eek");
     // log.debug( "creating a normal resource");
     // return super.createNew( newName, inputStream, length, contentType );
   }
 }
Exemple #2
0
  private Result deploySimple(String deployUrl, Folder currentFolder)
      throws MalformedURLException, IOException, Exception {
    URL url = new URL(deployUrl);

    try (InputStream in = url.openStream();
        BufferedInputStream bufIn = new BufferedInputStream(in)) {
      VfsTransactionManager.setRollbackOnly(true);
      Path path = Path.path(url.getPath());
      File deployWar = File.createTempFile("ettrema-deploy", path.getName());
      try (FileOutputStream fout = new FileOutputStream(deployWar);
          BufferedOutputStream bufOut = new BufferedOutputStream(fout)) {
        StreamUtils.readTo(bufIn, bufOut);
        bufOut.flush();
        fout.flush();
      }
      String deployName = findDeployName(path);
      deploymentService.deploy(deployWar, deployName, currentFolder.getWeb());
      VfsTransactionManager.setRollbackOnly(false);
      commit();
      return result("Deployed ok: " + deployName);
    } finally {
      VfsTransactionManager.setRollbackOnly(false);
    }
  }