}
}
+ private Long getRootFolderId(Long userId) throws ObjectNotFoundException {
+ if (userId == null)
+ throw new ObjectNotFoundException("No user specified");
+ return dao.getRootFolderId(userId);
+ }
+
@Override
public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException {
if (userId == null)
folder.getAuditInfo().setModifiedBy(user);
dao.update(folder);
touchParentFolders(folder, user, new Date());
+ // Re-index the folder contents if it was modified.
+ if ((permissions != null && !permissions.isEmpty()) || readForAll != null) {
+ indexFolder(folder);
+ }
+
return folder.getDTO();
}
+ private void indexFolder(Folder folder) {
+ for (FileHeader fh : folder.getFiles())
+ indexFile(fh.getId(), false);
+ for (Folder f : folder.getSubfolders())
+ indexFolder(f);
+ }
+
@Override
public void createGroup(final Long userId, final String name) throws ObjectNotFoundException, DuplicateNameException {
// Validate.
return getRootFolder(owner.getId());
// Store the last element, since it requires special handling.
String lastElement = pathElements.remove(pathElements.size() - 1);
- FolderDTO cursor = getRootFolder(owner.getId());
+
+ Folder cursor = null;
+ Long rootFolderId = getRootFolderId(owner.getId());
// Traverse and verify the specified folder path.
for (String pathElement : pathElements) {
- cursor = getFolder(cursor.getId(), pathElement);
+ cursor = getFolder(cursor==null ? rootFolderId : cursor.getId(), pathElement);
if (cursor.isDeleted())
throw new ObjectNotFoundException("Folder " + cursor.getPath() + " not found");
}
// Use the lastElement to retrieve the actual resource.
Object resource = null;
try {
- FileHeaderDTO file = getFile(cursor.getId(), lastElement);
+ FileHeaderDTO file = getFile(cursor==null ? rootFolderId : cursor.getId(), lastElement);
if (ignoreDeleted && file.isDeleted())
throw new ObjectNotFoundException("Resource not found");
resource = file;
} catch (ObjectNotFoundException e) {
// Perhaps the requested resource is not a file, so
// check for folders as well.
- FolderDTO folder = getFolder(cursor.getId(), lastElement);
+ FolderDTO folder = getFolder(cursor==null ? rootFolderId : cursor.getId(), lastElement).getDTO();
if (ignoreDeleted && folder.isDeleted())
throw new ObjectNotFoundException("Resource not found");
resource = folder;
* found, with the exception message mentioning the precise
* problem
*/
- private FolderDTO getFolder(Long parentId, String name) throws ObjectNotFoundException {
+ private Folder getFolder(Long parentId, String name) throws ObjectNotFoundException {
if (parentId == null)
throw new ObjectNotFoundException("No parent folder specified");
if (StringUtils.isEmpty(name))
throw new ObjectNotFoundException("No folder specified");
Folder folder = dao.getFolder(parentId, name);
- return folder.getDTO();
+ return folder;
}
private FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType, InputStream resourceInputStream) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
for (Long id : fileIds) {
postFileToSolr(solr, id);
i++;
- if (i % 100 == 0) {
+ if (i % 10 == 0) {
solr.commit();
logger.info("Sent commit to solr at file " + i);
}
postFileToSolr(solr, id);
i++;
}
- if (i % 100 == 0) {
+ if (i % 10 == 0) {
solr.commit();
logger.info("Sent commit to solr at file " + i);
}
* @throws ObjectNotFoundException
*/
- public List<UserLogin> getUserLogins(Long userId) throws ObjectNotFoundException{
+ public List<UserLogin> getLastUserLogins(Long userId) throws ObjectNotFoundException{
List<UserLogin> userLoginResults = new ArrayList<UserLogin>();
userLoginResults = dao.getLoginsForUser(userId);
if(userLoginResults.size() == 0)