Пример #1
0
 protected void validateDir(File dir) {
   if (!dir.exists()) {
     if (!dir.mkdirs()) {
       throw DeploymentRepositoryMessages.MESSAGES.cannotCreateDirectory(
           dir.getAbsolutePath());
     }
   } else if (!dir.isDirectory()) {
     throw DeploymentRepositoryMessages.MESSAGES.notADirectory(dir.getAbsolutePath());
   } else if (!dir.canWrite()) {
     throw DeploymentRepositoryMessages.MESSAGES.directoryNotWritable(dir.getAbsolutePath());
   }
 }
Пример #2
0
      protected ContentRepositoryImpl(final File repoRoot) {
        if (repoRoot == null) throw DeploymentRepositoryMessages.MESSAGES.nullVar("repoRoot");
        if (repoRoot.exists()) {
          if (!repoRoot.isDirectory()) {
            throw DeploymentRepositoryMessages.MESSAGES.notADirectory(repoRoot.getAbsolutePath());
          } else if (!repoRoot.canWrite()) {
            throw DeploymentRepositoryMessages.MESSAGES.directoryNotWritable(
                repoRoot.getAbsolutePath());
          }
        } else if (!repoRoot.mkdirs()) {
          throw DeploymentRepositoryMessages.MESSAGES.cannotCreateDirectory(
              repoRoot.getAbsolutePath());
        }
        this.repoRoot = repoRoot;

        try {
          this.messageDigest = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e) {
          throw DeploymentRepositoryMessages.MESSAGES.cannotObtainSha1(
              e, MessageDigest.class.getSimpleName());
        }
      }