@Override public void validate(String fileName, boolean validateFileExtension) throws PortalException { DLValidatorUtil.validateFileName(fileName); if (validateFileExtension) { DLValidatorUtil.validateFileExtension(fileName); } }
protected void validate(String fileName, boolean validateFileExtension, String versionLabel) throws PortalException { validate(fileName, validateFileExtension); DLValidatorUtil.validateVersionLabel(versionLabel); }
@Override public void validate(String fileName, boolean validateFileExtension, InputStream is) throws PortalException { validate(fileName, validateFileExtension); DLValidatorUtil.validateFileSize(fileName, is); }
@Override public void validate( String fileName, String fileExtension, String sourceFileName, boolean validateFileExtension) throws PortalException { validate(fileName, validateFileExtension); DLValidatorUtil.validateSourceFileExtension(fileExtension, sourceFileName); }
@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); }
@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); }
@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); }
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); }
@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); }
/** @deprecated As of 7.0.0, replaced by {@link DLValidatorUtil#validateDirectoryName(String)} */ @Deprecated @Override public void validateDirectoryName(String directoryName) throws PortalException { DLValidatorUtil.validateDirectoryName(directoryName); }
@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(); } } } }
/** @deprecated As of 7.0.0, replaced by {@link DLValidatorUtil#isValidName(String)} */ @Deprecated @Override public boolean isValidName(String name) { return DLValidatorUtil.isValidName(name); }