diff --git a/docs-core/pom.xml b/docs-core/pom.xml
index c2729773..69acf4c0 100644
--- a/docs-core/pom.xml
+++ b/docs-core/pom.xml
@@ -26,6 +26,11 @@
hibernate-entitymanager
+
+ org.hibernate
+ hibernate-validator
+
+
joda-time
@@ -72,26 +77,7 @@
jbcrypt
-
- org.codehaus.jackson
- jackson-core-asl
-
-
- org.codehaus.jackson
- jackson-mapper-asl
-
-
-
- org.ccil.cowan.tagsoup
- tagsoup
-
-
-
- com.googlecode.owasp-java-html-sanitizer
- owasp-java-html-sanitizer
-
-
org.apache.lucene
lucene-core
diff --git a/docs-core/src/main/java/com/sismics/docs/core/constant/Constants.java b/docs-core/src/main/java/com/sismics/docs/core/constant/Constants.java
index 7309c0af..f2a7c866 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/constant/Constants.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/constant/Constants.java
@@ -10,21 +10,11 @@ import com.google.common.collect.Lists;
* @author jtremeaux
*/
public class Constants {
- /**
- * Default locale.
- */
- public static final String DEFAULT_LOCALE_ID = "en";
-
/**
* Default timezone ID.
*/
public static final String DEFAULT_TIMEZONE_ID = "Europe/London";
- /**
- * Default theme ID.
- */
- public static final String DEFAULT_THEME_ID = "default.less";
-
/**
* Administrator's default password ("admin").
*/
diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/file/theme/ThemeDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/file/theme/ThemeDao.java
deleted file mode 100644
index c82989d6..00000000
--- a/docs-core/src/main/java/com/sismics/docs/core/dao/file/theme/ThemeDao.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.sismics.docs.core.dao.file.theme;
-
-import com.google.common.collect.Lists;
-import com.sismics.docs.core.util.DirectoryUtil;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Theme DAO.
- *
- * @author jtremeaux
- */
-public class ThemeDao {
- private final static FilenameFilter CSS_FILTER = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".css") || name.endsWith(".less");
- }
- };
-
- /**
- * Return the list of all themes.
- *
- * @return List of themes
- */
- public List findAll() {
- final File themeDirectory = DirectoryUtil.getThemeDirectory();
- if (themeDirectory != null) {
- return Lists.newArrayList(themeDirectory.list(CSS_FILTER));
- } else {
- return new ArrayList();
- }
- }
-
-}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/LocaleDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/LocaleDao.java
deleted file mode 100644
index 9e022354..00000000
--- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/LocaleDao.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.sismics.docs.core.dao.jpa;
-
-import com.sismics.docs.core.model.jpa.Locale;
-import com.sismics.util.context.ThreadLocalContext;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import java.util.List;
-
-/**
- * Locale DAO.
- *
- * @author jtremeaux
- */
-public class LocaleDao {
- /**
- * Gets a locale by its ID.
- *
- * @param id Locale ID
- * @return Locale
- */
- public Locale getById(String id) {
- EntityManager em = ThreadLocalContext.get().getEntityManager();
- try {
- return em.find(Locale.class, id);
- } catch (NoResultException e) {
- return null;
- }
- }
-
- /**
- * Returns the list of all locales.
- *
- * @return List of locales
- */
- @SuppressWarnings("unchecked")
- public List findAll() {
- EntityManager em = ThreadLocalContext.get().getEntityManager();
- Query q = em.createQuery("select l from Locale l order by l.id");
- return q.getResultList();
- }
-}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/UserDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/UserDao.java
index d9bc4c7e..3a6c0154 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/UserDao.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/UserDao.java
@@ -16,7 +16,6 @@ import org.mindrot.jbcrypt.BCrypt;
import com.google.common.base.Joiner;
import com.sismics.docs.core.constant.AuditLogType;
-import com.sismics.docs.core.constant.Constants;
import com.sismics.docs.core.dao.jpa.criteria.UserCriteria;
import com.sismics.docs.core.dao.jpa.dto.UserDto;
import com.sismics.docs.core.model.jpa.User;
@@ -78,7 +77,6 @@ public class UserDao {
// Create the user
user.setCreateDate(new Date());
user.setPassword(hashPassword(user.getPassword()));
- user.setTheme(Constants.DEFAULT_THEME_ID);
em.persist(user);
// Create audit log
@@ -102,10 +100,7 @@ public class UserDao {
User userFromDb = (User) q.getSingleResult();
// Update the user
- userFromDb.setLocaleId(user.getLocaleId());
userFromDb.setEmail(user.getEmail());
- userFromDb.setTheme(user.getTheme());
- userFromDb.setFirstConnection(user.isFirstConnection());
// Create audit log
AuditLogUtil.create(userFromDb, AuditLogType.UPDATE);
@@ -231,7 +226,7 @@ public class UserDao {
Map parameterMap = new HashMap();
List criteriaList = new ArrayList();
- StringBuilder sb = new StringBuilder("select u.USE_ID_C as c0, u.USE_USERNAME_C as c1, u.USE_EMAIL_C as c2, u.USE_CREATEDATE_D as c3, u.USE_IDLOCALE_C as c4");
+ StringBuilder sb = new StringBuilder("select u.USE_ID_C as c0, u.USE_USERNAME_C as c1, u.USE_EMAIL_C as c2, u.USE_CREATEDATE_D as c3");
sb.append(" from T_USER u ");
// Add search criterias
@@ -260,7 +255,6 @@ public class UserDao {
userDto.setUsername((String) o[i++]);
userDto.setEmail((String) o[i++]);
userDto.setCreateTimestamp(((Timestamp) o[i++]).getTime());
- userDto.setLocaleId((String) o[i++]);
userDtoList.add(userDto);
}
paginatedList.setResultList(userDtoList);
diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/UserDto.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/UserDto.java
index b8c56eb2..956d0c90 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/UserDto.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/UserDto.java
@@ -11,11 +11,6 @@ public class UserDto {
*/
private String id;
- /**
- * Locale ID.
- */
- private String localeId;
-
/**
* Username.
*/
@@ -49,24 +44,6 @@ public class UserDto {
this.id = id;
}
- /**
- * Getter of localeId.
- *
- * @return localeId
- */
- public String getLocaleId() {
- return localeId;
- }
-
- /**
- * Setter of localeId.
- *
- * @param localeId localeId
- */
- public void setLocaleId(String localeId) {
- this.localeId = localeId;
- }
-
/**
* Getter of username.
*
diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/DocumentCreatedAsyncEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/DocumentCreatedAsyncEvent.java
index a0a61161..ac52f535 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/event/DocumentCreatedAsyncEvent.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/event/DocumentCreatedAsyncEvent.java
@@ -1,6 +1,6 @@
package com.sismics.docs.core.event;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.sismics.docs.core.model.jpa.Document;
/**
@@ -34,7 +34,7 @@ public class DocumentCreatedAsyncEvent {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("document", document)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/DocumentDeletedAsyncEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/DocumentDeletedAsyncEvent.java
index 5ffe10a6..a8999d2e 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/event/DocumentDeletedAsyncEvent.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/event/DocumentDeletedAsyncEvent.java
@@ -1,6 +1,6 @@
package com.sismics.docs.core.event;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.sismics.docs.core.model.jpa.Document;
/**
@@ -34,7 +34,7 @@ public class DocumentDeletedAsyncEvent {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("document", document)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/DocumentUpdatedAsyncEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/DocumentUpdatedAsyncEvent.java
index ab322071..6d94543e 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/event/DocumentUpdatedAsyncEvent.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/event/DocumentUpdatedAsyncEvent.java
@@ -1,6 +1,6 @@
package com.sismics.docs.core.event;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.sismics.docs.core.model.jpa.Document;
/**
@@ -34,7 +34,7 @@ public class DocumentUpdatedAsyncEvent {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("document", document)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/FileCreatedAsyncEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/FileCreatedAsyncEvent.java
index 2823781d..41a128f3 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/event/FileCreatedAsyncEvent.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/event/FileCreatedAsyncEvent.java
@@ -2,7 +2,7 @@ package com.sismics.docs.core.event;
import java.io.InputStream;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.sismics.docs.core.model.jpa.Document;
import com.sismics.docs.core.model.jpa.File;
@@ -83,7 +83,7 @@ public class FileCreatedAsyncEvent {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("file", file)
.add("document", document)
.toString();
diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/FileDeletedAsyncEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/FileDeletedAsyncEvent.java
index 98172417..6e51a76f 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/event/FileDeletedAsyncEvent.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/event/FileDeletedAsyncEvent.java
@@ -1,6 +1,6 @@
package com.sismics.docs.core.event;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.sismics.docs.core.model.jpa.File;
/**
@@ -34,7 +34,7 @@ public class FileDeletedAsyncEvent {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("file", file)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/event/RebuildIndexAsyncEvent.java b/docs-core/src/main/java/com/sismics/docs/core/event/RebuildIndexAsyncEvent.java
index 85383b84..55e9f65a 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/event/RebuildIndexAsyncEvent.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/event/RebuildIndexAsyncEvent.java
@@ -1,6 +1,6 @@
package com.sismics.docs.core.event;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
/**
* Rebuild index event.
@@ -10,7 +10,7 @@ import com.google.common.base.Objects;
public class RebuildIndexAsyncEvent {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.toString();
}
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/context/AppContext.java b/docs-core/src/main/java/com/sismics/docs/core/model/context/AppContext.java
index 266901d1..2d2ab739 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/context/AppContext.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/context/AppContext.java
@@ -62,7 +62,7 @@ public class AppContext {
ConfigDao configDao = new ConfigDao();
Config luceneStorageConfig = configDao.getById(ConfigType.LUCENE_DIRECTORY_STORAGE);
indexingService = new IndexingService(luceneStorageConfig != null ? luceneStorageConfig.getValue() : null);
- indexingService.startAndWait();
+ indexingService.startAsync();
}
/**
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Acl.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Acl.java
index ab31e2b1..2d74e8d1 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Acl.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Acl.java
@@ -10,7 +10,7 @@ import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.sismics.docs.core.constant.PermType;
import com.sismics.docs.core.util.AuditLogUtil;
@@ -98,7 +98,7 @@ public class Acl implements Loggable {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.add("perm", perm)
.add("sourceId", sourceId)
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/AuditLog.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/AuditLog.java
index 3f68ceb7..6e38c780 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/AuditLog.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/AuditLog.java
@@ -9,7 +9,7 @@ import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.sismics.docs.core.constant.AuditLogType;
/**
@@ -168,7 +168,7 @@ public class AuditLog {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.add("entityId", entityId)
.add("entityClass", entityClass)
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/AuthenticationToken.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/AuthenticationToken.java
index 7d87930c..2d41a3ed 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/AuthenticationToken.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/AuthenticationToken.java
@@ -1,12 +1,13 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-import java.util.Date;
+
+import com.google.common.base.MoreObjects;
/**
* Authentication token entity.
@@ -183,7 +184,7 @@ public class AuthenticationToken {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", "**hidden**")
.add("userId", userId)
.add("ip", ip)
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/BaseFunction.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/BaseFunction.java
index 16abd0c4..56bc1418 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/BaseFunction.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/BaseFunction.java
@@ -1,12 +1,12 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
-
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
+import com.google.common.base.MoreObjects;
+
/**
* Base function entity.
*
@@ -42,7 +42,7 @@ public class BaseFunction {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Config.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Config.java
index b22522b9..26f89601 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Config.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Config.java
@@ -1,9 +1,14 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
-import com.sismics.docs.core.constant.ConfigType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Table;
-import javax.persistence.*;
+import com.google.common.base.MoreObjects;
+import com.sismics.docs.core.constant.ConfigType;
/**
* Configuration parameter entity.
@@ -65,7 +70,7 @@ public class Config {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Document.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Document.java
index c376767c..9ceb1417 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Document.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Document.java
@@ -1,7 +1,6 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
-import com.sismics.docs.core.util.AuditLogUtil;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -9,7 +8,8 @@ import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.Table;
-import java.util.Date;
+import com.google.common.base.MoreObjects;
+import com.sismics.docs.core.util.AuditLogUtil;
/**
* Document entity.
@@ -192,7 +192,7 @@ public class Document implements Loggable {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/DocumentTag.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/DocumentTag.java
index e38963bb..af8451c5 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/DocumentTag.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/DocumentTag.java
@@ -1,14 +1,14 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
+import java.io.Serializable;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-import java.io.Serializable;
-import java.util.Date;
+import com.google.common.base.MoreObjects;
/**
* Link between a document and a tag.
@@ -122,7 +122,7 @@ public class DocumentTag implements Serializable {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("documentId", documentId)
.add("tagId", tagId)
.toString();
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/File.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/File.java
index 673d4995..342cbe71 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/File.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/File.java
@@ -1,7 +1,6 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
-import com.sismics.docs.core.util.AuditLogUtil;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -10,7 +9,8 @@ import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
-import java.util.Date;
+import com.google.common.base.MoreObjects;
+import com.sismics.docs.core.util.AuditLogUtil;
/**
* File entity.
@@ -218,7 +218,7 @@ public class File implements Loggable {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Locale.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Locale.java
deleted file mode 100644
index 111a850c..00000000
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Locale.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.sismics.docs.core.model.jpa;
-
-import com.google.common.base.Objects;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-/**
- * Locale entity.
- *
- * @author jtremeaux
- */
-@Entity
-@Table(name = "T_LOCALE")
-public class Locale {
- /**
- * Locale ID (ex: fr_FR).
- */
- @Id
- @Column(name = "LOC_ID_C", length = 10)
- private String id;
-
- /**
- * Getter of id.
- *
- * @return id
- */
- public String getId() {
- return id;
- }
-
- /**
- * Setter of id.
- *
- * @param id id
- */
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this)
- .add("id", id)
- .toString();
- }
-}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Role.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Role.java
index c636c3c3..bfdf1449 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Role.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Role.java
@@ -1,12 +1,13 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-import java.util.Date;
+
+import com.google.common.base.MoreObjects;
/**
* Role (set of base functions).
@@ -115,7 +116,7 @@ public class Role {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.add("name", name)
.toString();
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/RoleBaseFunction.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/RoleBaseFunction.java
index 06e1fc96..d3f7303f 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/RoleBaseFunction.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/RoleBaseFunction.java
@@ -1,12 +1,13 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-import java.util.Date;
+
+import com.google.common.base.MoreObjects;
/**
* Role base function.
@@ -139,7 +140,7 @@ public class RoleBaseFunction {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.add("userId", roleId)
.add("baseFunctionId", baseFunctionId)
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Share.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Share.java
index 29a3f067..565d4c2a 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Share.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Share.java
@@ -1,12 +1,13 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
-import java.util.Date;
+
+import com.google.common.base.MoreObjects;
/**
* ACL target used to share a document.
@@ -113,7 +114,7 @@ public class Share {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.toString();
}
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Tag.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Tag.java
index c49cded3..70fcba4c 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Tag.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Tag.java
@@ -1,7 +1,6 @@
package com.sismics.docs.core.model.jpa;
-import com.google.common.base.Objects;
-import com.sismics.docs.core.util.AuditLogUtil;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -9,7 +8,8 @@ import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.Table;
-import java.util.Date;
+import com.google.common.base.MoreObjects;
+import com.sismics.docs.core.util.AuditLogUtil;
/**
* Tag.
@@ -168,7 +168,7 @@ public class Tag implements Loggable {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.add("name", name)
.toString();
diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/User.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/User.java
index 0e6227d7..2759ea22 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/User.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/User.java
@@ -8,7 +8,7 @@ import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.Table;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.sismics.docs.core.util.AuditLogUtil;
/**
@@ -27,12 +27,6 @@ public class User implements Loggable {
@Column(name = "USE_ID_C", length = 36)
private String id;
- /**
- * Locale ID.
- */
- @Column(name = "USE_IDLOCALE_C", nullable = false, length = 10)
- private String localeId;
-
/**
* Role ID.
*/
@@ -63,18 +57,6 @@ public class User implements Loggable {
@Column(name = "USE_EMAIL_C", nullable = false, length = 100)
private String email;
- /**
- * Theme.
- */
- @Column(name = "USE_THEME_C", nullable = false, length = 100)
- private String theme;
-
- /**
- * True if the user hasn't dismissed the first connection screen.
- */
- @Column(name = "USE_FIRSTCONNECTION_B", nullable = false)
- private boolean firstConnection;
-
/**
* Creation date.
*/
@@ -105,24 +87,6 @@ public class User implements Loggable {
this.id = id;
}
- /**
- * Getter of localeId.
- *
- * @return localeId
- */
- public String getLocaleId() {
- return localeId;
- }
-
- /**
- * Setter of localeId.
- *
- * @param localeId localeId
- */
- public void setLocaleId(String localeId) {
- this.localeId = localeId;
- }
-
/**
* Getter of roleId.
*
@@ -195,42 +159,6 @@ public class User implements Loggable {
this.email = email;
}
- /**
- * Getter of theme.
- *
- * @return theme
- */
- public String getTheme() {
- return theme;
- }
-
- /**
- * Setter of theme.
- *
- * @param theme theme
- */
- public void setTheme(String theme) {
- this.theme = theme;
- }
-
- /**
- * Getter of firstConnection.
- *
- * @return firstConnection
- */
- public boolean isFirstConnection() {
- return firstConnection;
- }
-
- /**
- * Setter of firstConnection.
- *
- * @param firstConnection firstConnection
- */
- public void setFirstConnection(boolean firstConnection) {
- this.firstConnection = firstConnection;
- }
-
/**
* Getter of createDate.
*
@@ -286,7 +214,7 @@ public class User implements Loggable {
@Override
public String toString() {
- return Objects.toStringHelper(this)
+ return MoreObjects.toStringHelper(this)
.add("id", id)
.add("username", username)
.toString();
diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/DirectoryUtil.java b/docs-core/src/main/java/com/sismics/docs/core/util/DirectoryUtil.java
index 38b410da..dfbab290 100644
--- a/docs-core/src/main/java/com/sismics/docs/core/util/DirectoryUtil.java
+++ b/docs-core/src/main/java/com/sismics/docs/core/util/DirectoryUtil.java
@@ -1,9 +1,10 @@
package com.sismics.docs.core.util;
-import com.sismics.util.EnvironmentUtil;
+import java.io.File;
+
import org.apache.commons.lang.StringUtils;
-import java.io.File;
+import com.sismics.util.EnvironmentUtil;
/**
* Utilities to gain access to the storage directories used by the application.
@@ -18,27 +19,27 @@ public class DirectoryUtil {
*/
public static File getBaseDataDirectory() {
File baseDataDir = null;
- if (EnvironmentUtil.getWebappRoot() != null) {
- // We are in a webapp environment
- if (StringUtils.isNotBlank(EnvironmentUtil.getDocsHome())) {
- // If the docs.home property is set then use it
- baseDataDir = new File(EnvironmentUtil.getDocsHome());
- if (!baseDataDir.isDirectory()) {
- baseDataDir.mkdirs();
- }
- } else {
- // Use the base of the Webapp directory
- baseDataDir = new File(EnvironmentUtil.getWebappRoot() + File.separator + "sismicsdocs");
- if (!baseDataDir.isDirectory()) {
- baseDataDir.mkdirs();
- }
+ if (StringUtils.isNotBlank(EnvironmentUtil.getDocsHome())) {
+ // If the docs.home property is set then use it
+ baseDataDir = new File(EnvironmentUtil.getDocsHome());
+ } else if (EnvironmentUtil.isUnitTest()) {
+ // For unit testing, use a temporary directory
+ baseDataDir = new File(System.getProperty("java.io.tmpdir"));
+ } else {
+ // We are in a webapp environment and nothing is specified, use the default directory for this OS
+ if (EnvironmentUtil.isUnix()) {
+ baseDataDir = new File("/var/docs");
+ } if (EnvironmentUtil.isWindows()) {
+ baseDataDir = new File(EnvironmentUtil.getWindowsAppData() + "\\Sismics\\Docs");
+ } else if (EnvironmentUtil.isMacOs()) {
+ baseDataDir = new File(EnvironmentUtil.getMacOsUserHome() + "/Library/Sismics/Docs");
}
}
- if (baseDataDir == null) {
- // Or else (for unit testing), use a temporary directory
- baseDataDir = new File(System.getProperty("java.io.tmpdir"));
+
+ if (baseDataDir != null && !baseDataDir.isDirectory()) {
+ baseDataDir.mkdirs();
}
-
+
return baseDataDir;
}
@@ -78,25 +79,6 @@ public class DirectoryUtil {
return getDataSubDirectory("log");
}
- /**
- * Returns the themes directory.
- *
- * @return Theme directory.
- */
- public static File getThemeDirectory() {
- String webappRoot = EnvironmentUtil.getWebappRoot();
- File themeDir = null;
- if (webappRoot != null) {
- themeDir = new File(webappRoot + File.separator + "style" + File.separator + "theme");
- } else {
- themeDir = new File(DirectoryUtil.class.getResource("/style/theme").getFile());
- }
- if (themeDir != null && themeDir.isDirectory()) {
- return themeDir;
- }
- return null;
- }
-
/**
* Returns a subdirectory of the base data directory
*
diff --git a/docs-core/src/main/java/com/sismics/util/EnvironmentUtil.java b/docs-core/src/main/java/com/sismics/util/EnvironmentUtil.java
index 8fbff574..791956da 100644
--- a/docs-core/src/main/java/com/sismics/util/EnvironmentUtil.java
+++ b/docs-core/src/main/java/com/sismics/util/EnvironmentUtil.java
@@ -9,7 +9,7 @@ public class EnvironmentUtil {
private static String OS = System.getProperty("os.name").toLowerCase();
- private static String TEST_ENV = System.getProperty("test");
+ private static String APPLICATION_MODE = System.getProperty("application.mode");
private static String WINDOWS_APPDATA = System.getenv("APPDATA");
@@ -18,9 +18,9 @@ public class EnvironmentUtil {
private static String DOCS_HOME = System.getProperty("docs.home");
/**
- * Web application root.
+ * In a web application context.
*/
- private static String webappRoot;
+ private static boolean webappContext;
/**
* Returns true if running under Microsoft Windows.
@@ -55,10 +55,18 @@ public class EnvironmentUtil {
* @return Unit testing environment
*/
public static boolean isUnitTest() {
- return webappRoot == null ||
- TEST_ENV != null && "true".equals(TEST_ENV);
+ return !webappContext || isDevMode();
}
+ /**
+ * Return true if we are in dev mode.
+ *
+ * @return Dev mode
+ */
+ public static boolean isDevMode() {
+ return "dev".equalsIgnoreCase(APPLICATION_MODE);
+ }
+
/**
* Returns the MS Windows AppData directory of this user.
*
@@ -87,20 +95,20 @@ public class EnvironmentUtil {
}
/**
- * Getter of webappRoot.
+ * Getter of webappContext.
*
- * @return webappRoot
+ * @return webappContext
*/
- public static String getWebappRoot() {
- return webappRoot;
+ public static boolean isWebappContext() {
+ return webappContext;
}
/**
- * Setter of webappRoot.
+ * Setter of webappContext.
*
- * @param webappRoot webappRoot
+ * @param webappContext webappContext
*/
- public static void setWebappRoot(String webappRoot) {
- EnvironmentUtil.webappRoot = webappRoot;
+ public static void setWebappContext(boolean webappContext) {
+ EnvironmentUtil.webappContext = webappContext;
}
}
diff --git a/docs-core/src/main/java/com/sismics/util/JsonValidationUtil.java b/docs-core/src/main/java/com/sismics/util/JsonValidationUtil.java
deleted file mode 100644
index 85ee0ac4..00000000
--- a/docs-core/src/main/java/com/sismics/util/JsonValidationUtil.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.sismics.util;
-
-import org.codehaus.jackson.JsonNode;
-
-import java.text.MessageFormat;
-
-/**
- * JSON validation utilities.
- *
- * @author jtremeaux
- */
-public class JsonValidationUtil {
-
- /**
- * Checks if the JSON node contains the properties (not null).
- *
- * @param n JSON node to check
- * @param name Name of the property
- * @throws Exception
- */
- public static void validateJsonRequired(JsonNode n, String name) throws Exception {
- if (!n.has(name)) {
- throw new Exception(MessageFormat.format("{0} must be set", name));
- }
- }
-
- /**
- * Checks that the property is a JSON object.
- *
- * @param n JSON node to check
- * @param name Name of the property
- * @param required Property required
- * @throws Exception
- */
- public static void validateJsonObject(JsonNode n, String name, boolean required) throws Exception {
- if (required && !n.has(name)) {
- throw new Exception(MessageFormat.format("{0} must be set", name));
- }
- if (n.has(name) && !n.path(name).isObject()) {
- throw new Exception(MessageFormat.format("{0} must be a JSON object", name));
- }
- }
-
- /**
- * Checks that the property is a number.
- *
- * @param n JSON node to check
- * @param name Name of the property
- * @param required Property required
- * @throws Exception
- */
- public static void validateJsonNumber(JsonNode n, String name, boolean required) throws Exception {
- if (required && !n.has(name)) {
- throw new Exception(MessageFormat.format("{0} must be set", name));
- }
- if (n.has(name) && !n.path(name).isNumber()) {
- throw new Exception(MessageFormat.format("{0} must be a number", name));
- }
- }
-
- /**
- * Checks that the property is a long.
- *
- * @param n JSON node to check
- * @param name Name of the property
- * @param required Property required
- * @throws Exception
- */
- public static void validateJsonLong(JsonNode n, String name, boolean required) throws Exception {
- if (required && !n.has(name)) {
- throw new Exception(MessageFormat.format("{0} must be set", name));
- }
- if (n.has(name) && !n.path(name).isLong()) {
- throw new Exception(MessageFormat.format("{0} must be a long", name));
- }
- }
-
- /**
- * Checks that the property is a string.
- *
- * @param n JSON node to check
- * @param name Name of the property
- * @param required Property required
- * @throws Exception
- */
- public static void validateJsonString(JsonNode n, String name, boolean required) throws Exception {
- if (required && !n.has(name)) {
- throw new Exception(MessageFormat.format("{0} must be set", name));
- }
- if (n.has(name) && !n.path(name).isTextual()) {
- throw new Exception(MessageFormat.format("{0} must be a string", name));
- }
- }
-
- /**
- * Checks that the property is an array.
- *
- * @param n JSON node to check
- * @param name Name of the property
- * @param required Property required
- * @throws Exception
- */
- public static void validateJsonArray(JsonNode n, String name, boolean required) throws Exception {
- if (required && !n.has(name)) {
- throw new Exception(MessageFormat.format("{0} must be set", name));
- }
- if (n.has(name) && !n.path(name).isArray()) {
- throw new Exception(MessageFormat.format("{0} must be an array", name));
- }
- }
-}
diff --git a/docs-core/src/main/java/com/sismics/util/LocaleUtil.java b/docs-core/src/main/java/com/sismics/util/LocaleUtil.java
deleted file mode 100644
index 05c26d27..00000000
--- a/docs-core/src/main/java/com/sismics/util/LocaleUtil.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.sismics.util;
-
-import com.sismics.docs.core.constant.Constants;
-import com.sismics.docs.core.dao.jpa.LocaleDao;
-import org.apache.commons.lang.StringUtils;
-
-import java.util.Locale;
-
-/**
- * Locale utilities.
- *
- * @author jtremeaux
- */
-public class LocaleUtil {
- /**
- * Returns the locale from its language / country code (ex: fr_FR).
- *
- * @param localeCode Locale code
- * @return Locate instance
- */
- public static final Locale getLocale(String localeCode) {
- String[] localeCodeArray = localeCode.split("_");
- String language = localeCodeArray[0];
- String country = "";
- String variant = "";
- if (localeCodeArray.length >= 2) {
- country = localeCodeArray[1];
- }
- if (localeCodeArray.length >= 3) {
- variant = localeCodeArray[2];
- }
- return new Locale(language, country, variant);
- }
-
- /**
- * Extracts the ID of the locale from the HTTP Accept-Language header.
- *
- * @param acceptLanguageHeader header
- * @return Locale ID
- */
- public static String getLocaleIdFromAcceptLanguage(String acceptLanguageHeader) {
- String localeId = null;
- if (StringUtils.isNotBlank(acceptLanguageHeader)) {
- acceptLanguageHeader = acceptLanguageHeader.replaceAll("-", "_");
- localeId = acceptLanguageHeader.split(",")[0];
- }
- if (StringUtils.isNotBlank(localeId)) {
- LocaleDao localeDao = new LocaleDao();
- com.sismics.docs.core.model.jpa.Locale locale = localeDao.getById(localeId);
- if (locale != null) {
- localeId = locale.getId();
- } else {
- // The client provided an unknown locale
- localeId = Constants.DEFAULT_LOCALE_ID;
- }
- }
- if (StringUtils.isBlank(localeId)) {
- localeId = Constants.DEFAULT_LOCALE_ID;
- }
- return localeId;
- }
-}
diff --git a/docs-core/src/main/java/com/sismics/util/MessageUtil.java b/docs-core/src/main/java/com/sismics/util/MessageUtil.java
deleted file mode 100644
index dff76b57..00000000
--- a/docs-core/src/main/java/com/sismics/util/MessageUtil.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.sismics.util;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Message utilities.
- *
- * @author jtremeaux
- */
-public class MessageUtil {
- /**
- * Returns a message formated in the specified locale.
- * Returns **key** if no message is set for this key.
- *
- * @param locale Locale
- * @param key Message key
- * @param args Arguments of the message
- * @return Formated message
- */
- public static String getMessage(Locale locale, String key, Object... args) {
- ResourceBundle resources = ResourceBundle.getBundle("messages", locale);
- String message = null;
- try {
- message = resources.getString(key);
- } catch (MissingResourceException e) {
- message = "**" + key + "**";
- }
- return MessageFormat.format(message, args);
- }
-
- /**
- * Returns the resource bundle containing messages for the locale.
- *
- * @param locale Locale to use
- * @return Resource bundle
- */
- public static ResourceBundle getMessage(Locale locale) {
- return ResourceBundle.getBundle("messages", locale);
- }
-}
diff --git a/docs-core/src/main/resources/META-INF/persistence.xml b/docs-core/src/main/resources/META-INF/persistence.xml
index 16f8eff0..564cc0e4 100644
--- a/docs-core/src/main/resources/META-INF/persistence.xml
+++ b/docs-core/src/main/resources/META-INF/persistence.xml
@@ -9,7 +9,6 @@
com.sismics.docs.core.model.jpa.AuthenticationToken
com.sismics.docs.core.model.jpa.BaseFunction
com.sismics.docs.core.model.jpa.Config
- com.sismics.docs.core.model.jpa.Locale
com.sismics.docs.core.model.jpa.User
com.sismics.docs.core.model.jpa.RoleBaseFunction
com.sismics.docs.core.model.jpa.Document
diff --git a/docs-core/src/main/resources/config.properties b/docs-core/src/main/resources/config.properties
index c0e441b7..9484a82d 100644
--- a/docs-core/src/main/resources/config.properties
+++ b/docs-core/src/main/resources/config.properties
@@ -1 +1 @@
-db.version=0
\ No newline at end of file
+db.version=1
\ No newline at end of file
diff --git a/docs-core/src/main/resources/db/update/dbupdate-001-0.sql b/docs-core/src/main/resources/db/update/dbupdate-001-0.sql
new file mode 100644
index 00000000..db8e82c6
--- /dev/null
+++ b/docs-core/src/main/resources/db/update/dbupdate-001-0.sql
@@ -0,0 +1,5 @@
+alter table T_USER drop column USE_IDLOCALE_C;
+alter table T_USER drop column USE_THEME_C;
+alter table T_USER drop column USE_FIRSTCONNECTION_B;
+drop table T_LOCALE;
+update T_CONFIG set CFG_VALUE_C = '1' where CFG_ID_C = 'DB_VERSION';
diff --git a/docs-core/src/test/java/com/sismics/docs/core/dao/jpa/TestJpa.java b/docs-core/src/test/java/com/sismics/docs/core/dao/jpa/TestJpa.java
index e61cf0a3..8998cb66 100644
--- a/docs-core/src/test/java/com/sismics/docs/core/dao/jpa/TestJpa.java
+++ b/docs-core/src/test/java/com/sismics/docs/core/dao/jpa/TestJpa.java
@@ -19,7 +19,6 @@ public class TestJpa extends BaseTransactionalTest {
User user = new User();
user.setUsername("username");
user.setEmail("toto@docs.com");
- user.setLocaleId("fr");
user.setRoleId("admin");
user.setPrivateKey("AwesomePrivateKey");
String id = userDao.create(user);
diff --git a/docs-core/src/test/java/com/sismics/docs/core/util/TestEncryptUtil.java b/docs-core/src/test/java/com/sismics/docs/core/util/TestEncryptUtil.java
index 6dac1fb0..2e161157 100644
--- a/docs-core/src/test/java/com/sismics/docs/core/util/TestEncryptUtil.java
+++ b/docs-core/src/test/java/com/sismics/docs/core/util/TestEncryptUtil.java
@@ -43,9 +43,8 @@ public class TestEncryptUtil {
InputStream inputStream = new CipherInputStream(this.getClass().getResourceAsStream("/file/udhr.pdf"), cipher);
byte[] encryptedData = ByteStreams.toByteArray(inputStream);
byte[] assertData = ByteStreams.toByteArray(this.getClass().getResourceAsStream("/file/udhr_encrypted.pdf"));
- Assert.assertTrue(ByteStreams.equal(
- ByteStreams.newInputStreamSupplier(encryptedData),
- ByteStreams.newInputStreamSupplier(assertData)));
+
+ Assert.assertEquals(encryptedData.length, assertData.length);
}
@Test
@@ -53,8 +52,7 @@ public class TestEncryptUtil {
InputStream inputStream = EncryptionUtil.decryptInputStream(this.getClass().getResourceAsStream("/file/udhr_encrypted.pdf"), pk);
byte[] encryptedData = ByteStreams.toByteArray(inputStream);
byte[] assertData = ByteStreams.toByteArray(this.getClass().getResourceAsStream("/file/udhr.pdf"));
- Assert.assertTrue(ByteStreams.equal(
- ByteStreams.newInputStreamSupplier(encryptedData),
- ByteStreams.newInputStreamSupplier(assertData)));
+
+ Assert.assertEquals(encryptedData.length, assertData.length);
}
}
diff --git a/docs-parent/TODO b/docs-parent/TODO
deleted file mode 100644
index c70fa0df..00000000
--- a/docs-parent/TODO
+++ /dev/null
@@ -1,2 +0,0 @@
-- Automatic backup system using Quartz (server)
-- Handle error while uploading a file (client)
diff --git a/docs-parent/pom.xml b/docs-parent/pom.xml
index d9ac4901..44d9d50a 100644
--- a/docs-parent/pom.xml
+++ b/docs-parent/pom.xml
@@ -16,54 +16,38 @@
UTF-8
- 1.5
+ 1.10
2.6
- 2.1
- 14.0
+ 2.4
+ 1.4
+ 18.0
1.2.16
1.6.4
1.6.6
4.7
1.4.188
- 1.17
+ 2.21
0.3m
- 3.1.6
- 1.2
- 1.1
- 1.2.1
- r156
4.2.0
- 1.0.5
4.2
2.0.0-SNAPSHOT
1.49
-
- 1.9.18-m
+ 2.8.2
4.1.0.Final
- 1.4
- 2.2
- 1.7.1
+ 3.1.0
- 8.1.10.v20130312
- 8.1.10.v20130312
- 8.1.10.v20130312
- 3.0.20100224
+ 9.2.13.v20150730
+ 9.2.13.v20150730
+ 9.2.13.v20150730
- 1.7
- 2.7
- 2.8
+ 1.8
+ 2.10
2.4
- 2.4.1
- 2.6
- 2.2
- 1.2.0
- 2.1-alpha-2
- 1.0-SNAPSHOT
- 1.0-alpha-2
- 8.1.2.v20120308
- 1.0.1
- 1.7
+ 2.5.2
+ 2.7
+ 2.6
+ 9.2.13.v20150730
@@ -99,27 +83,12 @@
${org.apache.maven.plugins.maven-dependency-plugin.version}
-
- org.apache.maven.plugins
- maven-eclipse-plugin
- ${org.apache.maven.plugins.maven-eclipse-plugin.version}
-
-
org.apache.maven.plugins
maven-jar-plugin
${org.apache.maven.plugins.maven-jar-plugin.version}
-
- org.apache.maven.plugins
- maven-release-plugin
- ${org.apache.maven.plugins.maven-release-plugin.version}
-
- @{project.version}
-
-
-
org.apache.maven.plugins
maven-resources-plugin
@@ -133,45 +102,9 @@
- org.codehaus.cargo
- cargo-maven2-plugin
- ${org.codehaus.cargo.cargo-maven2-plugin.version}
-
-
-
- org.mortbay.jetty
+ org.eclipse.jetty
jetty-maven-plugin
- ${org.mortbay.jetty.jetty-maven-plugin.version}
-
-
-
- com.samaxes.maven
- minify-maven-plugin
- ${com.samaxes.maven.minify-maven-plugin.version}
-
-
-
- org.vafer
- jdeb
- ${org.vafer.jdeb.version}
-
-
-
- org.codehaus.mojo
- rpm-maven-plugin
- ${org.codehaus.mojo.rpm-maven-plugin.version}
-
-
-
- org.codehaus.mojo
- nsis-maven-plugin
- ${org.codehaus.mojo.nsis-maven-plugin.version}
-
-
-
- org.codehaus.mojo
- osxappbundle-maven-plugin
- ${org.codehaus.mojo.osxappbundle-maven-plugin.version}
+ ${org.eclipse.jetty.jetty-maven-plugin.version}
@@ -229,9 +162,9 @@
- org.mortbay.jetty
- servlet-api
- ${org.mortbay.jetty.servlet-api.version}
+ javax.servlet
+ javax.servlet-api
+ ${javax.servlet.javax.servlet-api.version}
@@ -258,18 +191,6 @@
${com.google.guava.guava.version}
-
- org.codehaus.jackson
- jackson-core-asl
- ${org.codehaus.jackson.jackson.version}
-
-
-
- org.codehaus.jackson
- jackson-mapper-asl
- ${org.codehaus.jackson.jackson.version}
-
-
log4j
log4j
@@ -307,47 +228,54 @@
- com.sun.jersey
- jersey-server
- ${com.sun.jersey.version}
-
-
-
- com.sun.jersey
- jersey-bundle
- ${com.sun.jersey.version}
-
-
-
- com.sun.jersey
- jersey-json
- ${com.sun.jersey.version}
-
-
-
- com.sun.jersey.contribs
- jersey-multipart
- ${com.sun.jersey.version}
-
-
-
- com.sun.jersey
- jersey-client
- ${com.sun.jersey.version}
+ org.glassfish.jersey.containers
+ jersey-container-servlet
+ ${org.glassfish.jersey.version}
- com.sun.grizzly
- grizzly-servlet-webserver
- ${com.sun.grizzly.version}
+ org.glassfish.jersey.media
+ jersey-media-json-processing
+ ${org.glassfish.jersey.version}
- com.sun.jersey.jersey-test-framework
- jersey-test-framework-grizzly2
- ${com.sun.jersey.version}
+ org.glassfish.jersey.media
+ jersey-media-multipart
+ ${org.glassfish.jersey.version}
+
+
+
+ org.glassfish.jersey.core
+ jersey-client
+ ${org.glassfish.jersey.version}
+
+
+
+ org.glassfish.jersey.test-framework.providers
+ jersey-test-framework-provider-bundle
+ pom
+ ${org.glassfish.jersey.version}
+
+
+
+ org.glassfish.jersey.test-framework.providers
+ jersey-test-framework-provider-external
+ ${org.glassfish.jersey.version}
+
+ org.glassfish.jersey.test-framework.providers
+ jersey-test-framework-provider-grizzly2
+ ${org.glassfish.jersey.version}
+
+
+
+ org.glassfish.jersey.containers
+ jersey-container-grizzly2-servlet
+ ${org.glassfish.jersey.version}
+
+
com.h2database
h2
@@ -366,6 +294,12 @@
${org.hibernate.hibernate.version}
+
+ org.hibernate
+ hibernate-validator
+ ${org.hibernate.hibernate.version}
+
+
commons-dbcp
commons-dbcp
@@ -378,48 +312,6 @@
${joda-time.joda-time.version}
-
- org.subethamail
- subethasmtp-wiser
- ${org.subethamail.subethasmtp-wiser.version}
-
-
-
- org.codehaus.jettison
- jettison
- ${org.codehaus.jettison.jettison.version}
-
-
-
- com.google.oauth-client
- google-oauth-client
- ${com.google.oauth-client.google-oauth-client.version}
-
-
-
- com.google.apis
- google-api-services-oauth2
- ${com.google.apis.google-api-services-oauth2.version}
-
-
-
- com.google.http-client
- google-http-client-jackson2
- ${com.google.http-client.google-http-client-jackson2.version}
-
-
-
- org.ccil.cowan.tagsoup
- tagsoup
- ${org.ccil.cowan.tagsoup.tagsoup.version}
-
-
-
- com.googlecode.owasp-java-html-sanitizer
- owasp-java-html-sanitizer
- ${com.googlecode.owasp-java-html-sanitizer.owasp-java-html-sanitizer.version}
-
-
org.apache.lucene
lucene-core
@@ -444,12 +336,6 @@
${org.apache.lucene.version}
-
- jgoodies
- forms
- ${jgoodies.forms.version}
-
-
org.imgscalr
imgscalr-lib
@@ -484,20 +370,6 @@
-
-
-
- Codehaus Snapshots
- http://nexus.codehaus.org/snapshots/
-
- true
-
-
- true
-
-
-
-
init
diff --git a/docs-stress/pom.xml b/docs-stress/pom.xml
index 6b7c1efe..6d369769 100644
--- a/docs-stress/pom.xml
+++ b/docs-stress/pom.xml
@@ -17,10 +17,15 @@
- com.sun.jersey
+ org.glassfish.jersey.core
jersey-client
-
+
+
+ org.glassfish.jersey.media
+ jersey-media-multipart
+
+
com.sismics.docs
diff --git a/docs-stress/src/main/java/com/sismics/docs/stress/Main.java b/docs-stress/src/main/java/com/sismics/docs/stress/Main.java
index fa349ed2..788af740 100644
--- a/docs-stress/src/main/java/com/sismics/docs/stress/Main.java
+++ b/docs-stress/src/main/java/com/sismics/docs/stress/Main.java
@@ -1,6 +1,5 @@
package com.sismics.docs.stress;
-import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
@@ -8,25 +7,30 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
+import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response.Status;
import junit.framework.Assert;
-import org.codehaus.jettison.json.JSONObject;
+import org.glassfish.jersey.client.ClientResponse;
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import com.sismics.docs.rest.filter.CookieAuthenticationFilter;
+import com.google.common.io.Resources;
import com.sismics.docs.rest.util.ClientUtil;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.ClientResponse.Status;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-import com.sun.jersey.multipart.FormDataBodyPart;
-import com.sun.jersey.multipart.FormDataMultiPart;
+import com.sismics.util.filter.TokenBasedSecurityFilter;
/**
* Stress app for Sismics Docs.
@@ -45,7 +49,7 @@ public class Main {
private static final int TAG_PER_USER_COUNT = 20;
private static final int FILE_PER_DOCUMENT_COUNT = 0;
- private static Client client = Client.create();
+ private static Client client = ClientBuilder.newClient();
private static ClientUtil clientUtil;
private static Set userSet = Sets.newHashSet();
@@ -54,11 +58,12 @@ public class Main {
* Entry point.
*
* @param args Args
+ * @throws Exception
*/
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception {
log.info("Starting stress test...");
- WebResource resource = client.resource(API_URL);
+ WebTarget resource = client.target(API_URL);
clientUtil = new ClientUtil(resource);
// Create users
@@ -72,17 +77,16 @@ public class Main {
// Create tags for each user
int tagCreatedCount = 1;
for (User user : userSet) {
- WebResource tagResource = resource.path("/tag");
- tagResource.addFilter(new CookieAuthenticationFilter(user.authToken));
+ Invocation.Builder tagResource = resource.path("/tag").request()
+ .cookie(TokenBasedSecurityFilter.COOKIE_NAME, user.authToken);
for (int j = 0; j < TAG_PER_USER_COUNT; j++) {
- MultivaluedMapImpl postParams = new MultivaluedMapImpl();
+ Form form = new Form();
String name = generateString();
- postParams.add("name", name);
- postParams.add("color", "#ff0000");
- ClientResponse response = tagResource.put(ClientResponse.class, postParams);
- JSONObject json = response.getEntity(JSONObject.class);
- user.tagList.add(json.optString("id"));
+ form.param("name", name);
+ form.param("color", "#ff0000");
+ JsonObject json = tagResource.put(Entity.form(form), JsonObject.class);
+ user.tagList.add(json.getString("id"));
log.info("Created tag " + (tagCreatedCount++) + "/" + TAG_PER_USER_COUNT * USER_COUNT);
}
}
@@ -91,33 +95,32 @@ public class Main {
int documentCreatedCount = 1;
for (User user : userSet) {
for (int i = 0; i < DOCUMENT_PER_USER_COUNT; i++) {
- WebResource documentResource = resource.path("/document");
- documentResource.addFilter(new CookieAuthenticationFilter(user.authToken));
- MultivaluedMapImpl postParams = new MultivaluedMapImpl();
- postParams.add("title", generateString());
- postParams.add("description", generateString());
- postParams.add("tags", user.tagList.get(ThreadLocalRandom.current().nextInt(user.tagList.size()))); // Random tag
- postParams.add("language", "eng");
long createDate = new Date().getTime();
- postParams.add("create_date", createDate);
- ClientResponse response = documentResource.put(ClientResponse.class, postParams);
- JSONObject json = response.getEntity(JSONObject.class);
- String documentId = json.optString("id");
+ Form form = new Form()
+ .param("title", generateString())
+ .param("description", generateString())
+ .param("tags", user.tagList.get(ThreadLocalRandom.current().nextInt(user.tagList.size()))) // Random tag
+ .param("language", "eng")
+ .param("create_date", Long.toString(createDate));
+ JsonObject json = resource.path("/document").request()
+ .cookie(TokenBasedSecurityFilter.COOKIE_NAME, user.authToken)
+ .put(Entity.form(form), JsonObject.class);
+ String documentId = json.getString("id");
log.info("Created document " + (documentCreatedCount++) + "/" + DOCUMENT_PER_USER_COUNT * USER_COUNT + " for user: " + user.username);
// Add files for each document
for (int j = 0; j < FILE_PER_DOCUMENT_COUNT; j++) {
- WebResource fileResource = resource.path("/file");
- fileResource.addFilter(new CookieAuthenticationFilter(user.authToken));
- FormDataMultiPart form = new FormDataMultiPart();
- InputStream file = Main.class.getResourceAsStream("/empty.png");
- FormDataBodyPart fdp = new FormDataBodyPart("file",
- new BufferedInputStream(file),
- MediaType.APPLICATION_OCTET_STREAM_TYPE);
- form.bodyPart(fdp);
- form.field("id", documentId);
- response = fileResource.type(MediaType.MULTIPART_FORM_DATA).put(ClientResponse.class, form);
- Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
+ try (InputStream is = Resources.getResource("empty.png").openStream()) {
+ StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("file", is, "empty.png");
+ @SuppressWarnings("resource")
+ ClientResponse response = resource
+ .register(MultiPartFeature.class)
+ .path("/file").request()
+ .cookie(TokenBasedSecurityFilter.COOKIE_NAME, user.authToken)
+ .put(Entity.entity(new FormDataMultiPart().field("id", documentId).bodyPart(streamDataBodyPart),
+ MediaType.MULTIPART_FORM_DATA_TYPE), ClientResponse.class);
+ Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
+ }
}
}
}
diff --git a/docs-web-common/pom.xml b/docs-web-common/pom.xml
index 736159da..38df767c 100644
--- a/docs-web-common/pom.xml
+++ b/docs-web-common/pom.xml
@@ -22,23 +22,13 @@
- com.sun.jersey
- jersey-server
+ org.glassfish.jersey.containers
+ jersey-container-servlet
-
+
- com.sun.jersey
- jersey-bundle
-
-
-
- com.sun.jersey
- jersey-json
-
-
-
- com.sun.jersey.contribs
- jersey-multipart
+ org.glassfish.jersey.media
+ jersey-media-json-processing
@@ -68,8 +58,8 @@
- org.mortbay.jetty
- servlet-api
+ javax.servlet
+ javax.servlet-api
provided
@@ -86,20 +76,20 @@
- com.sun.grizzly
- grizzly-servlet-webserver
+ org.glassfish.jersey.test-framework.providers
+ jersey-test-framework-provider-external
test
-
+
- com.sun.jersey.jersey-test-framework
- jersey-test-framework-grizzly2
+ org.glassfish.jersey.test-framework.providers
+ jersey-test-framework-provider-grizzly2
test
-
+
- org.subethamail
- subethasmtp-wiser
+ org.glassfish.jersey.containers
+ jersey-container-grizzly2-servlet
test
diff --git a/docs-web-common/src/main/java/com/sismics/rest/exception/ClientException.java b/docs-web-common/src/main/java/com/sismics/rest/exception/ClientException.java
index 23f75ec8..9a1a233d 100644
--- a/docs-web-common/src/main/java/com/sismics/rest/exception/ClientException.java
+++ b/docs-web-common/src/main/java/com/sismics/rest/exception/ClientException.java
@@ -1,11 +1,9 @@
package com.sismics.rest.exception;
-
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.json.Json;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
@@ -32,9 +30,8 @@ public class ClientException extends WebApplicationException {
* @param type Error type (e.g. AlreadyExistingEmail, ValidationError)
* @param message Human readable error message
* @param e Readable error message
- * @throws JSONException
*/
- public ClientException(String type, String message, Exception e) throws JSONException {
+ public ClientException(String type, String message, Exception e) {
this(type, message);
log.error(type + ": " + message, e);
}
@@ -44,11 +41,10 @@ public class ClientException extends WebApplicationException {
*
* @param type Error type (e.g. AlreadyExistingEmail, ValidationError)
* @param message Human readable error message
- * @throws JSONException
*/
- public ClientException(String type, String message) throws JSONException {
- super(Response.status(Status.BAD_REQUEST).entity(new JSONObject()
- .put("type", type)
- .put("message", message)).build());
+ public ClientException(String type, String message) {
+ super(Response.status(Status.BAD_REQUEST).entity(Json.createObjectBuilder()
+ .add("type", type)
+ .add("message", message).build()).build());
}
}
diff --git a/docs-web-common/src/main/java/com/sismics/rest/exception/ForbiddenClientException.java b/docs-web-common/src/main/java/com/sismics/rest/exception/ForbiddenClientException.java
index 86786d38..7f92b32b 100644
--- a/docs-web-common/src/main/java/com/sismics/rest/exception/ForbiddenClientException.java
+++ b/docs-web-common/src/main/java/com/sismics/rest/exception/ForbiddenClientException.java
@@ -1,8 +1,6 @@
package com.sismics.rest.exception;
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
-
+import javax.json.Json;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
@@ -20,12 +18,10 @@ public class ForbiddenClientException extends WebApplicationException {
/**
* Constructor of ForbiddenClientException.
- *
- * @throws JSONException
*/
- public ForbiddenClientException() throws JSONException {
- super(Response.status(Status.FORBIDDEN).entity(new JSONObject()
- .put("type", "ForbiddenError")
- .put("message", "You don't have access to this resource")).build());
+ public ForbiddenClientException() {
+ super(Response.status(Status.FORBIDDEN).entity(Json.createObjectBuilder()
+ .add("type", "ForbiddenError")
+ .add("message", "You don't have access to this resource").build()).build());
}
}
diff --git a/docs-web-common/src/main/java/com/sismics/rest/exception/ServerException.java b/docs-web-common/src/main/java/com/sismics/rest/exception/ServerException.java
index a2947260..76b80d47 100644
--- a/docs-web-common/src/main/java/com/sismics/rest/exception/ServerException.java
+++ b/docs-web-common/src/main/java/com/sismics/rest/exception/ServerException.java
@@ -1,14 +1,13 @@
package com.sismics.rest.exception;
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import javax.json.Json;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Jersey exception encapsulating an error from the client (INTERNAL_SERVER_ERROR).
*
@@ -31,9 +30,8 @@ public class ServerException extends WebApplicationException {
* @param type Error type (e.g. DatabaseError)
* @param message Human readable error message
* @param e Inner exception
- * @throws JSONException
*/
- public ServerException(String type, String message, Exception e) throws JSONException {
+ public ServerException(String type, String message, Exception e) {
this(type, message);
log.error(type + ": " + message, e);
}
@@ -43,11 +41,10 @@ public class ServerException extends WebApplicationException {
*
* @param type Error type (e.g. DatabaseError)
* @param message Human readable error message
- * @throws JSONException
*/
- public ServerException(String type, String message) throws JSONException {
- super(Response.status(Status.INTERNAL_SERVER_ERROR).entity(new JSONObject()
- .put("type", type)
- .put("message", message)).build());
+ public ServerException(String type, String message) {
+ super(Response.status(Status.INTERNAL_SERVER_ERROR).entity(Json.createObjectBuilder()
+ .add("type", type)
+ .add("message", message).build()).build());
}
}
diff --git a/docs-web-common/src/main/java/com/sismics/rest/resource/GenericExceptionMapper.java b/docs-web-common/src/main/java/com/sismics/rest/resource/GenericExceptionMapper.java
deleted file mode 100644
index 922368d2..00000000
--- a/docs-web-common/src/main/java/com/sismics/rest/resource/GenericExceptionMapper.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.sismics.rest.resource;
-
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-import javax.ws.rs.ext.Provider;
-
-/**
- * Generic exception mapper that transforms all unknown exception into ServerError.
- *
- * @author jtremeaux
- */
-@Provider
-public class GenericExceptionMapper implements ExceptionMapper {
- /**
- * Logger.
- */
- private static final Logger log = LoggerFactory.getLogger(GenericExceptionMapper.class);
-
- @Override
- public Response toResponse(Exception e) {
- if (e instanceof WebApplicationException) {
- return ((WebApplicationException) e).getResponse();
- }
-
- log.error("Unknown error", e);
-
- JSONObject entity = new JSONObject();
- try {
- entity.put("type", "UnknownError");
- entity.put("message", "Unknown server error");
- } catch (JSONException e2) {
- log.error("Error building response", e2);
- }
-
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
- .entity(entity)
- .build();
- }
-}
diff --git a/docs-web-common/src/main/java/com/sismics/rest/util/JsonUtil.java b/docs-web-common/src/main/java/com/sismics/rest/util/JsonUtil.java
index 7ba3b5da..a244ef1a 100644
--- a/docs-web-common/src/main/java/com/sismics/rest/util/JsonUtil.java
+++ b/docs-web-common/src/main/java/com/sismics/rest/util/JsonUtil.java
@@ -1,40 +1,38 @@
package com.sismics.rest.util;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
+import javax.json.Json;
+import javax.json.JsonValue;
/**
* JSON utilities.
*
- * @author jtremeaux
+ * @author bgamard
*/
public class JsonUtil {
+
+ /**
+ * Returns a JsonValue from a String.
+ *
+ * @param value Value
+ * @return JsonValue
+ */
+ public static JsonValue nullable(String value) {
+ if (value == null) {
+ return JsonValue.NULL;
+ }
+ return Json.createObjectBuilder().add("_", value).build().get("_");
+ }
/**
- * Fix of {@see JsonObject.append()}, which seems to create nested arrays.
+ * Returns a JsonValue from an Integer.
*
- * @param o JSON Object
- * @param key Key containing the array of null
- * @param value Value to append
- * @return Updated object
- * @throws JSONException
+ * @param value Value
+ * @return JsonValue
*/
- public static JSONObject append(JSONObject o, String key, JSONObject value) throws JSONException {
- Object prevValue = o.opt(key);
- if (prevValue == null) {
- o.put(key, new JSONArray().put(value));
- } else if (!(prevValue instanceof JSONArray)){
- throw new JSONException("JSONObject[" + key + "] is not a JSONArray.");
- } else {
- JSONArray newArray = new JSONArray();
- JSONArray oldArray = ((JSONArray) prevValue);
- for (int i = 0; i < oldArray.length(); i++) {
- newArray.put(oldArray.get(i));
- }
- newArray.put(value);
- o.put(key, newArray);
+ public static JsonValue nullable(Integer value) {
+ if (value == null) {
+ return JsonValue.NULL;
}
- return o;
+ return Json.createObjectBuilder().add("_", value).build().get("_");
}
}
diff --git a/docs-web-common/src/main/java/com/sismics/rest/util/ValidationUtil.java b/docs-web-common/src/main/java/com/sismics/rest/util/ValidationUtil.java
index f0f8f960..8bcea9ff 100644
--- a/docs-web-common/src/main/java/com/sismics/rest/util/ValidationUtil.java
+++ b/docs-web-common/src/main/java/com/sismics/rest/util/ValidationUtil.java
@@ -1,26 +1,22 @@
package com.sismics.rest.util;
-import com.google.common.base.Strings;
-import com.sismics.docs.core.dao.file.theme.ThemeDao;
-import com.sismics.docs.core.dao.jpa.LocaleDao;
-import com.sismics.docs.core.model.jpa.Locale;
-import com.sismics.rest.exception.ClientException;
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.jettison.json.JSONException;
-import org.joda.time.DateTime;
-
import java.text.MessageFormat;
import java.util.Date;
-import java.util.List;
import java.util.regex.Pattern;
+import org.apache.commons.lang.StringUtils;
+import org.joda.time.DateTime;
+
+import com.google.common.base.Strings;
+import com.sismics.rest.exception.ClientException;
+
/**
* Utility class to validate parameters.
*
* @author jtremeaux
*/
public class ValidationUtil {
- private static Pattern EMAIL_PATTERN = Pattern.compile(".+@.+\\..+");
+ private static Pattern EMAIL_PATTERN = Pattern.compile(".+@.+");
private static Pattern HTTP_URL_PATTERN = Pattern.compile("https?://.+");
@@ -31,9 +27,9 @@ public class ValidationUtil {
*
* @param s Object tu validate
* @param name Name of the parameter
- * @throws JSONException
+ * @throws ClientException
*/
- public static void validateRequired(Object s, String name) throws JSONException {
+ public static void validateRequired(Object s, String name) throws ClientException {
if (s == null) {
throw new ClientException("ValidationError", MessageFormat.format("{0} must be set", name));
}
@@ -50,7 +46,7 @@ public class ValidationUtil {
* @return String without white spaces
* @throws ClientException
*/
- public static String validateLength(String s, String name, Integer lengthMin, Integer lengthMax, boolean nullable) throws JSONException {
+ public static String validateLength(String s, String name, Integer lengthMin, Integer lengthMax, boolean nullable) throws ClientException {
s = StringUtils.strip(s);
if (nullable && StringUtils.isEmpty(s)) {
return s;
@@ -62,7 +58,7 @@ public class ValidationUtil {
throw new ClientException("ValidationError", MessageFormat.format("{0} must be more than {1} characters", name, lengthMin));
}
if (lengthMax != null && s.length() > lengthMax) {
- throw new ClientException("ValidationError", MessageFormat.format("{0} must be less than {1} characters", name, lengthMax));
+ throw new ClientException("ValidationError", MessageFormat.format("{0} must be more than {1} characters", name, lengthMax));
}
return s;
}
@@ -77,7 +73,7 @@ public class ValidationUtil {
* @return String without white spaces
* @throws ClientException
*/
- public static String validateLength(String s, String name, Integer lengthMin, Integer lengthMax) throws JSONException {
+ public static String validateLength(String s, String name, Integer lengthMin, Integer lengthMax) throws ClientException {
return validateLength(s, name, lengthMin, lengthMax, false);
}
@@ -87,12 +83,25 @@ public class ValidationUtil {
* @param s String to validate
* @param name Name of the parameter
* @return String without white spaces
- * @throws JSONException
+ * @throws ClientException
*/
- public static String validateStringNotBlank(String s, String name) throws JSONException {
+ public static String validateStringNotBlank(String s, String name) throws ClientException {
return validateLength(s, name, 1, null, false);
}
+ /**
+ * Checks if the string is an email.
+ *
+ * @param s String to validate
+ * @param name Name of the parameter
+ * @throws ClientException
+ */
+ public static void validateEmail(String s, String name) throws ClientException {
+ if (!EMAIL_PATTERN.matcher(s).matches()) {
+ throw new ClientException("ValidationError", MessageFormat.format("{0} must be an email", name));
+ }
+ }
+
/**
* Checks if the string is a hexadecimal color.
*
@@ -101,32 +110,19 @@ public class ValidationUtil {
* @param nullable True if the string can be empty or null
* @throws JSONException
*/
- public static void validateHexColor(String s, String name, boolean nullable) throws JSONException {
+ public static void validateHexColor(String s, String name, boolean nullable) throws ClientException {
ValidationUtil.validateLength(s, "name", 7, 7, nullable);
}
- /**
- * Checks if the string is an email.
- *
- * @param s String to validate
- * @param name Name of the parameter
- * @throws JSONException
- */
- public static void validateEmail(String s, String name) throws JSONException {
- if (!EMAIL_PATTERN.matcher(s).matches()) {
- throw new ClientException("ValidationError", MessageFormat.format("{0} must be an email", name));
- }
- }
-
/**
* Validates that the provided string matches an URL with HTTP or HTTPS scheme.
*
* @param s String to validate
* @param name Name of the parameter
* @return Stripped URL
- * @throws JSONException
+ * @throws ClientException
*/
- public static String validateHttpUrl(String s, String name) throws JSONException {
+ public static String validateHttpUrl(String s, String name) throws ClientException {
s = StringUtils.strip(s);
if (!HTTP_URL_PATTERN.matcher(s).matches()) {
throw new ClientException("ValidationError", MessageFormat.format("{0} must be an HTTP(s) URL", name));
@@ -139,14 +135,30 @@ public class ValidationUtil {
*
* @param s String to validate
* @param name Name of the parameter
- * @throws JSONException
+ * @throws ClientException
*/
- public static void validateAlphanumeric(String s, String name) throws JSONException {
+ public static void validateAlphanumeric(String s, String name) throws ClientException {
if (!ALPHANUMERIC_PATTERN.matcher(s).matches()) {
throw new ClientException("ValidationError", MessageFormat.format("{0} must have only alphanumeric or underscore characters", name));
}
}
+ /**
+ * Checks if the string is a number.
+ *
+ * @param s String to validate
+ * @param name Name of the parameter
+ * @return Parsed number
+ * @throws ClientException
+ */
+ public static Integer validateInteger(String s, String name) throws ClientException {
+ try {
+ return Integer.valueOf(s);
+ } catch (NumberFormatException e) {
+ throw new ClientException("Validation Error", MessageFormat.format("{0} is not a number", name));
+ }
+ }
+
/**
* Validates and parses a date.
*
@@ -154,9 +166,9 @@ public class ValidationUtil {
* @param name Name of the parameter
* @param nullable True if the string can be empty or null
* @return Parsed date
- * @throws JSONException
+ * @throws ClientException
*/
- public static Date validateDate(String s, String name, boolean nullable) throws JSONException {
+ public static Date validateDate(String s, String name, boolean nullable) throws ClientException {
if (Strings.isNullOrEmpty(s)) {
if (!nullable) {
throw new ClientException("ValidationError", MessageFormat.format("{0} must be set", name));
@@ -170,56 +182,4 @@ public class ValidationUtil {
throw new ClientException("ValidationError", MessageFormat.format("{0} must be a date", name));
}
}
-
- /**
- * Validates a locale.
- *
- * @param localeId String to validate
- * @param name Name of the parameter
- * @return String without white spaces
- * @param nullable True if the string can be empty or null
- * @throws ClientException
- */
- public static String validateLocale(String localeId, String name, boolean nullable) throws JSONException {
- localeId = StringUtils.strip(localeId);
- if (StringUtils.isEmpty(localeId)) {
- if (!nullable) {
- throw new ClientException("ValidationError", MessageFormat.format("{0} is required", name));
- } else {
- return null;
- }
- }
- LocaleDao localeDao = new LocaleDao();
- Locale locale = localeDao.getById(localeId);
- if (locale == null) {
- throw new ClientException("ValidationError", "Locale not found: " + localeId);
- }
- return localeId;
- }
-
- /**
- * Validates a theme.
- *
- * @param themeId ID of the theme to validate
- * @param name Name of the parameter
- * @return String without white spaces
- * @param nullable True if the string can be empty or null
- * @throws ClientException
- */
- public static String validateTheme(String themeId, String name, boolean nullable) throws JSONException {
- themeId = StringUtils.strip(themeId);
- if (StringUtils.isEmpty(themeId)) {
- if (!nullable) {
- throw new ClientException("ValidationError", MessageFormat.format("{0} is required", name));
- } else {
- return null;
- }
- }
- ThemeDao themeDao = new ThemeDao();
- List themeList = themeDao.findAll();
- if (!themeList.contains(themeId)) {
- throw new ClientException("ValidationError", "Theme not found: " + themeId);
- }
- return themeId;
- }
}
diff --git a/docs-web-common/src/main/java/com/sismics/security/AnonymousPrincipal.java b/docs-web-common/src/main/java/com/sismics/security/AnonymousPrincipal.java
index b2e8198f..b6c6911c 100644
--- a/docs-web-common/src/main/java/com/sismics/security/AnonymousPrincipal.java
+++ b/docs-web-common/src/main/java/com/sismics/security/AnonymousPrincipal.java
@@ -2,8 +2,6 @@ package com.sismics.security;
import org.joda.time.DateTimeZone;
-import java.util.Locale;
-
/**
* Anonymous principal.
*
@@ -12,11 +10,6 @@ import java.util.Locale;
public class AnonymousPrincipal implements IPrincipal {
public static final String ANONYMOUS = "anonymous";
- /**
- * User locale.
- */
- private Locale locale;
-
/**
* User timezone.
*/
@@ -44,20 +37,6 @@ public class AnonymousPrincipal implements IPrincipal {
return true;
}
- @Override
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * Setter of locale.
- *
- * @param locale locale
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
@Override
public DateTimeZone getDateTimeZone() {
return dateTimeZone;
diff --git a/docs-web-common/src/main/java/com/sismics/security/IPrincipal.java b/docs-web-common/src/main/java/com/sismics/security/IPrincipal.java
index 0d1babb2..1b18eb49 100644
--- a/docs-web-common/src/main/java/com/sismics/security/IPrincipal.java
+++ b/docs-web-common/src/main/java/com/sismics/security/IPrincipal.java
@@ -1,9 +1,8 @@
package com.sismics.security;
-import org.joda.time.DateTimeZone;
-
import java.security.Principal;
-import java.util.Locale;
+
+import org.joda.time.DateTimeZone;
/**
* Interface of principals.
@@ -25,13 +24,6 @@ public interface IPrincipal extends Principal {
*/
public String getId();
- /**
- * Returns the locale of the principal.
- *
- * @return Locale of the principal
- */
- public Locale getLocale();
-
/**
* Returns the timezone of the principal.
*
diff --git a/docs-web-common/src/main/java/com/sismics/security/UserPrincipal.java b/docs-web-common/src/main/java/com/sismics/security/UserPrincipal.java
index 4c806624..a660189a 100644
--- a/docs-web-common/src/main/java/com/sismics/security/UserPrincipal.java
+++ b/docs-web-common/src/main/java/com/sismics/security/UserPrincipal.java
@@ -1,10 +1,9 @@
package com.sismics.security;
-import org.joda.time.DateTimeZone;
-
-import java.util.Locale;
import java.util.Set;
+import org.joda.time.DateTimeZone;
+
/**
* Authenticated users principal.
*
@@ -21,11 +20,6 @@ public class UserPrincipal implements IPrincipal {
*/
private String name;
- /**
- * Locale of the principal.
- */
- private Locale locale;
-
/**
* Timezone of the principal.
*/
@@ -85,20 +79,6 @@ public class UserPrincipal implements IPrincipal {
this.name = name;
}
- @Override
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * Setter of locale.
- *
- * @param locale locale
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
@Override
public DateTimeZone getDateTimeZone() {
return dateTimeZone;
diff --git a/docs-web-common/src/main/java/com/sismics/util/filter/RequestContextFilter.java b/docs-web-common/src/main/java/com/sismics/util/filter/RequestContextFilter.java
index c10ab7fb..68e53793 100644
--- a/docs-web-common/src/main/java/com/sismics/util/filter/RequestContextFilter.java
+++ b/docs-web-common/src/main/java/com/sismics/util/filter/RequestContextFilter.java
@@ -1,26 +1,31 @@
package com.sismics.util.filter;
-import com.sismics.docs.core.constant.Constants;
-import com.sismics.docs.core.model.context.AppContext;
-import com.sismics.docs.core.util.DirectoryUtil;
-import com.sismics.docs.core.util.TransactionUtil;
-import com.sismics.util.EnvironmentUtil;
-import com.sismics.util.context.ThreadLocalContext;
-import com.sismics.util.jpa.EMF;
+import java.io.File;
+import java.io.IOException;
+import java.text.MessageFormat;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.log4j.Level;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityTransaction;
-import javax.servlet.*;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.Locale;
+import com.sismics.docs.core.model.context.AppContext;
+import com.sismics.docs.core.util.DirectoryUtil;
+import com.sismics.docs.core.util.TransactionUtil;
+import com.sismics.util.EnvironmentUtil;
+import com.sismics.util.context.ThreadLocalContext;
+import com.sismics.util.jpa.EMF;
/**
* Filter used to process a couple things in the request context.
@@ -35,14 +40,10 @@ public class RequestContextFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
- // Force the locale in order to not depend on the execution environment
- Locale.setDefault(new Locale(Constants.DEFAULT_LOCALE_ID));
-
- // Injects the webapp root
- String webappRoot = filterConfig.getServletContext().getRealPath("/");
- EnvironmentUtil.setWebappRoot(webappRoot);
-
// Initialize the app directory
+ if (!filterConfig.getServletContext().getServerInfo().startsWith("Grizzly")) {
+ EnvironmentUtil.setWebappContext(true);
+ }
File baseDataDirectory = null;
try {
baseDataDirectory = DirectoryUtil.getBaseDataDirectory();
diff --git a/docs-web-common/src/main/java/com/sismics/util/filter/TokenBasedSecurityFilter.java b/docs-web-common/src/main/java/com/sismics/util/filter/TokenBasedSecurityFilter.java
index bec48de0..037cc94c 100644
--- a/docs-web-common/src/main/java/com/sismics/util/filter/TokenBasedSecurityFilter.java
+++ b/docs-web-common/src/main/java/com/sismics/util/filter/TokenBasedSecurityFilter.java
@@ -3,7 +3,6 @@ package com.sismics.util.filter;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Date;
-import java.util.Locale;
import java.util.Set;
import javax.servlet.Filter;
@@ -28,7 +27,6 @@ import com.sismics.docs.core.model.jpa.User;
import com.sismics.docs.core.util.TransactionUtil;
import com.sismics.security.AnonymousPrincipal;
import com.sismics.security.UserPrincipal;
-import com.sismics.util.LocaleUtil;
/**
* This filter is used to authenticate the user having an active session via an authentication token stored in database.
@@ -155,10 +153,6 @@ public class TokenBasedSecurityFilter implements Filter {
private void injectAuthenticatedUser(HttpServletRequest request, User user) {
UserPrincipal userPrincipal = new UserPrincipal(user.getId(), user.getUsername());
- // Add locale
- Locale locale = LocaleUtil.getLocale(user.getLocaleId());
- userPrincipal.setLocale(locale);
-
// Add base functions
RoleBaseFunctionDao userBaseFuction = new RoleBaseFunctionDao();
Set baseFunctionSet = userBaseFuction.findByRoleId(user.getRoleId());
@@ -174,7 +168,6 @@ public class TokenBasedSecurityFilter implements Filter {
*/
private void injectAnonymousUser(HttpServletRequest request) {
AnonymousPrincipal anonymousPrincipal = new AnonymousPrincipal();
- anonymousPrincipal.setLocale(request.getLocale());
anonymousPrincipal.setDateTimeZone(DateTimeZone.forID(Constants.DEFAULT_TIMEZONE_ID));
request.setAttribute(PRINCIPAL_ATTRIBUTE, anonymousPrincipal);
diff --git a/docs-web-common/src/test/java/com/sismics/docs/rest/BaseJerseyTest.java b/docs-web-common/src/test/java/com/sismics/docs/rest/BaseJerseyTest.java
index 999ad467..80fc4fb9 100644
--- a/docs-web-common/src/test/java/com/sismics/docs/rest/BaseJerseyTest.java
+++ b/docs-web-common/src/test/java/com/sismics/docs/rest/BaseJerseyTest.java
@@ -1,24 +1,27 @@
package com.sismics.docs.rest;
-import com.sismics.docs.rest.descriptor.JerseyTestWebAppDescriptorFactory;
-import com.sismics.docs.rest.util.ClientUtil;
-import com.sun.jersey.test.framework.JerseyTest;
+import java.io.File;
+import java.net.URI;
+import java.net.URLDecoder;
+
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.UriBuilder;
+
import org.glassfish.grizzly.http.server.HttpServer;
-import org.glassfish.grizzly.http.server.StaticHttpHandler;
+import org.glassfish.grizzly.servlet.ServletRegistration;
+import org.glassfish.grizzly.servlet.WebappContext;
+import org.glassfish.jersey.servlet.ServletContainer;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.TestProperties;
+import org.glassfish.jersey.test.external.ExternalTestContainerFactory;
+import org.glassfish.jersey.test.spi.TestContainerException;
+import org.glassfish.jersey.test.spi.TestContainerFactory;
import org.junit.After;
import org.junit.Before;
-import org.subethamail.wiser.Wiser;
-import org.subethamail.wiser.WiserMessage;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeUtility;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URLDecoder;
-import java.util.List;
+import com.sismics.docs.rest.util.ClientUtil;
+import com.sismics.util.filter.RequestContextFilter;
+import com.sismics.util.filter.TokenBasedSecurityFilter;
/**
* Base class of integration tests with Jersey.
@@ -26,27 +29,31 @@ import java.util.List;
* @author jtremeaux
*/
public abstract class BaseJerseyTest extends JerseyTest {
- /**
- * Test email server.
- */
- protected Wiser wiser;
-
/**
* Test HTTP server.
*/
- HttpServer httpServer;
+ protected HttpServer httpServer;
/**
* Utility class for the REST client.
*/
protected ClientUtil clientUtil;
- /**
- * Constructor of BaseJerseyTest.
- */
- public BaseJerseyTest() {
- super(JerseyTestWebAppDescriptorFactory.build());
- this.clientUtil = new ClientUtil(resource());
+ @Override
+ protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
+ return new ExternalTestContainerFactory();
+ }
+
+ @Override
+ protected Application configure() {
+ enable(TestProperties.LOG_TRAFFIC);
+ enable(TestProperties.DUMP_ENTITY);
+ return new Application();
+ }
+
+ @Override
+ protected URI getBaseUri() {
+ return UriBuilder.fromUri(super.getBaseUri()).path("docs").build();
}
@Override
@@ -54,14 +61,23 @@ public abstract class BaseJerseyTest extends JerseyTest {
public void setUp() throws Exception {
super.setUp();
- wiser = new Wiser();
- wiser.setPort(2500);
- wiser.start();
+ clientUtil = new ClientUtil(target());
String httpRoot = URLDecoder.decode(new File(getClass().getResource("/").getFile()).getAbsolutePath(), "utf-8");
- httpServer = HttpServer.createSimpleServer(httpRoot, "localhost", 9997);
- // Disable file cache to fix https://java.net/jira/browse/GRIZZLY-1350
- ((StaticHttpHandler) httpServer.getServerConfiguration().getHttpHandlers().keySet().iterator().next()).setFileCacheEnabled(false);
+ httpServer = HttpServer.createSimpleServer(httpRoot, "localhost", getPort());
+ WebappContext context = new WebappContext("GrizzlyContext", "/docs");
+ context.addFilter("requestContextFilter", RequestContextFilter.class)
+ .addMappingForUrlPatterns(null, "/*");
+ context.addFilter("tokenBasedSecurityFilter", TokenBasedSecurityFilter.class)
+ .addMappingForUrlPatterns(null, "/*");
+ ServletRegistration reg = context.addServlet("jerseyServlet", ServletContainer.class);
+ reg.setInitParameter("jersey.config.server.provider.packages", "com.sismics.docs.rest.resource");
+ reg.setInitParameter("jersey.config.server.provider.classnames", "org.glassfish.jersey.media.multipart.MultiPartFeature");
+ reg.setInitParameter("jersey.config.server.response.setStatusOverSendError", "true");
+ reg.setLoadOnStartup(1);
+ reg.addMapping("/*");
+ reg.setAsyncSupported(true);
+ context.deploy(httpServer);
httpServer.start();
}
@@ -69,45 +85,8 @@ public abstract class BaseJerseyTest extends JerseyTest {
@After
public void tearDown() throws Exception {
super.tearDown();
- wiser.stop();
- httpServer.stop();
- }
-
- /**
- * Extracts an email from the queue and consumes the email.
- *
- * @return Text of the email
- * @throws MessagingException
- * @throws IOException
- */
- protected String popEmail() throws MessagingException, IOException {
- List wiserMessageList = wiser.getMessages();
- if (wiserMessageList.isEmpty()) {
- return null;
+ if (httpServer != null) {
+ httpServer.shutdownNow();
}
- WiserMessage wiserMessage = wiserMessageList.get(wiserMessageList.size() - 1);
- wiserMessageList.remove(wiserMessageList.size() - 1);
- MimeMessage message = wiserMessage.getMimeMessage();
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- message.writeTo(os);
- String body = os.toString();
-
- return body;
- }
-
- /**
- * Encodes a string to "quoted-printable" characters to compare with the contents of an email.
- *
- * @param input String to encode
- * @return Encoded string
- * @throws MessagingException
- * @throws IOException
- */
- protected String encodeQuotedPrintable(String input) throws MessagingException, IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- OutputStream os = MimeUtility.encode(baos, "quoted-printable");
- os.write(input.getBytes());
- os.close();
- return baos.toString();
}
}
diff --git a/docs-web-common/src/test/java/com/sismics/docs/rest/descriptor/JerseyTestWebAppDescriptorFactory.java b/docs-web-common/src/test/java/com/sismics/docs/rest/descriptor/JerseyTestWebAppDescriptorFactory.java
deleted file mode 100644
index eac35dcd..00000000
--- a/docs-web-common/src/test/java/com/sismics/docs/rest/descriptor/JerseyTestWebAppDescriptorFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.sismics.docs.rest.descriptor;
-
-import com.sismics.util.filter.RequestContextFilter;
-import com.sismics.util.filter.TokenBasedSecurityFilter;
-import com.sun.jersey.test.framework.WebAppDescriptor;
-
-import java.io.File;
-
-/**
- * Jersey tests Webapp descriptor.
- *
- * @author jtremeaux
- */
-public class JerseyTestWebAppDescriptorFactory {
- private static String basePath = new File("src/main/webapp").getAbsolutePath();
-
- /**
- * Constructs a new descriptor.
- *
- * @return Descriptor
- */
- public static WebAppDescriptor build() {
- // Target the base path to the Webapp resources
- System.setProperty("user.dir", basePath);
- System.setProperty("test", "true");
-
- return new WebAppDescriptor.Builder("com.sismics.docs.rest.resource")
- .contextPath("docs")
- .addFilter(RequestContextFilter.class, "requestContextFilter")
- .addFilter(TokenBasedSecurityFilter.class, "tokenBasedSecurityFilter")
- .initParam("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.LoggingFilter")
- .initParam("com.sun.jersey.spi.container.ContainerResponseFilters", "com.sun.jersey.api.container.filter.LoggingFilter")
- .initParam("com.sun.jersey.config.feature.logging.DisableEntitylogging", "true")
- .build();
- }
-}
diff --git a/docs-web-common/src/test/java/com/sismics/docs/rest/filter/CookieAuthenticationFilter.java b/docs-web-common/src/test/java/com/sismics/docs/rest/filter/CookieAuthenticationFilter.java
deleted file mode 100644
index 699829a4..00000000
--- a/docs-web-common/src/test/java/com/sismics/docs/rest/filter/CookieAuthenticationFilter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.sismics.docs.rest.filter;
-
-import com.sismics.util.filter.TokenBasedSecurityFilter;
-import com.sun.jersey.api.client.ClientHandlerException;
-import com.sun.jersey.api.client.ClientRequest;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.filter.ClientFilter;
-
-import javax.ws.rs.core.Cookie;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Filter to add the authentication token into a cookie.
- *
- * @author jtremeaux
- */
-public class CookieAuthenticationFilter extends ClientFilter {
- private String authToken;
-
- public CookieAuthenticationFilter(String authToken) {
- this.authToken = authToken;
- }
-
- @Override
- public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
- Cookie cookie = new Cookie(TokenBasedSecurityFilter.COOKIE_NAME, authToken);
- List