Exemple #1
0
 @Override
 protected void doValidate(Task task, ValidationStatus status) throws PackageException {
   if (file == null || tofile == null) {
     status.addError(
         "Cannot execute command in installer."
             + " Invalid copy syntax: file, dir, tofile or todir was not specified.");
   }
   if (tofile.isFile() && !overwrite && !append) {
     if (removeOnExit) {
       // a plugin is still there due to a previous action that needs a
       // restart
       status.addError(
           "A restart is needed to perform this operation: cleaning " + tofile.getName());
     } else {
       status.addError("Cannot overwrite existing file: " + tofile.getName());
     }
   }
   if (md5 != null) {
     try {
       if (tofile.isFile() && !md5.equals(IOUtils.createMd5(tofile))) {
         status.addError("MD5 check failed. File: " + tofile + " has changed since its backup");
       }
     } catch (Exception e) {
       throw new PackageException(e);
     }
   }
 }
Exemple #2
0
 @Override
 protected void doValidate(Task task, ValidationStatus status) throws PackageException {
   if (addtemplate == null && rmtemplate == null && set == null) {
     status.addError(
         "Cannot execute command in installer."
             + " Invalid config syntax: neither addtemplate, rmtemplate "
             + "or set was specified.");
   }
   if (set != null && !set.contains("=")) {
     status.addError("Invalid config syntax: badly-formed property " + set);
   }
 }
 protected void performTask(Task task) throws PackageException {
   ValidationStatus validationStatus = task.validate();
   if (validationStatus.hasErrors()) {
     throw new PackageException(
         "Failed to validate package "
             + task.getPackage().getId()
             + " -> "
             + validationStatus.getErrors());
   }
   if (validationStatus.hasWarnings()) {
     log.warn(
         "Got warnings on package validation "
             + task.getPackage().getId()
             + " -> "
             + validationStatus.getWarnings());
   }
   task.run(null);
 }