Added comments, moved EntityHandlerIface, and cleaned up old codes.
Change-Id: I1a182b6ecd3dfeea4af08f3accd72fbce9af0f9c
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java b/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
index 0f75d84..73728a4 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
@@ -36,9 +36,9 @@
import de.ids_mannheim.korap.interfaces.AuthenticationIface;
import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
import de.ids_mannheim.korap.interfaces.EncryptionIface;
+import de.ids_mannheim.korap.interfaces.EntityHandlerIface;
import de.ids_mannheim.korap.interfaces.ValidatorIface;
import de.ids_mannheim.korap.interfaces.db.AuditingIface;
-import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.interfaces.defaults.ApacheValidator;
import de.ids_mannheim.korap.user.DemoUser;
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/http/AuthorizationData.java b/full/src/main/java/de/ids_mannheim/korap/authentication/http/AuthorizationData.java
index 32c9c7b..a1ad185 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/http/AuthorizationData.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/http/AuthorizationData.java
@@ -4,6 +4,11 @@
import lombok.Getter;
import lombok.Setter;
+/** Describes the values stored in Authorization header of HTTP requests.
+ *
+ * @author margaretha
+ *
+ */
@Getter
@Setter
public class AuthorizationData {
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/AuthenticationMethod.java b/full/src/main/java/de/ids_mannheim/korap/config/AuthenticationMethod.java
index afd81ed..b44d0a0 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/AuthenticationMethod.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/AuthenticationMethod.java
@@ -1,5 +1,14 @@
package de.ids_mannheim.korap.config;
+/** Lists possible actual authentication methods. Multiple
+ * {@link AuthenticationScheme} may use an identical
+ * authentication method.
+ *
+ * @author margaretha
+ *
+ * @see AuthenticationScheme
+ *
+ */
public enum AuthenticationMethod {
LDAP, SHIBBOLETH, DATABASE;
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/AuthenticationScheme.java b/full/src/main/java/de/ids_mannheim/korap/config/AuthenticationScheme.java
index 6d9c58e..4459e56 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/AuthenticationScheme.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/AuthenticationScheme.java
@@ -2,12 +2,18 @@
import org.apache.commons.lang.WordUtils;
+/** Lists possible authentication schemes used in the Authorization header
+ * of HTTP requests.
+ *
+ * @author margaretha
+ *
+ */
public enum AuthenticationScheme {
// standard http
BASIC, BEARER,
// custom
SESSION, API;
-
+
public String displayName () {
return WordUtils.capitalizeFully(name());
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/constant/GroupMemberStatus.java b/full/src/main/java/de/ids_mannheim/korap/constant/GroupMemberStatus.java
index 59c1154..c9b5229 100644
--- a/full/src/main/java/de/ids_mannheim/korap/constant/GroupMemberStatus.java
+++ b/full/src/main/java/de/ids_mannheim/korap/constant/GroupMemberStatus.java
@@ -1,5 +1,16 @@
package de.ids_mannheim.korap.constant;
+/** Defines the status of a user-group member
+ *
+ * @author margaretha
+ *
+ */
public enum GroupMemberStatus {
- ACTIVE, PENDING, DELETED;
+ ACTIVE,
+ // membership invitation was sent and has not been accepted
+ // or rejected yet
+ PENDING,
+ // either membership invitation was rejected or the member was
+ // deleted by a user-group admin
+ DELETED;
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/constant/PredefinedRole.java b/full/src/main/java/de/ids_mannheim/korap/constant/PredefinedRole.java
index 65b0fad..d784cb0 100644
--- a/full/src/main/java/de/ids_mannheim/korap/constant/PredefinedRole.java
+++ b/full/src/main/java/de/ids_mannheim/korap/constant/PredefinedRole.java
@@ -1,5 +1,10 @@
package de.ids_mannheim.korap.constant;
+/** Defines some predefined roles used in the system.
+ *
+ * @author margaretha
+ *
+ */
public enum PredefinedRole {
USER_GROUP_ADMIN(1), USER_GROUP_MEMBER(2), VC_ACCESS_ADMIN(3), VC_ACCESS_MEMBER(4);
diff --git a/full/src/main/java/de/ids_mannheim/korap/constant/PrivilegeType.java b/full/src/main/java/de/ids_mannheim/korap/constant/PrivilegeType.java
index ad05f18..f9900b3 100644
--- a/full/src/main/java/de/ids_mannheim/korap/constant/PrivilegeType.java
+++ b/full/src/main/java/de/ids_mannheim/korap/constant/PrivilegeType.java
@@ -1,5 +1,15 @@
package de.ids_mannheim.korap.constant;
+import de.ids_mannheim.korap.entity.Privilege;
+import de.ids_mannheim.korap.entity.Role;
+
+/** Defines the privilege or permissions of users or admins
+ * based on their roles.
+ *
+ * @author margaretha
+ * @see Privilege
+ * @see Role
+ */
public enum PrivilegeType {
READ, WRITE, DELETE;
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/constant/UserGroupStatus.java b/full/src/main/java/de/ids_mannheim/korap/constant/UserGroupStatus.java
index 5cb939e..a1507ed 100644
--- a/full/src/main/java/de/ids_mannheim/korap/constant/UserGroupStatus.java
+++ b/full/src/main/java/de/ids_mannheim/korap/constant/UserGroupStatus.java
@@ -1,5 +1,12 @@
package de.ids_mannheim.korap.constant;
+import de.ids_mannheim.korap.entity.UserGroup;
+
+/** Defines possible statuses of {@link UserGroup}s
+ *
+ * @author margaretha
+ *
+ */
public enum UserGroupStatus {
ACTIVE, DELETED,
// group members cannot see the group
diff --git a/full/src/main/java/de/ids_mannheim/korap/constant/VirtualCorpusAccessStatus.java b/full/src/main/java/de/ids_mannheim/korap/constant/VirtualCorpusAccessStatus.java
index 381ae4c..0b0ab0d 100644
--- a/full/src/main/java/de/ids_mannheim/korap/constant/VirtualCorpusAccessStatus.java
+++ b/full/src/main/java/de/ids_mannheim/korap/constant/VirtualCorpusAccessStatus.java
@@ -1,8 +1,17 @@
package de.ids_mannheim.korap.constant;
+import de.ids_mannheim.korap.entity.VirtualCorpusAccess;
+
+/** Defines possible statusess of {@link VirtualCorpusAccess}
+ *
+ * @author margaretha
+ * @see VirtualCorpusAccess
+ *
+ */
public enum VirtualCorpusAccessStatus {
ACTIVE, DELETED,
+ // has not been used yet
PENDING,
// access for hidden group
// maybe not necessary?
diff --git a/full/src/main/java/de/ids_mannheim/korap/constant/VirtualCorpusType.java b/full/src/main/java/de/ids_mannheim/korap/constant/VirtualCorpusType.java
index 0072c67..5abd54c 100644
--- a/full/src/main/java/de/ids_mannheim/korap/constant/VirtualCorpusType.java
+++ b/full/src/main/java/de/ids_mannheim/korap/constant/VirtualCorpusType.java
@@ -1,5 +1,12 @@
package de.ids_mannheim.korap.constant;
+import de.ids_mannheim.korap.entity.VirtualCorpus;
+
+/** Defines types of {@link VirtualCorpus}
+ *
+ * @author margaretha
+ *
+ */
public enum VirtualCorpusType {
// available for all
PREDEFINED,
diff --git a/full/src/main/java/de/ids_mannheim/korap/dao/PrivilegeDao.java b/full/src/main/java/de/ids_mannheim/korap/dao/PrivilegeDao.java
index 874850a..8bd533d 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dao/PrivilegeDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dao/PrivilegeDao.java
@@ -18,6 +18,16 @@
import de.ids_mannheim.korap.entity.Role;
import de.ids_mannheim.korap.entity.Role_;
+/** Manages database transactions regarding {@link Privilege} entity or
+ * database table.
+ *
+ * @see Privilege
+ * @see PrivilegeType
+ * @see Role
+ *
+ * @author margaretha
+ *
+ */
@Transactional
@Repository
public class PrivilegeDao {
diff --git a/full/src/main/java/de/ids_mannheim/korap/dao/RoleDao.java b/full/src/main/java/de/ids_mannheim/korap/dao/RoleDao.java
index 6cbfaa1..b02a283 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dao/RoleDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dao/RoleDao.java
@@ -20,6 +20,12 @@
import de.ids_mannheim.korap.entity.UserGroupMember;
import de.ids_mannheim.korap.entity.UserGroupMember_;
+/** Manages database transactions regarding {@link Role} entity or database table.
+ *
+ * @author margaretha
+ * @see Role
+ * @see PrivilegeDao
+ */
@Transactional
@Repository
public class RoleDao {
@@ -28,7 +34,7 @@
private EntityManager entityManager;
@Autowired
- PrivilegeDao privilegeDao;
+ private PrivilegeDao privilegeDao;
public void createRole (String name, List<PrivilegeType> privilegeTypes) {
Role r = new Role();
diff --git a/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java b/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
index 72c856a..43eee36 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
@@ -35,6 +35,14 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.utils.ParameterChecker;
+/** Manages database transactions regarding {@link UserGroup} entity and
+ * database table.
+ *
+ * @author margaretha
+ *
+ * @see UserGroup
+ *
+ */
@Transactional
@Repository
public class UserGroupDao {
diff --git a/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupMemberDao.java b/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupMemberDao.java
index d2ffe28..ae58ec6 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupMemberDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dao/UserGroupMemberDao.java
@@ -24,6 +24,13 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.utils.ParameterChecker;
+/** Manages database transactions regarding {@link UserGroupMember} entity and
+ * database table.
+ *
+ * @author margaretha
+ * @see UserGroupMember
+ *
+ */
@Transactional
@Repository
public class UserGroupMemberDao {
diff --git a/full/src/main/java/de/ids_mannheim/korap/dao/VirtualCorpusAccessDao.java b/full/src/main/java/de/ids_mannheim/korap/dao/VirtualCorpusAccessDao.java
index 82678cf..00eb460 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dao/VirtualCorpusAccessDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dao/VirtualCorpusAccessDao.java
@@ -25,6 +25,14 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.utils.ParameterChecker;
+/** Manages database transactions regarding {@link VirtualCorpusAccess} entity
+ * and its corresponding database table.
+ *
+ * @author margaretha
+ *
+ * @see VirtualCorpusAccess
+ * @see VirtualCorpus
+ */
@Transactional
@Repository
public class VirtualCorpusAccessDao {
diff --git a/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java b/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java
index 82f05eb..8d64c09 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupDto.java
@@ -8,6 +8,12 @@
import lombok.Getter;
import lombok.Setter;
+/** Defines the structure of UserGroup description, e.g.
+ * to be sent as JSON objects in HTTP response.
+ *
+ * @author margaretha
+ *
+ */
@Setter
@Getter
public class UserGroupDto {
diff --git a/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupMemberDto.java b/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupMemberDto.java
index 1a5eda3..bf3cfea 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupMemberDto.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dto/UserGroupMemberDto.java
@@ -6,6 +6,11 @@
import lombok.Getter;
import lombok.Setter;
+/** Defines UserGroupMember description, e.g. to be sent as
+ * JSON objects in HTTP Responses.
+ * @author margaretha
+ *
+ */
@Setter
@Getter
public class UserGroupMemberDto {
diff --git a/full/src/main/java/de/ids_mannheim/korap/dto/VirtualCorpusAccessDto.java b/full/src/main/java/de/ids_mannheim/korap/dto/VirtualCorpusAccessDto.java
index 93875ee..74d0df6 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dto/VirtualCorpusAccessDto.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dto/VirtualCorpusAccessDto.java
@@ -3,6 +3,10 @@
import lombok.Getter;
import lombok.Setter;
+/**
+ * @author margaretha
+ *
+ */
@Getter
@Setter
public class VirtualCorpusAccessDto {
diff --git a/full/src/main/java/de/ids_mannheim/korap/dto/VirtualCorpusDto.java b/full/src/main/java/de/ids_mannheim/korap/dto/VirtualCorpusDto.java
index f69f19d..d44ade7 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dto/VirtualCorpusDto.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dto/VirtualCorpusDto.java
@@ -1,8 +1,15 @@
package de.ids_mannheim.korap.dto;
+import de.ids_mannheim.korap.entity.VirtualCorpus;
import lombok.Getter;
import lombok.Setter;
+/** Defines the structure of {@link VirtualCorpus} description to be
+ * sent as JSON objects in HTTP responses.
+ *
+ * @author margaretha
+ *
+ */
@Getter
@Setter
public class VirtualCorpusDto {
diff --git a/full/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java b/full/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
index 0d61db3..9dd4df9 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
@@ -12,6 +12,13 @@
import de.ids_mannheim.korap.entity.UserGroup;
import de.ids_mannheim.korap.entity.UserGroupMember;
+/** Manages conversion of {@link UserGroup} objects to their data access objects (DTO),
+ * e.g. UserGroupDto. DTO structure defines controllers output, namely the structure of
+ * JSON objects in HTTP responses.
+ *
+ * @author margaretha
+ *
+ */
@Component
public class UserGroupConverter {
@@ -39,7 +46,8 @@
UserGroupMemberDto memberDto = new UserGroupMemberDto();
memberDto.setUserId(member.getUserId());
memberDto.setStatus(member.getStatus());
- List<String> memberRoles = new ArrayList<>(member.getRoles().size());
+ List<String> memberRoles =
+ new ArrayList<>(member.getRoles().size());
for (Role r : member.getRoles()) {
memberRoles.add(r.getName());
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java b/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
index 8577a1b..35c7cbc 100644
--- a/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
@@ -7,7 +7,7 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.exceptions.DatabaseException;
-import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
+import de.ids_mannheim.korap.interfaces.EntityHandlerIface;
import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
import de.ids_mannheim.korap.user.KorAPUser;
import de.ids_mannheim.korap.user.ShibUser;
diff --git a/full/src/main/java/de/ids_mannheim/korap/interfaces/EntityHandlerIface.java b/full/src/main/java/de/ids_mannheim/korap/interfaces/EntityHandlerIface.java
new file mode 100644
index 0000000..9bcf614
--- /dev/null
+++ b/full/src/main/java/de/ids_mannheim/korap/interfaces/EntityHandlerIface.java
@@ -0,0 +1,36 @@
+package de.ids_mannheim.korap.interfaces;
+
+import de.ids_mannheim.korap.exceptions.EmptyResultException;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.user.User;
+
+/**
+ * User: hanl
+ * Date: 8/19/13
+ * Time: 11:04 AM
+ */
+public interface EntityHandlerIface {
+
+ User getAccount (String username) throws EmptyResultException,
+ KustvaktException;
+
+
+ int updateAccount (User user) throws KustvaktException;
+
+
+ int createAccount (User user) throws KustvaktException;
+
+
+ int deleteAccount (Integer userid) throws KustvaktException;
+
+
+ int truncate () throws KustvaktException;
+
+
+ int resetPassphrase (String username, String uriToken, String passphrase)
+ throws KustvaktException;
+
+
+ int activateAccount (String username, String uriToken)
+ throws KustvaktException;
+}
diff --git a/full/src/main/java/de/ids_mannheim/korap/rewrite/FullRewriteHandler.java b/full/src/main/java/de/ids_mannheim/korap/rewrite/FullRewriteHandler.java
index c65d89f..a353064 100644
--- a/full/src/main/java/de/ids_mannheim/korap/rewrite/FullRewriteHandler.java
+++ b/full/src/main/java/de/ids_mannheim/korap/rewrite/FullRewriteHandler.java
@@ -6,6 +6,11 @@
import de.ids_mannheim.korap.resource.rewrite.IdWriter;
import de.ids_mannheim.korap.resource.rewrite.RewriteHandler;
+/** Defines rewrite handling methods relevant only in full version.
+ *
+ * @author margaretha
+ *
+ */
public class FullRewriteHandler extends RewriteHandler{
public FullRewriteHandler (FullConfiguration config) {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
index 8af6516..a49c276 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
@@ -39,9 +39,6 @@
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public class AnnotationController {
- private static Logger jlog =
- LoggerFactory.getLogger(AnnotationController.class);
-
@Autowired
CoreResponseHandler responseHandler;
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index 1ef5429..e901b2a 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -261,7 +261,7 @@
<bean id="kustvakt_authenticationmanager"
class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
<constructor-arg
- type="de.ids_mannheim.korap.interfaces.db.EntityHandlerIface" ref="kustvakt_userdb" />
+ type="de.ids_mannheim.korap.interfaces.EntityHandlerIface" ref="kustvakt_userdb" />
<constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
ref="kustvakt_encryption" />
<constructor-arg ref="kustvakt_config" />