Exemplo n.º 1
0
  protected void validate(String fileName, boolean validateFileExtension, String versionLabel)
      throws PortalException {

    validate(fileName, validateFileExtension);

    DLValidatorUtil.validateVersionLabel(versionLabel);
  }
Exemplo n.º 2
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);
  }
Exemplo n.º 3
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);
  }
Exemplo n.º 4
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();
        }
      }
    }
  }