Revision 68410d59 gss/src/gr/ebs/gss/server/GSSServiceImpl.java
b/gss/src/gr/ebs/gss/server/GSSServiceImpl.java | ||
---|---|---|
39 | 39 |
|
40 | 40 |
import java.io.UnsupportedEncodingException; |
41 | 41 |
import java.net.URLDecoder; |
42 |
import java.util.Iterator; |
|
42 | 43 |
import java.util.List; |
43 | 44 |
import java.util.Set; |
44 | 45 |
|
... | ... | |
108 | 109 |
return users; |
109 | 110 |
} |
110 | 111 |
|
111 |
/* |
|
112 |
* (non-Javadoc) |
|
113 |
* |
|
114 |
* @see gr.ebs.gss.client.GSSService#getRootFolder(java.lang.Long) |
|
115 |
*/ |
|
116 |
public FolderDTO getRootFolder(final Long userId) throws RpcException, ObjectNotFoundException { |
|
117 |
FolderDTO dto = getService().getRootFolder(userId); |
|
118 |
|
|
119 |
return dto; |
|
112 |
@Override |
|
113 |
public FolderDTO getRootFolder(Long userId) throws RpcException, ObjectNotFoundException { |
|
114 |
FolderDTO folder = getService().getRootFolder(userId); |
|
115 |
if (folder.isDeleted()) |
|
116 |
throw new ObjectNotFoundException("Folder was not found"); |
|
117 |
trimDeleted(folder); |
|
118 |
return folder; |
|
120 | 119 |
} |
121 | 120 |
|
122 |
/* |
|
123 |
* (non-Javadoc) |
|
124 |
* |
|
125 |
* @see gr.ebs.gss.client.GSSService#getFolder(java.lang.Long, |
|
126 |
* java.lang.Long) |
|
127 |
*/ |
|
128 |
public FolderDTO getFolder(final Long userId, final Long folderId) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException { |
|
129 |
return getService().getFolder(userId, folderId); |
|
121 |
@Override |
|
122 |
public FolderDTO getFolder(Long userId, Long folderId) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException { |
|
123 |
FolderDTO folder = getService().getFolder(userId, folderId); |
|
124 |
if (folder.isDeleted()) |
|
125 |
throw new ObjectNotFoundException("Folder was not found"); |
|
126 |
trimDeleted(folder); |
|
127 |
return folder; |
|
130 | 128 |
} |
131 | 129 |
|
132 | 130 |
/* |
... | ... | |
160 | 158 |
getService().deleteFolder(userId, folderId); |
161 | 159 |
} |
162 | 160 |
|
163 |
/* |
|
164 |
* (non-Javadoc) |
|
165 |
* |
|
166 |
* @see gr.ebs.gss.client.GSSService#getSubfolders(java.lang.Long, |
|
167 |
* java.lang.Long) |
|
168 |
*/ |
|
169 |
public List<FolderDTO> getSubfolders(final Long userId, final Long folderId) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException { |
|
170 |
List<FolderDTO> res = getService().getSubfolders(userId, folderId); |
|
171 |
return res; |
|
161 |
@Override |
|
162 |
public List<FolderDTO> getSubfolders(Long userId, Long folderId) |
|
163 |
throws RpcException, ObjectNotFoundException, InsufficientPermissionsException { |
|
164 |
List<FolderDTO> folders = getService().getSubfolders(userId, folderId); |
|
165 |
Iterator<FolderDTO> i = folders.iterator(); |
|
166 |
while (i.hasNext()) { |
|
167 |
FolderDTO folder = i.next(); |
|
168 |
if (folder.isDeleted()) |
|
169 |
i.remove(); |
|
170 |
else |
|
171 |
trimDeleted(folder); |
|
172 |
} |
|
173 |
return folders; |
|
172 | 174 |
} |
173 | 175 |
|
174 | 176 |
/* |
... | ... | |
448 | 450 |
return getService().getSharedRootFolders(userId, callingUserId); |
449 | 451 |
} |
450 | 452 |
|
451 |
/* (non-Javadoc) |
|
452 |
* @see gr.ebs.gss.client.GSSService#getSharedSubfolders(java.lang.Long, java.lang.Long) |
|
453 |
*/ |
|
454 | 453 |
@Override |
455 | 454 |
public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws RpcException, ObjectNotFoundException { |
456 |
return getService().getSharedSubfolders(userId, folderId); |
|
455 |
List<FolderDTO> folders = getService().getSharedSubfolders(userId, folderId); |
|
456 |
Iterator<FolderDTO> i = folders.iterator(); |
|
457 |
while (i.hasNext()) { |
|
458 |
FolderDTO folder = i.next(); |
|
459 |
if (folder.isDeleted()) |
|
460 |
i.remove(); |
|
461 |
else |
|
462 |
trimDeleted(folder); |
|
463 |
} |
|
464 |
return folders; |
|
457 | 465 |
} |
458 | 466 |
|
459 | 467 |
/* (non-Javadoc) |
... | ... | |
576 | 584 |
|
577 | 585 |
} |
578 | 586 |
|
579 |
/* (non-Javadoc) |
|
580 |
* @see gr.ebs.gss.client.GSSService#getFolderWithSubfolders(java.lang.Long, java.lang.Long) |
|
581 |
*/ |
|
582 | 587 |
@Override |
583 | 588 |
public FolderDTO getFolderWithSubfolders(Long userId, Long folderId) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException { |
584 |
return getService().getFolderWithSubfolders(userId, folderId); |
|
589 |
FolderDTO folder = getService().getFolderWithSubfolders(userId, folderId); |
|
590 |
if (folder.isDeleted()) |
|
591 |
throw new ObjectNotFoundException("Folder was not found"); |
|
592 |
trimDeleted(folder); |
|
593 |
return folder; |
|
585 | 594 |
} |
586 | 595 |
|
587 | 596 |
/* (non-Javadoc) |
... | ... | |
592 | 601 |
return getService().getSharedSubfolders(userId, callingUserId, folderId); |
593 | 602 |
} |
594 | 603 |
|
595 |
/* (non-Javadoc) |
|
596 |
* @see gr.ebs.gss.client.GSSService#getFolderWithSubfolders(java.lang.Long, java.lang.Long, java.lang.Long) |
|
597 |
*/ |
|
598 | 604 |
@Override |
599 | 605 |
public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException { |
600 |
return getService().getFolderWithSubfolders(userId, callingUserId, folderId); |
|
606 |
FolderDTO folder = getService().getFolderWithSubfolders(userId, callingUserId, folderId); |
|
607 |
if (folder.isDeleted()) |
|
608 |
throw new ObjectNotFoundException("Folder was not found"); |
|
609 |
trimDeleted(folder); |
|
610 |
return folder; |
|
611 |
} |
|
612 |
|
|
613 |
/** |
|
614 |
* Removes the 1st & 2nd level subfolders of the specified folder that |
|
615 |
* have been moved into the trash. |
|
616 |
* |
|
617 |
* @param folder the folder whose children will be scanned |
|
618 |
*/ |
|
619 |
private void trimDeleted(FolderDTO folder) { |
|
620 |
Iterator<FolderDTO> i = folder.getSubfolders().iterator(); |
|
621 |
while (i.hasNext()) { |
|
622 |
FolderDTO f = i.next(); |
|
623 |
if (f.isDeleted()) |
|
624 |
i.remove(); |
|
625 |
else { |
|
626 |
Iterator<FolderDTO> i2 = f.getSubfolders().iterator(); |
|
627 |
while (i2.hasNext()) { |
|
628 |
FolderDTO subf = i2.next(); |
|
629 |
if (subf.isDeleted()) |
|
630 |
i2.remove(); |
|
631 |
} |
|
632 |
} |
|
633 |
} |
|
601 | 634 |
} |
602 | 635 |
|
603 | 636 |
} |
Also available in: Unified diff