예제 #1
0
  @Override
  public void validate(String fileName, boolean validateFileExtension) throws PortalException {

    DLValidatorUtil.validateFileName(fileName);

    if (validateFileExtension) {
      DLValidatorUtil.validateFileExtension(fileName);
    }
  }
예제 #2
0
  protected void validate(String fileName, boolean validateFileExtension, String versionLabel)
      throws PortalException {

    validate(fileName, validateFileExtension);

    DLValidatorUtil.validateVersionLabel(versionLabel);
  }
예제 #3
0
  @Override
  public void validate(String fileName, boolean validateFileExtension, InputStream is)
      throws PortalException {

    validate(fileName, validateFileExtension);

    DLValidatorUtil.validateFileSize(fileName, is);
  }
예제 #4
0
  @Override
  public void validate(
      String fileName, String fileExtension, String sourceFileName, boolean validateFileExtension)
      throws PortalException {

    validate(fileName, validateFileExtension);

    DLValidatorUtil.validateSourceFileExtension(fileExtension, sourceFileName);
  }
예제 #5
0
  @Override
  public void addDirectory(long companyId, long repositoryId, String dirName)
      throws PortalException {

    if (!DLValidatorUtil.isValidName(dirName) || dirName.equals("/")) {
      throw new DirectoryNameException(dirName);
    }

    store.addDirectory(companyId, repositoryId, dirName);
  }
예제 #6
0
  @Override
  public boolean hasDirectory(long companyId, long repositoryId, String dirName)
      throws PortalException {

    if (!DLValidatorUtil.isValidName(dirName)) {
      throw new DirectoryNameException(dirName);
    }

    return store.hasDirectory(companyId, repositoryId, dirName);
  }
예제 #7
0
  @Override
  public String[] getFileNames(long companyId, long repositoryId, String dirName)
      throws PortalException {

    if (!DLValidatorUtil.isValidName(dirName)) {
      throw new DirectoryNameException(dirName);
    }

    return store.getFileNames(companyId, repositoryId, dirName);
  }
예제 #8
0
  protected void validate(
      String fileName,
      String fileExtension,
      String sourceFileName,
      boolean validateFileExtension,
      InputStream is,
      String versionLabel)
      throws PortalException {

    validate(fileName, fileExtension, sourceFileName, validateFileExtension, is);

    DLValidatorUtil.validateVersionLabel(versionLabel);
  }
예제 #9
0
  @Override
  public void updateFile(
      long companyId,
      long repositoryId,
      String fileName,
      String fileExtension,
      boolean validateFileExtension,
      String versionLabel,
      String sourceFileName,
      File file)
      throws PortalException {

    validate(fileName, fileExtension, sourceFileName, validateFileExtension);

    DLValidatorUtil.validateVersionLabel(versionLabel);

    if (PropsValues.DL_STORE_ANTIVIRUS_ENABLED) {
      AntivirusScannerUtil.scan(file);
    }

    store.updateFile(companyId, repositoryId, fileName, versionLabel, file);
  }
예제 #10
0
  /** @deprecated As of 7.0.0, replaced by {@link DLValidatorUtil#validateDirectoryName(String)} */
  @Deprecated
  @Override
  public void validateDirectoryName(String directoryName) throws PortalException {

    DLValidatorUtil.validateDirectoryName(directoryName);
  }
예제 #11
0
  @Override
  public void updateFile(
      long companyId,
      long repositoryId,
      String fileName,
      String fileExtension,
      boolean validateFileExtension,
      String versionLabel,
      String sourceFileName,
      InputStream is)
      throws PortalException {

    if (is instanceof ByteArrayFileInputStream) {
      ByteArrayFileInputStream byteArrayFileInputStream = (ByteArrayFileInputStream) is;

      File file = byteArrayFileInputStream.getFile();

      updateFile(
          companyId,
          repositoryId,
          fileName,
          fileExtension,
          validateFileExtension,
          versionLabel,
          sourceFileName,
          file);

      return;
    }

    validate(fileName, fileExtension, sourceFileName, validateFileExtension);

    DLValidatorUtil.validateVersionLabel(versionLabel);

    if (!PropsValues.DL_STORE_ANTIVIRUS_ENABLED || !AntivirusScannerUtil.isActive()) {

      store.updateFile(companyId, repositoryId, fileName, versionLabel, is);
    } else {
      File tempFile = null;

      try {
        if (is.markSupported()) {
          is.mark(is.available() + 1);

          AntivirusScannerUtil.scan(is);

          is.reset();

          store.updateFile(companyId, repositoryId, fileName, versionLabel, is);
        } else {
          tempFile = FileUtil.createTempFile();

          FileUtil.write(tempFile, is);

          AntivirusScannerUtil.scan(tempFile);

          store.updateFile(companyId, repositoryId, fileName, versionLabel, tempFile);
        }
      } catch (IOException ioe) {
        throw new SystemException("Unable to scan file " + fileName, ioe);
      } finally {
        if (tempFile != null) {
          tempFile.delete();
        }
      }
    }
  }
예제 #12
0
 /** @deprecated As of 7.0.0, replaced by {@link DLValidatorUtil#isValidName(String)} */
 @Deprecated
 @Override
 public boolean isValidName(String name) {
   return DLValidatorUtil.isValidName(name);
 }