try {
if (StringUtils.isBlank(directory))
return Response.ok().build();
final String fileType = type;
IUserContentAccess access = contentAccessFactory.getUserContentAccess(null);
if( !access.fileExists(directory) && access.hasAccess(directory, FileAccess.READ)) {
throw new SaikuServiceException("Access to Repository has failed File does not exist or no read right: " + directory);
}
IBasicFileFilter txtFilter = StringUtils.isBlank(type) ? null : new IBasicFileFilter() {
public boolean accept(IBasicFile file) {
return file.isDirectory() || file.getExtension().equals(fileType);
}
};
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(bos);
List<IBasicFile> basicFiles = access.listFiles(directory, txtFilter);
for (IBasicFile basicFile : basicFiles) {
if (!basicFile.isDirectory()) {
String entry = basicFile.getName();
byte[] doc = IOUtils.toByteArray(basicFile.getContents());