]> SALOME platform Git repositories - modules/gde.git/commitdiff
Salome HOME
Separate tests from the application
authorKavoos Bojnourdi <kavoos.bojnourdi@edf.fr>
Sun, 16 Aug 2015 08:41:29 +0000 (10:41 +0200)
committerKavoos Bojnourdi <kavoos.bojnourdi@edf.fr>
Sun, 16 Aug 2015 08:41:29 +0000 (10:41 +0200)
72 files changed:
gitignore/gitignore [new file with mode: 0644]
projects/GDE-test/src/com/edf/gde/base/BaseTest.java [new file with mode: 0644]
projects/GDE-test/src/com/edf/gde/dao/AttributeDaoClient.java [new file with mode: 0644]
projects/GDE-test/src/com/edf/gde/dao/BaseDao.java [new file with mode: 0644]
projects/GDE-test/src/com/edf/gde/dao/ProfileDaoClient.java [new file with mode: 0644]
projects/GDE-test/src/com/edf/gde/dao/StudyDaoClient.java [new file with mode: 0644]
projects/GDE-test/src/com/edf/gde/dao/UserDaoClient.java [new file with mode: 0644]
projects/GDE-test/src/gde/test/GDETest.java [new file with mode: 0644]
projects/GDE-test/src/restapi/Base64.java [new file with mode: 0644]
projects/GDE-test/src/restapi/DefaultResponseHandler.java [new file with mode: 0644]
projects/GDE-test/src/restapi/ResponseHandler.java [new file with mode: 0644]
projects/GDE-test/src/restapi/RestContext.java [new file with mode: 0644]
projects/GDE-test/src/restapi/SimpleRestApi.java [new file with mode: 0644]
projects/GDE-test/src/restapi/exceptions/RestResponseException.java [new file with mode: 0644]
projects/GDE-test/src/restapi/providers/CertificateProvider.java [new file with mode: 0644]
projects/GDE-test/src/restapi/providers/FileCertificateProvider.java [new file with mode: 0644]
projects/GDE-test/test/com/edf/gde/test/dao/AttributeDaoTest.java [new file with mode: 0644]
projects/GDE-test/test/com/edf/gde/test/dao/ProfileDaoTest.java [new file with mode: 0644]
projects/GDE-test/test/com/edf/gde/test/dao/StudyDaoTest.java [new file with mode: 0644]
projects/GDE-test/test/com/edf/gde/test/dao/UserDaoTest.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/AttributeGroupTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/AttributeTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/ChunkTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/CommandTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/FileTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/GroupTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/LongListTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/ProfileAttributeTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/ProfileTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/StudyTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/UserTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/responses/CommandResultTO.java [new file with mode: 0644]
projects/GDE-transferables/src/com/edf/gde/transferables/responses/ObjectCreationResponseTO.java [new file with mode: 0644]
projects/GDE_App/GDE-ejb/nbproject/build-impl.xml
projects/GDE_App/GDE-ejb/nbproject/genfiles.properties
projects/GDE_App/GDE-ejb/nbproject/project.properties
projects/GDE_App/GDE-ejb/nbproject/project.xml
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/AttributeGroupTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/AttributeTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ChunkTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/CommandTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/FileTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/GroupTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/LongListTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ProfileAttributeTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ProfileTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/StudyTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/UserTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/responses/CommandResultTO.java [deleted file]
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/responses/ObjectCreationResponseTO.java [deleted file]
projects/GDE_App/GDE-war/nbproject/build-impl.xml
projects/GDE_App/GDE-war/nbproject/genfiles.properties
projects/GDE_App/GDE-war/nbproject/project.properties
projects/GDE_App/GDE-war/nbproject/project.xml
projects/GDE_App/GDE-war/test/com/edf/gde/dao/AttributeDaoClient.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/dao/ProfileDaoClient.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/dao/StudyDaoClient.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/dao/UserDaoClient.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/test/base/BaseTest.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/AttributeDaoTest.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/ProfileDaoTest.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/StudyDaoTest.java [deleted file]
projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/UserDaoTest.java [deleted file]
projects/GDE_App/GDE-war/test/restapi/Base64.java [deleted file]
projects/GDE_App/GDE-war/test/restapi/DefaultResponseHandler.java [deleted file]
projects/GDE_App/GDE-war/test/restapi/ResponseHandler.java [deleted file]
projects/GDE_App/GDE-war/test/restapi/RestContext.java [deleted file]
projects/GDE_App/GDE-war/test/restapi/SimpleRestApi.java [deleted file]
projects/GDE_App/GDE-war/test/restapi/exceptions/RestResponseException.java [deleted file]
projects/GDE_App/GDE-war/test/restapi/providers/CertificateProvider.java [deleted file]
projects/GDE_App/GDE-war/test/restapi/providers/FileCertificateProvider.java [deleted file]

diff --git a/gitignore/gitignore b/gitignore/gitignore
new file mode 100644 (file)
index 0000000..1910254
--- /dev/null
@@ -0,0 +1,17 @@
+/projects/GDE_App/nbproject/private/
+/projects/GDE_App/GDE-ejb/nbproject/private/
+/projects/GDE_App/GDE-war/nbproject/private/
+/projects/GDE_App/GDE-ejb/build/
+/projects/GDE_App/GDE-ejb/dist/
+/projects/GDE_App/GDE-war/build/
+/projects/GDE_App/dist/
+/projects/GDE_App/build/
+/projects/GDE_App/GDE-war/dist/
+/GDE-test/nbproject/private/
+/projects/JavaApplication5/nbproject/private/
+/projects/GDE-test/nbproject/private/
+/projects/GDE-transferables/nbproject/private/
+/projects/GDE-transferables/build/
+/projects/GDE-transferables/dist/
+/projects/GDE-test/build/
+/projects/GDE-test/dist/
\ No newline at end of file
diff --git a/projects/GDE-test/src/com/edf/gde/base/BaseTest.java b/projects/GDE-test/src/com/edf/gde/base/BaseTest.java
new file mode 100644 (file)
index 0000000..448613a
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.base;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class BaseTest {
+
+    public BaseTest() {
+    }
+    
+    protected void testName(String message) {
+        System.out.print(message);
+    }
+    
+    protected void passed() {
+        System.out.println(" -- [OK]");
+    }
+}
diff --git a/projects/GDE-test/src/com/edf/gde/dao/AttributeDaoClient.java b/projects/GDE-test/src/com/edf/gde/dao/AttributeDaoClient.java
new file mode 100644 (file)
index 0000000..52b6591
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.dao;
+
+import com.edf.gde.transferables.AttributeGroupTO;
+import com.edf.gde.transferables.AttributeTO;
+import com.edf.gde.transferables.CommandTO;
+import java.io.IOException;
+import restapi.RestContext;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class AttributeDaoClient extends BaseDao {
+
+    public static final String ServiceName = "AttributesService";
+    public static final int CREATEATTRIBUTE = 1;
+    public static final int DELETEATTRIBUTE = 2;
+    public static final int READATTRIBUTE = 3;
+    public static final int CREATEATTRIBUTEGROUP = 4;
+    public static final int DELETEATTRIBUTEGROUP = 5;
+    public static final int UPDATEATTRIBUTEGROUP = 6;
+    public static final int READATTRIBUTEGROUP = 7;
+
+
+    public AttributeDaoClient() {
+        getContext().setBaseResource("http://localhost:8080/GDE-war/AttributesService");
+        getContext().setUserName("admin");
+        getContext().setPassword("edf123");
+    }
+
+    public AttributeDaoClient(DaoResponseHandler daoResponseHandler, RestContext context) {
+        super(context);
+    }
+
+    public AttributeTO createAttribute(AttributeTO ato) throws IOException {
+        CommandTO commandTO = createCommand(CREATEATTRIBUTE);
+        return postCommand(commandTO, ato, AttributeTO.class);
+    }
+
+    public void deleteAttribute(long id) throws IOException {
+        CommandTO commandTO = createCommand(DELETEATTRIBUTE);
+        commandTO.setLong("attributeId", id);
+        postCommand(commandTO, null);
+    }
+
+    public AttributeTO readAttribute(long id) throws IOException {
+        CommandTO commandTO = createCommand(READATTRIBUTE);
+        commandTO.setLong("attributeId", id);
+        return postCommand(commandTO, null, AttributeTO.class);
+    }
+
+    public AttributeGroupTO createAttributeGroup(AttributeGroupTO agto) throws IOException {
+        CommandTO commandTO = createCommand(CREATEATTRIBUTEGROUP);
+        return postCommand(commandTO, agto, AttributeGroupTO.class);
+    }
+    
+    public void deleteAttributeGroup(long id) throws IOException {
+        CommandTO commandTO = createCommand(DELETEATTRIBUTEGROUP);
+        commandTO.setLong("attributeGroupId", id);
+        postCommand(commandTO, null);
+    }
+    
+    public AttributeGroupTO updateAttributeGroup(AttributeGroupTO agto) throws IOException {
+        CommandTO commandTO = createCommand(UPDATEATTRIBUTEGROUP);
+        return postCommand(commandTO, agto, AttributeGroupTO.class);
+    }
+    
+    public AttributeGroupTO readAttributeGroup(long id) throws IOException {
+        CommandTO commandTO = createCommand(READATTRIBUTEGROUP);
+        commandTO.setLong("attributeGroupId", id);
+        return postCommand(commandTO, null, AttributeGroupTO.class);
+    }
+    
+}
diff --git a/projects/GDE-test/src/com/edf/gde/dao/BaseDao.java b/projects/GDE-test/src/com/edf/gde/dao/BaseDao.java
new file mode 100644 (file)
index 0000000..cb81114
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.dao;
+
+import com.edf.gde.transferables.CommandTO;
+import com.edf.gde.transferables.responses.CommandResultTO;
+import java.io.IOException;
+import restapi.ResponseHandler;
+import restapi.RestContext;
+import restapi.SimpleRestApi;
+
+/**
+ *
+ * @author Kavoos
+ */
+public abstract class BaseDao extends SimpleRestApi {
+
+    protected DaoResponseHandler daoResponseHandler = new DaoResponseHandler();
+
+    public BaseDao() {
+        super();
+
+    }
+
+    public BaseDao(RestContext context) {
+        super(context);
+    }
+
+    protected <T> T fromJson(String json, Class<T> classOf) {
+
+        return gson.fromJson(json, classOf);
+    }
+
+    protected String toJson(Object object) {
+        return gson.toJson(object);
+    }
+
+    protected CommandTO createCommand(int methodIndex) {
+        CommandTO commandTO = new CommandTO();
+        commandTO.setMethod(methodIndex);
+        return commandTO;
+    }
+
+    protected class DaoResponseHandler implements ResponseHandler {
+
+        protected boolean callResult;
+        protected int resultCode;
+        protected String callResponse;
+
+        @Override
+        public boolean checkResponse(int code, String response) {
+            this.resultCode = code;
+            callResult = false;
+            if (resultCode == 200) {
+                callResult = true;
+                callResponse = response;
+            }
+            return callResult;
+        }
+
+        public boolean isCallResult() {
+            return callResult;
+        }
+
+        public int getResultCode() {
+            return resultCode;
+        }
+
+        public CommandResultTO getResultTO() {
+            CommandResultTO resultTO;
+            resultTO = fromJson(callResponse, CommandResultTO.class);
+            return resultTO;
+        }
+    }
+
+    /**
+     * Post a command
+     * @param <T> 
+     * @param commandTO 
+     * @param object Object to be posted or null if no object
+     * @param classOf Type of the return value 
+     * @return Return a value of type T
+     * @throws IOException
+     */
+    protected <T> T postCommand(CommandTO commandTO, Object object, Class<T> classOf) throws IOException {
+        if (object != null) {
+            commandTO.setData(toJson(object));
+        }
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                T ato = fromJson(resultTO.getData(), classOf);
+                return ato;
+            }
+        }
+        throw new RuntimeException("Unable to execute command (methode : " + commandTO.getMethod() + ")");
+    }
+
+    /**
+     * Post a command
+     * @param commandTO
+     * @param object Object to be posted or null if no object
+     * @throws IOException
+     */
+    protected void postCommand(CommandTO commandTO, Object object) throws IOException {
+        if (object != null) {
+            commandTO.setData(toJson(object));
+        }
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                return;
+            }
+        }
+        throw new RuntimeException("Unable to execute command (methode : " + commandTO.getMethod() + ")");
+    }
+
+}
diff --git a/projects/GDE-test/src/com/edf/gde/dao/ProfileDaoClient.java b/projects/GDE-test/src/com/edf/gde/dao/ProfileDaoClient.java
new file mode 100644 (file)
index 0000000..e137ba4
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.dao;
+
+import com.edf.gde.transferables.CommandTO;
+import com.edf.gde.transferables.ProfileAttributeTO;
+import com.edf.gde.transferables.ProfileTO;
+import java.io.IOException;
+import restapi.RestContext;
+
+/**
+ *
+ * @author mordicus
+ */
+public class ProfileDaoClient extends BaseDao {
+
+    public static final String ServiceName = "AttributesService";
+    public static final int CREATEPROFILE = 1;
+    public static final int DELETEPROFILE = 2;
+    public static final int READPROFILE = 3;
+    public static final int UPDATEPROFILE = 4;
+    public static final int CREATEPROFILEATTRIBUTE = 5;
+    public static final int DELETEPROFILEATTRIBUTE = 6;
+    public static final int READPROFILEATTRIBUTE = 7;
+    public static final int UPDATEPROFILEATTRIBUTE = 8;
+
+    public ProfileDaoClient() {
+        getContext().setBaseResource("http://localhost:8080/GDE-war/ProfilesService");
+        getContext().setUserName("admin");
+        getContext().setPassword("edf123");
+    }
+
+    public ProfileDaoClient(RestContext context) {
+        super(context);
+    }
+
+    public ProfileTO createProfile(ProfileTO profileTO) throws IOException {
+        CommandTO commandTO = createCommand(CREATEPROFILE);
+        return postCommand(commandTO, profileTO, ProfileTO.class);
+    }
+
+    public void deleteProfile(long profileId) throws IOException {
+        CommandTO commandTO = createCommand(DELETEPROFILE);
+        commandTO.setLong("profileId", profileId);
+        postCommand(commandTO, null);
+    }
+
+    public ProfileTO readProfile(long profileId) throws IOException {
+        CommandTO commandTO = createCommand(READPROFILE);
+        commandTO.setLong("profileId", profileId);
+        return postCommand(commandTO, null, ProfileTO.class);
+    }
+
+    public ProfileTO updateProfile(ProfileTO profileTO) throws IOException {
+        CommandTO commandTO = createCommand(UPDATEPROFILE);
+        return postCommand(commandTO, profileTO, ProfileTO.class);
+    }
+
+    public ProfileAttributeTO createProfileAttribute(ProfileAttributeTO attributeTO) throws IOException {
+        CommandTO commandTO = createCommand(CREATEPROFILEATTRIBUTE);
+        return postCommand(commandTO, attributeTO, ProfileAttributeTO.class);
+    }
+
+    public void deleteProfileAttribute(long profileAttributeId) throws IOException {
+        CommandTO commandTO = createCommand(DELETEPROFILEATTRIBUTE);
+        commandTO.setLong("profileAttributeId", profileAttributeId);
+        postCommand(commandTO, null);
+    }
+
+    public ProfileAttributeTO readProfileAttribute(long profileAttributeId) throws IOException {
+        CommandTO commandTO = createCommand(READPROFILEATTRIBUTE);
+        commandTO.setLong("profileAttributeId", profileAttributeId);
+        return postCommand(commandTO, null, ProfileAttributeTO.class);
+    }
+
+    public ProfileAttributeTO updateProfileAttribute(ProfileAttributeTO attributeTO) throws IOException {
+        CommandTO commandTO = createCommand(UPDATEPROFILEATTRIBUTE);
+        return postCommand(commandTO, attributeTO, ProfileAttributeTO.class);
+    }
+
+}
diff --git a/projects/GDE-test/src/com/edf/gde/dao/StudyDaoClient.java b/projects/GDE-test/src/com/edf/gde/dao/StudyDaoClient.java
new file mode 100644 (file)
index 0000000..182de8b
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.dao;
+
+import com.edf.gde.transferables.CommandTO;
+import com.edf.gde.transferables.StudyTO;
+import com.edf.gde.transferables.responses.CommandResultTO;
+import java.io.IOException;
+import restapi.RestContext;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class StudyDaoClient extends BaseDao {
+
+    public static final String ServiceName = "StudyService";
+    public static final int CREATESTUDY = 1;
+    public static final int SETSTUDYSTATE = 2;
+    public static final int READSTUDY = 3;
+    public static final int DELETESTUDY = 4;
+
+    public StudyDaoClient() {
+        getContext().setBaseResource("http://localhost:8080/GDE-war/StudyService");
+        getContext().setUserName("admin");
+        getContext().setPassword("edf123");
+    }
+
+    public StudyDaoClient(RestContext context) {
+        super(context);
+    }
+
+    public StudyTO createStudy(StudyTO studyTO) throws IOException {
+        CommandTO commandTO = createCommand(CREATESTUDY);
+        commandTO.setData(toJson(studyTO));
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                StudyTO newStudyTO = fromJson(resultTO.getData(), StudyTO.class);
+                return newStudyTO;
+            }
+        }
+        throw new RuntimeException("Unable to create study");
+    }
+
+    public void setStudyState(long studyId, int state) throws IOException {
+        CommandTO commandTO = createCommand(SETSTUDYSTATE);
+        commandTO.setInt("lock", state);
+        commandTO.setLong("studyId", studyId);
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                return;
+            }
+        }
+        throw new RuntimeException("Unable to change study state");
+    }
+
+    public StudyTO readStudy(long studyId) throws IOException {
+        CommandTO commandTO = createCommand(READSTUDY);
+        commandTO.setLong("studyId", studyId);
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                StudyTO newStudyTO = fromJson(resultTO.getData(), StudyTO.class);
+                return newStudyTO;
+            }
+        }
+        throw new RuntimeException("Unable to read study");
+    }
+
+    public void deleteStudy(long studyId) throws IOException {
+        CommandTO commandTO = createCommand(DELETESTUDY);
+        commandTO.setLong("studyId", studyId);
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                return;
+            }
+        }
+        throw new RuntimeException("Unable to delete study");
+    }
+}
diff --git a/projects/GDE-test/src/com/edf/gde/dao/UserDaoClient.java b/projects/GDE-test/src/com/edf/gde/dao/UserDaoClient.java
new file mode 100644 (file)
index 0000000..14bcae0
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.dao;
+
+import com.edf.gde.transferables.CommandTO;
+import com.edf.gde.transferables.GroupTO;
+import com.edf.gde.transferables.UserTO;
+import com.edf.gde.transferables.responses.CommandResultTO;
+import restapi.RestContext;
+import java.io.IOException;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class UserDaoClient extends BaseDao {
+
+    public static final int CREATEUSER = 1;
+    public static final int DELETEUSER = 2;
+    public static final int ADDTOGROUP = 3;
+    public static final int REMOVEFROMGROUP = 4;
+    public static final int CREATEGROUP = 5;
+    public static final int DELETEGROUP = 6;
+    public static final int FINDUSER = 7;
+    public static final int FINDGROUP = 8;
+
+    public UserDaoClient() {
+        getContext().setBaseResource("http://localhost:8080/GDE-war/UserService");
+        getContext().setUserName("admin");
+        getContext().setPassword("edf123");
+    }
+
+    public UserDaoClient(RestContext context) {
+        super(context);
+    }
+
+    /**
+     *
+     * @param userName
+     * @param password
+     * @return
+     * @throws IOException
+     */
+    public UserTO createUser(String userName, String password) throws IOException {
+        CommandTO commandTO = createCommand(CREATEUSER);
+        UserTO userTO = new UserTO();
+        userTO.setName(userName);
+        userTO.setPassword(password);
+        commandTO.setData(toJson(userTO));
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                userTO = fromJson(resultTO.getData(), UserTO.class);
+                return userTO;
+            }
+        }
+        throw new RuntimeException("Unable to create user");
+    }
+
+    /**
+     *
+     * @param userId
+     * @return
+     * @throws IOException
+     */
+    public boolean deleteUser(long userId) throws IOException {
+        CommandTO commandTO = createCommand(DELETEUSER);
+        commandTO.setLong("id", userId);
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            if (daoResponseHandler.getResultTO().getCode() == CommandResultTO.OK) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     *
+     * @param userName
+     * @return null if user not found
+     * @throws IOException
+     */
+    public UserTO findUser(String userName) throws IOException {
+        CommandTO commandTO = createCommand(FINDUSER);
+        commandTO.setString("username", userName);
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                UserTO userTO = fromJson(resultTO.getData(), UserTO.class);
+                return userTO;
+            }
+        }
+        return null;
+    }
+
+    /**
+     *
+     * @param groupName
+     * @return
+     * @throws IOException
+     */
+    public GroupTO createGroup(String groupName) throws IOException {
+        CommandTO commandTO = createCommand(CREATEGROUP);
+        commandTO.setString("name", groupName);
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                GroupTO groupTO = fromJson(resultTO.getData(), GroupTO.class);
+                return groupTO;
+            }
+        }
+        return null;
+    }
+
+    /**
+     *
+     * @param groupName
+     * @return
+     * @throws IOException
+     */
+    public GroupTO findGroup(String groupName) throws IOException {
+        CommandTO commandTO = createCommand(FINDGROUP);
+        commandTO.setString("groupname", groupName);
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                GroupTO groupTO = fromJson(resultTO.getData(), GroupTO.class);
+                return groupTO;
+            }
+        }
+        return null;
+    }
+/**
+ * 
+ * @param id
+ * @return
+ * @throws IOException 
+ */
+    public boolean deleteGroup(long id) throws IOException {
+        CommandTO commandTO = createCommand(DELETEGROUP);
+        commandTO.setLong("id", id);
+        if (postAsJSonData(commandTO, daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public boolean addToGroup(long groupId, long userId) throws IOException {
+        CommandTO commandTO = createCommand(ADDTOGROUP);
+        commandTO.setLong("groupId", groupId);
+        commandTO.setLong("userId", userId);
+        if (postAsJSonData(commandTO,daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public boolean removeFromGroup(long groupId, long userId) throws IOException {
+        CommandTO commandTO = createCommand(REMOVEFROMGROUP);
+        commandTO.setLong("groupId", groupId);
+        commandTO.setLong("userId", userId);
+        if (postAsJSonData(commandTO,daoResponseHandler)) {
+            CommandResultTO resultTO = daoResponseHandler.getResultTO();
+            if (resultTO.getCode() == CommandResultTO.OK) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
diff --git a/projects/GDE-test/src/gde/test/GDETest.java b/projects/GDE-test/src/gde/test/GDETest.java
new file mode 100644 (file)
index 0000000..9b56a30
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * (C) 2015 EDF
+ */
+package gde.test;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class GDETest {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        // TODO code application logic here
+    }
+    
+}
diff --git a/projects/GDE-test/src/restapi/Base64.java b/projects/GDE-test/src/restapi/Base64.java
new file mode 100644 (file)
index 0000000..7f765b5
--- /dev/null
@@ -0,0 +1,228 @@
+// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
+// www.source-code.biz, www.inventec.ch/chdh
+//
+// This module is multi-licensed and may be used under the terms
+// of any of the following licenses:
+//
+//  EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal
+//  LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html
+//  GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html
+//  AGPL, GNU Affero General Public License V3 or later, http://www.gnu.org/licenses/agpl.html
+//  AL, Apache License, V2.0 or later, http://www.apache.org/licenses
+//  BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
+//  MIT, MIT License, http://www.opensource.org/licenses/MIT
+//
+// Please contact the author if you need another license.
+// This module is provided "as is", without warranties of any kind.
+//
+// Project home page: www.source-code.biz/base64coder/java
+
+package restapi;
+
+/**
+* A Base64 encoder/decoder.
+*
+* <p>
+* This class is used to encode and decode data in Base64 format as described in RFC 1521.
+*
+* @author
+*    Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland, www.source-code.biz
+*/
+public class Base64 {
+
+// The line separator string of the operating system.
+private static final String systemLineSeparator = System.getProperty("line.separator");
+
+// Mapping table from 6-bit nibbles to Base64 characters.
+private static final char[] map1 = new char[64];
+   static {
+      int i=0;
+      for (char c='A'; c<='Z'; c++) map1[i++] = c;
+      for (char c='a'; c<='z'; c++) map1[i++] = c;
+      for (char c='0'; c<='9'; c++) map1[i++] = c;
+      map1[i++] = '+'; map1[i++] = '/'; }
+
+// Mapping table from Base64 characters to 6-bit nibbles.
+private static final byte[] map2 = new byte[128];
+   static {
+      for (int i=0; i<map2.length; i++) map2[i] = -1;
+      for (int i=0; i<64; i++) map2[map1[i]] = (byte)i; }
+
+/**
+* Encodes a string into Base64 format.
+* No blanks or line breaks are inserted.
+* @param s  A String to be encoded.
+* @return   A String containing the Base64 encoded data.
+*/
+public static String encodeString (String s) {
+   return new String(encode(s.getBytes())); }
+
+/**
+* Encodes a byte array into Base 64 format and breaks the output into lines of 76 characters.
+* This method is compatible with <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
+* @param in  An array containing the data bytes to be encoded.
+* @return    A String containing the Base64 encoded data, broken into lines.
+*/
+public static String encodeLines (byte[] in) {
+   return encodeLines(in, 0, in.length, 76, systemLineSeparator); }
+
+/**
+* Encodes a byte array into Base 64 format and breaks the output into lines.
+* @param in            An array containing the data bytes to be encoded.
+* @param iOff          Offset of the first byte in <code>in</code> to be processed.
+* @param iLen          Number of bytes to be processed in <code>in</code>, starting at <code>iOff</code>.
+* @param lineLen       Line length for the output data. Should be a multiple of 4.
+* @param lineSeparator The line separator to be used to separate the output lines.
+* @return              A String containing the Base64 encoded data, broken into lines.
+*/
+public static String encodeLines (byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) {
+   int blockLen = (lineLen*3) / 4;
+   if (blockLen <= 0) throw new IllegalArgumentException();
+   int lines = (iLen+blockLen-1) / blockLen;
+   int bufLen = ((iLen+2)/3)*4 + lines*lineSeparator.length();
+   StringBuilder buf = new StringBuilder(bufLen);
+   int ip = 0;
+   while (ip < iLen) {
+      int l = Math.min(iLen-ip, blockLen);
+      buf.append(encode(in, iOff+ip, l));
+      buf.append(lineSeparator);
+      ip += l; }
+   return buf.toString(); }
+
+/**
+* Encodes a byte array into Base64 format.
+* No blanks or line breaks are inserted in the output.
+* @param in  An array containing the data bytes to be encoded.
+* @return    A character array containing the Base64 encoded data.
+*/
+public static char[] encode (byte[] in) {
+   return encode(in, 0, in.length); }
+
+/**
+* Encodes a byte array into Base64 format.
+* No blanks or line breaks are inserted in the output.
+* @param in    An array containing the data bytes to be encoded.
+* @param iLen  Number of bytes to process in <code>in</code>.
+* @return      A character array containing the Base64 encoded data.
+*/
+public static char[] encode (byte[] in, int iLen) {
+   return encode(in, 0, iLen); }
+
+/**
+* Encodes a byte array into Base64 format.
+* No blanks or line breaks are inserted in the output.
+* @param in    An array containing the data bytes to be encoded.
+* @param iOff  Offset of the first byte in <code>in</code> to be processed.
+* @param iLen  Number of bytes to process in <code>in</code>, starting at <code>iOff</code>.
+* @return      A character array containing the Base64 encoded data.
+*/
+public static char[] encode (byte[] in, int iOff, int iLen) {
+   int oDataLen = (iLen*4+2)/3;       // output length without padding
+   int oLen = ((iLen+2)/3)*4;         // output length including padding
+   char[] out = new char[oLen];
+   int ip = iOff;
+   int iEnd = iOff + iLen;
+   int op = 0;
+   while (ip < iEnd) {
+      int i0 = in[ip++] & 0xff;
+      int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
+      int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
+      int o0 = i0 >>> 2;
+      int o1 = ((i0 &   3) << 4) | (i1 >>> 4);
+      int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
+      int o3 = i2 & 0x3F;
+      out[op++] = map1[o0];
+      out[op++] = map1[o1];
+      out[op] = op < oDataLen ? map1[o2] : '='; op++;
+      out[op] = op < oDataLen ? map1[o3] : '='; op++; }
+   return out; }
+
+/**
+* Decodes a string from Base64 format.
+* No blanks or line breaks are allowed within the Base64 encoded input data.
+* @param s  A Base64 String to be decoded.
+* @return   A String containing the decoded data.
+* @throws   IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static String decodeString (String s) {
+   return new String(decode(s)); }
+
+/**
+* Decodes a byte array from Base64 format and ignores line separators, tabs and blanks.
+* CR, LF, Tab and Space characters are ignored in the input data.
+* This method is compatible with <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
+* @param s  A Base64 String to be decoded.
+* @return   An array containing the decoded data bytes.
+* @throws   IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static byte[] decodeLines (String s) {
+   char[] buf = new char[s.length()];
+   int p = 0;
+   for (int ip = 0; ip < s.length(); ip++) {
+      char c = s.charAt(ip);
+      if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
+         buf[p++] = c; }
+   return decode(buf, 0, p); }
+
+/**
+* Decodes a byte array from Base64 format.
+* No blanks or line breaks are allowed within the Base64 encoded input data.
+* @param s  A Base64 String to be decoded.
+* @return   An array containing the decoded data bytes.
+* @throws   IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static byte[] decode (String s) {
+   return decode(s.toCharArray()); }
+
+/**
+* Decodes a byte array from Base64 format.
+* No blanks or line breaks are allowed within the Base64 encoded input data.
+* @param in  A character array containing the Base64 encoded data.
+* @return    An array containing the decoded data bytes.
+* @throws    IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static byte[] decode (char[] in) {
+   return decode(in, 0, in.length); }
+
+/**
+* Decodes a byte array from Base64 format.
+* No blanks or line breaks are allowed within the Base64 encoded input data.
+* @param in    A character array containing the Base64 encoded data.
+* @param iOff  Offset of the first character in <code>in</code> to be processed.
+* @param iLen  Number of characters to process in <code>in</code>, starting at <code>iOff</code>.
+* @return      An array containing the decoded data bytes.
+* @throws      IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static byte[] decode (char[] in, int iOff, int iLen) {
+   if (iLen%4 != 0) throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4.");
+   while (iLen > 0 && in[iOff+iLen-1] == '=') iLen--;
+   int oLen = (iLen*3) / 4;
+   byte[] out = new byte[oLen];
+   int ip = iOff;
+   int iEnd = iOff + iLen;
+   int op = 0;
+   while (ip < iEnd) {
+      int i0 = in[ip++];
+      int i1 = in[ip++];
+      int i2 = ip < iEnd ? in[ip++] : 'A';
+      int i3 = ip < iEnd ? in[ip++] : 'A';
+      if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
+         throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+      int b0 = map2[i0];
+      int b1 = map2[i1];
+      int b2 = map2[i2];
+      int b3 = map2[i3];
+      if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
+         throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+      int o0 = ( b0       <<2) | (b1>>>4);
+      int o1 = ((b1 & 0xf)<<4) | (b2>>>2);
+      int o2 = ((b2 &   3)<<6) |  b3;
+      out[op++] = (byte)o0;
+      if (op<oLen) out[op++] = (byte)o1;
+      if (op<oLen) out[op++] = (byte)o2; }
+   return out; }
+
+// Dummy constructor.
+private Base64() {}
+
+} // end class Base64
\ No newline at end of file
diff --git a/projects/GDE-test/src/restapi/DefaultResponseHandler.java b/projects/GDE-test/src/restapi/DefaultResponseHandler.java
new file mode 100644 (file)
index 0000000..d6358c3
--- /dev/null
@@ -0,0 +1,17 @@
+package restapi;
+
+/**
+ *
+ * @author mordicus
+ */
+public class DefaultResponseHandler implements ResponseHandler {
+
+    @Override
+    public boolean checkResponse(int code, String response) {
+        if (code == 200) {
+            return true;
+        }
+        return false;
+    }
+    
+}
diff --git a/projects/GDE-test/src/restapi/ResponseHandler.java b/projects/GDE-test/src/restapi/ResponseHandler.java
new file mode 100644 (file)
index 0000000..bd5afa0
--- /dev/null
@@ -0,0 +1,11 @@
+package restapi;
+
+/**
+ *
+ * @author mordicus
+ */
+public interface ResponseHandler {
+
+    boolean checkResponse(int code, String response);
+
+}
diff --git a/projects/GDE-test/src/restapi/RestContext.java b/projects/GDE-test/src/restapi/RestContext.java
new file mode 100644 (file)
index 0000000..97ab7bd
--- /dev/null
@@ -0,0 +1,111 @@
+package restapi;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import restapi.providers.CertificateProvider;
+
+/**
+ *
+ * @author mordicus
+ */
+public class RestContext {
+
+    private String baseResource;
+    private String userName;
+    private String password;
+    private Map<String, String> parametters;
+    private CertificateProvider certificateProvider;
+    
+    public RestContext() {
+        parametters = new HashMap<String, String>();
+    }
+
+    public RestContext(String resource) {
+        this.baseResource = resource;
+        parametters = new HashMap<String, String>();
+    }
+
+    public RestContext(String resource, String trustStorePath) {
+        this.baseResource = resource;
+        parametters = new HashMap<String, String>();
+    }
+
+    public RestContext(String resource, String userName, String password) {
+        this.baseResource = resource;
+        this.userName = userName;
+        this.password = password;
+        parametters = new HashMap<String, String>();
+    }
+
+    public CertificateProvider getCertificateProvider() {
+        return certificateProvider;
+    }
+
+    public void setCertificateProvider(CertificateProvider certificateProvider) {
+        this.certificateProvider = certificateProvider;
+    }
+
+    public void clear() {
+        this.parametters.clear();
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setParametter(String name, String value) {
+        this.parametters.put(name, value);
+    }
+
+    public String getResource() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(baseResource);
+        if (parametters.size() > 0) {
+            Set<String> keys = parametters.keySet();
+            String[] k = keys.toArray(new String[0]);
+
+            sb.append("?");
+            try {
+                sb.append(k[0]).append("=").append(URLEncoder.encode(parametters.get(k[0]), "utf-8"));
+            } catch (UnsupportedEncodingException ex) {
+                Logger.getLogger(RestContext.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            for (int i = 1; i < k.length; i++) {
+                try {
+                    sb.append("&").append(k[i]).append("=").append(URLEncoder.encode(parametters.get(k[i]), "utf-8"));
+                } catch (UnsupportedEncodingException ex) {
+                    Logger.getLogger(RestContext.class.getName()).log(Level.SEVERE, null, ex);
+                }
+
+            }
+
+        }
+        String ret = sb.toString();
+        return ret;
+    }
+
+    public String getBaseResource() {
+        return baseResource;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void setBaseResource(String resource) {
+        this.baseResource = resource;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+}
diff --git a/projects/GDE-test/src/restapi/SimpleRestApi.java b/projects/GDE-test/src/restapi/SimpleRestApi.java
new file mode 100644 (file)
index 0000000..53a6859
--- /dev/null
@@ -0,0 +1,591 @@
+package restapi;
+
+import com.google.gson.Gson;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.lang.reflect.Type;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManagerFactory;
+import restapi.providers.CertificateProvider;
+
+/**
+ *
+ * @author Kavoos Bojnourdi
+ */
+public class SimpleRestApi {
+
+    /**
+     * RestContext
+     */
+    protected RestContext restContext;
+
+    private KeyStore keyStore;
+    private TrustManagerFactory tmf;
+    private SSLContext context;
+    private boolean verifyHostName;
+    private HttpURLConnection connection;
+    protected Gson gson;
+    
+    public SimpleRestApi() {
+        restContext = new RestContext();
+        gson = new Gson();
+    }
+
+    public SimpleRestApi(RestContext context) {
+        this.restContext = context;
+        gson = new Gson();
+    }
+
+    public boolean isVerifyHostName() {
+        return verifyHostName;
+    }
+
+    public void setVerifyHostName(boolean verifyHostName) {
+        this.verifyHostName = verifyHostName;
+    }
+
+    protected void setContext(RestContext context) {
+        this.restContext = context;
+        if (context.getBaseResource() != null) {
+            initResource();
+        }
+    }
+
+    private void initResource() {
+
+    }
+
+    public RestContext getContext() {
+        return restContext;
+    }
+
+    protected void setResource(String resource) {
+        restContext.setBaseResource(resource);
+        initResource();
+    }
+
+    protected void setResource(String base, String resource) {
+        restContext.setBaseResource(base + resource);
+        initResource();
+    }
+
+    public void closeConnection() {
+        if (connection != null) {
+            connection.disconnect();
+        }
+    }
+
+    public void setCertificateProvider(CertificateProvider certificateProvider) {
+        restContext.setCertificateProvider(certificateProvider);
+    }
+    
+    /**
+     *
+     * @param connection
+     */
+    protected void initAuthentication(HttpURLConnection connection) {
+        if (restContext.getUserName() == null) {
+            return;
+        }
+        String userCredentials = restContext.getUserName() + ":" + restContext.getPassword();
+        String basicAuth = "Basic " + new String(Base64.encode(userCredentials.getBytes()));
+        connection.setRequestProperty("Authorization", basicAuth);
+        connection.setRequestProperty("User-Agent", "Deuterium/1.0");
+    }
+
+    /**
+     *
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected boolean remove(ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+
+        try {
+            connection.setDoInput(true);
+            connection.setDoOutput(false);
+            initAuthentication(connection);
+
+            connection.setRequestMethod("DELETE");
+
+            // Open and do query
+            int responseCode = connection.getResponseCode();
+            String resultString = readStringResponse(connection);
+
+            if (rh == null) {
+                rh = new DefaultResponseHandler();
+            }
+            return rh.checkResponse(responseCode, resultString);
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @param data
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected boolean putAsJSonData(Object data, ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        try {
+            connection.setRequestMethod("PUT");
+            return writeJsonData(data, connection, rh);
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @param data
+     * @return
+     * @throws IOException
+     */
+    protected boolean putAsJSonData(Object data) throws IOException {
+        return putAsJSonData(data, null);
+    }
+
+    /**
+     *
+     * @param data
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected boolean postAsJSonData(Object data, ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        try {
+            connection.setRequestMethod("POST");
+            return writeJsonData(data, connection, rh);
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @param data
+     * @return
+     * @throws IOException
+     */
+    protected boolean postAsJSonData(Object data) throws IOException {
+        return postAsJSonData(data, null);
+    }
+
+    /**
+     *
+     * @param data
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected boolean postAsBinaryData(byte[] data, ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        try {
+            connection.setRequestMethod("POST");
+            return sendBinaryData(connection, data, rh);
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @param data
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected boolean putAsBinaryData(byte[] data, ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        try {
+            connection.setRequestMethod("PUT");
+            return sendBinaryData(connection, data, rh);
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @param data
+     * @return
+     * @throws IOException
+     */
+    protected boolean putAsBinaryData(byte[] data) throws IOException {
+        return putAsBinaryData(data, null);
+    }
+
+    /**
+     *
+     * @param in
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected boolean postAsBinaryStream(InputStream in, ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        try {
+            connection.setRequestMethod("POST");
+            return sendBinaryStream(connection, in, rh);
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @param in
+     * @return
+     * @throws IOException
+     */
+    protected boolean postAsBinaryStream(InputStream in) throws IOException {
+        return postAsBinaryStream(in, null);
+    }
+
+    /**
+     *
+     * @param in
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected boolean putAsBinaryStream(InputStream in, ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        try {
+            connection.setRequestMethod("PUT");
+            return sendBinaryStream(connection, in, rh);
+
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @param in
+     * @return
+     * @throws IOException
+     */
+    protected boolean putAsBinaryStream(InputStream in) throws IOException {
+        return putAsBinaryStream(in, null);
+    }
+
+    /**
+     *
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected byte[] getBinaryData(ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        try {
+            connection.setRequestMethod("GET");
+            connection.setDoInput(true);
+            connection.setDoOutput(false);
+            initAuthentication(connection);
+
+            int responseCode = connection.getResponseCode();
+
+            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            copy(connection.getInputStream(), outputStream);
+
+            if (rh == null) {
+                rh = new DefaultResponseHandler();
+            }
+            rh.checkResponse(responseCode, connection.getResponseMessage());
+
+            return outputStream.toByteArray();
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @return @throws IOException
+     */
+    protected byte[] getBinaryData() throws IOException {
+        return getBinaryData(null);
+    }
+
+    /**
+     *
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected InputStream getBinaryStream(ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        connection.setRequestMethod("GET");
+        connection.setDoInput(true);
+        connection.setDoOutput(false);
+        initAuthentication(connection);
+
+        int responseCode = connection.getResponseCode();
+        if (rh == null) {
+            rh = new DefaultResponseHandler();
+        }
+        rh.checkResponse(responseCode, connection.getResponseMessage());
+        return connection.getInputStream();
+    }
+
+    /**
+     *
+     * @return @throws IOException
+     */
+    protected InputStream getBinaryStream() throws IOException {
+        return getBinaryStream(null);
+    }
+
+    /**
+     *
+     * @param <T>
+     * @param classOfT
+     * @param rh
+     * @return
+     * @throws IOException
+     */
+    protected <T> T getData(Class<T> classOfT, ResponseHandler rh) throws IOException {
+        setUpHttpConnection();
+        try {
+            connection.setRequestMethod("GET");
+            connection.setDoInput(true);
+            connection.setDoOutput(false);
+            initAuthentication(connection);
+            
+            String data = readStringResponse(connection);
+            int responseCode = connection.getResponseCode();
+            if (rh == null) {
+                rh = new DefaultResponseHandler();
+            }
+            rh.checkResponse(responseCode, connection.getResponseMessage());
+            T o = gson.fromJson(data, classOfT);
+            return o;
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /**
+     *
+     * @param <T>
+     * @param classOfT
+     * @return
+     * @throws IOException
+     */
+    protected <T> T getData(Class<T> classOfT) throws IOException {
+        return getData(classOfT, null);
+    }
+
+    protected <T> List<T> getDataList(Type typeOfT, ResponseHandler rh) throws IOException {
+
+        setUpHttpConnection();
+        try {
+
+        connection.setRequestMethod("GET");
+        connection.setDoInput(true);
+        connection.setDoOutput(false);
+        initAuthentication(connection);
+
+        int responseCode = connection.getResponseCode();
+        if (rh == null) {
+            rh = new DefaultResponseHandler();
+        }
+        rh.checkResponse(responseCode, connection.getResponseMessage());
+
+        String data = readStringResponse(connection);
+        T[] o = gson.fromJson(data, typeOfT);
+        List<T> ret = new ArrayList<T>();
+        ret.addAll(Arrays.asList(o));
+        return ret;
+        } finally {
+            closeConnection();
+        }
+    }
+
+    /* Private methods */
+    /* ********************************************************************** */
+    private boolean sendBinaryStream(HttpURLConnection connection, InputStream in, ResponseHandler rh) throws IOException {
+        initAuthentication(connection);
+        connection.setDoInput(true);
+        connection.setDoOutput(true);
+        connection.setChunkedStreamingMode(4096);
+        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+        copy(in, connection.getOutputStream());
+        int responseCode = connection.getResponseCode();
+        String response = readStringResponse(connection);
+        if (rh == null) {
+            rh = new DefaultResponseHandler();
+        }
+
+        return rh.checkResponse(responseCode, response);
+
+    }
+
+    private void copy(InputStream in, OutputStream out) throws IOException {
+        ReadableByteChannel source = Channels.newChannel(in);
+        WritableByteChannel target = Channels.newChannel(out);
+
+        ByteBuffer buffer = ByteBuffer.allocate(16 * 1024);
+        while (source.read(buffer) != -1) {
+            buffer.flip(); // Prepare the buffer to be drained
+            while (buffer.hasRemaining()) {
+                target.write(buffer);
+            }
+            buffer.clear(); // Empty buffer to get ready for filling
+        }
+
+        source.close();
+        target.close();
+
+    }
+
+    private boolean sendBinaryData(HttpURLConnection connection, byte[] data, ResponseHandler rh) throws IOException {
+        initAuthentication(connection);
+        writeData(connection, data);
+        int responseCode = connection.getResponseCode();
+        String response = readStringResponse(connection);
+        if (rh == null) {
+            rh = new DefaultResponseHandler();
+        }
+
+        return rh.checkResponse(responseCode, response);
+    }
+
+    private void writeData(HttpURLConnection connection, byte[] data) throws IOException {
+        connection.setDoInput(true);
+        connection.setDoOutput(true);
+        connection.setChunkedStreamingMode(4096);
+        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+        BufferedOutputStream outputStream = new BufferedOutputStream(connection.getOutputStream());
+        outputStream.write(data);
+        outputStream.flush();
+        outputStream.close();
+
+    }
+
+    private boolean writeJsonData(Object data, HttpURLConnection connection, ResponseHandler rh) throws IOException {
+
+        String dataStr = gson.toJson(data);
+        initAuthentication(connection);
+        writeData(connection, dataStr.getBytes("UTF-8"));
+        int responseCode = connection.getResponseCode();
+        String response = readStringResponse(connection);
+        if (rh == null) {
+            rh = new DefaultResponseHandler();
+        }
+
+        return rh.checkResponse(responseCode, response);
+    }
+
+    private String readStringResponse(HttpURLConnection connection) throws IOException {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+        String inputLine;
+        StringBuilder builder = new StringBuilder();
+        while ((inputLine = reader.readLine()) != null) {
+            builder.append(inputLine);
+        }
+        String resultString = builder.toString();
+        reader.close();
+        return resultString;
+    }
+
+    private void setUpHttpConnection() {
+        try {
+
+            String urlString = restContext.getResource();
+            URL url = new URL(urlString);
+            if (url.getProtocol().equals("http")) {
+                connection = (HttpURLConnection) url.openConnection();
+
+            }
+            if (url.getProtocol().equals("https")) {
+                connection = makeHttpsConnection(url);
+            }
+
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     *
+     * @param url
+     * @return
+     * @throws CertificateException
+     * @throws IOException
+     * @throws KeyManagementException
+     * @throws NoSuchAlgorithmException
+     * @throws KeyStoreException
+     * @throws FileNotFoundException
+     */
+    private HttpURLConnection makeHttpsConnection(URL url) throws CertificateException, IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
+        if (keyStore == null) {
+            CertificateProvider certificateProvider = restContext.getCertificateProvider();
+            if (certificateProvider == null) {
+                throw new CertificateException("Need a certification provider");
+            }
+            Certificate ca = certificateProvider.getCertificate();
+            
+            String keyStoreType = KeyStore.getDefaultType();
+            keyStore = KeyStore.getInstance(keyStoreType);
+            keyStore.load(null, null);
+            keyStore.setCertificateEntry("ca", ca);
+
+            // Create a TrustManager that trusts the CAs in our KeyStore
+            String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
+            tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
+            tmf.init(keyStore);
+            
+            // Create an SSLContext that uses our TrustManager
+            context = SSLContext.getInstance("TLS");
+            context.init(null, tmf.getTrustManagers(), null);
+        }
+
+        // Tell the URLConnection to use a SocketFactory from our SSLContext
+        HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
+        urlConnection.setSSLSocketFactory(context.getSocketFactory());
+
+        if (!verifyHostName) {
+            HostnameVerifier hv = new HostnameVerifier() {
+
+                @Override
+                public boolean verify(String string, SSLSession ssls) {
+                    return true;
+                }
+            };
+            urlConnection.setHostnameVerifier(hv);
+        }
+
+        return urlConnection;
+    }
+}
diff --git a/projects/GDE-test/src/restapi/exceptions/RestResponseException.java b/projects/GDE-test/src/restapi/exceptions/RestResponseException.java
new file mode 100644 (file)
index 0000000..7ae9462
--- /dev/null
@@ -0,0 +1,24 @@
+package restapi.exceptions;
+
+/**
+ *
+ * @author mordicus
+ */
+public class RestResponseException extends RuntimeException {
+
+    public RestResponseException(Throwable cause) {
+        super(cause);
+    }
+
+    public RestResponseException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public RestResponseException(String message) {
+        super(message);
+    }
+
+    public RestResponseException() {
+    }
+    
+}
diff --git a/projects/GDE-test/src/restapi/providers/CertificateProvider.java b/projects/GDE-test/src/restapi/providers/CertificateProvider.java
new file mode 100644 (file)
index 0000000..f48cd8a
--- /dev/null
@@ -0,0 +1,11 @@
+package restapi.providers;
+
+import java.io.IOException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+
+public interface CertificateProvider {
+    
+    public Certificate getCertificate() throws CertificateException, IOException;
+    
+}
diff --git a/projects/GDE-test/src/restapi/providers/FileCertificateProvider.java b/projects/GDE-test/src/restapi/providers/FileCertificateProvider.java
new file mode 100644 (file)
index 0000000..4b92289
--- /dev/null
@@ -0,0 +1,47 @@
+package restapi.providers;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+
+public class FileCertificateProvider implements CertificateProvider {
+
+    private final File file;
+    private Certificate ca;
+
+    public FileCertificateProvider(File file) {
+        this.file = file;
+    }
+
+    public FileCertificateProvider(String fileName) {
+        file = new File(fileName);
+    }
+
+    @Override
+    public Certificate getCertificate() throws CertificateException, IOException {
+        if (ca != null) {
+            return ca;
+        }
+
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        InputStream caInput = null;
+        try {
+            caInput = new BufferedInputStream(new FileInputStream(file));
+            ca = cf.generateCertificate(caInput);
+            return ca;
+        } catch (FileNotFoundException ex) {
+            throw new IOException(ex);
+        } finally {
+            if (caInput != null) {
+                caInput.close();
+            }
+        }
+    }
+
+}
diff --git a/projects/GDE-test/test/com/edf/gde/test/dao/AttributeDaoTest.java b/projects/GDE-test/test/com/edf/gde/test/dao/AttributeDaoTest.java
new file mode 100644 (file)
index 0000000..acd352b
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.test.dao;
+
+import com.edf.gde.dao.AttributeDaoClient;
+import com.edf.gde.base.BaseTest;
+import com.edf.gde.transferables.AttributeGroupTO;
+import com.edf.gde.transferables.AttributeTO;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author mordicus
+ */
+public class AttributeDaoTest extends BaseTest {
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    public void testCreateAttribute() throws Exception {
+        AttributeDaoClient daoClient = new AttributeDaoClient();
+        testName("createAttribute");
+        /* Create an instance of AttributeGroup*/
+        AttributeGroupTO attributeGroup = new AttributeGroupTO();
+        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
+        assertNotNull(resultAttributeGroup);
+        assertTrue(resultAttributeGroup.getId() > 0);
+        /* Create Attribute */
+        AttributeTO ato = new AttributeTO();
+        ato.setName("Attribute1");
+        ato.setType("integer");
+        ato.setValue("12");
+        ato.setGroupId(resultAttributeGroup.getId());
+        AttributeTO newAttribute = daoClient.createAttribute(ato);
+        assertNotNull(newAttribute);
+        assertEquals(ato.getName(), newAttribute.getName());
+        assertTrue(newAttribute.getId() != 0);
+        passed();
+    }
+
+    @Test
+    public void testDeleteAttribute() throws Exception {
+        AttributeDaoClient daoClient = new AttributeDaoClient();
+        testName("deleteAttribute");
+        /* Create an instance of AttributeGroup*/
+        AttributeGroupTO attributeGroup = new AttributeGroupTO();
+        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
+        assertNotNull(resultAttributeGroup);
+        assertTrue(resultAttributeGroup.getId() > 0);
+        /* Create Attribute */
+        AttributeTO ato = new AttributeTO();
+        ato.setName("Attribute2");
+        ato.setType("long");
+        ato.setValue("13");
+        ato.setGroupId(resultAttributeGroup.getId());
+        AttributeTO newAttribute = daoClient.createAttribute(ato);
+        assertNotNull(newAttribute);
+        assertEquals(ato.getName(), newAttribute.getName());
+        assertTrue(newAttribute.getId() != 0);
+        daoClient.deleteAttribute(newAttribute.getId());
+        passed();
+    }
+
+    @Test
+    public void createAttributeGroup() throws Exception {
+        AttributeDaoClient daoClient = new AttributeDaoClient();
+        testName("createAttributeGroup");
+        /* Create an instance of AttributeGroup*/
+        AttributeGroupTO attributeGroup = new AttributeGroupTO();
+        AttributeTO ato = new AttributeTO();
+        ato.setName("Test");
+        ato.setType("string");
+        ato.setValue("test");
+        ato.setMandatory(false);
+        List<AttributeTO> l = new ArrayList<>();
+        l.add(ato);
+        attributeGroup.setAttributeCollection(l);
+        
+        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
+        
+        assertNotNull(resultAttributeGroup);
+        assertTrue(resultAttributeGroup.getId() > 0);
+        passed();
+    }
+    
+    @Test
+    public void deleteAttributeGroup() throws Exception {
+        AttributeDaoClient daoClient = new AttributeDaoClient();
+        testName("deleteAttributeGroup");
+        /* Create an instance of AttributeGroup*/
+        AttributeGroupTO attributeGroup = new AttributeGroupTO();
+        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
+        assertNotNull(resultAttributeGroup);
+        assertTrue(resultAttributeGroup.getId() > 0);
+        /* Delete it */
+        daoClient.deleteAttributeGroup(resultAttributeGroup.getId());
+        passed();
+    }
+    
+    @Test
+    public void testReadAttributeGroup() throws Exception {
+        AttributeDaoClient daoClient = new AttributeDaoClient();
+        testName("readAttributeGroup");
+        /* Create an instance of AttributeGroup*/
+        AttributeGroupTO attributeGroup = new AttributeGroupTO();
+        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
+        assertNotNull(resultAttributeGroup);
+        assertTrue(resultAttributeGroup.getId() > 0);
+        /* Read it */
+        AttributeGroupTO newAttributeGroupTO = daoClient.readAttributeGroup(resultAttributeGroup.getId());
+        assertNotNull(newAttributeGroupTO);
+        assertTrue(newAttributeGroupTO.getId()>0);
+        passed();
+    }
+}
diff --git a/projects/GDE-test/test/com/edf/gde/test/dao/ProfileDaoTest.java b/projects/GDE-test/test/com/edf/gde/test/dao/ProfileDaoTest.java
new file mode 100644 (file)
index 0000000..758d545
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.test.dao;
+
+import com.edf.gde.dao.ProfileDaoClient;
+import com.edf.gde.base.BaseTest;
+import com.edf.gde.transferables.ProfileAttributeTO;
+import com.edf.gde.transferables.ProfileTO;
+import java.util.ArrayList;
+import java.util.List;
+import junit.framework.Assert;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author mordicus
+ */
+public class ProfileDaoTest extends BaseTest {
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    public void testCreateProfile() throws Exception {
+        testName("createProfile");
+        ProfileDaoClient daoClient = new ProfileDaoClient();
+        ProfileTO profileTO = new ProfileTO();
+        Assert.assertEquals(0, profileTO.getId());
+        profileTO.setName("ProfileTest1");
+        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
+        Assert.assertNotNull(newProfileTO);
+        Assert.assertTrue(newProfileTO.getId() != 0);
+        Assert.assertEquals("ProfileTest1", newProfileTO.getName());
+        passed();
+    }
+
+    @Test
+    public void testDeleteProfile() throws Exception {
+        testName("deleteProfile");
+        ProfileDaoClient daoClient = new ProfileDaoClient();
+        ProfileTO profileTO = new ProfileTO();
+        Assert.assertEquals(0, profileTO.getId());
+        profileTO.setName("ProfileTest2");
+        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
+        Assert.assertNotNull(newProfileTO);
+        Assert.assertTrue(newProfileTO.getId() != 0);
+        Assert.assertEquals("ProfileTest2", newProfileTO.getName());
+        daoClient.deleteProfile(newProfileTO.getId());
+        passed();
+    }
+
+    @Test
+    public void testReadProfile() throws Exception {
+        testName("readProfile");
+        ProfileDaoClient daoClient = new ProfileDaoClient();
+        ProfileTO profileTO = new ProfileTO();
+        Assert.assertEquals(0, profileTO.getId());
+        profileTO.setName("ProfileTest3");
+        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
+        Assert.assertNotNull(newProfileTO);
+        Assert.assertTrue(newProfileTO.getId() != 0);
+        Assert.assertEquals("ProfileTest3", newProfileTO.getName());
+        ProfileTO testProfileTO = daoClient.readProfile(newProfileTO.getId());
+        Assert.assertNotNull(testProfileTO);
+        Assert.assertEquals(newProfileTO.getId(), testProfileTO.getId());
+        Assert.assertEquals(newProfileTO.getName(), testProfileTO.getName());
+        passed();
+    }
+
+    @Test
+    public void testUpdateProfile() throws Exception {
+        testName("updateProfile");
+        ProfileDaoClient daoClient = new ProfileDaoClient();
+        ProfileTO profileTO = new ProfileTO();
+        Assert.assertEquals(0, profileTO.getId());
+        profileTO.setName("ProfileTest4");
+        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
+        Assert.assertNotNull(newProfileTO);
+        Assert.assertTrue(newProfileTO.getId() != 0);
+        Assert.assertEquals("ProfileTest4", newProfileTO.getName());
+        /* update */
+        newProfileTO.setName("ProfileTest4 - 1");
+        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
+        attributeTO.setMandatory(true);
+        attributeTO.setName("attribute1");
+        attributeTO.setProfileId(newProfileTO.getId());
+        attributeTO.setType("string");
+        List<ProfileAttributeTO> attributeTOs = new ArrayList<>();
+        attributeTOs.add(attributeTO);
+        newProfileTO.setAttributes(attributeTOs);
+        ProfileTO testProfileTO = daoClient.updateProfile(newProfileTO);
+        Assert.assertNotNull(testProfileTO);
+        // Read
+        testProfileTO = daoClient.readProfile(testProfileTO.getId());
+        Assert.assertEquals("ProfileTest4 - 1", testProfileTO.getName());
+        passed();
+    }
+
+    @Test
+    public void testCreateProfileAttribute() throws Exception {
+        testName("createProfileAttribute");
+        ProfileDaoClient daoClient = new ProfileDaoClient();
+        /* Create a new profile **/
+        ProfileTO profileTO = new ProfileTO();
+        Assert.assertEquals(0, profileTO.getId());
+        profileTO.setName("ProfileTest5");
+        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
+        Assert.assertNotNull(newProfileTO);
+        Assert.assertTrue(newProfileTO.getId() != 0);
+        Assert.assertEquals("ProfileTest5", newProfileTO.getName());
+        /* Create a new ProfileAttribute */
+        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
+        attributeTO.setMandatory(true);
+        attributeTO.setName("Attribute for test 5");
+        attributeTO.setType("string");
+        attributeTO.setProfileId(newProfileTO.getId());
+        ProfileAttributeTO newAttributeTO = daoClient.createProfileAttribute(attributeTO);
+        Assert.assertNotNull(newAttributeTO);
+        Assert.assertTrue(newAttributeTO.getId() != 0);
+        Assert.assertEquals(newProfileTO.getId(), newAttributeTO.getProfileId());
+        passed();
+    }
+
+    @Test
+    public void testDeleteProfileAttribute() throws Exception {
+        testName("deleteProfileattribute");
+        ProfileDaoClient daoClient = new ProfileDaoClient();
+        /* Create a new profile **/
+        ProfileTO profileTO = new ProfileTO();
+        Assert.assertEquals(0, profileTO.getId());
+        profileTO.setName("ProfileTest6");
+        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
+        Assert.assertNotNull(newProfileTO);
+        Assert.assertTrue(newProfileTO.getId() != 0);
+        Assert.assertEquals("ProfileTest6", newProfileTO.getName());
+
+        /* Create a new ProfileAttribute */
+        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
+        attributeTO.setMandatory(true);
+        attributeTO.setName("Attribute for test 6");
+        attributeTO.setType("string");
+        attributeTO.setProfileId(newProfileTO.getId());
+        ProfileAttributeTO newAttributeTO = daoClient.createProfileAttribute(attributeTO);
+        Assert.assertNotNull(newAttributeTO);
+        Assert.assertTrue(newAttributeTO.getId() != 0);
+        daoClient.deleteProfileAttribute(newAttributeTO.getId());
+        passed();
+    }
+
+    @Test
+    public void testReadProfileAttribute() throws Exception {
+        testName("readProfileAttribute");
+        ProfileDaoClient daoClient = new ProfileDaoClient();
+        /* Create a new profile **/
+        ProfileTO profileTO = new ProfileTO();
+        Assert.assertEquals(0, profileTO.getId());
+        profileTO.setName("ProfileTest7");
+        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
+        Assert.assertNotNull(newProfileTO);
+        Assert.assertTrue(newProfileTO.getId() != 0);
+        Assert.assertEquals("ProfileTest7", newProfileTO.getName());
+        /* Create a new ProfileAttribute */
+        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
+        attributeTO.setMandatory(true);
+        attributeTO.setName("Attribute for test 7");
+        attributeTO.setType("string");
+        attributeTO.setProfileId(newProfileTO.getId());
+        ProfileAttributeTO newAttributeTO = daoClient.createProfileAttribute(attributeTO);
+        Assert.assertNotNull(newAttributeTO);
+        Assert.assertTrue(newAttributeTO.getId() != 0);
+        Assert.assertEquals(newProfileTO.getId(), newAttributeTO.getProfileId());
+        /* Read */
+        ProfileAttributeTO testAttributeTO = daoClient.readProfileAttribute(newAttributeTO.getId());
+        Assert.assertNotNull(testAttributeTO);
+        Assert.assertEquals(newAttributeTO.getId(), testAttributeTO.getId());
+        Assert.assertEquals(newAttributeTO.getName(), testAttributeTO.getName());
+        passed();
+    }
+    
+    @Test
+    public void testUpdateProfileAttribute() throws Exception {
+        testName("updateProfileAttribute");
+        ProfileDaoClient daoClient = new ProfileDaoClient();
+        /* Create a new profile **/
+        ProfileTO profileTO = new ProfileTO();
+        Assert.assertEquals(0, profileTO.getId());
+        profileTO.setName("ProfileTest8");
+        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
+        Assert.assertNotNull(newProfileTO);
+        Assert.assertTrue(newProfileTO.getId() != 0);
+        Assert.assertEquals("ProfileTest8", newProfileTO.getName());
+        /* Create a new ProfileAttribute */
+        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
+        attributeTO.setMandatory(true);
+        attributeTO.setName("Attribute for test 8");
+        attributeTO.setType("string");
+        attributeTO.setProfileId(newProfileTO.getId());
+        ProfileAttributeTO newAttributeTO = daoClient.createProfileAttribute(attributeTO);
+        Assert.assertNotNull(newAttributeTO);
+        Assert.assertTrue(newAttributeTO.getId() != 0);
+        Assert.assertEquals(newProfileTO.getId(), newAttributeTO.getProfileId());
+        /* Update */ 
+        newAttributeTO.setName("Attribute for test 8 update");
+        newAttributeTO = daoClient.updateProfileAttribute(newAttributeTO);
+        /* Read */
+        ProfileAttributeTO testAttributeTO = daoClient.readProfileAttribute(newAttributeTO.getId());
+        Assert.assertNotNull(testAttributeTO);
+        Assert.assertEquals(newAttributeTO.getId(), testAttributeTO.getId());
+        Assert.assertEquals(newAttributeTO.getName(), testAttributeTO.getName());
+        passed();
+    }
+    
+}
diff --git a/projects/GDE-test/test/com/edf/gde/test/dao/StudyDaoTest.java b/projects/GDE-test/test/com/edf/gde/test/dao/StudyDaoTest.java
new file mode 100644 (file)
index 0000000..3d99f8d
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.test.dao;
+
+import com.edf.gde.dao.StudyDaoClient;
+import com.edf.gde.base.BaseTest;
+import com.edf.gde.transferables.StudyTO;
+import java.util.Date;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class StudyDaoTest extends BaseTest {
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    public void testCreateStudy() throws Exception {
+        testName("createStudy");
+        StudyDaoClient daoClient = new StudyDaoClient();
+        StudyTO studyTO = createStudyTO("my study");
+        StudyTO newStudyTO = daoClient.createStudy(studyTO);
+        assertNotNull(newStudyTO);
+        assertEquals(studyTO.getName(), newStudyTO.getName());
+        passed();
+    }
+
+    @Test
+    public void testSetStudyState() throws Exception {
+        testName("setStudyState");
+        /* Create new study */
+        StudyDaoClient daoClient = new StudyDaoClient();
+        StudyTO studyTO = createStudyTO("state study");
+        StudyTO newStudyTO = daoClient.createStudy(studyTO);
+        /* Change state of the study */
+        daoClient.setStudyState(newStudyTO.getId(), 1);
+        passed();
+    }
+    
+    @Test
+    public void testReadStudy() throws Exception {
+        testName("readStudy");
+        /* Create new study */
+        StudyDaoClient daoClient = new StudyDaoClient();
+        StudyTO studyTO = createStudyTO("read study");
+        StudyTO newStudyTO = daoClient.createStudy(studyTO);
+        /* Read the new study from server */
+        StudyTO remoteStudyTO = daoClient.readStudy(newStudyTO.getId());
+        assertEquals("read study", remoteStudyTO.getName());
+        assertNotNull(remoteStudyTO.getCreationDate());
+        assertTrue(remoteStudyTO.getCreationDate().before(new Date()));
+        passed();
+    }
+    
+    @Test
+    public void testDeleteStudy() throws Exception {
+        testName("deleteStudy");
+        /* Create new study */
+        StudyDaoClient daoClient = new StudyDaoClient();
+        StudyTO studyTO = createStudyTO("read study");
+        StudyTO newStudyTO = daoClient.createStudy(studyTO);
+        /* delete the new study from server */
+        daoClient.deleteStudy(newStudyTO.getId());
+        passed();
+    }
+    
+    private StudyTO createStudyTO(String name) {
+        StudyTO studyTO = new StudyTO();
+        studyTO.setName(name);
+        studyTO.setCreationDate(new Date(System.currentTimeMillis()));
+        studyTO.setValid(false);
+        return studyTO;
+    }
+}
diff --git a/projects/GDE-test/test/com/edf/gde/test/dao/UserDaoTest.java b/projects/GDE-test/test/com/edf/gde/test/dao/UserDaoTest.java
new file mode 100644 (file)
index 0000000..68d1b7e
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.test.dao;
+
+import com.edf.gde.dao.UserDaoClient;
+import com.edf.gde.base.BaseTest;
+import com.edf.gde.transferables.GroupTO;
+import com.edf.gde.transferables.UserTO;
+import java.io.IOException;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author mordicus
+ */
+public class UserDaoTest extends BaseTest {
+
+    public UserDaoTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    private long createUser(String userName, String password) throws IOException {
+        UserDaoClient instance = new UserDaoClient();
+        long result = instance.createUser(userName, password).getId();
+        return result;
+    }
+
+    private boolean deleteUser(long id) throws IOException {
+        UserDaoClient instance = new UserDaoClient();
+        boolean result = instance.deleteUser(id);
+        return result;
+    }
+
+    private UserTO findUser(String userName) throws IOException {
+        UserDaoClient instance = new UserDaoClient();
+        UserTO userTO = instance.findUser(userName);
+        return userTO;
+    }
+
+    private GroupTO createGroup(String groupName) throws IOException {
+        UserDaoClient daoClient = new UserDaoClient();
+        GroupTO result = daoClient.createGroup(groupName);
+        return result;
+    }
+
+    private GroupTO findGroup(String groupName) throws IOException {
+        UserDaoClient daoClient = new UserDaoClient();
+        GroupTO groupTO = daoClient.findGroup(groupName);
+        return groupTO;
+    }
+
+    private boolean deleteGroup(long groupID) throws IOException {
+        UserDaoClient daoClient = new UserDaoClient();
+        boolean result = daoClient.deleteGroup(groupID);
+        return result;
+    }
+
+    private boolean addToGroup(long groupId, long userId) throws IOException {
+        UserDaoClient daoClient = new UserDaoClient();
+        boolean result = daoClient.addToGroup(groupId, userId);
+        return result;
+    }
+
+    private boolean removeFromGroup(long groupId, long userId) throws IOException {
+        UserDaoClient daoClient = new UserDaoClient();
+        boolean result = daoClient.removeFromGroup(groupId, userId);
+        return result;
+    }
+
+    /**
+     * Test of createUser method, of class UserDao.
+     */
+    @Test
+    public void testCreateUser() throws Exception {
+        testName("createUser");
+        String userName = "Kavoos";
+        String password = "edf123";
+        long userId = createUser(userName, password);
+        assertTrue((userId != -1) && (userId > 0));
+        assertTrue(deleteUser(userId));
+        passed();
+    }
+
+    /**
+     * Test of deleteUser method, of class UserDao.
+     */
+    @Test
+    public void testDeleteUser() throws Exception {
+        testName("deleteUser");
+        long userId = createUser("Kavoos", "edf123");
+        assertTrue(userId > 0);
+        boolean expResult = true;
+        boolean result = deleteUser(userId);
+        assertEquals(expResult, result);
+        passed();
+    }
+
+    @Test
+    public void testFindUser() throws Exception {
+        testName("findUser");
+        long userId = createUser("Kavoos", "edf123");
+        assertTrue(userId > 0);
+        UserTO userTO = findUser("Kavoos");
+        assertNotNull(userTO);
+        assertTrue(userTO.getId() == userId);
+        assertEquals("Kavoos", userTO.getName());
+        assertTrue(deleteUser(userId));
+        passed();
+    }
+
+    @Test
+    public void testCreateGroup() throws Exception {
+        testName("createGroup");
+        GroupTO groupTO = createGroup("Admin");
+        assertNotNull(groupTO);
+        assertEquals("Admin", groupTO.getName());
+        assertTrue(deleteGroup(groupTO.getId()));
+        passed();
+    }
+
+    @Test
+    public void testFindGroup() throws Exception {
+        testName("findGroup");
+        GroupTO groupTO = createGroup("Admin");
+        assertNotNull(groupTO);
+        assertEquals("Admin", groupTO.getName());
+        groupTO = findGroup("Admin");
+        assertNotNull(groupTO);
+        assertEquals("Admin", groupTO.getName());
+        assertTrue(deleteGroup(groupTO.getId()));
+        passed();
+    }
+
+    @Test
+    public void testDeleteGroup() throws Exception {
+        testName("deleteGroup");
+        GroupTO groupTO = createGroup("Admin");
+        assertNotNull(groupTO);
+        assertEquals("Admin", groupTO.getName());
+        assertTrue(deleteGroup(groupTO.getId()));
+        passed();
+    }
+
+    @Test
+    public void testAddToGroup() throws Exception {
+        testName("addToGroup");
+        /* create a group */
+        GroupTO groupTO = createGroup("Admin");
+        assertNotNull(groupTO);
+        assertTrue(groupTO.getId() > 0);
+        assertEquals("Admin", groupTO.getName());
+        /* Create a user */
+        long userId = createUser("Kavoos", "edf123");
+        assertTrue(userId > 0);
+        /* add the user to the group */
+        boolean result = addToGroup(groupTO.getId(), userId);
+        assertTrue(result);
+        assertTrue(deleteGroup(groupTO.getId()));
+        assertTrue(deleteUser(userId));
+        passed();
+    }
+
+    @Test
+    public void testRemoveFromGroup() throws Exception {
+        testName("removeFromGroup");
+        /* create a group */
+        GroupTO groupTO = createGroup("Admin");
+        assertNotNull(groupTO);
+        assertTrue(groupTO.getId() > 0);
+        assertEquals("Admin", groupTO.getName());
+        /* Create a user */
+        long userId = createUser("Kavoos", "edf123");
+        assertTrue(userId > 0);
+        /* add the user to the group */
+        boolean result = addToGroup(groupTO.getId(), userId);
+        assertTrue(result);
+        /* Remove the user from the group */
+        result = removeFromGroup(groupTO.getId(), userId);
+        assertTrue(result);
+        assertTrue(deleteGroup(groupTO.getId()));
+        assertTrue(deleteUser(userId));
+        passed();
+    }
+
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/AttributeGroupTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/AttributeGroupTO.java
new file mode 100644 (file)
index 0000000..bd78f8a
--- /dev/null
@@ -0,0 +1,40 @@
+package com.edf.gde.transferables;
+
+import java.io.Serializable;
+import java.util.Collection;
+
+/**
+ *
+ * @author F62173
+ */
+public class AttributeGroupTO implements Serializable {
+    
+    private static final long serialVersionUID = 1L;
+    private long id;
+    private Collection<AttributeTO> attributeCollection;
+
+    public AttributeGroupTO() {
+    }
+
+    public AttributeGroupTO(long id, Collection<AttributeTO> attributeCollection) {
+        this.id = id;
+        this.attributeCollection = attributeCollection;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public Collection<AttributeTO> getAttributeCollection() {
+        return attributeCollection;
+    }
+
+    public void setAttributeCollection(Collection<AttributeTO> attributeCollection) {
+        this.attributeCollection = attributeCollection;
+    }
+    
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/AttributeTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/AttributeTO.java
new file mode 100644 (file)
index 0000000..4cfd511
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.transferables;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ *
+ * @author F62173
+ */
+public class AttributeTO implements Serializable {
+    
+    private static final long serialVersionUID = 1L;
+    private long id;
+    private String name;
+    private String type;
+    private String value;
+    private long groupId;
+    private boolean mandatory;
+
+    public AttributeTO() {
+    }
+
+    public AttributeTO(long id, String name, String type, String value, long groupId, boolean mandatory) {
+        this.id = id;
+        this.name = name;
+        this.type = type;
+        this.value = value;
+        this.groupId = groupId;
+        this.mandatory = mandatory;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public long getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(long groupId) {
+        this.groupId = groupId;
+    }
+
+    public boolean getMandatory() {
+        return mandatory;
+    }
+
+    public void setMandatory(boolean mandatory) {
+        this.mandatory = mandatory;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 3;
+        hash = 67 * hash + (int) (this.id ^ (this.id >>> 32));
+        hash = 67 * hash + Objects.hashCode(this.name);
+        hash = 67 * hash + Objects.hashCode(this.type);
+        hash = 67 * hash + Objects.hashCode(this.value);
+        hash = 67 * hash + (int) (this.groupId ^ (this.groupId >>> 32));
+        hash = 67 * hash + (this.mandatory ? 1 : 0);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final AttributeTO other = (AttributeTO) obj;
+        if (this.id != other.id) {
+            return false;
+        }
+        return true;
+    }
+    
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/ChunkTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/ChunkTO.java
new file mode 100644 (file)
index 0000000..40b3d7b
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.transferables;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author F62173
+ */
+public class ChunkTO implements Serializable {
+    
+    private static final long serialVersionUID = 1L;
+    private long id;
+    private long fileId;
+    private long rank;
+    private String checksum;
+    private long size;
+    private byte data[];
+
+    public ChunkTO() {
+    }
+
+    public ChunkTO(long id, long fileId, long rank, String checksum, long size, byte[] data) {
+        this.id = id;
+        this.fileId = fileId;
+        this.rank = rank;
+        this.checksum = checksum;
+        this.size = size;
+        this.data = data;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getFileId() {
+        return fileId;
+    }
+
+    public void setFileId(long fileId) {
+        this.fileId = fileId;
+    }
+
+    public long getRank() {
+        return rank;
+    }
+
+    public void setRank(long rank) {
+        this.rank = rank;
+    }
+
+    public String getChecksum() {
+        return checksum;
+    }
+
+    public void setChecksum(String checksum) {
+        this.checksum = checksum;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public void setSize(long size) {
+        this.size = size;
+    }
+
+    public byte[] getData() {
+        return data;
+    }
+
+    public void setData(byte[] data) {
+        this.data = data;
+    }
+    
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/CommandTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/CommandTO.java
new file mode 100644 (file)
index 0000000..a2b3531
--- /dev/null
@@ -0,0 +1,99 @@
+package com.edf.gde.transferables;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author kavoos
+ */
+public class CommandTO {
+
+    private int method;
+    private Map<String, String> parameters;
+    private String data;
+
+    public CommandTO() {
+        parameters = new HashMap<>();
+    }
+
+    public int getMethod() {
+        return method;
+    }
+
+    public void setMethod(int method) {
+        this.method = method;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+
+    public Map<String, String> getParameters() {
+        return parameters;
+    }
+
+    public void setParameters(Map<String, String> parameters) {
+        this.parameters = parameters;
+    }
+
+    public String getParameter(String name) {
+        String ret = parameters.get(name);
+        if (ret == null) {
+            throw new RuntimeException("Parameter " + name + " not found");
+        }
+        return ret;
+    }
+
+    public long getLong(String name) {
+        return Long.parseLong(parameters.get(name));
+    }
+
+    public void setLong(String name, long value) {
+        parameters.put(name, Long.toString(value));
+    }
+    
+    public int getInt(String name) {
+        return Integer.parseInt(parameters.get(name));
+    }
+    
+    public void setInt(String name, int value) {
+        parameters.put(name, Integer.toString(value));
+    }
+
+    public float getFloat(String name) {
+        return Float.parseFloat(parameters.get(name));
+    }
+    
+    public void setFloat(String name, float value) {
+        parameters.put(name, Float.toString(value));
+    }
+
+    public boolean getBoolean(String name) {
+        return Boolean.parseBoolean(parameters.get(name));
+    }
+
+    public void setBoolean(String name, boolean value) {
+        parameters.put(name, Boolean.toString(value));
+    }
+    
+    public double getDouble(String name) {
+        return Double.parseDouble(parameters.get(name));
+    }
+    
+    public void setDouble(String name, double value) {
+        parameters.put(name, Double.toString(value));
+    }
+    
+    public String getString(String name) {
+        return parameters.get(name);
+    }
+    
+    public void setString(String name, String value) {
+        parameters.put(name, value);
+    }
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/FileTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/FileTO.java
new file mode 100644 (file)
index 0000000..e7cb272
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.edf.gde.transferables;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ *
+ * @author F62173
+ */
+public class FileTO implements Serializable {
+    
+    private static final long serialVersionUID = 1L;
+    private long id;
+    private String name;
+    private long length;
+    private String checksum;
+    private Date creationDate;
+    private Date updateDate;
+    private Boolean valid;
+    private Boolean deleted;
+    private Date deletionDate;
+    private long attributeGroupId;
+    private Collection<ChunkTO> chunkCollection;
+    private long dataProfileId;
+
+    public FileTO() {
+    }
+
+    public FileTO(long id, String name, long length, String checksum, Date creationDate, Date updateDate, Boolean valid, Boolean deleted, Date deletionDate, long attributeGroupId, Collection<ChunkTO> chunkCollection, long dataProfileId) {
+        this.id = id;
+        this.name = name;
+        this.length = length;
+        this.checksum = checksum;
+        this.creationDate = creationDate;
+        this.updateDate = updateDate;
+        this.valid = valid;
+        this.deleted = deleted;
+        this.deletionDate = deletionDate;
+        this.attributeGroupId = attributeGroupId;
+        this.chunkCollection = chunkCollection;
+        this.dataProfileId = dataProfileId;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public long getLength() {
+        return length;
+    }
+
+    public void setLength(long length) {
+        this.length = length;
+    }
+
+    public String getChecksum() {
+        return checksum;
+    }
+
+    public void setChecksum(String checksum) {
+        this.checksum = checksum;
+    }
+
+    public Date getCreationDate() {
+        return creationDate;
+    }
+
+    public void setCreationDate(Date creationDate) {
+        this.creationDate = creationDate;
+    }
+
+    public Date getUpdateDate() {
+        return updateDate;
+    }
+
+    public void setUpdateDate(Date updateDate) {
+        this.updateDate = updateDate;
+    }
+
+    public Boolean getValid() {
+        return valid;
+    }
+
+    public void setValid(Boolean valid) {
+        this.valid = valid;
+    }
+
+    public Boolean getDeleted() {
+        return deleted;
+    }
+
+    public void setDeleted(Boolean deleted) {
+        this.deleted = deleted;
+    }
+
+    public Date getDeletionDate() {
+        return deletionDate;
+    }
+
+    public void setDeletionDate(Date deletionDate) {
+        this.deletionDate = deletionDate;
+    }
+
+    public long getAttributeGroupId() {
+        return attributeGroupId;
+    }
+
+    public void setAttributeGroupId(long attributeGroupId) {
+        this.attributeGroupId = attributeGroupId;
+    }
+
+    public Collection<ChunkTO> getChunkCollection() {
+        return chunkCollection;
+    }
+
+    public void setChunkCollection(Collection<ChunkTO> chunkCollection) {
+        this.chunkCollection = chunkCollection;
+    }
+
+    public long getDataProfileId() {
+        return dataProfileId;
+    }
+
+    public void setDataProfileId(long dataProfileId) {
+        this.dataProfileId = dataProfileId;
+    }
+
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/GroupTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/GroupTO.java
new file mode 100644 (file)
index 0000000..3b8d47d
--- /dev/null
@@ -0,0 +1,29 @@
+package com.edf.gde.transferables;
+
+/**
+ *
+ * @author kavoos
+ */
+public class GroupTO {
+    private long id;
+    private String name;
+
+    public GroupTO() {
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/LongListTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/LongListTO.java
new file mode 100644 (file)
index 0000000..8c029a0
--- /dev/null
@@ -0,0 +1,24 @@
+package com.edf.gde.transferables;
+
+import java.util.List;
+
+/**
+ * Collection of long
+ * @author kavoos
+ */
+
+public class LongListTO {
+    private List<Long> list;
+
+    public LongListTO() {
+    }
+
+    public List<Long> getList() {
+        return list;
+    }
+
+    public void setList(List<Long> list) {
+        this.list = list;
+    }
+    
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/ProfileAttributeTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/ProfileAttributeTO.java
new file mode 100644 (file)
index 0000000..b8f46e7
--- /dev/null
@@ -0,0 +1,62 @@
+package com.edf.gde.transferables;
+
+import java.io.Serializable;
+
+/*
+ * (C) 2015 EDF
+ */
+/**
+ *
+ * @author Kavoos
+ */
+public class ProfileAttributeTO implements Serializable {
+
+    private long id;
+    private String name;
+    private String type;
+    private boolean mandatory;
+    private long profileId;
+
+    public ProfileAttributeTO() {
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public boolean isMandatory() {
+        return mandatory;
+    }
+
+    public void setMandatory(boolean mandatory) {
+        this.mandatory = mandatory;
+    }
+
+    public long getProfileId() {
+        return profileId;
+    }
+
+    public void setProfileId(long profileId) {
+        this.profileId = profileId;
+    }
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/ProfileTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/ProfileTO.java
new file mode 100644 (file)
index 0000000..c9aae13
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.transferables;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class ProfileTO implements Serializable {
+    private long id;
+    private String name;
+    List<ProfileAttributeTO> attributes;
+
+    public ProfileTO() {
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<ProfileAttributeTO> getAttributes() {
+        return attributes;
+    }
+
+    public void setAttributes(List<ProfileAttributeTO> attributes) {
+        this.attributes = attributes;
+    }
+    
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/StudyTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/StudyTO.java
new file mode 100644 (file)
index 0000000..36436ab
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.transferables;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *
+ * @author F62173
+ */
+public class StudyTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    private long id;
+    private String name;
+    private Date creationDate;
+    private Date updateDate;
+    private boolean valid;
+    private boolean deleted;
+    private Date deletionDate;
+    private long attributeGroupId;
+    private long profileId;
+    private boolean locked;
+
+    public StudyTO() {
+    }
+
+    public StudyTO(long id, String name, Date creationDate, Date updateDate, boolean valid, boolean deleted, Date deletionDate, long attributeGroupId, long profileId) {
+        this.id = id;
+        this.name = name;
+        this.creationDate = creationDate;
+        this.updateDate = updateDate;
+        this.valid = valid;
+        this.deleted = deleted;
+        this.deletionDate = deletionDate;
+        this.attributeGroupId = attributeGroupId;
+        this.profileId = profileId;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Date getCreationDate() {
+        return creationDate;
+    }
+
+    public void setCreationDate(Date creationDate) {
+        this.creationDate = creationDate;
+    }
+
+    public Date getUpdateDate() {
+        return updateDate;
+    }
+
+    public void setUpdateDate(Date updateDate) {
+        this.updateDate = updateDate;
+    }
+
+    public boolean getValid() {
+        return valid;
+    }
+
+    public void setValid(boolean valid) {
+        this.valid = valid;
+    }
+
+    public boolean getDeleted() {
+        return deleted;
+    }
+
+    public void setDeleted(boolean deleted) {
+        this.deleted = deleted;
+    }
+
+    public Date getDeletionDate() {
+        return deletionDate;
+    }
+
+    public void setDeletionDate(Date deletionDate) {
+        this.deletionDate = deletionDate;
+    }
+
+    public long getAttributeGroupId() {
+        return attributeGroupId;
+    }
+
+    public void setAttributeGroupId(long attributeGroupId) {
+        this.attributeGroupId = attributeGroupId;
+    }
+
+    public long getProfileId() {
+        return profileId;
+    }
+
+    public void setProfileId(long profileId) {
+        this.profileId = profileId;
+    }
+
+    public boolean isLocked() {
+        return locked;
+    }
+
+    public void setLocked(boolean locked) {
+        this.locked = locked;
+    }
+
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/UserTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/UserTO.java
new file mode 100644 (file)
index 0000000..0370855
--- /dev/null
@@ -0,0 +1,40 @@
+package com.edf.gde.transferables;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class UserTO {
+    private Long id;
+    private String name;
+    private String password;
+
+    public UserTO() {
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/responses/CommandResultTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/responses/CommandResultTO.java
new file mode 100644 (file)
index 0000000..642177e
--- /dev/null
@@ -0,0 +1,43 @@
+package com.edf.gde.transferables.responses;
+
+/**
+ *
+ * @author Kavoos
+ */
+public class CommandResultTO {
+    public static final int OK = 1;
+    public static final int ERROR = 2;
+    
+    private int code;
+    private String msg;
+    private String data;
+    
+    public CommandResultTO() {
+        code = OK;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+    
+}
diff --git a/projects/GDE-transferables/src/com/edf/gde/transferables/responses/ObjectCreationResponseTO.java b/projects/GDE-transferables/src/com/edf/gde/transferables/responses/ObjectCreationResponseTO.java
new file mode 100644 (file)
index 0000000..ebd02ab
--- /dev/null
@@ -0,0 +1,22 @@
+package com.edf.gde.transferables.responses;
+
+/**
+ *
+ * @author kavoos
+ */
+public class ObjectCreationResponseTO extends CommandResultTO {
+    long id;
+
+    public ObjectCreationResponseTO() {
+        super();
+        id = -1;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+}
index 996afa6f7bec3b28fec72f4bfc0e9174db6d5759..03f9b3f1d5806f6e8339349734f33dfe75418aa6 100644 (file)
@@ -780,8 +780,16 @@ exists or setup the property manually. For example like this:
     <!--
                 COMPILATION SECTION
             -->
-    <target depends="init" if="no.dist.ear.dir" name="-deps-module-jar" unless="no.deps"/>
-    <target depends="init" if="dist.ear.dir" name="-deps-ear-jar" unless="no.deps"/>
+    <target depends="init" if="no.dist.ear.dir" name="-deps-module-jar" unless="no.deps">
+        <ant antfile="${project.GDE-transferables}/build.xml" inheritall="false" target="jar">
+            <property name="deploy.on.save" value="false"/>
+        </ant>
+    </target>
+    <target depends="init" if="dist.ear.dir" name="-deps-ear-jar" unless="no.deps">
+        <ant antfile="${project.GDE-transferables}/build.xml" inheritall="false" target="jar">
+            <property name="deploy.on.save" value="false"/>
+        </ant>
+    </target>
     <target depends="init, -deps-module-jar, -deps-ear-jar" name="deps-jar"/>
     <target depends="init,deps-jar" name="-pre-pre-compile">
         <mkdir dir="${build.classes.dir}"/>
@@ -792,11 +800,18 @@ exists or setup the property manually. For example like this:
         <!-- You can override this target in the ../build.xml file. -->
     </target>
     <target depends="compile,-library-inclusion-in-archive-weblogic,-library-inclusion-in-archive-by-user" name="library-inclusion-in-archive"/>
-    <target if="is.jars.in.ejbjar" name="-library-inclusion-in-archive-by-user"/>
+    <target if="is.jars.in.ejbjar" name="-library-inclusion-in-archive-by-user">
+        <copyfiles files="${reference.GDE-transferables.jar}" todir="${build.classes.dir}"/>
+    </target>
     <target if="is.server.weblogic" name="-library-inclusion-in-archive-weblogic">
-        <manifest file="${build.ear.classes.dir}/META-INF/MANIFEST.MF" mode="update"/>
+        <basename file="${reference.GDE-transferables.jar}" property="manifest.reference.GDE-transferables.jar"/>
+        <manifest file="${build.ear.classes.dir}/META-INF/MANIFEST.MF" mode="update">
+            <attribute name="Extension-List" value="jar-1 "/>
+            <attribute name="jar-1-Extension-Name" value="${manifest.reference.GDE-transferables.jar}"/>
+        </manifest>
     </target>
     <target depends="compile" name="library-inclusion-in-manifest">
+        <copyfiles files="${reference.GDE-transferables.jar}" todir="${dist.ear.dir}/lib"/>
         <manifest file="${build.ear.classes.dir}/META-INF/MANIFEST.MF" mode="update"/>
     </target>
     <target name="-copy-meta-inf">
@@ -1179,7 +1194,9 @@ exists or setup the property manually. For example like this:
     <!--
                 CLEANUP SECTION
             -->
-    <target depends="init" name="deps-clean" unless="no.deps"/>
+    <target depends="init" name="deps-clean" unless="no.deps">
+        <ant antfile="${project.GDE-transferables}/build.xml" inheritall="false" target="clean"/>
+    </target>
     <target depends="init" name="-do-clean">
         <delete dir="${build.dir}"/>
         <delete dir="${dist.dir}"/>
index d97902bde4b0448c0ce783c7083f7d115a64962f..8b50590ea1333cc722323f06f98d25b9866a1199 100644 (file)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=dd11cbd0
+build.xml.data.CRC32=3861114a
 build.xml.script.CRC32=e2a8c789
 build.xml.stylesheet.CRC32=5910fda3@1.51.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=dd11cbd0
-nbproject/build-impl.xml.script.CRC32=fd1a82f0
+nbproject/build-impl.xml.data.CRC32=3861114a
+nbproject/build-impl.xml.script.CRC32=8477a541
 nbproject/build-impl.xml.stylesheet.CRC32=6096d939@1.51.1
index 41ec3c9f0239313116576ef8d8646b9b2245d58c..f7684ecb709fb9fc4cfed8834a30298126b0aa2f 100644 (file)
@@ -35,7 +35,9 @@ j2ee.platform.wsit.classpath=
 j2ee.server.type=gfv3ee6
 jar.compress=false
 jar.name=GDE-ejb.jar
-javac.classpath=
+jars.in.ejbjar=false
+javac.classpath=\
+    ${reference.GDE-transferables.jar}
 javac.debug=true
 javac.deprecation=false
 javac.processorpath=\
@@ -63,6 +65,8 @@ javadoc.windowtitle=
 meta.inf=${source.root}/conf
 meta.inf.excludes=sun-cmp-mappings.xml
 platform.active=default_platform
+project.GDE-transferables=../../GDE-transferables
+reference.GDE-transferables.jar=${project.GDE-transferables}/dist/GDE-transferables.jar
 resource.dir=setup
 run.test.classpath=\
     ${javac.test.classpath}:\
index 312bb1dca8903ecf896a5d299914dd92ef9828b3..53725ad58c5be83a641635d273d0d91ea7811055 100644 (file)
@@ -5,6 +5,7 @@
         <data xmlns="http://www.netbeans.org/ns/j2ee-ejbjarproject/3">
             <name>GDE-ejb</name>
             <minimum-ant-version>1.6.5</minimum-ant-version>
+            <included-library dirs="200">reference.GDE-transferables.jar</included-library>
             <source-roots>
                 <root id="src.dir"/>
             </source-roots>
                 <root id="test.src.dir"/>
             </test-roots>
         </data>
+        <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
+            <reference>
+                <foreign-project>GDE-transferables</foreign-project>
+                <artifact-type>jar</artifact-type>
+                <script>build.xml</script>
+                <target>jar</target>
+                <clean-target>clean</clean-target>
+                <id>jar</id>
+            </reference>
+        </references>
     </configuration>
 </project>
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/AttributeGroupTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/AttributeGroupTO.java
deleted file mode 100644 (file)
index bd78f8a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.edf.gde.transferables;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-/**
- *
- * @author F62173
- */
-public class AttributeGroupTO implements Serializable {
-    
-    private static final long serialVersionUID = 1L;
-    private long id;
-    private Collection<AttributeTO> attributeCollection;
-
-    public AttributeGroupTO() {
-    }
-
-    public AttributeGroupTO(long id, Collection<AttributeTO> attributeCollection) {
-        this.id = id;
-        this.attributeCollection = attributeCollection;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public Collection<AttributeTO> getAttributeCollection() {
-        return attributeCollection;
-    }
-
-    public void setAttributeCollection(Collection<AttributeTO> attributeCollection) {
-        this.attributeCollection = attributeCollection;
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/AttributeTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/AttributeTO.java
deleted file mode 100644 (file)
index 4cfd511..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.transferables;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- *
- * @author F62173
- */
-public class AttributeTO implements Serializable {
-    
-    private static final long serialVersionUID = 1L;
-    private long id;
-    private String name;
-    private String type;
-    private String value;
-    private long groupId;
-    private boolean mandatory;
-
-    public AttributeTO() {
-    }
-
-    public AttributeTO(long id, String name, String type, String value, long groupId, boolean mandatory) {
-        this.id = id;
-        this.name = name;
-        this.type = type;
-        this.value = value;
-        this.groupId = groupId;
-        this.mandatory = mandatory;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-
-    public long getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(long groupId) {
-        this.groupId = groupId;
-    }
-
-    public boolean getMandatory() {
-        return mandatory;
-    }
-
-    public void setMandatory(boolean mandatory) {
-        this.mandatory = mandatory;
-    }
-
-    @Override
-    public int hashCode() {
-        int hash = 3;
-        hash = 67 * hash + (int) (this.id ^ (this.id >>> 32));
-        hash = 67 * hash + Objects.hashCode(this.name);
-        hash = 67 * hash + Objects.hashCode(this.type);
-        hash = 67 * hash + Objects.hashCode(this.value);
-        hash = 67 * hash + (int) (this.groupId ^ (this.groupId >>> 32));
-        hash = 67 * hash + (this.mandatory ? 1 : 0);
-        return hash;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        final AttributeTO other = (AttributeTO) obj;
-        if (this.id != other.id) {
-            return false;
-        }
-        return true;
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ChunkTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ChunkTO.java
deleted file mode 100644 (file)
index 40b3d7b..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.transferables;
-
-import java.io.Serializable;
-
-/**
- *
- * @author F62173
- */
-public class ChunkTO implements Serializable {
-    
-    private static final long serialVersionUID = 1L;
-    private long id;
-    private long fileId;
-    private long rank;
-    private String checksum;
-    private long size;
-    private byte data[];
-
-    public ChunkTO() {
-    }
-
-    public ChunkTO(long id, long fileId, long rank, String checksum, long size, byte[] data) {
-        this.id = id;
-        this.fileId = fileId;
-        this.rank = rank;
-        this.checksum = checksum;
-        this.size = size;
-        this.data = data;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public long getFileId() {
-        return fileId;
-    }
-
-    public void setFileId(long fileId) {
-        this.fileId = fileId;
-    }
-
-    public long getRank() {
-        return rank;
-    }
-
-    public void setRank(long rank) {
-        this.rank = rank;
-    }
-
-    public String getChecksum() {
-        return checksum;
-    }
-
-    public void setChecksum(String checksum) {
-        this.checksum = checksum;
-    }
-
-    public long getSize() {
-        return size;
-    }
-
-    public void setSize(long size) {
-        this.size = size;
-    }
-
-    public byte[] getData() {
-        return data;
-    }
-
-    public void setData(byte[] data) {
-        this.data = data;
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/CommandTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/CommandTO.java
deleted file mode 100644 (file)
index a2b3531..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.edf.gde.transferables;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * @author kavoos
- */
-public class CommandTO {
-
-    private int method;
-    private Map<String, String> parameters;
-    private String data;
-
-    public CommandTO() {
-        parameters = new HashMap<>();
-    }
-
-    public int getMethod() {
-        return method;
-    }
-
-    public void setMethod(int method) {
-        this.method = method;
-    }
-
-    public String getData() {
-        return data;
-    }
-
-    public void setData(String data) {
-        this.data = data;
-    }
-
-    public Map<String, String> getParameters() {
-        return parameters;
-    }
-
-    public void setParameters(Map<String, String> parameters) {
-        this.parameters = parameters;
-    }
-
-    public String getParameter(String name) {
-        String ret = parameters.get(name);
-        if (ret == null) {
-            throw new RuntimeException("Parameter " + name + " not found");
-        }
-        return ret;
-    }
-
-    public long getLong(String name) {
-        return Long.parseLong(parameters.get(name));
-    }
-
-    public void setLong(String name, long value) {
-        parameters.put(name, Long.toString(value));
-    }
-    
-    public int getInt(String name) {
-        return Integer.parseInt(parameters.get(name));
-    }
-    
-    public void setInt(String name, int value) {
-        parameters.put(name, Integer.toString(value));
-    }
-
-    public float getFloat(String name) {
-        return Float.parseFloat(parameters.get(name));
-    }
-    
-    public void setFloat(String name, float value) {
-        parameters.put(name, Float.toString(value));
-    }
-
-    public boolean getBoolean(String name) {
-        return Boolean.parseBoolean(parameters.get(name));
-    }
-
-    public void setBoolean(String name, boolean value) {
-        parameters.put(name, Boolean.toString(value));
-    }
-    
-    public double getDouble(String name) {
-        return Double.parseDouble(parameters.get(name));
-    }
-    
-    public void setDouble(String name, double value) {
-        parameters.put(name, Double.toString(value));
-    }
-    
-    public String getString(String name) {
-        return parameters.get(name);
-    }
-    
-    public void setString(String name, String value) {
-        parameters.put(name, value);
-    }
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/FileTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/FileTO.java
deleted file mode 100644 (file)
index e7cb272..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.edf.gde.transferables;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Date;
-
-/**
- *
- * @author F62173
- */
-public class FileTO implements Serializable {
-    
-    private static final long serialVersionUID = 1L;
-    private long id;
-    private String name;
-    private long length;
-    private String checksum;
-    private Date creationDate;
-    private Date updateDate;
-    private Boolean valid;
-    private Boolean deleted;
-    private Date deletionDate;
-    private long attributeGroupId;
-    private Collection<ChunkTO> chunkCollection;
-    private long dataProfileId;
-
-    public FileTO() {
-    }
-
-    public FileTO(long id, String name, long length, String checksum, Date creationDate, Date updateDate, Boolean valid, Boolean deleted, Date deletionDate, long attributeGroupId, Collection<ChunkTO> chunkCollection, long dataProfileId) {
-        this.id = id;
-        this.name = name;
-        this.length = length;
-        this.checksum = checksum;
-        this.creationDate = creationDate;
-        this.updateDate = updateDate;
-        this.valid = valid;
-        this.deleted = deleted;
-        this.deletionDate = deletionDate;
-        this.attributeGroupId = attributeGroupId;
-        this.chunkCollection = chunkCollection;
-        this.dataProfileId = dataProfileId;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public long getLength() {
-        return length;
-    }
-
-    public void setLength(long length) {
-        this.length = length;
-    }
-
-    public String getChecksum() {
-        return checksum;
-    }
-
-    public void setChecksum(String checksum) {
-        this.checksum = checksum;
-    }
-
-    public Date getCreationDate() {
-        return creationDate;
-    }
-
-    public void setCreationDate(Date creationDate) {
-        this.creationDate = creationDate;
-    }
-
-    public Date getUpdateDate() {
-        return updateDate;
-    }
-
-    public void setUpdateDate(Date updateDate) {
-        this.updateDate = updateDate;
-    }
-
-    public Boolean getValid() {
-        return valid;
-    }
-
-    public void setValid(Boolean valid) {
-        this.valid = valid;
-    }
-
-    public Boolean getDeleted() {
-        return deleted;
-    }
-
-    public void setDeleted(Boolean deleted) {
-        this.deleted = deleted;
-    }
-
-    public Date getDeletionDate() {
-        return deletionDate;
-    }
-
-    public void setDeletionDate(Date deletionDate) {
-        this.deletionDate = deletionDate;
-    }
-
-    public long getAttributeGroupId() {
-        return attributeGroupId;
-    }
-
-    public void setAttributeGroupId(long attributeGroupId) {
-        this.attributeGroupId = attributeGroupId;
-    }
-
-    public Collection<ChunkTO> getChunkCollection() {
-        return chunkCollection;
-    }
-
-    public void setChunkCollection(Collection<ChunkTO> chunkCollection) {
-        this.chunkCollection = chunkCollection;
-    }
-
-    public long getDataProfileId() {
-        return dataProfileId;
-    }
-
-    public void setDataProfileId(long dataProfileId) {
-        this.dataProfileId = dataProfileId;
-    }
-
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/GroupTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/GroupTO.java
deleted file mode 100644 (file)
index 3b8d47d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.edf.gde.transferables;
-
-/**
- *
- * @author kavoos
- */
-public class GroupTO {
-    private long id;
-    private String name;
-
-    public GroupTO() {
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/LongListTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/LongListTO.java
deleted file mode 100644 (file)
index 8c029a0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.edf.gde.transferables;
-
-import java.util.List;
-
-/**
- * Collection of long
- * @author kavoos
- */
-
-public class LongListTO {
-    private List<Long> list;
-
-    public LongListTO() {
-    }
-
-    public List<Long> getList() {
-        return list;
-    }
-
-    public void setList(List<Long> list) {
-        this.list = list;
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ProfileAttributeTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ProfileAttributeTO.java
deleted file mode 100644 (file)
index b8f46e7..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.edf.gde.transferables;
-
-import java.io.Serializable;
-
-/*
- * (C) 2015 EDF
- */
-/**
- *
- * @author Kavoos
- */
-public class ProfileAttributeTO implements Serializable {
-
-    private long id;
-    private String name;
-    private String type;
-    private boolean mandatory;
-    private long profileId;
-
-    public ProfileAttributeTO() {
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public boolean isMandatory() {
-        return mandatory;
-    }
-
-    public void setMandatory(boolean mandatory) {
-        this.mandatory = mandatory;
-    }
-
-    public long getProfileId() {
-        return profileId;
-    }
-
-    public void setProfileId(long profileId) {
-        this.profileId = profileId;
-    }
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ProfileTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/ProfileTO.java
deleted file mode 100644 (file)
index c9aae13..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.transferables;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- *
- * @author Kavoos
- */
-public class ProfileTO implements Serializable {
-    private long id;
-    private String name;
-    List<ProfileAttributeTO> attributes;
-
-    public ProfileTO() {
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public List<ProfileAttributeTO> getAttributes() {
-        return attributes;
-    }
-
-    public void setAttributes(List<ProfileAttributeTO> attributes) {
-        this.attributes = attributes;
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/StudyTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/StudyTO.java
deleted file mode 100644 (file)
index 36436ab..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.transferables;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- *
- * @author F62173
- */
-public class StudyTO implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-    private long id;
-    private String name;
-    private Date creationDate;
-    private Date updateDate;
-    private boolean valid;
-    private boolean deleted;
-    private Date deletionDate;
-    private long attributeGroupId;
-    private long profileId;
-    private boolean locked;
-
-    public StudyTO() {
-    }
-
-    public StudyTO(long id, String name, Date creationDate, Date updateDate, boolean valid, boolean deleted, Date deletionDate, long attributeGroupId, long profileId) {
-        this.id = id;
-        this.name = name;
-        this.creationDate = creationDate;
-        this.updateDate = updateDate;
-        this.valid = valid;
-        this.deleted = deleted;
-        this.deletionDate = deletionDate;
-        this.attributeGroupId = attributeGroupId;
-        this.profileId = profileId;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Date getCreationDate() {
-        return creationDate;
-    }
-
-    public void setCreationDate(Date creationDate) {
-        this.creationDate = creationDate;
-    }
-
-    public Date getUpdateDate() {
-        return updateDate;
-    }
-
-    public void setUpdateDate(Date updateDate) {
-        this.updateDate = updateDate;
-    }
-
-    public boolean getValid() {
-        return valid;
-    }
-
-    public void setValid(boolean valid) {
-        this.valid = valid;
-    }
-
-    public boolean getDeleted() {
-        return deleted;
-    }
-
-    public void setDeleted(boolean deleted) {
-        this.deleted = deleted;
-    }
-
-    public Date getDeletionDate() {
-        return deletionDate;
-    }
-
-    public void setDeletionDate(Date deletionDate) {
-        this.deletionDate = deletionDate;
-    }
-
-    public long getAttributeGroupId() {
-        return attributeGroupId;
-    }
-
-    public void setAttributeGroupId(long attributeGroupId) {
-        this.attributeGroupId = attributeGroupId;
-    }
-
-    public long getProfileId() {
-        return profileId;
-    }
-
-    public void setProfileId(long profileId) {
-        this.profileId = profileId;
-    }
-
-    public boolean isLocked() {
-        return locked;
-    }
-
-    public void setLocked(boolean locked) {
-        this.locked = locked;
-    }
-
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/UserTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/UserTO.java
deleted file mode 100644 (file)
index 0370855..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.edf.gde.transferables;
-
-/**
- *
- * @author Kavoos
- */
-public class UserTO {
-    private Long id;
-    private String name;
-    private String password;
-
-    public UserTO() {
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/responses/CommandResultTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/responses/CommandResultTO.java
deleted file mode 100644 (file)
index 642177e..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.edf.gde.transferables.responses;
-
-/**
- *
- * @author Kavoos
- */
-public class CommandResultTO {
-    public static final int OK = 1;
-    public static final int ERROR = 2;
-    
-    private int code;
-    private String msg;
-    private String data;
-    
-    public CommandResultTO() {
-        code = OK;
-    }
-
-    public int getCode() {
-        return code;
-    }
-
-    public void setCode(int code) {
-        this.code = code;
-    }
-
-    public String getMsg() {
-        return msg;
-    }
-
-    public void setMsg(String msg) {
-        this.msg = msg;
-    }
-
-    public String getData() {
-        return data;
-    }
-
-    public void setData(String data) {
-        this.data = data;
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/responses/ObjectCreationResponseTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/responses/ObjectCreationResponseTO.java
deleted file mode 100644 (file)
index ebd02ab..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.edf.gde.transferables.responses;
-
-/**
- *
- * @author kavoos
- */
-public class ObjectCreationResponseTO extends CommandResultTO {
-    long id;
-
-    public ObjectCreationResponseTO() {
-        super();
-        id = -1;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-}
index 1cf395fd5edcf30db5b633aaa222f2a92d0b9679..f142641c9a30fcb664a49c9051a23d52a6a851f4 100644 (file)
@@ -854,11 +854,17 @@ exists or setup the property manually. For example like this:
             -->
     <target depends="init" if="no.dist.ear.dir" name="deps-module-jar" unless="no.deps">
         <ant antfile="${project.GDE-ejb}/build.xml" inheritall="false" target="dist"/>
+        <ant antfile="${project.GDE-transferables}/build.xml" inheritall="false" target="jar">
+            <property name="deploy.on.save" value="false"/>
+        </ant>
     </target>
     <target depends="init" if="dist.ear.dir" name="deps-ear-jar" unless="no.deps">
         <ant antfile="${project.GDE-ejb}/build.xml" inheritall="false" target="dist-ear">
             <property location="${build.dir}" name="dist.ear.dir"/>
         </ant>
+        <ant antfile="${project.GDE-transferables}/build.xml" inheritall="false" target="jar">
+            <property name="deploy.on.save" value="false"/>
+        </ant>
     </target>
     <target depends="init, deps-module-jar, deps-ear-jar" name="deps-jar" unless="no.deps"/>
     <target depends="init,deps-jar" name="-pre-pre-compile">
@@ -1006,6 +1012,7 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.gson-2.3.1.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${reference.GDE-ejb.dist}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}"/>
         <copyfiles files="${libs.junit_4.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${reference.GDE-transferables.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <mkdir dir="${build.web.dir}/META-INF"/>
         <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
     </target>
@@ -1013,6 +1020,7 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.gson-2.3.1.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${reference.GDE-ejb.dist}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${libs.junit_4.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${reference.GDE-transferables.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
     </target>
     <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
         <delete dir="${build.web.dir}/WEB-INF/lib"/>
@@ -1427,6 +1435,7 @@ exists or setup the property manually. For example like this:
             -->
     <target depends="init" name="deps-clean" unless="no.deps">
         <ant antfile="${project.GDE-ejb}/build.xml" inheritall="false" target="clean"/>
+        <ant antfile="${project.GDE-transferables}/build.xml" inheritall="false" target="clean"/>
     </target>
     <target depends="init" name="do-clean">
         <condition property="build.dir.to.clean" value="${build.web.dir}">
index 99898629c4163880bd5305783a353b972b0e1635..50fe26d4ebc669eec85c32a3e62ea3eb4583fe4e 100644 (file)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=60648d1e
+build.xml.data.CRC32=4fab2992
 build.xml.script.CRC32=aa84c400
 build.xml.stylesheet.CRC32=651128d4@1.68.1.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=60648d1e
-nbproject/build-impl.xml.script.CRC32=c7df2aa1
+nbproject/build-impl.xml.data.CRC32=4fab2992
+nbproject/build-impl.xml.script.CRC32=ac448c9e
 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1
index 3a4345494e64d169e5ebe23f9c08417019bcf971..57526dcbd4e68222771ee1e2a53a42eceae722b4 100644 (file)
@@ -45,7 +45,8 @@ jar.compress=false
 javac.classpath=\
     ${file.reference.gson-2.3.1.jar}:\
     ${reference.GDE-ejb.dist}:\
-    ${libs.junit_4.classpath}
+    ${libs.junit_4.classpath}:\
+    ${reference.GDE-transferables.jar}
 # Space-separated list of extra javac options
 javac.compilerargs=
 javac.debug=true
@@ -75,7 +76,9 @@ lib.dir=${web.docbase.dir}/WEB-INF/lib
 persistence.xml.dir=${conf.dir}
 platform.active=default_platform
 project.GDE-ejb=../GDE-ejb
+project.GDE-transferables=../../GDE-transferables
 reference.GDE-ejb.dist=${project.GDE-ejb}/dist/GDE-ejb.jar
+reference.GDE-transferables.jar=${project.GDE-transferables}/dist/GDE-transferables.jar
 resource.dir=setup
 run.test.classpath=\
     ${javac.test.classpath}:\
index fcd9ad9ec51fed511b77f5470d88f4d67bb747b0..5679b7deb8f86cc8e87021aad2ede4084833b74d 100644 (file)
                     <file>${libs.junit_4.classpath}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
+                <library dirs="200">
+                    <file>${reference.GDE-transferables.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
             </web-module-libraries>
             <web-module-additional-libraries/>
             <source-roots>
                 <clean-target>clean</clean-target>
                 <id>dist</id>
             </reference>
+            <reference>
+                <foreign-project>GDE-transferables</foreign-project>
+                <artifact-type>jar</artifact-type>
+                <script>build.xml</script>
+                <target>jar</target>
+                <clean-target>clean</clean-target>
+                <id>jar</id>
+            </reference>
         </references>
     </configuration>
 </project>
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/AttributeDaoClient.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/AttributeDaoClient.java
deleted file mode 100644 (file)
index 52b6591..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.dao;
-
-import com.edf.gde.transferables.AttributeGroupTO;
-import com.edf.gde.transferables.AttributeTO;
-import com.edf.gde.transferables.CommandTO;
-import java.io.IOException;
-import restapi.RestContext;
-
-/**
- *
- * @author Kavoos
- */
-public class AttributeDaoClient extends BaseDao {
-
-    public static final String ServiceName = "AttributesService";
-    public static final int CREATEATTRIBUTE = 1;
-    public static final int DELETEATTRIBUTE = 2;
-    public static final int READATTRIBUTE = 3;
-    public static final int CREATEATTRIBUTEGROUP = 4;
-    public static final int DELETEATTRIBUTEGROUP = 5;
-    public static final int UPDATEATTRIBUTEGROUP = 6;
-    public static final int READATTRIBUTEGROUP = 7;
-
-
-    public AttributeDaoClient() {
-        getContext().setBaseResource("http://localhost:8080/GDE-war/AttributesService");
-        getContext().setUserName("admin");
-        getContext().setPassword("edf123");
-    }
-
-    public AttributeDaoClient(DaoResponseHandler daoResponseHandler, RestContext context) {
-        super(context);
-    }
-
-    public AttributeTO createAttribute(AttributeTO ato) throws IOException {
-        CommandTO commandTO = createCommand(CREATEATTRIBUTE);
-        return postCommand(commandTO, ato, AttributeTO.class);
-    }
-
-    public void deleteAttribute(long id) throws IOException {
-        CommandTO commandTO = createCommand(DELETEATTRIBUTE);
-        commandTO.setLong("attributeId", id);
-        postCommand(commandTO, null);
-    }
-
-    public AttributeTO readAttribute(long id) throws IOException {
-        CommandTO commandTO = createCommand(READATTRIBUTE);
-        commandTO.setLong("attributeId", id);
-        return postCommand(commandTO, null, AttributeTO.class);
-    }
-
-    public AttributeGroupTO createAttributeGroup(AttributeGroupTO agto) throws IOException {
-        CommandTO commandTO = createCommand(CREATEATTRIBUTEGROUP);
-        return postCommand(commandTO, agto, AttributeGroupTO.class);
-    }
-    
-    public void deleteAttributeGroup(long id) throws IOException {
-        CommandTO commandTO = createCommand(DELETEATTRIBUTEGROUP);
-        commandTO.setLong("attributeGroupId", id);
-        postCommand(commandTO, null);
-    }
-    
-    public AttributeGroupTO updateAttributeGroup(AttributeGroupTO agto) throws IOException {
-        CommandTO commandTO = createCommand(UPDATEATTRIBUTEGROUP);
-        return postCommand(commandTO, agto, AttributeGroupTO.class);
-    }
-    
-    public AttributeGroupTO readAttributeGroup(long id) throws IOException {
-        CommandTO commandTO = createCommand(READATTRIBUTEGROUP);
-        commandTO.setLong("attributeGroupId", id);
-        return postCommand(commandTO, null, AttributeGroupTO.class);
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java
deleted file mode 100644 (file)
index cb81114..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.dao;
-
-import com.edf.gde.transferables.CommandTO;
-import com.edf.gde.transferables.responses.CommandResultTO;
-import java.io.IOException;
-import restapi.ResponseHandler;
-import restapi.RestContext;
-import restapi.SimpleRestApi;
-
-/**
- *
- * @author Kavoos
- */
-public abstract class BaseDao extends SimpleRestApi {
-
-    protected DaoResponseHandler daoResponseHandler = new DaoResponseHandler();
-
-    public BaseDao() {
-        super();
-
-    }
-
-    public BaseDao(RestContext context) {
-        super(context);
-    }
-
-    protected <T> T fromJson(String json, Class<T> classOf) {
-
-        return gson.fromJson(json, classOf);
-    }
-
-    protected String toJson(Object object) {
-        return gson.toJson(object);
-    }
-
-    protected CommandTO createCommand(int methodIndex) {
-        CommandTO commandTO = new CommandTO();
-        commandTO.setMethod(methodIndex);
-        return commandTO;
-    }
-
-    protected class DaoResponseHandler implements ResponseHandler {
-
-        protected boolean callResult;
-        protected int resultCode;
-        protected String callResponse;
-
-        @Override
-        public boolean checkResponse(int code, String response) {
-            this.resultCode = code;
-            callResult = false;
-            if (resultCode == 200) {
-                callResult = true;
-                callResponse = response;
-            }
-            return callResult;
-        }
-
-        public boolean isCallResult() {
-            return callResult;
-        }
-
-        public int getResultCode() {
-            return resultCode;
-        }
-
-        public CommandResultTO getResultTO() {
-            CommandResultTO resultTO;
-            resultTO = fromJson(callResponse, CommandResultTO.class);
-            return resultTO;
-        }
-    }
-
-    /**
-     * Post a command
-     * @param <T> 
-     * @param commandTO 
-     * @param object Object to be posted or null if no object
-     * @param classOf Type of the return value 
-     * @return Return a value of type T
-     * @throws IOException
-     */
-    protected <T> T postCommand(CommandTO commandTO, Object object, Class<T> classOf) throws IOException {
-        if (object != null) {
-            commandTO.setData(toJson(object));
-        }
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                T ato = fromJson(resultTO.getData(), classOf);
-                return ato;
-            }
-        }
-        throw new RuntimeException("Unable to execute command (methode : " + commandTO.getMethod() + ")");
-    }
-
-    /**
-     * Post a command
-     * @param commandTO
-     * @param object Object to be posted or null if no object
-     * @throws IOException
-     */
-    protected void postCommand(CommandTO commandTO, Object object) throws IOException {
-        if (object != null) {
-            commandTO.setData(toJson(object));
-        }
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                return;
-            }
-        }
-        throw new RuntimeException("Unable to execute command (methode : " + commandTO.getMethod() + ")");
-    }
-
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/ProfileDaoClient.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/ProfileDaoClient.java
deleted file mode 100644 (file)
index e137ba4..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.dao;
-
-import com.edf.gde.transferables.CommandTO;
-import com.edf.gde.transferables.ProfileAttributeTO;
-import com.edf.gde.transferables.ProfileTO;
-import java.io.IOException;
-import restapi.RestContext;
-
-/**
- *
- * @author mordicus
- */
-public class ProfileDaoClient extends BaseDao {
-
-    public static final String ServiceName = "AttributesService";
-    public static final int CREATEPROFILE = 1;
-    public static final int DELETEPROFILE = 2;
-    public static final int READPROFILE = 3;
-    public static final int UPDATEPROFILE = 4;
-    public static final int CREATEPROFILEATTRIBUTE = 5;
-    public static final int DELETEPROFILEATTRIBUTE = 6;
-    public static final int READPROFILEATTRIBUTE = 7;
-    public static final int UPDATEPROFILEATTRIBUTE = 8;
-
-    public ProfileDaoClient() {
-        getContext().setBaseResource("http://localhost:8080/GDE-war/ProfilesService");
-        getContext().setUserName("admin");
-        getContext().setPassword("edf123");
-    }
-
-    public ProfileDaoClient(RestContext context) {
-        super(context);
-    }
-
-    public ProfileTO createProfile(ProfileTO profileTO) throws IOException {
-        CommandTO commandTO = createCommand(CREATEPROFILE);
-        return postCommand(commandTO, profileTO, ProfileTO.class);
-    }
-
-    public void deleteProfile(long profileId) throws IOException {
-        CommandTO commandTO = createCommand(DELETEPROFILE);
-        commandTO.setLong("profileId", profileId);
-        postCommand(commandTO, null);
-    }
-
-    public ProfileTO readProfile(long profileId) throws IOException {
-        CommandTO commandTO = createCommand(READPROFILE);
-        commandTO.setLong("profileId", profileId);
-        return postCommand(commandTO, null, ProfileTO.class);
-    }
-
-    public ProfileTO updateProfile(ProfileTO profileTO) throws IOException {
-        CommandTO commandTO = createCommand(UPDATEPROFILE);
-        return postCommand(commandTO, profileTO, ProfileTO.class);
-    }
-
-    public ProfileAttributeTO createProfileAttribute(ProfileAttributeTO attributeTO) throws IOException {
-        CommandTO commandTO = createCommand(CREATEPROFILEATTRIBUTE);
-        return postCommand(commandTO, attributeTO, ProfileAttributeTO.class);
-    }
-
-    public void deleteProfileAttribute(long profileAttributeId) throws IOException {
-        CommandTO commandTO = createCommand(DELETEPROFILEATTRIBUTE);
-        commandTO.setLong("profileAttributeId", profileAttributeId);
-        postCommand(commandTO, null);
-    }
-
-    public ProfileAttributeTO readProfileAttribute(long profileAttributeId) throws IOException {
-        CommandTO commandTO = createCommand(READPROFILEATTRIBUTE);
-        commandTO.setLong("profileAttributeId", profileAttributeId);
-        return postCommand(commandTO, null, ProfileAttributeTO.class);
-    }
-
-    public ProfileAttributeTO updateProfileAttribute(ProfileAttributeTO attributeTO) throws IOException {
-        CommandTO commandTO = createCommand(UPDATEPROFILEATTRIBUTE);
-        return postCommand(commandTO, attributeTO, ProfileAttributeTO.class);
-    }
-
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/StudyDaoClient.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/StudyDaoClient.java
deleted file mode 100644 (file)
index 182de8b..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.dao;
-
-import com.edf.gde.transferables.CommandTO;
-import com.edf.gde.transferables.StudyTO;
-import com.edf.gde.transferables.responses.CommandResultTO;
-import java.io.IOException;
-import restapi.RestContext;
-
-/**
- *
- * @author Kavoos
- */
-public class StudyDaoClient extends BaseDao {
-
-    public static final String ServiceName = "StudyService";
-    public static final int CREATESTUDY = 1;
-    public static final int SETSTUDYSTATE = 2;
-    public static final int READSTUDY = 3;
-    public static final int DELETESTUDY = 4;
-
-    public StudyDaoClient() {
-        getContext().setBaseResource("http://localhost:8080/GDE-war/StudyService");
-        getContext().setUserName("admin");
-        getContext().setPassword("edf123");
-    }
-
-    public StudyDaoClient(RestContext context) {
-        super(context);
-    }
-
-    public StudyTO createStudy(StudyTO studyTO) throws IOException {
-        CommandTO commandTO = createCommand(CREATESTUDY);
-        commandTO.setData(toJson(studyTO));
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                StudyTO newStudyTO = fromJson(resultTO.getData(), StudyTO.class);
-                return newStudyTO;
-            }
-        }
-        throw new RuntimeException("Unable to create study");
-    }
-
-    public void setStudyState(long studyId, int state) throws IOException {
-        CommandTO commandTO = createCommand(SETSTUDYSTATE);
-        commandTO.setInt("lock", state);
-        commandTO.setLong("studyId", studyId);
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                return;
-            }
-        }
-        throw new RuntimeException("Unable to change study state");
-    }
-
-    public StudyTO readStudy(long studyId) throws IOException {
-        CommandTO commandTO = createCommand(READSTUDY);
-        commandTO.setLong("studyId", studyId);
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                StudyTO newStudyTO = fromJson(resultTO.getData(), StudyTO.class);
-                return newStudyTO;
-            }
-        }
-        throw new RuntimeException("Unable to read study");
-    }
-
-    public void deleteStudy(long studyId) throws IOException {
-        CommandTO commandTO = createCommand(DELETESTUDY);
-        commandTO.setLong("studyId", studyId);
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                return;
-            }
-        }
-        throw new RuntimeException("Unable to delete study");
-    }
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/UserDaoClient.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/UserDaoClient.java
deleted file mode 100644 (file)
index 14bcae0..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.dao;
-
-import com.edf.gde.transferables.CommandTO;
-import com.edf.gde.transferables.GroupTO;
-import com.edf.gde.transferables.UserTO;
-import com.edf.gde.transferables.responses.CommandResultTO;
-import restapi.RestContext;
-import java.io.IOException;
-
-/**
- *
- * @author Kavoos
- */
-public class UserDaoClient extends BaseDao {
-
-    public static final int CREATEUSER = 1;
-    public static final int DELETEUSER = 2;
-    public static final int ADDTOGROUP = 3;
-    public static final int REMOVEFROMGROUP = 4;
-    public static final int CREATEGROUP = 5;
-    public static final int DELETEGROUP = 6;
-    public static final int FINDUSER = 7;
-    public static final int FINDGROUP = 8;
-
-    public UserDaoClient() {
-        getContext().setBaseResource("http://localhost:8080/GDE-war/UserService");
-        getContext().setUserName("admin");
-        getContext().setPassword("edf123");
-    }
-
-    public UserDaoClient(RestContext context) {
-        super(context);
-    }
-
-    /**
-     *
-     * @param userName
-     * @param password
-     * @return
-     * @throws IOException
-     */
-    public UserTO createUser(String userName, String password) throws IOException {
-        CommandTO commandTO = createCommand(CREATEUSER);
-        UserTO userTO = new UserTO();
-        userTO.setName(userName);
-        userTO.setPassword(password);
-        commandTO.setData(toJson(userTO));
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                userTO = fromJson(resultTO.getData(), UserTO.class);
-                return userTO;
-            }
-        }
-        throw new RuntimeException("Unable to create user");
-    }
-
-    /**
-     *
-     * @param userId
-     * @return
-     * @throws IOException
-     */
-    public boolean deleteUser(long userId) throws IOException {
-        CommandTO commandTO = createCommand(DELETEUSER);
-        commandTO.setLong("id", userId);
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            if (daoResponseHandler.getResultTO().getCode() == CommandResultTO.OK) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     *
-     * @param userName
-     * @return null if user not found
-     * @throws IOException
-     */
-    public UserTO findUser(String userName) throws IOException {
-        CommandTO commandTO = createCommand(FINDUSER);
-        commandTO.setString("username", userName);
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                UserTO userTO = fromJson(resultTO.getData(), UserTO.class);
-                return userTO;
-            }
-        }
-        return null;
-    }
-
-    /**
-     *
-     * @param groupName
-     * @return
-     * @throws IOException
-     */
-    public GroupTO createGroup(String groupName) throws IOException {
-        CommandTO commandTO = createCommand(CREATEGROUP);
-        commandTO.setString("name", groupName);
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                GroupTO groupTO = fromJson(resultTO.getData(), GroupTO.class);
-                return groupTO;
-            }
-        }
-        return null;
-    }
-
-    /**
-     *
-     * @param groupName
-     * @return
-     * @throws IOException
-     */
-    public GroupTO findGroup(String groupName) throws IOException {
-        CommandTO commandTO = createCommand(FINDGROUP);
-        commandTO.setString("groupname", groupName);
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                GroupTO groupTO = fromJson(resultTO.getData(), GroupTO.class);
-                return groupTO;
-            }
-        }
-        return null;
-    }
-/**
- * 
- * @param id
- * @return
- * @throws IOException 
- */
-    public boolean deleteGroup(long id) throws IOException {
-        CommandTO commandTO = createCommand(DELETEGROUP);
-        commandTO.setLong("id", id);
-        if (postAsJSonData(commandTO, daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    public boolean addToGroup(long groupId, long userId) throws IOException {
-        CommandTO commandTO = createCommand(ADDTOGROUP);
-        commandTO.setLong("groupId", groupId);
-        commandTO.setLong("userId", userId);
-        if (postAsJSonData(commandTO,daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    public boolean removeFromGroup(long groupId, long userId) throws IOException {
-        CommandTO commandTO = createCommand(REMOVEFROMGROUP);
-        commandTO.setLong("groupId", groupId);
-        commandTO.setLong("userId", userId);
-        if (postAsJSonData(commandTO,daoResponseHandler)) {
-            CommandResultTO resultTO = daoResponseHandler.getResultTO();
-            if (resultTO.getCode() == CommandResultTO.OK) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/base/BaseTest.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/base/BaseTest.java
deleted file mode 100644 (file)
index 763d801..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.test.base;
-
-/**
- *
- * @author Kavoos
- */
-public class BaseTest {
-
-    public BaseTest() {
-    }
-    
-    protected void testName(String message) {
-        System.out.print(message);
-    }
-    
-    protected void passed() {
-        System.out.println(" -- [OK]");
-    }
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/AttributeDaoTest.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/AttributeDaoTest.java
deleted file mode 100644 (file)
index f2e163d..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.test.dao;
-
-import com.edf.gde.dao.AttributeDaoClient;
-import com.edf.gde.test.base.BaseTest;
-import com.edf.gde.transferables.AttributeGroupTO;
-import com.edf.gde.transferables.AttributeTO;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.After;
-import org.junit.AfterClass;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author mordicus
- */
-public class AttributeDaoTest extends BaseTest {
-
-    @BeforeClass
-    public static void setUpClass() {
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-
-    @Test
-    public void testCreateAttribute() throws Exception {
-        AttributeDaoClient daoClient = new AttributeDaoClient();
-        testName("createAttribute");
-        /* Create an instance of AttributeGroup*/
-        AttributeGroupTO attributeGroup = new AttributeGroupTO();
-        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
-        assertNotNull(resultAttributeGroup);
-        assertTrue(resultAttributeGroup.getId() > 0);
-        /* Create Attribute */
-        AttributeTO ato = new AttributeTO();
-        ato.setName("Attribute1");
-        ato.setType("integer");
-        ato.setValue("12");
-        ato.setGroupId(resultAttributeGroup.getId());
-        AttributeTO newAttribute = daoClient.createAttribute(ato);
-        assertNotNull(newAttribute);
-        assertEquals(ato.getName(), newAttribute.getName());
-        assertTrue(newAttribute.getId() != 0);
-        passed();
-    }
-
-    @Test
-    public void testDeleteAttribute() throws Exception {
-        AttributeDaoClient daoClient = new AttributeDaoClient();
-        testName("deleteAttribute");
-        /* Create an instance of AttributeGroup*/
-        AttributeGroupTO attributeGroup = new AttributeGroupTO();
-        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
-        assertNotNull(resultAttributeGroup);
-        assertTrue(resultAttributeGroup.getId() > 0);
-        /* Create Attribute */
-        AttributeTO ato = new AttributeTO();
-        ato.setName("Attribute2");
-        ato.setType("long");
-        ato.setValue("13");
-        ato.setGroupId(resultAttributeGroup.getId());
-        AttributeTO newAttribute = daoClient.createAttribute(ato);
-        assertNotNull(newAttribute);
-        assertEquals(ato.getName(), newAttribute.getName());
-        assertTrue(newAttribute.getId() != 0);
-        daoClient.deleteAttribute(newAttribute.getId());
-        passed();
-    }
-
-    @Test
-    public void createAttributeGroup() throws Exception {
-        AttributeDaoClient daoClient = new AttributeDaoClient();
-        testName("createAttributeGroup");
-        /* Create an instance of AttributeGroup*/
-        AttributeGroupTO attributeGroup = new AttributeGroupTO();
-        AttributeTO ato = new AttributeTO();
-        ato.setName("Test");
-        ato.setType("string");
-        ato.setValue("test");
-        ato.setMandatory(false);
-        List<AttributeTO> l = new ArrayList<>();
-        l.add(ato);
-        attributeGroup.setAttributeCollection(l);
-        
-        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
-        
-        assertNotNull(resultAttributeGroup);
-        assertTrue(resultAttributeGroup.getId() > 0);
-        passed();
-    }
-    
-    @Test
-    public void deleteAttributeGroup() throws Exception {
-        AttributeDaoClient daoClient = new AttributeDaoClient();
-        testName("deleteAttributeGroup");
-        /* Create an instance of AttributeGroup*/
-        AttributeGroupTO attributeGroup = new AttributeGroupTO();
-        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
-        assertNotNull(resultAttributeGroup);
-        assertTrue(resultAttributeGroup.getId() > 0);
-        /* Delete it */
-        daoClient.deleteAttributeGroup(resultAttributeGroup.getId());
-        passed();
-    }
-    
-    @Test
-    public void testReadAttributeGroup() throws Exception {
-        AttributeDaoClient daoClient = new AttributeDaoClient();
-        testName("readAttributeGroup");
-        /* Create an instance of AttributeGroup*/
-        AttributeGroupTO attributeGroup = new AttributeGroupTO();
-        AttributeGroupTO resultAttributeGroup = daoClient.createAttributeGroup(attributeGroup);
-        assertNotNull(resultAttributeGroup);
-        assertTrue(resultAttributeGroup.getId() > 0);
-        /* Read it */
-        AttributeGroupTO newAttributeGroupTO = daoClient.readAttributeGroup(resultAttributeGroup.getId());
-        assertNotNull(newAttributeGroupTO);
-        assertTrue(newAttributeGroupTO.getId()>0);
-        passed();
-    }
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/ProfileDaoTest.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/ProfileDaoTest.java
deleted file mode 100644 (file)
index 0ae96bc..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.test.dao;
-
-import com.edf.gde.dao.ProfileDaoClient;
-import com.edf.gde.test.base.BaseTest;
-import com.edf.gde.transferables.ProfileAttributeTO;
-import com.edf.gde.transferables.ProfileTO;
-import java.util.ArrayList;
-import java.util.List;
-import junit.framework.Assert;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author mordicus
- */
-public class ProfileDaoTest extends BaseTest {
-
-    @BeforeClass
-    public static void setUpClass() {
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-
-    @Test
-    public void testCreateProfile() throws Exception {
-        testName("createProfile");
-        ProfileDaoClient daoClient = new ProfileDaoClient();
-        ProfileTO profileTO = new ProfileTO();
-        Assert.assertEquals(0, profileTO.getId());
-        profileTO.setName("ProfileTest1");
-        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
-        Assert.assertNotNull(newProfileTO);
-        Assert.assertTrue(newProfileTO.getId() != 0);
-        Assert.assertEquals("ProfileTest1", newProfileTO.getName());
-        passed();
-    }
-
-    @Test
-    public void testDeleteProfile() throws Exception {
-        testName("deleteProfile");
-        ProfileDaoClient daoClient = new ProfileDaoClient();
-        ProfileTO profileTO = new ProfileTO();
-        Assert.assertEquals(0, profileTO.getId());
-        profileTO.setName("ProfileTest2");
-        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
-        Assert.assertNotNull(newProfileTO);
-        Assert.assertTrue(newProfileTO.getId() != 0);
-        Assert.assertEquals("ProfileTest2", newProfileTO.getName());
-        daoClient.deleteProfile(newProfileTO.getId());
-        passed();
-    }
-
-    @Test
-    public void testReadProfile() throws Exception {
-        testName("readProfile");
-        ProfileDaoClient daoClient = new ProfileDaoClient();
-        ProfileTO profileTO = new ProfileTO();
-        Assert.assertEquals(0, profileTO.getId());
-        profileTO.setName("ProfileTest3");
-        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
-        Assert.assertNotNull(newProfileTO);
-        Assert.assertTrue(newProfileTO.getId() != 0);
-        Assert.assertEquals("ProfileTest3", newProfileTO.getName());
-        ProfileTO testProfileTO = daoClient.readProfile(newProfileTO.getId());
-        Assert.assertNotNull(testProfileTO);
-        Assert.assertEquals(newProfileTO.getId(), testProfileTO.getId());
-        Assert.assertEquals(newProfileTO.getName(), testProfileTO.getName());
-        passed();
-    }
-
-    @Test
-    public void testUpdateProfile() throws Exception {
-        testName("updateProfile");
-        ProfileDaoClient daoClient = new ProfileDaoClient();
-        ProfileTO profileTO = new ProfileTO();
-        Assert.assertEquals(0, profileTO.getId());
-        profileTO.setName("ProfileTest4");
-        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
-        Assert.assertNotNull(newProfileTO);
-        Assert.assertTrue(newProfileTO.getId() != 0);
-        Assert.assertEquals("ProfileTest4", newProfileTO.getName());
-        /* update */
-        newProfileTO.setName("ProfileTest4 - 1");
-        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
-        attributeTO.setMandatory(true);
-        attributeTO.setName("attribute1");
-        attributeTO.setProfileId(newProfileTO.getId());
-        attributeTO.setType("string");
-        List<ProfileAttributeTO> attributeTOs = new ArrayList<>();
-        attributeTOs.add(attributeTO);
-        newProfileTO.setAttributes(attributeTOs);
-        ProfileTO testProfileTO = daoClient.updateProfile(newProfileTO);
-        Assert.assertNotNull(testProfileTO);
-        // Read
-        testProfileTO = daoClient.readProfile(testProfileTO.getId());
-        Assert.assertEquals("ProfileTest4 - 1", testProfileTO.getName());
-        passed();
-    }
-
-    @Test
-    public void testCreateProfileAttribute() throws Exception {
-        testName("createProfileAttribute");
-        ProfileDaoClient daoClient = new ProfileDaoClient();
-        /* Create a new profile **/
-        ProfileTO profileTO = new ProfileTO();
-        Assert.assertEquals(0, profileTO.getId());
-        profileTO.setName("ProfileTest5");
-        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
-        Assert.assertNotNull(newProfileTO);
-        Assert.assertTrue(newProfileTO.getId() != 0);
-        Assert.assertEquals("ProfileTest5", newProfileTO.getName());
-        /* Create a new ProfileAttribute */
-        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
-        attributeTO.setMandatory(true);
-        attributeTO.setName("Attribute for test 5");
-        attributeTO.setType("string");
-        attributeTO.setProfileId(newProfileTO.getId());
-        ProfileAttributeTO newAttributeTO = daoClient.createProfileAttribute(attributeTO);
-        Assert.assertNotNull(newAttributeTO);
-        Assert.assertTrue(newAttributeTO.getId() != 0);
-        Assert.assertEquals(newProfileTO.getId(), newAttributeTO.getProfileId());
-        passed();
-    }
-
-    @Test
-    public void testDeleteProfileAttribute() throws Exception {
-        testName("deleteProfileattribute");
-        ProfileDaoClient daoClient = new ProfileDaoClient();
-        /* Create a new profile **/
-        ProfileTO profileTO = new ProfileTO();
-        Assert.assertEquals(0, profileTO.getId());
-        profileTO.setName("ProfileTest6");
-        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
-        Assert.assertNotNull(newProfileTO);
-        Assert.assertTrue(newProfileTO.getId() != 0);
-        Assert.assertEquals("ProfileTest6", newProfileTO.getName());
-
-        /* Create a new ProfileAttribute */
-        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
-        attributeTO.setMandatory(true);
-        attributeTO.setName("Attribute for test 6");
-        attributeTO.setType("string");
-        attributeTO.setProfileId(newProfileTO.getId());
-        ProfileAttributeTO newAttributeTO = daoClient.createProfileAttribute(attributeTO);
-        Assert.assertNotNull(newAttributeTO);
-        Assert.assertTrue(newAttributeTO.getId() != 0);
-        daoClient.deleteProfileAttribute(newAttributeTO.getId());
-        passed();
-    }
-
-    @Test
-    public void testReadProfileAttribute() throws Exception {
-        testName("readProfileAttribute");
-        ProfileDaoClient daoClient = new ProfileDaoClient();
-        /* Create a new profile **/
-        ProfileTO profileTO = new ProfileTO();
-        Assert.assertEquals(0, profileTO.getId());
-        profileTO.setName("ProfileTest7");
-        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
-        Assert.assertNotNull(newProfileTO);
-        Assert.assertTrue(newProfileTO.getId() != 0);
-        Assert.assertEquals("ProfileTest7", newProfileTO.getName());
-        /* Create a new ProfileAttribute */
-        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
-        attributeTO.setMandatory(true);
-        attributeTO.setName("Attribute for test 7");
-        attributeTO.setType("string");
-        attributeTO.setProfileId(newProfileTO.getId());
-        ProfileAttributeTO newAttributeTO = daoClient.createProfileAttribute(attributeTO);
-        Assert.assertNotNull(newAttributeTO);
-        Assert.assertTrue(newAttributeTO.getId() != 0);
-        Assert.assertEquals(newProfileTO.getId(), newAttributeTO.getProfileId());
-        /* Read */
-        ProfileAttributeTO testAttributeTO = daoClient.readProfileAttribute(newAttributeTO.getId());
-        Assert.assertNotNull(testAttributeTO);
-        Assert.assertEquals(newAttributeTO.getId(), testAttributeTO.getId());
-        Assert.assertEquals(newAttributeTO.getName(), testAttributeTO.getName());
-        passed();
-    }
-    
-    @Test
-    public void testUpdateProfileAttribute() throws Exception {
-        testName("updateProfileAttribute");
-        ProfileDaoClient daoClient = new ProfileDaoClient();
-        /* Create a new profile **/
-        ProfileTO profileTO = new ProfileTO();
-        Assert.assertEquals(0, profileTO.getId());
-        profileTO.setName("ProfileTest8");
-        ProfileTO newProfileTO = daoClient.createProfile(profileTO);
-        Assert.assertNotNull(newProfileTO);
-        Assert.assertTrue(newProfileTO.getId() != 0);
-        Assert.assertEquals("ProfileTest8", newProfileTO.getName());
-        /* Create a new ProfileAttribute */
-        ProfileAttributeTO attributeTO = new ProfileAttributeTO();
-        attributeTO.setMandatory(true);
-        attributeTO.setName("Attribute for test 8");
-        attributeTO.setType("string");
-        attributeTO.setProfileId(newProfileTO.getId());
-        ProfileAttributeTO newAttributeTO = daoClient.createProfileAttribute(attributeTO);
-        Assert.assertNotNull(newAttributeTO);
-        Assert.assertTrue(newAttributeTO.getId() != 0);
-        Assert.assertEquals(newProfileTO.getId(), newAttributeTO.getProfileId());
-        /* Update */ 
-        newAttributeTO.setName("Attribute for test 8 update");
-        newAttributeTO = daoClient.updateProfileAttribute(newAttributeTO);
-        /* Read */
-        ProfileAttributeTO testAttributeTO = daoClient.readProfileAttribute(newAttributeTO.getId());
-        Assert.assertNotNull(testAttributeTO);
-        Assert.assertEquals(newAttributeTO.getId(), testAttributeTO.getId());
-        Assert.assertEquals(newAttributeTO.getName(), testAttributeTO.getName());
-        passed();
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/StudyDaoTest.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/StudyDaoTest.java
deleted file mode 100644 (file)
index 871d3d7..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.test.dao;
-
-import com.edf.gde.dao.StudyDaoClient;
-import com.edf.gde.test.base.BaseTest;
-import com.edf.gde.transferables.StudyTO;
-import java.util.Date;
-import org.junit.After;
-import org.junit.AfterClass;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author Kavoos
- */
-public class StudyDaoTest extends BaseTest {
-
-    @BeforeClass
-    public static void setUpClass() {
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-
-    @Test
-    public void testCreateStudy() throws Exception {
-        testName("createStudy");
-        StudyDaoClient daoClient = new StudyDaoClient();
-        StudyTO studyTO = createStudyTO("my study");
-        StudyTO newStudyTO = daoClient.createStudy(studyTO);
-        assertNotNull(newStudyTO);
-        assertEquals(studyTO.getName(), newStudyTO.getName());
-        passed();
-    }
-
-    @Test
-    public void testSetStudyState() throws Exception {
-        testName("setStudyState");
-        /* Create new study */
-        StudyDaoClient daoClient = new StudyDaoClient();
-        StudyTO studyTO = createStudyTO("state study");
-        StudyTO newStudyTO = daoClient.createStudy(studyTO);
-        /* Change state of the study */
-        daoClient.setStudyState(newStudyTO.getId(), 1);
-        passed();
-    }
-    
-    @Test
-    public void testReadStudy() throws Exception {
-        testName("readStudy");
-        /* Create new study */
-        StudyDaoClient daoClient = new StudyDaoClient();
-        StudyTO studyTO = createStudyTO("read study");
-        StudyTO newStudyTO = daoClient.createStudy(studyTO);
-        /* Read the new study from server */
-        StudyTO remoteStudyTO = daoClient.readStudy(newStudyTO.getId());
-        assertEquals("read study", remoteStudyTO.getName());
-        assertNotNull(remoteStudyTO.getCreationDate());
-        assertTrue(remoteStudyTO.getCreationDate().before(new Date()));
-        passed();
-    }
-    
-    @Test
-    public void testDeleteStudy() throws Exception {
-        testName("deleteStudy");
-        /* Create new study */
-        StudyDaoClient daoClient = new StudyDaoClient();
-        StudyTO studyTO = createStudyTO("read study");
-        StudyTO newStudyTO = daoClient.createStudy(studyTO);
-        /* delete the new study from server */
-        daoClient.deleteStudy(newStudyTO.getId());
-        passed();
-    }
-    
-    private StudyTO createStudyTO(String name) {
-        StudyTO studyTO = new StudyTO();
-        studyTO.setName(name);
-        studyTO.setCreationDate(new Date(System.currentTimeMillis()));
-        studyTO.setValid(false);
-        return studyTO;
-    }
-}
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/UserDaoTest.java b/projects/GDE_App/GDE-war/test/com/edf/gde/test/dao/UserDaoTest.java
deleted file mode 100644 (file)
index ff32d94..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * (C) 2015 EDF
- */
-package com.edf.gde.test.dao;
-
-import com.edf.gde.dao.UserDaoClient;
-import com.edf.gde.test.base.BaseTest;
-import com.edf.gde.transferables.GroupTO;
-import com.edf.gde.transferables.UserTO;
-import java.io.IOException;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author mordicus
- */
-public class UserDaoTest extends BaseTest {
-
-    public UserDaoTest() {
-    }
-
-    @BeforeClass
-    public static void setUpClass() {
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-
-    private long createUser(String userName, String password) throws IOException {
-        UserDaoClient instance = new UserDaoClient();
-        long result = instance.createUser(userName, password).getId();
-        return result;
-    }
-
-    private boolean deleteUser(long id) throws IOException {
-        UserDaoClient instance = new UserDaoClient();
-        boolean result = instance.deleteUser(id);
-        return result;
-    }
-
-    private UserTO findUser(String userName) throws IOException {
-        UserDaoClient instance = new UserDaoClient();
-        UserTO userTO = instance.findUser(userName);
-        return userTO;
-    }
-
-    private GroupTO createGroup(String groupName) throws IOException {
-        UserDaoClient daoClient = new UserDaoClient();
-        GroupTO result = daoClient.createGroup(groupName);
-        return result;
-    }
-
-    private GroupTO findGroup(String groupName) throws IOException {
-        UserDaoClient daoClient = new UserDaoClient();
-        GroupTO groupTO = daoClient.findGroup(groupName);
-        return groupTO;
-    }
-
-    private boolean deleteGroup(long groupID) throws IOException {
-        UserDaoClient daoClient = new UserDaoClient();
-        boolean result = daoClient.deleteGroup(groupID);
-        return result;
-    }
-
-    private boolean addToGroup(long groupId, long userId) throws IOException {
-        UserDaoClient daoClient = new UserDaoClient();
-        boolean result = daoClient.addToGroup(groupId, userId);
-        return result;
-    }
-
-    private boolean removeFromGroup(long groupId, long userId) throws IOException {
-        UserDaoClient daoClient = new UserDaoClient();
-        boolean result = daoClient.removeFromGroup(groupId, userId);
-        return result;
-    }
-
-    /**
-     * Test of createUser method, of class UserDao.
-     */
-    @Test
-    public void testCreateUser() throws Exception {
-        testName("createUser");
-        String userName = "Kavoos";
-        String password = "edf123";
-        long userId = createUser(userName, password);
-        assertTrue((userId != -1) && (userId > 0));
-        assertTrue(deleteUser(userId));
-        passed();
-    }
-
-    /**
-     * Test of deleteUser method, of class UserDao.
-     */
-    @Test
-    public void testDeleteUser() throws Exception {
-        testName("deleteUser");
-        long userId = createUser("Kavoos", "edf123");
-        assertTrue(userId > 0);
-        boolean expResult = true;
-        boolean result = deleteUser(userId);
-        assertEquals(expResult, result);
-        passed();
-    }
-
-    @Test
-    public void testFindUser() throws Exception {
-        testName("findUser");
-        long userId = createUser("Kavoos", "edf123");
-        assertTrue(userId > 0);
-        UserTO userTO = findUser("Kavoos");
-        assertNotNull(userTO);
-        assertTrue(userTO.getId() == userId);
-        assertEquals("Kavoos", userTO.getName());
-        assertTrue(deleteUser(userId));
-        passed();
-    }
-
-    @Test
-    public void testCreateGroup() throws Exception {
-        testName("createGroup");
-        GroupTO groupTO = createGroup("Admin");
-        assertNotNull(groupTO);
-        assertEquals("Admin", groupTO.getName());
-        assertTrue(deleteGroup(groupTO.getId()));
-        passed();
-    }
-
-    @Test
-    public void testFindGroup() throws Exception {
-        testName("findGroup");
-        GroupTO groupTO = createGroup("Admin");
-        assertNotNull(groupTO);
-        assertEquals("Admin", groupTO.getName());
-        groupTO = findGroup("Admin");
-        assertNotNull(groupTO);
-        assertEquals("Admin", groupTO.getName());
-        assertTrue(deleteGroup(groupTO.getId()));
-        passed();
-    }
-
-    @Test
-    public void testDeleteGroup() throws Exception {
-        testName("deleteGroup");
-        GroupTO groupTO = createGroup("Admin");
-        assertNotNull(groupTO);
-        assertEquals("Admin", groupTO.getName());
-        assertTrue(deleteGroup(groupTO.getId()));
-        passed();
-    }
-
-    @Test
-    public void testAddToGroup() throws Exception {
-        testName("addToGroup");
-        /* create a group */
-        GroupTO groupTO = createGroup("Admin");
-        assertNotNull(groupTO);
-        assertTrue(groupTO.getId() > 0);
-        assertEquals("Admin", groupTO.getName());
-        /* Create a user */
-        long userId = createUser("Kavoos", "edf123");
-        assertTrue(userId > 0);
-        /* add the user to the group */
-        boolean result = addToGroup(groupTO.getId(), userId);
-        assertTrue(result);
-        assertTrue(deleteGroup(groupTO.getId()));
-        assertTrue(deleteUser(userId));
-        passed();
-    }
-
-    @Test
-    public void testRemoveFromGroup() throws Exception {
-        testName("removeFromGroup");
-        /* create a group */
-        GroupTO groupTO = createGroup("Admin");
-        assertNotNull(groupTO);
-        assertTrue(groupTO.getId() > 0);
-        assertEquals("Admin", groupTO.getName());
-        /* Create a user */
-        long userId = createUser("Kavoos", "edf123");
-        assertTrue(userId > 0);
-        /* add the user to the group */
-        boolean result = addToGroup(groupTO.getId(), userId);
-        assertTrue(result);
-        /* Remove the user from the group */
-        result = removeFromGroup(groupTO.getId(), userId);
-        assertTrue(result);
-        assertTrue(deleteGroup(groupTO.getId()));
-        assertTrue(deleteUser(userId));
-        passed();
-    }
-
-}
diff --git a/projects/GDE_App/GDE-war/test/restapi/Base64.java b/projects/GDE_App/GDE-war/test/restapi/Base64.java
deleted file mode 100644 (file)
index 7f765b5..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
-// www.source-code.biz, www.inventec.ch/chdh
-//
-// This module is multi-licensed and may be used under the terms
-// of any of the following licenses:
-//
-//  EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal
-//  LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html
-//  GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html
-//  AGPL, GNU Affero General Public License V3 or later, http://www.gnu.org/licenses/agpl.html
-//  AL, Apache License, V2.0 or later, http://www.apache.org/licenses
-//  BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
-//  MIT, MIT License, http://www.opensource.org/licenses/MIT
-//
-// Please contact the author if you need another license.
-// This module is provided "as is", without warranties of any kind.
-//
-// Project home page: www.source-code.biz/base64coder/java
-
-package restapi;
-
-/**
-* A Base64 encoder/decoder.
-*
-* <p>
-* This class is used to encode and decode data in Base64 format as described in RFC 1521.
-*
-* @author
-*    Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland, www.source-code.biz
-*/
-public class Base64 {
-
-// The line separator string of the operating system.
-private static final String systemLineSeparator = System.getProperty("line.separator");
-
-// Mapping table from 6-bit nibbles to Base64 characters.
-private static final char[] map1 = new char[64];
-   static {
-      int i=0;
-      for (char c='A'; c<='Z'; c++) map1[i++] = c;
-      for (char c='a'; c<='z'; c++) map1[i++] = c;
-      for (char c='0'; c<='9'; c++) map1[i++] = c;
-      map1[i++] = '+'; map1[i++] = '/'; }
-
-// Mapping table from Base64 characters to 6-bit nibbles.
-private static final byte[] map2 = new byte[128];
-   static {
-      for (int i=0; i<map2.length; i++) map2[i] = -1;
-      for (int i=0; i<64; i++) map2[map1[i]] = (byte)i; }
-
-/**
-* Encodes a string into Base64 format.
-* No blanks or line breaks are inserted.
-* @param s  A String to be encoded.
-* @return   A String containing the Base64 encoded data.
-*/
-public static String encodeString (String s) {
-   return new String(encode(s.getBytes())); }
-
-/**
-* Encodes a byte array into Base 64 format and breaks the output into lines of 76 characters.
-* This method is compatible with <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
-* @param in  An array containing the data bytes to be encoded.
-* @return    A String containing the Base64 encoded data, broken into lines.
-*/
-public static String encodeLines (byte[] in) {
-   return encodeLines(in, 0, in.length, 76, systemLineSeparator); }
-
-/**
-* Encodes a byte array into Base 64 format and breaks the output into lines.
-* @param in            An array containing the data bytes to be encoded.
-* @param iOff          Offset of the first byte in <code>in</code> to be processed.
-* @param iLen          Number of bytes to be processed in <code>in</code>, starting at <code>iOff</code>.
-* @param lineLen       Line length for the output data. Should be a multiple of 4.
-* @param lineSeparator The line separator to be used to separate the output lines.
-* @return              A String containing the Base64 encoded data, broken into lines.
-*/
-public static String encodeLines (byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) {
-   int blockLen = (lineLen*3) / 4;
-   if (blockLen <= 0) throw new IllegalArgumentException();
-   int lines = (iLen+blockLen-1) / blockLen;
-   int bufLen = ((iLen+2)/3)*4 + lines*lineSeparator.length();
-   StringBuilder buf = new StringBuilder(bufLen);
-   int ip = 0;
-   while (ip < iLen) {
-      int l = Math.min(iLen-ip, blockLen);
-      buf.append(encode(in, iOff+ip, l));
-      buf.append(lineSeparator);
-      ip += l; }
-   return buf.toString(); }
-
-/**
-* Encodes a byte array into Base64 format.
-* No blanks or line breaks are inserted in the output.
-* @param in  An array containing the data bytes to be encoded.
-* @return    A character array containing the Base64 encoded data.
-*/
-public static char[] encode (byte[] in) {
-   return encode(in, 0, in.length); }
-
-/**
-* Encodes a byte array into Base64 format.
-* No blanks or line breaks are inserted in the output.
-* @param in    An array containing the data bytes to be encoded.
-* @param iLen  Number of bytes to process in <code>in</code>.
-* @return      A character array containing the Base64 encoded data.
-*/
-public static char[] encode (byte[] in, int iLen) {
-   return encode(in, 0, iLen); }
-
-/**
-* Encodes a byte array into Base64 format.
-* No blanks or line breaks are inserted in the output.
-* @param in    An array containing the data bytes to be encoded.
-* @param iOff  Offset of the first byte in <code>in</code> to be processed.
-* @param iLen  Number of bytes to process in <code>in</code>, starting at <code>iOff</code>.
-* @return      A character array containing the Base64 encoded data.
-*/
-public static char[] encode (byte[] in, int iOff, int iLen) {
-   int oDataLen = (iLen*4+2)/3;       // output length without padding
-   int oLen = ((iLen+2)/3)*4;         // output length including padding
-   char[] out = new char[oLen];
-   int ip = iOff;
-   int iEnd = iOff + iLen;
-   int op = 0;
-   while (ip < iEnd) {
-      int i0 = in[ip++] & 0xff;
-      int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
-      int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
-      int o0 = i0 >>> 2;
-      int o1 = ((i0 &   3) << 4) | (i1 >>> 4);
-      int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
-      int o3 = i2 & 0x3F;
-      out[op++] = map1[o0];
-      out[op++] = map1[o1];
-      out[op] = op < oDataLen ? map1[o2] : '='; op++;
-      out[op] = op < oDataLen ? map1[o3] : '='; op++; }
-   return out; }
-
-/**
-* Decodes a string from Base64 format.
-* No blanks or line breaks are allowed within the Base64 encoded input data.
-* @param s  A Base64 String to be decoded.
-* @return   A String containing the decoded data.
-* @throws   IllegalArgumentException If the input is not valid Base64 encoded data.
-*/
-public static String decodeString (String s) {
-   return new String(decode(s)); }
-
-/**
-* Decodes a byte array from Base64 format and ignores line separators, tabs and blanks.
-* CR, LF, Tab and Space characters are ignored in the input data.
-* This method is compatible with <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
-* @param s  A Base64 String to be decoded.
-* @return   An array containing the decoded data bytes.
-* @throws   IllegalArgumentException If the input is not valid Base64 encoded data.
-*/
-public static byte[] decodeLines (String s) {
-   char[] buf = new char[s.length()];
-   int p = 0;
-   for (int ip = 0; ip < s.length(); ip++) {
-      char c = s.charAt(ip);
-      if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
-         buf[p++] = c; }
-   return decode(buf, 0, p); }
-
-/**
-* Decodes a byte array from Base64 format.
-* No blanks or line breaks are allowed within the Base64 encoded input data.
-* @param s  A Base64 String to be decoded.
-* @return   An array containing the decoded data bytes.
-* @throws   IllegalArgumentException If the input is not valid Base64 encoded data.
-*/
-public static byte[] decode (String s) {
-   return decode(s.toCharArray()); }
-
-/**
-* Decodes a byte array from Base64 format.
-* No blanks or line breaks are allowed within the Base64 encoded input data.
-* @param in  A character array containing the Base64 encoded data.
-* @return    An array containing the decoded data bytes.
-* @throws    IllegalArgumentException If the input is not valid Base64 encoded data.
-*/
-public static byte[] decode (char[] in) {
-   return decode(in, 0, in.length); }
-
-/**
-* Decodes a byte array from Base64 format.
-* No blanks or line breaks are allowed within the Base64 encoded input data.
-* @param in    A character array containing the Base64 encoded data.
-* @param iOff  Offset of the first character in <code>in</code> to be processed.
-* @param iLen  Number of characters to process in <code>in</code>, starting at <code>iOff</code>.
-* @return      An array containing the decoded data bytes.
-* @throws      IllegalArgumentException If the input is not valid Base64 encoded data.
-*/
-public static byte[] decode (char[] in, int iOff, int iLen) {
-   if (iLen%4 != 0) throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4.");
-   while (iLen > 0 && in[iOff+iLen-1] == '=') iLen--;
-   int oLen = (iLen*3) / 4;
-   byte[] out = new byte[oLen];
-   int ip = iOff;
-   int iEnd = iOff + iLen;
-   int op = 0;
-   while (ip < iEnd) {
-      int i0 = in[ip++];
-      int i1 = in[ip++];
-      int i2 = ip < iEnd ? in[ip++] : 'A';
-      int i3 = ip < iEnd ? in[ip++] : 'A';
-      if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
-         throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
-      int b0 = map2[i0];
-      int b1 = map2[i1];
-      int b2 = map2[i2];
-      int b3 = map2[i3];
-      if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
-         throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
-      int o0 = ( b0       <<2) | (b1>>>4);
-      int o1 = ((b1 & 0xf)<<4) | (b2>>>2);
-      int o2 = ((b2 &   3)<<6) |  b3;
-      out[op++] = (byte)o0;
-      if (op<oLen) out[op++] = (byte)o1;
-      if (op<oLen) out[op++] = (byte)o2; }
-   return out; }
-
-// Dummy constructor.
-private Base64() {}
-
-} // end class Base64
\ No newline at end of file
diff --git a/projects/GDE_App/GDE-war/test/restapi/DefaultResponseHandler.java b/projects/GDE_App/GDE-war/test/restapi/DefaultResponseHandler.java
deleted file mode 100644 (file)
index d6358c3..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package restapi;
-
-/**
- *
- * @author mordicus
- */
-public class DefaultResponseHandler implements ResponseHandler {
-
-    @Override
-    public boolean checkResponse(int code, String response) {
-        if (code == 200) {
-            return true;
-        }
-        return false;
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-war/test/restapi/ResponseHandler.java b/projects/GDE_App/GDE-war/test/restapi/ResponseHandler.java
deleted file mode 100644 (file)
index bd5afa0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package restapi;
-
-/**
- *
- * @author mordicus
- */
-public interface ResponseHandler {
-
-    boolean checkResponse(int code, String response);
-
-}
diff --git a/projects/GDE_App/GDE-war/test/restapi/RestContext.java b/projects/GDE_App/GDE-war/test/restapi/RestContext.java
deleted file mode 100644 (file)
index 97ab7bd..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-package restapi;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import restapi.providers.CertificateProvider;
-
-/**
- *
- * @author mordicus
- */
-public class RestContext {
-
-    private String baseResource;
-    private String userName;
-    private String password;
-    private Map<String, String> parametters;
-    private CertificateProvider certificateProvider;
-    
-    public RestContext() {
-        parametters = new HashMap<String, String>();
-    }
-
-    public RestContext(String resource) {
-        this.baseResource = resource;
-        parametters = new HashMap<String, String>();
-    }
-
-    public RestContext(String resource, String trustStorePath) {
-        this.baseResource = resource;
-        parametters = new HashMap<String, String>();
-    }
-
-    public RestContext(String resource, String userName, String password) {
-        this.baseResource = resource;
-        this.userName = userName;
-        this.password = password;
-        parametters = new HashMap<String, String>();
-    }
-
-    public CertificateProvider getCertificateProvider() {
-        return certificateProvider;
-    }
-
-    public void setCertificateProvider(CertificateProvider certificateProvider) {
-        this.certificateProvider = certificateProvider;
-    }
-
-    public void clear() {
-        this.parametters.clear();
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setParametter(String name, String value) {
-        this.parametters.put(name, value);
-    }
-
-    public String getResource() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(baseResource);
-        if (parametters.size() > 0) {
-            Set<String> keys = parametters.keySet();
-            String[] k = keys.toArray(new String[0]);
-
-            sb.append("?");
-            try {
-                sb.append(k[0]).append("=").append(URLEncoder.encode(parametters.get(k[0]), "utf-8"));
-            } catch (UnsupportedEncodingException ex) {
-                Logger.getLogger(RestContext.class.getName()).log(Level.SEVERE, null, ex);
-            }
-            for (int i = 1; i < k.length; i++) {
-                try {
-                    sb.append("&").append(k[i]).append("=").append(URLEncoder.encode(parametters.get(k[i]), "utf-8"));
-                } catch (UnsupportedEncodingException ex) {
-                    Logger.getLogger(RestContext.class.getName()).log(Level.SEVERE, null, ex);
-                }
-
-            }
-
-        }
-        String ret = sb.toString();
-        return ret;
-    }
-
-    public String getBaseResource() {
-        return baseResource;
-    }
-
-    public String getUserName() {
-        return userName;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public void setBaseResource(String resource) {
-        this.baseResource = resource;
-    }
-
-    public void setUserName(String userName) {
-        this.userName = userName;
-    }
-}
diff --git a/projects/GDE_App/GDE-war/test/restapi/SimpleRestApi.java b/projects/GDE_App/GDE-war/test/restapi/SimpleRestApi.java
deleted file mode 100644 (file)
index 53a6859..0000000
+++ /dev/null
@@ -1,591 +0,0 @@
-package restapi;
-
-import com.google.gson.Gson;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.lang.reflect.Type;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManagerFactory;
-import restapi.providers.CertificateProvider;
-
-/**
- *
- * @author Kavoos Bojnourdi
- */
-public class SimpleRestApi {
-
-    /**
-     * RestContext
-     */
-    protected RestContext restContext;
-
-    private KeyStore keyStore;
-    private TrustManagerFactory tmf;
-    private SSLContext context;
-    private boolean verifyHostName;
-    private HttpURLConnection connection;
-    protected Gson gson;
-    
-    public SimpleRestApi() {
-        restContext = new RestContext();
-        gson = new Gson();
-    }
-
-    public SimpleRestApi(RestContext context) {
-        this.restContext = context;
-        gson = new Gson();
-    }
-
-    public boolean isVerifyHostName() {
-        return verifyHostName;
-    }
-
-    public void setVerifyHostName(boolean verifyHostName) {
-        this.verifyHostName = verifyHostName;
-    }
-
-    protected void setContext(RestContext context) {
-        this.restContext = context;
-        if (context.getBaseResource() != null) {
-            initResource();
-        }
-    }
-
-    private void initResource() {
-
-    }
-
-    public RestContext getContext() {
-        return restContext;
-    }
-
-    protected void setResource(String resource) {
-        restContext.setBaseResource(resource);
-        initResource();
-    }
-
-    protected void setResource(String base, String resource) {
-        restContext.setBaseResource(base + resource);
-        initResource();
-    }
-
-    public void closeConnection() {
-        if (connection != null) {
-            connection.disconnect();
-        }
-    }
-
-    public void setCertificateProvider(CertificateProvider certificateProvider) {
-        restContext.setCertificateProvider(certificateProvider);
-    }
-    
-    /**
-     *
-     * @param connection
-     */
-    protected void initAuthentication(HttpURLConnection connection) {
-        if (restContext.getUserName() == null) {
-            return;
-        }
-        String userCredentials = restContext.getUserName() + ":" + restContext.getPassword();
-        String basicAuth = "Basic " + new String(Base64.encode(userCredentials.getBytes()));
-        connection.setRequestProperty("Authorization", basicAuth);
-        connection.setRequestProperty("User-Agent", "Deuterium/1.0");
-    }
-
-    /**
-     *
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected boolean remove(ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-
-        try {
-            connection.setDoInput(true);
-            connection.setDoOutput(false);
-            initAuthentication(connection);
-
-            connection.setRequestMethod("DELETE");
-
-            // Open and do query
-            int responseCode = connection.getResponseCode();
-            String resultString = readStringResponse(connection);
-
-            if (rh == null) {
-                rh = new DefaultResponseHandler();
-            }
-            return rh.checkResponse(responseCode, resultString);
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @param data
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected boolean putAsJSonData(Object data, ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        try {
-            connection.setRequestMethod("PUT");
-            return writeJsonData(data, connection, rh);
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @param data
-     * @return
-     * @throws IOException
-     */
-    protected boolean putAsJSonData(Object data) throws IOException {
-        return putAsJSonData(data, null);
-    }
-
-    /**
-     *
-     * @param data
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected boolean postAsJSonData(Object data, ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        try {
-            connection.setRequestMethod("POST");
-            return writeJsonData(data, connection, rh);
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @param data
-     * @return
-     * @throws IOException
-     */
-    protected boolean postAsJSonData(Object data) throws IOException {
-        return postAsJSonData(data, null);
-    }
-
-    /**
-     *
-     * @param data
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected boolean postAsBinaryData(byte[] data, ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        try {
-            connection.setRequestMethod("POST");
-            return sendBinaryData(connection, data, rh);
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @param data
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected boolean putAsBinaryData(byte[] data, ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        try {
-            connection.setRequestMethod("PUT");
-            return sendBinaryData(connection, data, rh);
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @param data
-     * @return
-     * @throws IOException
-     */
-    protected boolean putAsBinaryData(byte[] data) throws IOException {
-        return putAsBinaryData(data, null);
-    }
-
-    /**
-     *
-     * @param in
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected boolean postAsBinaryStream(InputStream in, ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        try {
-            connection.setRequestMethod("POST");
-            return sendBinaryStream(connection, in, rh);
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @param in
-     * @return
-     * @throws IOException
-     */
-    protected boolean postAsBinaryStream(InputStream in) throws IOException {
-        return postAsBinaryStream(in, null);
-    }
-
-    /**
-     *
-     * @param in
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected boolean putAsBinaryStream(InputStream in, ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        try {
-            connection.setRequestMethod("PUT");
-            return sendBinaryStream(connection, in, rh);
-
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @param in
-     * @return
-     * @throws IOException
-     */
-    protected boolean putAsBinaryStream(InputStream in) throws IOException {
-        return putAsBinaryStream(in, null);
-    }
-
-    /**
-     *
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected byte[] getBinaryData(ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        try {
-            connection.setRequestMethod("GET");
-            connection.setDoInput(true);
-            connection.setDoOutput(false);
-            initAuthentication(connection);
-
-            int responseCode = connection.getResponseCode();
-
-            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-            copy(connection.getInputStream(), outputStream);
-
-            if (rh == null) {
-                rh = new DefaultResponseHandler();
-            }
-            rh.checkResponse(responseCode, connection.getResponseMessage());
-
-            return outputStream.toByteArray();
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @return @throws IOException
-     */
-    protected byte[] getBinaryData() throws IOException {
-        return getBinaryData(null);
-    }
-
-    /**
-     *
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected InputStream getBinaryStream(ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        connection.setRequestMethod("GET");
-        connection.setDoInput(true);
-        connection.setDoOutput(false);
-        initAuthentication(connection);
-
-        int responseCode = connection.getResponseCode();
-        if (rh == null) {
-            rh = new DefaultResponseHandler();
-        }
-        rh.checkResponse(responseCode, connection.getResponseMessage());
-        return connection.getInputStream();
-    }
-
-    /**
-     *
-     * @return @throws IOException
-     */
-    protected InputStream getBinaryStream() throws IOException {
-        return getBinaryStream(null);
-    }
-
-    /**
-     *
-     * @param <T>
-     * @param classOfT
-     * @param rh
-     * @return
-     * @throws IOException
-     */
-    protected <T> T getData(Class<T> classOfT, ResponseHandler rh) throws IOException {
-        setUpHttpConnection();
-        try {
-            connection.setRequestMethod("GET");
-            connection.setDoInput(true);
-            connection.setDoOutput(false);
-            initAuthentication(connection);
-            
-            String data = readStringResponse(connection);
-            int responseCode = connection.getResponseCode();
-            if (rh == null) {
-                rh = new DefaultResponseHandler();
-            }
-            rh.checkResponse(responseCode, connection.getResponseMessage());
-            T o = gson.fromJson(data, classOfT);
-            return o;
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /**
-     *
-     * @param <T>
-     * @param classOfT
-     * @return
-     * @throws IOException
-     */
-    protected <T> T getData(Class<T> classOfT) throws IOException {
-        return getData(classOfT, null);
-    }
-
-    protected <T> List<T> getDataList(Type typeOfT, ResponseHandler rh) throws IOException {
-
-        setUpHttpConnection();
-        try {
-
-        connection.setRequestMethod("GET");
-        connection.setDoInput(true);
-        connection.setDoOutput(false);
-        initAuthentication(connection);
-
-        int responseCode = connection.getResponseCode();
-        if (rh == null) {
-            rh = new DefaultResponseHandler();
-        }
-        rh.checkResponse(responseCode, connection.getResponseMessage());
-
-        String data = readStringResponse(connection);
-        T[] o = gson.fromJson(data, typeOfT);
-        List<T> ret = new ArrayList<T>();
-        ret.addAll(Arrays.asList(o));
-        return ret;
-        } finally {
-            closeConnection();
-        }
-    }
-
-    /* Private methods */
-    /* ********************************************************************** */
-    private boolean sendBinaryStream(HttpURLConnection connection, InputStream in, ResponseHandler rh) throws IOException {
-        initAuthentication(connection);
-        connection.setDoInput(true);
-        connection.setDoOutput(true);
-        connection.setChunkedStreamingMode(4096);
-        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
-        copy(in, connection.getOutputStream());
-        int responseCode = connection.getResponseCode();
-        String response = readStringResponse(connection);
-        if (rh == null) {
-            rh = new DefaultResponseHandler();
-        }
-
-        return rh.checkResponse(responseCode, response);
-
-    }
-
-    private void copy(InputStream in, OutputStream out) throws IOException {
-        ReadableByteChannel source = Channels.newChannel(in);
-        WritableByteChannel target = Channels.newChannel(out);
-
-        ByteBuffer buffer = ByteBuffer.allocate(16 * 1024);
-        while (source.read(buffer) != -1) {
-            buffer.flip(); // Prepare the buffer to be drained
-            while (buffer.hasRemaining()) {
-                target.write(buffer);
-            }
-            buffer.clear(); // Empty buffer to get ready for filling
-        }
-
-        source.close();
-        target.close();
-
-    }
-
-    private boolean sendBinaryData(HttpURLConnection connection, byte[] data, ResponseHandler rh) throws IOException {
-        initAuthentication(connection);
-        writeData(connection, data);
-        int responseCode = connection.getResponseCode();
-        String response = readStringResponse(connection);
-        if (rh == null) {
-            rh = new DefaultResponseHandler();
-        }
-
-        return rh.checkResponse(responseCode, response);
-    }
-
-    private void writeData(HttpURLConnection connection, byte[] data) throws IOException {
-        connection.setDoInput(true);
-        connection.setDoOutput(true);
-        connection.setChunkedStreamingMode(4096);
-        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
-        BufferedOutputStream outputStream = new BufferedOutputStream(connection.getOutputStream());
-        outputStream.write(data);
-        outputStream.flush();
-        outputStream.close();
-
-    }
-
-    private boolean writeJsonData(Object data, HttpURLConnection connection, ResponseHandler rh) throws IOException {
-
-        String dataStr = gson.toJson(data);
-        initAuthentication(connection);
-        writeData(connection, dataStr.getBytes("UTF-8"));
-        int responseCode = connection.getResponseCode();
-        String response = readStringResponse(connection);
-        if (rh == null) {
-            rh = new DefaultResponseHandler();
-        }
-
-        return rh.checkResponse(responseCode, response);
-    }
-
-    private String readStringResponse(HttpURLConnection connection) throws IOException {
-        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-        String inputLine;
-        StringBuilder builder = new StringBuilder();
-        while ((inputLine = reader.readLine()) != null) {
-            builder.append(inputLine);
-        }
-        String resultString = builder.toString();
-        reader.close();
-        return resultString;
-    }
-
-    private void setUpHttpConnection() {
-        try {
-
-            String urlString = restContext.getResource();
-            URL url = new URL(urlString);
-            if (url.getProtocol().equals("http")) {
-                connection = (HttpURLConnection) url.openConnection();
-
-            }
-            if (url.getProtocol().equals("https")) {
-                connection = makeHttpsConnection(url);
-            }
-
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    /**
-     *
-     * @param url
-     * @return
-     * @throws CertificateException
-     * @throws IOException
-     * @throws KeyManagementException
-     * @throws NoSuchAlgorithmException
-     * @throws KeyStoreException
-     * @throws FileNotFoundException
-     */
-    private HttpURLConnection makeHttpsConnection(URL url) throws CertificateException, IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
-        if (keyStore == null) {
-            CertificateProvider certificateProvider = restContext.getCertificateProvider();
-            if (certificateProvider == null) {
-                throw new CertificateException("Need a certification provider");
-            }
-            Certificate ca = certificateProvider.getCertificate();
-            
-            String keyStoreType = KeyStore.getDefaultType();
-            keyStore = KeyStore.getInstance(keyStoreType);
-            keyStore.load(null, null);
-            keyStore.setCertificateEntry("ca", ca);
-
-            // Create a TrustManager that trusts the CAs in our KeyStore
-            String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
-            tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
-            tmf.init(keyStore);
-            
-            // Create an SSLContext that uses our TrustManager
-            context = SSLContext.getInstance("TLS");
-            context.init(null, tmf.getTrustManagers(), null);
-        }
-
-        // Tell the URLConnection to use a SocketFactory from our SSLContext
-        HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
-        urlConnection.setSSLSocketFactory(context.getSocketFactory());
-
-        if (!verifyHostName) {
-            HostnameVerifier hv = new HostnameVerifier() {
-
-                @Override
-                public boolean verify(String string, SSLSession ssls) {
-                    return true;
-                }
-            };
-            urlConnection.setHostnameVerifier(hv);
-        }
-
-        return urlConnection;
-    }
-}
diff --git a/projects/GDE_App/GDE-war/test/restapi/exceptions/RestResponseException.java b/projects/GDE_App/GDE-war/test/restapi/exceptions/RestResponseException.java
deleted file mode 100644 (file)
index 7ae9462..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package restapi.exceptions;
-
-/**
- *
- * @author mordicus
- */
-public class RestResponseException extends RuntimeException {
-
-    public RestResponseException(Throwable cause) {
-        super(cause);
-    }
-
-    public RestResponseException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public RestResponseException(String message) {
-        super(message);
-    }
-
-    public RestResponseException() {
-    }
-    
-}
diff --git a/projects/GDE_App/GDE-war/test/restapi/providers/CertificateProvider.java b/projects/GDE_App/GDE-war/test/restapi/providers/CertificateProvider.java
deleted file mode 100644 (file)
index f48cd8a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package restapi.providers;
-
-import java.io.IOException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-
-public interface CertificateProvider {
-    
-    public Certificate getCertificate() throws CertificateException, IOException;
-    
-}
diff --git a/projects/GDE_App/GDE-war/test/restapi/providers/FileCertificateProvider.java b/projects/GDE_App/GDE-war/test/restapi/providers/FileCertificateProvider.java
deleted file mode 100644 (file)
index 4b92289..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package restapi.providers;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-
-public class FileCertificateProvider implements CertificateProvider {
-
-    private final File file;
-    private Certificate ca;
-
-    public FileCertificateProvider(File file) {
-        this.file = file;
-    }
-
-    public FileCertificateProvider(String fileName) {
-        file = new File(fileName);
-    }
-
-    @Override
-    public Certificate getCertificate() throws CertificateException, IOException {
-        if (ca != null) {
-            return ca;
-        }
-
-        CertificateFactory cf = CertificateFactory.getInstance("X.509");
-        InputStream caInput = null;
-        try {
-            caInput = new BufferedInputStream(new FileInputStream(file));
-            ca = cf.generateCertificate(caInput);
-            return ca;
-        } catch (FileNotFoundException ex) {
-            throw new IOException(ex);
-        } finally {
-            if (caInput != null) {
-                caInput.close();
-            }
-        }
-    }
-
-}