Package org.shiftone.jrat.inject

Examples of org.shiftone.jrat.inject.InjectionException


    Assert.assertNotNull("transformer", transformer);
    long lastModified;

        if (!source.exists()) {
      throw new InjectionException("source file does not exist : " + source);
    }
        LOG.debug("source exists");
        if (source.isDirectory()) {
      throw new InjectionException("source file is a directory : " + source);
    }
        LOG.debug("source is real file (not dir)");
        if (source.canRead() == false) {
      throw new InjectionException("source file can not be read (check permissions): " + source);
    }

        LOG.debug("source can be read");
        lastModified = source.lastModified();

        if (target.exists()) {

            LOG.debug("target exists " + target.getAbsolutePath());

            if (forceOverwrite == false) {
        throw new InjectionException("target exists and forceOverwrite is disabled : " + source);
      }
      if (target.isDirectory()) {
        throw new InjectionException("target is directory : " + target);
      }
      if (target.canWrite() == false) {
        throw new InjectionException("unable to write to target (check permissions) : " + target);
      }
      // newer is bigger

            if (target.lastModified() > source.lastModified()) {
        // target is newer than source
        if (!overwriteNewer) {
          throw new InjectionException("target is newer than source and overwriteNewer is disabled : "
              + source);
        }
      }

            processUsingSwapFile(transformer, options, source, target);
View Full Code Here


      IOUtil.delete(workFile);
    }
    try {
      processFile(transformer, options, source, workFile);
      if (!workFile.exists()) {
        throw new InjectionException("processFile seems to have worked, but target file doesn't exist : "
            + source);
      }
      IOUtil.rename(workFile, target, true);
    } catch (Throwable e) {
      String msg = "Failed to instrument " + source + " : " + e;
      if ((workFile.exists()) && (!workFile.delete())) {
        msg += " and couldn't delete the corrupt file " + workFile.getAbsolutePath();
      }
      throw new InjectionException(msg, e);
    } finally {
      IOUtil.deleteIfExists(workFile);
    }
  }
View Full Code Here

    ZipOutputStream targetStream = new ZipOutputStream(IOUtil.openOutputStream(target, BUFFER_SIZE));
    targetStream.setLevel(Deflater.BEST_SPEED);
    try {
      processStreams(transformer, options, sourceStream, targetStream);
    } catch (Exception e) {
      throw new InjectionException("error injecting " + source.getAbsoluteFile() + " => "
          + target.getAbsolutePath(), e);
    } finally {
      IOUtil.close(sourceStream);
      IOUtil.close(targetStream);
    }
View Full Code Here

TOP

Related Classes of org.shiftone.jrat.inject.InjectionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.