diff --git a/1.0/.classpath b/1.0/.classpath deleted file mode 100644 index 9ace2b1..0000000 --- a/1.0/.classpath +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/1.0/.gwt/.gwt-log b/1.0/.gwt/.gwt-log deleted file mode 100644 index e69de29..0000000 diff --git a/1.0/.project b/1.0/.project deleted file mode 100644 index 190a7fc..0000000 --- a/1.0/.project +++ /dev/null @@ -1,53 +0,0 @@ - - - create-users - - - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - com.google.gdt.eclipse.core.webAppProjectValidator - - - - - com.google.gwt.eclipse.core.gwtProjectValidator - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - com.google.gwt.eclipse.core.gwtNature - - diff --git a/1.0/.settings/.jsdtscope b/1.0/.settings/.jsdtscope deleted file mode 100644 index b72a6a4..0000000 --- a/1.0/.settings/.jsdtscope +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/1.0/.settings/com.google.appengine.eclipse.core.prefs b/1.0/.settings/com.google.appengine.eclipse.core.prefs deleted file mode 100644 index 82c36af..0000000 --- a/1.0/.settings/com.google.appengine.eclipse.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -filesCopiedToWebInfLib= diff --git a/1.0/.settings/com.google.gdt.eclipse.core.prefs b/1.0/.settings/com.google.gdt.eclipse.core.prefs deleted file mode 100644 index d83ef36..0000000 --- a/1.0/.settings/com.google.gdt.eclipse.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -lastWarOutDir=/home/costantino/workspace/create-users/target/create-users-1.0.0-SNAPSHOT -warSrcDir=src/main/webapp -warSrcDirIsOutput=false diff --git a/1.0/.settings/com.google.gwt.eclipse.core.prefs b/1.0/.settings/com.google.gwt.eclipse.core.prefs deleted file mode 100644 index f23a752..0000000 --- a/1.0/.settings/com.google.gwt.eclipse.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -entryPointModules= diff --git a/1.0/.settings/org.eclipse.core.resources.prefs b/1.0/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 29abf99..0000000 --- a/1.0/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 diff --git a/1.0/.settings/org.eclipse.jdt.core.prefs b/1.0/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 443e085..0000000 --- a/1.0/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/1.0/.settings/org.eclipse.jst.jsp.core.prefs b/1.0/.settings/org.eclipse.jst.jsp.core.prefs deleted file mode 100644 index 3a5c98d..0000000 --- a/1.0/.settings/org.eclipse.jst.jsp.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -validateFragments=false -validation.use-project-settings=true diff --git a/1.0/.settings/org.eclipse.m2e.core.prefs b/1.0/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/1.0/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/1.0/.settings/org.eclipse.wst.common.component b/1.0/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 4b7cda2..0000000 --- a/1.0/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/1.0/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/1.0/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml deleted file mode 100644 index cc81385..0000000 --- a/1.0/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/1.0/.settings/org.eclipse.wst.common.project.facet.core.xml b/1.0/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 0777079..0000000 --- a/1.0/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/1.0/.settings/org.eclipse.wst.jsdt.ui.superType.container b/1.0/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 3bd5d0a..0000000 --- a/1.0/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/1.0/.settings/org.eclipse.wst.jsdt.ui.superType.name b/1.0/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 05bd71b..0000000 --- a/1.0/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Window \ No newline at end of file diff --git a/1.0/.settings/org.eclipse.wst.validation.prefs b/1.0/.settings/org.eclipse.wst.validation.prefs deleted file mode 100644 index 04cad8c..0000000 --- a/1.0/.settings/org.eclipse.wst.validation.prefs +++ /dev/null @@ -1,2 +0,0 @@ -disabled=06target -eclipse.preferences.version=1 diff --git a/1.0/distro/LICENSE b/1.0/distro/LICENSE deleted file mode 100644 index 7bca8c8..0000000 --- a/1.0/distro/LICENSE +++ /dev/null @@ -1,2 +0,0 @@ -${gcube.license} - diff --git a/1.0/distro/README b/1.0/distro/README deleted file mode 100644 index 65b75d6..0000000 --- a/1.0/distro/README +++ /dev/null @@ -1,63 +0,0 @@ -The gCube System - ${name} --------------------------------------------------- - -${description} - - -${gcube.description} - -${gcube.funding} - - -Version --------------------------------------------------- - -${version} (${buildDate}) - -Please see the file named "changelog.xml" in this directory for the release notes. - - -Authors --------------------------------------------------- - -* Costantino Perciante at ISTI-CNR(Pisa), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). - -Maintainers ------------ - -* Costantino Perciante at ISTI-CNR(Pisa), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). - -Download information --------------------------------------------------- - -Source code is available from SVN: - ${scm.url} - -Binaries can be downloaded from the gCube website: - ${gcube.website} - - -Installation --------------------------------------------------- - -Installation documentation is available on-line in the gCube Wiki: - ${gcube.wikiRoot} - -Documentation --------------------------------------------------- - -Documentation is available on-line in the gCube Wiki: - ${gcube.wikiRoot} - ${gcube.wikiRoot} - -Support --------------------------------------------------- - -Bugs and support requests can be reported in the gCube issue tracking tool: - ${gcube.issueTracking} - - -Licensing --------------------------------------------------- - -This software is licensed under the terms you may find in the file named "LICENSE" in this directory. \ No newline at end of file diff --git a/1.0/distro/changelog.xml b/1.0/distro/changelog.xml deleted file mode 100644 index 08f83d2..0000000 --- a/1.0/distro/changelog.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - First Release - - diff --git a/1.0/distro/descriptor.xml b/1.0/distro/descriptor.xml deleted file mode 100644 index 5e80428..0000000 --- a/1.0/distro/descriptor.xml +++ /dev/null @@ -1,32 +0,0 @@ - - servicearchive - - tar.gz - - / - - - ${distroDirectory} - / - true - - README - LICENSE - changelog.xml - profile.xml - - 755 - true - - - - - target/${build.finalName}.${project.packaging} - /${artifactId} - - - - \ No newline at end of file diff --git a/1.0/distro/profile.xml b/1.0/distro/profile.xml deleted file mode 100644 index 51c3b6b..0000000 --- a/1.0/distro/profile.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - Service - - ${description} - PortletUser - ${artifactId} - ${version} - - - ${artifactId} - ${version} - - ${groupId} - ${artifactId} - ${version} - - - target/${build.finalName}.war - - - - - diff --git a/1.0/pom.xml b/1.0/pom.xml deleted file mode 100644 index e3bd4f9..0000000 --- a/1.0/pom.xml +++ /dev/null @@ -1,245 +0,0 @@ - - - - 4.0.0 - - maven-parent - org.gcube.tools - 1.0.0 - - - - org.gcube.portlets.admin - create-users - war - 1.0.0-SNAPSHOT - Create users portlet - - Create users portlet allows a VRE-Manager to enter user's personal data and automatically register he/she in the portal. - The portlet also sends a temporary password to the just registered user. - - - - scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/${project.artifactId} - scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/${project.artifactId} - http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/${project.artifactId} - - - - - 2.7.0 - 6.0.6 - - 1.7 - 1.7 - - ${project.build.directory}/${project.build.finalName} - UTF-8 - UTF-8 - - - - - - com.google.gwt - gwt - ${gwtVersion} - pom - import - - - org.gcube.distribution - maven-portal-bom - LATEST - pom - import - - - - - - - org.gcube.common.portal - portal-manager - provided - - - com.sun.mail - javax.mail - provided - - - com.google.gwt - gwt-servlet - provided - ${gwtVersion} - - - com.google.gwt - gwt-user - provided - ${gwtVersion} - - - com.google.gwt - gwt-dev - provided - ${gwtVersion} - - - org.gcube.portal - custom-portal-handler - - - com.github.gwtbootstrap - gwt-bootstrap - 2.3.2.0 - - - org.gcube.dvos - usermanagement-core - provided - - - com.liferay.portal - portal-service - ${liferayVersion} - provided - - - org.gcube.applicationsupportlayer - aslcore - - - commons-codec - commons-codec - compile - - - org.gcube.core - common-scope-maps - compile - - - javax.portlet - portlet-api - provided - - - org.gcube.portal - social-networking-library - provided - - - org.gcube.common - home-library-model - provided - - - org.gcube.common - home-library - provided - - - asm-all - asm - - - - - org.gcube.common - home-library-jcr - provided - - - junit - junit - 4.11 - test - - - - - - ${webappDirectory}/WEB-INF/classes - - - - - - org.codehaus.mojo - gwt-maven-plugin - ${gwtVersion} - - - - compile - - - - - - - - Statistics.html - ${webappDirectory} - - - - - org.apache.maven.plugins - maven-war-plugin - 2.1.1 - - - compile - - exploded - - - - - ${webappDirectory} - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2 - - - ${distroDirectory}/descriptor.xml - - - - - servicearchive - install - - single - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - - - - diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/CreateUsers.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/CreateUsers.java deleted file mode 100644 index 9c2c658..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/CreateUsers.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.gcube.portlets.admin.createusers.client; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.user.client.ui.RootPanel; - - -/** - * The main module that contains the entry point of the portlet. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -public class CreateUsers implements EntryPoint { - - @Override - public void onModuleLoad() { - - RootPanel.get("create-users-container").add(new CreateUsersPanel()); - - } -} \ No newline at end of file diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/CreateUsersPanel.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/CreateUsersPanel.java deleted file mode 100644 index 8de69e4..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/CreateUsersPanel.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.gcube.portlets.admin.createusers.client; -import java.util.List; - -import org.gcube.portlets.admin.createusers.client.ui.AddUserForm; -import org.gcube.portlets.admin.createusers.client.ui.LoadingText; -import org.gcube.portlets.admin.createusers.client.ui.RegisteredUsersTable; -import org.gcube.portlets.admin.createusers.shared.VreUserBean; - -import com.github.gwtbootstrap.client.ui.AlertBlock; -import com.github.gwtbootstrap.client.ui.TabPane; -import com.github.gwtbootstrap.client.ui.TabPanel; -import com.github.gwtbootstrap.client.ui.constants.AlertType; -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.shared.HandlerManager; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.VerticalPanel; - -/** - * The panel that contains the list of users already registered and the form to add new ones. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -public class CreateUsersPanel extends Composite { - - // main vertical panel - private VerticalPanel mainPanel = new VerticalPanel(); - - // Tab panel - private TabPanel navTabs = new TabPanel(); - - // add user subpanel - private TabPane addUserSubPanel = new TabPane("Create New User"); - - // registered users subpanel - private TabPane registeredUsersSubPanel = new TabPane("Already Created Users") ; - - // Create a remote service proxy to talk to the server-side user manager service. - private final HandleUsersServiceAsync userServices = GWT.create(HandleUsersService.class); - - // table of registered users - private RegisteredUsersTable registeredUsersTable; - - // event bus - private final HandlerManager eventBus = new HandlerManager(null); - - public CreateUsersPanel(){ - - super(); - initWidget(mainPanel); - - // form panel - AddUserForm addUserForm = new AddUserForm(userServices, eventBus, this); - addUserSubPanel.add(addUserForm); - - // add temporary loader for registered users table - LoadingText loader = new LoadingText(); - loader.setVisible(true); - registeredUsersSubPanel.add(loader); - - // add stuff to the main panel - navTabs.add(addUserSubPanel); - navTabs.add(registeredUsersSubPanel); - mainPanel.add(navTabs); - - // select add user form tab - navTabs.selectTab(0); - - // enlarge navTabs - mainPanel.setWidth("100%"); - - // squeeze the form panel - addUserSubPanel.setWidth("50%"); - - // require already registered users - userServices.getAlreadyRegisterdUsers(new AsyncCallback>() { - - @Override - public void onSuccess(List result) { - - if(result == null){ - showProblemsRetrievingList(); - return; - } - - GWT.log("List of registered users received!"); - registeredUsersTable = new RegisteredUsersTable(result, eventBus, userServices); - registeredUsersSubPanel.clear(); - registeredUsersSubPanel.add(registeredUsersTable); - } - - @Override - public void onFailure(Throwable caught) { - - GWT.log("Unable to retrieve list of registered users!" + caught.toString()); - showProblemsRetrievingList(); - - } - }); - } - - /** - * Show error block if retrieving registered data fails. - */ - private void showProblemsRetrievingList() { - - registeredUsersSubPanel.clear(); - AlertBlock error = new AlertBlock(AlertType.ERROR); - error.setText("It is not possible to retrieve the requested data at the moment. Retry later..."); - error.setAnimation(true); - error.setClose(false); - registeredUsersSubPanel.add(error); - - } - - /** - * Determine if a user with this email has been already registered - * @param actualEmail - * @return - */ - public boolean isUserPresent(String actualEmail) { - return registeredUsersTable.isUserPresent(actualEmail); - } - -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/HandleUsersService.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/HandleUsersService.java deleted file mode 100644 index c2d4bb4..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/HandleUsersService.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.gcube.portlets.admin.createusers.client; - -import java.util.List; - -import org.gcube.portlets.admin.createusers.shared.VreUserBean; - -import com.google.gwt.user.client.rpc.RemoteService; -import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; -/** - * The client side stub for the RPC service. - */ -@RemoteServiceRelativePath("usersservice") -public interface HandleUsersService extends RemoteService { - - /** - * Register this user to the current vre. - * @param name - * @param surname - * @param institution/organization - * @param email - * @param sendEmail - * @param isMale - * @return the registered user information or null if the registration failed - */ - VreUserBean register(String name, String surname, String institution, String email, boolean sendEmail, boolean isMale); - - /** - * Retrieve the list of already registered users. - * @return a list of already registered users or null in case of error - */ - List getAlreadyRegisterdUsers(); - - /** - * Delete an already invited user that didn't change his password. - * @param email - */ - public boolean deleteInvitedUser(String email); - - /** - * Send the registration email to this user - * @param email - */ - public void sendEmailToUser(String email); - -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/HandleUsersServiceAsync.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/HandleUsersServiceAsync.java deleted file mode 100644 index b8896cb..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/HandleUsersServiceAsync.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.gcube.portlets.admin.createusers.client; - -import java.util.List; - -import org.gcube.portlets.admin.createusers.shared.VreUserBean; - -import com.google.gwt.user.client.rpc.AsyncCallback; - -/** - * Async version of the service for the client. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -public interface HandleUsersServiceAsync { - - void getAlreadyRegisterdUsers(AsyncCallback> callback); - - void register(String name, String surname, String institution, String email, - boolean sendEmail, boolean isMale, AsyncCallback callback); - - void deleteInvitedUser(String email, AsyncCallback callback); - - void sendEmailToUser(String email, AsyncCallback callback); -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/event/AddUserEvent.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/event/AddUserEvent.java deleted file mode 100644 index d6a0fa2..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/event/AddUserEvent.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.gcube.portlets.admin.createusers.client.event; -import org.gcube.portlets.admin.createusers.shared.VreUserBean; - -import com.google.gwt.event.shared.GwtEvent; - - -public class AddUserEvent extends GwtEvent { - public static Type TYPE = new Type(); - - private VreUserBean addedUserBean; - - public AddUserEvent(VreUserBean addedUserBean) { - this.addedUserBean = addedUserBean; - } - - public VreUserBean getAddedUserBean() { - return addedUserBean; - } - - @Override - public Type getAssociatedType() { - return TYPE; - } - - @Override - protected void dispatch(AddUserEventHandler handler) { - handler.onAddUser(this); - } -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/event/AddUserEventHandler.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/event/AddUserEventHandler.java deleted file mode 100644 index 1062950..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/event/AddUserEventHandler.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.gcube.portlets.admin.createusers.client.event; - -import com.google.gwt.event.shared.EventHandler; - -public interface AddUserEventHandler extends EventHandler { - void onAddUser(AddUserEvent event); -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.java deleted file mode 100644 index d5734c0..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.java +++ /dev/null @@ -1,271 +0,0 @@ -package org.gcube.portlets.admin.createusers.client.ui; - -import org.gcube.portlets.admin.createusers.client.CreateUsersPanel; -import org.gcube.portlets.admin.createusers.client.HandleUsersServiceAsync; -import org.gcube.portlets.admin.createusers.client.event.AddUserEvent; -import org.gcube.portlets.admin.createusers.shared.VreUserBean; - -import com.github.gwtbootstrap.client.ui.AlertBlock; -import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.CheckBox; -import com.github.gwtbootstrap.client.ui.Form; -import com.github.gwtbootstrap.client.ui.Image; -import com.github.gwtbootstrap.client.ui.TextBox; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.shared.HandlerManager; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiHandler; -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.Widget; - -/** - * Form to add new user to the vre. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -public class AddUserForm extends Composite{ - - private static AddUserFormUiBinder uiBinder = GWT - .create(AddUserFormUiBinder.class); - - /** - * Path of the image to be shown during loading - */ - public static final String imagePath = GWT.getModuleBaseURL() + "../images/loader.gif"; - - interface AddUserFormUiBinder extends UiBinder { - } - - @UiField - Form form; - - @UiField - Button submit; - - @UiField - CheckBox sendMailCheckbox; - - @UiField - Image performingRequest; - - @UiField - TextBox emailTextbox; - - @UiField - TextBox nameTextbox; - - @UiField - TextBox surnameTextbox; - - @UiField - TextBox companyTextbox; - - @UiField - AlertBlock errorBlock; - - @UiField - AlertBlock successBlock; - - private static final String NAME_SURNAME_PATTERN = "^[a-zA-Z\\s]*$"; - - private static final String EMAIL_PATTERN = - "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" - + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; - - private static final int HIDE_AFTER_MILLISECONDS = 10000; - - private final HandleUsersServiceAsync registrationService; - - private final HandlerManager eventBus; - - private final CreateUsersPanel parent; - - public AddUserForm(HandleUsersServiceAsync userServices, HandlerManager eventBus, CreateUsersPanel parent) { - initWidget(uiBinder.createAndBindUi(this)); - this.registrationService = userServices; - this.eventBus = eventBus; - this.parent = parent; - - // set loader url - performingRequest.setUrl(imagePath); - } - - - @Override - protected void onAttach() { - super.onAttach(); - Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand () { - public void execute () { - GWT.log("Setting focus"); - emailTextbox.getElement().focus(); - } - }); - } - - - @UiHandler("submit") - void onClick(ClickEvent e) { - - // input validation - String actualName = nameTextbox.getText(); - String actualSurname = surnameTextbox.getText(); - String actualEmail = emailTextbox.getText(); - String actualCompany = companyTextbox.getText(); - - if(actualEmail.isEmpty() || !actualEmail.matches(EMAIL_PATTERN)){ - - showError("Wrong or empty Email field"); - return; - - } - - if(actualName.isEmpty() || !actualName.matches(NAME_SURNAME_PATTERN)){ - - showError("Wrong or empty Name field"); - return; - - } - - if(actualSurname.isEmpty() || !actualSurname.matches(NAME_SURNAME_PATTERN)){ - - showError("Wrong or empty Surname field"); - return; - - } - - // check if this user is already present among the people added with this portlet - boolean presentTable = parent.isUserPresent(actualEmail); - - if(presentTable){ - - showAlertBlockThenHide( - errorBlock, - "Please note that a user with this email already exists", - HIDE_AFTER_MILLISECONDS - ); - - }else{ - - // show loading image - performingRequest.setVisible(true); - - // disable add button - submit.setEnabled(false); - - // remote service invocation - registrationService.register( - actualName, - actualSurname, - actualCompany, - actualEmail, - sendMailCheckbox.getValue(), - // maleCheckbox.getValue(), - true, - new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - - GWT.log("There was an error while adding the new user.", caught); - showAlertBlockThenHide( - errorBlock, - "It is not possible to add this user at the moment, retry later.", - HIDE_AFTER_MILLISECONDS); - } - - @Override - public void onSuccess(VreUserBean result) { - - if(result == null){ - - GWT.log("There was an error while adding the new user." - + " Are you sure he/she is not already present?"); - - showAlertBlockThenHide( - errorBlock, - "It is not possible to add this user at the moment, retry later." - + " Also check that he/she was not already registered in the portal.", - HIDE_AFTER_MILLISECONDS); - - }else{ - - showAlertBlockThenHide( - successBlock, - "User correctly added to this VRE", - HIDE_AFTER_MILLISECONDS); - - // append to the list of registered users - eventBus.fireEvent(new AddUserEvent(result)); - - } - - } - }); - } - - // reset form - form.reset(); - } - - private void showAlertBlockThenHide(final AlertBlock alert, String msg, int hideAfterMs){ - - // hide loading image - performingRequest.setVisible(false); - - // enable button again - submit.setEnabled(true); - - // set text - alert.setText(msg); - alert.setVisible(true); - - // hide after a while - Timer t = new Timer() { - @Override - public void run() { - alert.setVisible(false); - } - }; - t.schedule(hideAfterMs); - - } - - private void showError(String msg) { - - errorBlock.setText(msg); - errorBlock.setVisible(true); - - } - - private void hideAlertBlocks(){ - - errorBlock.setVisible(false); - successBlock.setVisible(false); - } - - @UiHandler("emailTextbox") - void onChangeEmailTextbox(KeyUpEvent event){ - hideAlertBlocks(); - } - - @UiHandler("nameTextbox") - void onChangeNameTextbox(KeyUpEvent event){ - hideAlertBlocks(); - } - - @UiHandler("surnameTextbox") - void onChangeSurnameTextbox(KeyUpEvent event){ - hideAlertBlocks(); - } - - @UiHandler("companyTextbox") - void onChangeCompanyTextbox(KeyUpEvent event){ - hideAlertBlocks(); - } - -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.ui.xml b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.ui.xml deleted file mode 100644 index a64e045..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.ui.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - .form-main-style { - margin-left: 10px; - } - - .fieldset-border-style { - border: 1px groove #444; - -webkit-box-shadow: 0px 0px 0px 0px #000; - box-shadow: 0px 0px 0px 0px #000; - padding: 10px; - } - - .legend-style { - width: auto; - padding: 10px; - margin-bottom: 0px; - } - - @external .form-horizontal .control-label; - .form-horizontal .control-label { - margin-bottom: 15px; - text-align: left; - } - - @external .form-horizontal .input-large; - .form-horizontal .input-large { - width: 95%; - margin-bottom: 15px; - } - - .block-alert-style { - margin-top: 10px; - padding: 10px; - } - - - - - - - Insert User Information - * is required - - - - - - * - E-mail: - - - - - - - * - Name: - - - - - - - * - Surname: - - - - - - Institution/Organization: - - - - - Send mail: - - - - - - - - - - - - -

- - - Add - - -

- - - - - - - -
-
-
-
-
\ No newline at end of file diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/LoadingText.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/LoadingText.java deleted file mode 100644 index a543721..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/LoadingText.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.gcube.portlets.admin.createusers.client.ui; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.Widget; - -public class LoadingText extends Composite { - - private static LoadingTextUiBinder uiBinder = GWT - .create(LoadingTextUiBinder.class); - - interface LoadingTextUiBinder extends UiBinder { - } - - public LoadingText() { - initWidget(uiBinder.createAndBindUi(this)); - } -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/LoadingText.ui.xml b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/LoadingText.ui.xml deleted file mode 100644 index 2055b1b..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/LoadingText.ui.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Please wait - - Contacting database... - - - - \ No newline at end of file diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/RegisteredUsersTable.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/RegisteredUsersTable.java deleted file mode 100644 index fa210e8..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/RegisteredUsersTable.java +++ /dev/null @@ -1,432 +0,0 @@ -package org.gcube.portlets.admin.createusers.client.ui; -import java.util.Comparator; -import java.util.Date; -import java.util.List; - -import org.gcube.portlets.admin.createusers.client.HandleUsersServiceAsync; -import org.gcube.portlets.admin.createusers.client.event.AddUserEvent; -import org.gcube.portlets.admin.createusers.client.event.AddUserEventHandler; -import org.gcube.portlets.admin.createusers.shared.VreUserBean; - -import com.github.gwtbootstrap.client.ui.CellTable; -import com.google.gwt.cell.client.ButtonCell; -import com.google.gwt.cell.client.Cell; -import com.google.gwt.cell.client.TextCell; -import com.google.gwt.core.client.GWT; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.EventTarget; -import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.event.shared.HandlerManager; -import com.google.gwt.i18n.client.DateTimeFormat; -import com.google.gwt.safehtml.shared.SafeHtmlBuilder; -import com.google.gwt.user.cellview.client.Column; -import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.view.client.ListDataProvider; -import com.google.gwt.view.client.Range; - -/** - * Show already registered users list. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -public class RegisteredUsersTable extends Composite { - - //CellTable custom UI resource - private CellTable.Resources tableRes = GWT.create(TableResources.class); - protected ListDataProvider dataProvider = new ListDataProvider(); - private CellTable table = new CellTable(1, tableRes); - private final HandlerManager eventBus; - - public RegisteredUsersTable(List registeredUsers, HandlerManager eventBus, final HandleUsersServiceAsync userServices) { - - super(); - initWidget(table); - - // bind event - this.eventBus = eventBus; - bind(); - - dataProvider.setList(registeredUsers); - dataProvider.addDataDisplay(table); - table.setStriped(true); - table.setWidth("95%", false); - table.addStyleName("table-style"); - table.setVisibleRange(new Range(0, registeredUsers.size())); - table.setBordered(true); - table.setRowCount(registeredUsers.size(), true); - - // column for mail and sorting handler - Column emailCol = getColumn(new TextCell(), new GetValue() { - @Override - public String getValue(VreUserBean user) { - return user.getEmail(); - } - }); - - ListHandler emailColHandler = new ListHandler(dataProvider.getList()); - emailColHandler.setComparator(emailCol, new Comparator() { - @Override - public int compare(VreUserBean o1, VreUserBean o2) { - - return o1.getEmail().compareTo(o2.getEmail()); - - } - }); - emailCol.setSortable(true); - emailCol.setDefaultSortAscending(false); - table.addColumnSortHandler(emailColHandler); - - // name column plus handler for sorting - Column nameCol = getColumn(new TextCell(), new GetValue() { - @Override - public String getValue(VreUserBean user) { - return user.getName(); - } - }); - - ListHandler nameColHandler = new ListHandler(dataProvider.getList()); - nameColHandler.setComparator(nameCol, new Comparator() { - @Override - public int compare(VreUserBean o1, VreUserBean o2) { - - return o1.getName().compareTo(o2.getName()); - - } - }); - nameCol.setSortable(true); - nameCol.setDefaultSortAscending(false); - table.addColumnSortHandler(nameColHandler); - - // surname column plus handler for sorting - Column surnameCol = getColumn(new TextCell(), new GetValue() { - @Override - public String getValue(VreUserBean user) { - return user.getSurname(); - } - }); - - ListHandler surnameColHandler = new ListHandler(dataProvider.getList()); - nameColHandler.setComparator(surnameCol, new Comparator() { - @Override - public int compare(VreUserBean o1, VreUserBean o2) { - - return o1.getSurname().compareTo(o2.getSurname()); - - } - }); - surnameCol.setSortable(true); - surnameCol.setDefaultSortAscending(false); - table.addColumnSortHandler(surnameColHandler); - - // institution/organization and handler for sorting - Column institutionCol = getColumn(new TextCell(), new GetValue() { - @Override - public String getValue(VreUserBean user) { - return user.getInstitution(); - } - }); - - ListHandler institutionColHandler = new ListHandler(dataProvider.getList()); - institutionColHandler.setComparator(institutionCol, new Comparator() { - @Override - public int compare(VreUserBean o1, VreUserBean o2) { - - return o1.getInstitution().compareTo(o2.getInstitution()); - - } - }); - institutionCol.setSortable(true); - institutionCol.setDefaultSortAscending(false); - table.addColumnSortHandler(institutionColHandler); - - // password and handler for sorting - Column passwordChanged = getColumn(new TextCell(), new GetValue() { - @Override - public String getValue(VreUserBean user) { - return (user.isPasswordChanged() ? "True" : "False"); - } - }); - - ListHandler passwordChangedColHandler = new ListHandler(dataProvider.getList()); - passwordChangedColHandler.setComparator(passwordChanged, new Comparator() { - @Override - public int compare(VreUserBean o1, VreUserBean o2) { - - String o1PasswordChangedString = o1.isPasswordChanged() ? "True" : "False"; - String o2PasswordChangedString = o2.isPasswordChanged() ? "True" : "False"; - return o1PasswordChangedString.compareTo(o2PasswordChangedString); - - } - }); - passwordChanged.setSortable(true); - passwordChanged.setDefaultSortAscending(false); - table.addColumnSortHandler(passwordChangedColHandler); - - // registration column plus handler for sorting - Column registrationDate = getColumn(new TextCell(), new GetValue() { - @Override - public String getValue(VreUserBean user) { - return DateTimeFormat.getShortDateFormat().format(new Date(user.getRegisrationDate())); - } - }); - - ListHandler registrationDateColHandler = new ListHandler(dataProvider.getList()); - registrationDateColHandler.setComparator(registrationDate, new Comparator() { - @Override - public int compare(VreUserBean o1, VreUserBean o2) { - return new Long(o1.getRegisrationDate()).compareTo(new Long(o2.getRegisrationDate())); - - } - }); - registrationDate.setDefaultSortAscending(false); - registrationDate.setSortable(true); - table.addColumnSortHandler(registrationDateColHandler); - table.getColumnSortList().push(registrationDate); - - // delete option - Column deleteUser = new Column(new ButtonCell()) { - - @Override - public String getValue(VreUserBean object) { - return object.isPasswordChanged() ? "True" : "False"; // useless - } - - @Override - public void render(Cell.Context context, VreUserBean value, SafeHtmlBuilder sb){ - - if(value == null) - return; - - if(!value.isPasswordChanged()) - sb.appendHtmlConstant(""); - else - sb.appendHtmlConstant(""); - - } - - @Override - public void onBrowserEvent(Cell.Context context, final Element parent, final VreUserBean user, NativeEvent event) { - event.preventDefault(); - - if(!"click".equals(event.getType())) - return; - - EventTarget eventTarget = event.getEventTarget(); - - if(parent.getFirstChildElement().isOrHasChild(Element.as(eventTarget))){ - - // get the button and disable it - parent.getFirstChildElement().setPropertyBoolean("disabled", true); - - userServices.deleteInvitedUser(user.getEmail(), new AsyncCallback() { - - @Override - public void onSuccess(Boolean result) { - - // delete this row too - if(result){ - - dataProvider.getList().remove(user); - table.setVisibleRange(new Range(0, dataProvider.getList().size())); - table.setRowCount(dataProvider.getList().size(), true); - dataProvider.refresh(); - - Window.alert("Deleted user with email " + user.getEmail()); - - }else - Window.alert("Unable to delete this user, sorry!"); - - // enable the button again - parent.getFirstChildElement().setPropertyBoolean("disabled", false); - - } - - @Override - public void onFailure(Throwable caught) { - - Window.alert("Unable to delete this user, sorry!"); - - // enable the button again - parent.getFirstChildElement().setPropertyBoolean("disabled", false); - - } - }); - } - }; - }; - - // send email option - Column sendWelcomeMessage = new Column(new ButtonCell()) { - - @Override - public String getValue(VreUserBean object) { - return "Send Welcome"; // useless - } - - @Override - public void render(Cell.Context context, VreUserBean value, SafeHtmlBuilder sb){ - - if(value == null) - return; - - sb.appendHtmlConstant(""); - - } - - @Override - public void onBrowserEvent(Cell.Context context, final Element parent, final VreUserBean user, NativeEvent event) { - event.preventDefault(); - - if(!"click".equals(event.getType())) - return; - - EventTarget eventTarget = event.getEventTarget(); - - if(parent.getFirstChildElement().isOrHasChild(Element.as(eventTarget))){ - - // get the button and disable it - parent.getFirstChildElement().setPropertyBoolean("disabled", true); - - userServices.sendEmailToUser(user.getEmail(), new AsyncCallback() { - - @Override - public void onSuccess(Void result) { - - Window.alert("Welcome message sent to " + user.getEmail()); - - // get the button and enable it - parent.getFirstChildElement().setPropertyBoolean("disabled", false); - - } - - @Override - public void onFailure(Throwable caught) { - - Window.alert("Unable to send the welcome message to " + user.getEmail()); - - // get the button and enable it - parent.getFirstChildElement().setPropertyBoolean("disabled", false); - - } - }); - } - } - }; - - - // add columns - SafeHtmlBuilder builder = new SafeHtmlBuilder(); - builder.appendHtmlConstant(""); - builder.appendEscaped("Email"); - builder.appendHtmlConstant(""); - table.addColumn(emailCol, builder.toSafeHtml()); - builder = new SafeHtmlBuilder(); - builder.appendHtmlConstant(""); - builder.appendEscaped("Name"); - builder.appendHtmlConstant(""); - table.addColumn(nameCol, builder.toSafeHtml()); - builder = new SafeHtmlBuilder(); - builder.appendHtmlConstant(""); - builder.appendEscaped("Surname"); - builder.appendHtmlConstant(""); - table.addColumn(surnameCol, builder.toSafeHtml()); - builder = new SafeHtmlBuilder(); - builder.appendHtmlConstant(""); - builder.appendEscaped("Institution / Organisation"); - builder.appendHtmlConstant(""); - table.addColumn(institutionCol, builder.toSafeHtml()); - builder = new SafeHtmlBuilder(); - builder.appendHtmlConstant(""); - builder.appendEscaped("Password Changed"); - builder.appendHtmlConstant(""); - table.addColumn(passwordChanged, builder.toSafeHtml()); - builder = new SafeHtmlBuilder(); - builder.appendHtmlConstant(""); - builder.appendEscaped("Registration date"); - builder.appendHtmlConstant(""); - table.addColumn(registrationDate, builder.toSafeHtml()); - builder = new SafeHtmlBuilder(); - builder.appendHtmlConstant(""); - builder.appendEscaped("Delete"); - builder.appendHtmlConstant(""); - table.addColumn(deleteUser, builder.toSafeHtml()); - builder = new SafeHtmlBuilder(); - builder.appendHtmlConstant(""); - builder.appendEscaped("Send Welcome"); - builder.appendHtmlConstant(""); - table.addColumn(sendWelcomeMessage, builder.toSafeHtml()); - } - - /** - * events binder - */ - private void bind() { - eventBus.addHandler(AddUserEvent.TYPE, new AddUserEventHandler() { - - @Override - public void onAddUser(AddUserEvent user) { - - addUserToTable(user); - - } - }); - } - - /** - * Update the list of registered users - * @param event - */ - private void addUserToTable(AddUserEvent event) { - - VreUserBean userToAdd = event.getAddedUserBean(); - GWT.log("Adding " + userToAdd); - dataProvider.getList().add(userToAdd); - table.setVisibleRange(new Range(0, dataProvider.getList().size())); - table.setRowCount(dataProvider.getList().size(), true); - dataProvider.refresh(); - - } - - /** - * Check if a user whit this email already exists - * @param actualEmail - * @return - */ - public boolean isUserPresent(String actualEmail) { - List users = dataProvider.getList(); - - for (VreUserBean vreUserBean : users) { - if(vreUserBean.getEmail().equals(actualEmail)) - return true; - } - - return false; - } - - /** - * Interface for getting a cell value - * @param - */ - private static interface GetValue { - C getValue(VreUserBean user); - } - - /** - * get a column - * - * @param the cell type - * @param cell the cell used to render the column - * @param getter the value getter for the cell - */ - private Column getColumn(Cell cell, final GetValue getter) { - Column column = new Column(cell) { - @Override - public C getValue(VreUserBean object) { - return getter.getValue(object); - } - }; - return column; - } -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/Table.css b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/Table.css deleted file mode 100644 index 2f4eb08..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/Table.css +++ /dev/null @@ -1,65 +0,0 @@ -.cellTableHeader { -/* padding: 0px; */ -/* color: #545454; */ -/* text-align: center !important; */ -/* font-size: 13px; */ -/* background-image: none; */ -/* background-color: #cfcfcf; */ -/* height: 25px; */ - vertical-align: bottom!important; - font-weight: bold; -/* text-shadow: 0 1px 1px rgba(255, 255, 255, .7); */ -/* border: 2px solid #999999; */ -} - -.cellTableFirstColumnHeader { -} - -.cellTableLastColumnHeader { - -} - -.cellTableCell { - padding: 4px; -/* text-align: center !important; */ - vertical-align: middle !important; - overflow: hidden; - font-size: 12px; -/* border: 1px dotted #999999; */ -} - -.cellTableEvenRow { - -} - -.cellTableOddRow { - -} - -.cellTableSelectedRow { - background: #628cd5; -} - -.cellTableSelectedRowCell { - -} - -.cellTableHoveredRow { - -} - -.cellTableHoveredRowCell { - -} - -.cellTableKeyboardSelectedRow { - background: #c9c9c1; -} - -.cellTableKeyboardSelectedRowCell { - border: none; -} - -.cellTableKeyboardSelectedCell { - border: none; -} \ No newline at end of file diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/TableResources.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/TableResources.java deleted file mode 100644 index b8d0feb..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/client/ui/TableResources.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.gcube.portlets.admin.createusers.client.ui; - -import com.github.gwtbootstrap.client.ui.CellTable; - -public interface TableResources extends CellTable.Resources{ - - @Source({CellTable.Style.DEFAULT_CSS, "org/gcube/portlets/admin/createusers/client/ui/Table.css"}) - TableStyle cellTableStyle(); - - interface TableStyle extends CellTable.Style {} -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/server/CreateUsersImpl.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/server/CreateUsersImpl.java deleted file mode 100644 index 8b7f3e3..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/server/CreateUsersImpl.java +++ /dev/null @@ -1,551 +0,0 @@ -package org.gcube.portlets.admin.createusers.server; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.mail.internet.InternetAddress; - -import org.gcube.application.framework.core.session.ASLSession; -import org.gcube.application.framework.core.session.SessionManager; -import org.gcube.common.homelibrary.home.HomeLibrary; -import org.gcube.common.portal.PortalContext; -import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; -import org.gcube.portlets.admin.createusers.client.HandleUsersService; -import org.gcube.portlets.admin.createusers.shared.VreUserBean; -import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; -import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException; -import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; -import org.gcube.vomanagement.usermanagement.model.GCubeUser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.gwt.user.server.rpc.RemoteServiceServlet; -import com.liferay.mail.service.MailServiceUtil; -import com.liferay.portal.kernel.dao.jdbc.DataAccess; -import com.liferay.portal.kernel.exception.PortalException; -import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.mail.MailMessage; -import com.liferay.portal.kernel.util.GetterUtil; -import com.liferay.portal.kernel.util.PropsUtil; -import com.liferay.portal.model.Company; -import com.liferay.portal.service.CompanyLocalServiceUtil; -import com.liferay.portal.service.UserLocalServiceUtil; -import com.liferay.portal.util.PortalUtil; - -/** - * The server side implementation of the RPC service. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsersService{ - - private final static Logger logger = LoggerFactory.getLogger(CreateUsersImpl.class); - private static final long serialVersionUID = -3124676000683430170L; - private static final String REGISTERED_USERS_TABLE = "registered_users"; - - //dev user - public static final String userid = "test.user"; - - //dev vre - private static final String vreID = "/gcube/devsec/devVRE"; - - // SQL TABLE FIELDS - private static final String FIELD_EMAIL = "email"; - private static final String FIELD_NAME = "name"; - private static final String FIELD_SURNAME = "surname"; - private static final String FIELD_INSTITUTION = "institution_organization"; - private static final String FIELD_REGISTRATION_DATE = "registration_date"; - private static final String FIELD_VRE = "vre"; - - public static final String DEFAULT_COMPANY_WEB_ID = "liferay.com"; - - @Override - public void init(){ - - logger.debug("Trying to get connect to liferay's DB from API"); - try { - - Connection con = DataAccess.getConnection(); - logger.debug("Connected!"); - - // check if the table already exists - boolean exists = tableExists(con); - - if(exists){ - logger.debug("Table " + REGISTERED_USERS_TABLE + " already exists."); - } - else{ - initializeTable(con); - } - } catch (Exception e) { - logger.error("Failed to connect to liferay's DB"); - return; - } - } - - /** - * check if tables exist in the database - * @param conn . - * @throws SQLException - */ - private boolean tableExists(Connection con) throws SQLException { - logger.debug("Looking for " + REGISTERED_USERS_TABLE + " table"); - Statement s = con.createStatement(); - ResultSet rs = s.executeQuery("SELECT * FROM pg_tables where schemaname='public' and tablename = '" + REGISTERED_USERS_TABLE +"' "); - boolean toReturn = rs.next(); - if (toReturn) - logger.debug("Auxiliary Table Found! Returning ... "); - return toReturn; - } - - /** - * create the table REGISTERED_USERS_TABLE - * @throws SQLException - */ - private void initializeTable(Connection con) { - try { - - logger.debug("Creating table " + REGISTERED_USERS_TABLE); - Statement s = con.createStatement(); - - s.execute("CREATE TABLE " + REGISTERED_USERS_TABLE - + " (id serial primary key, " // like autoincrement - + "email varchar(255) NOT NULL, " - + "name" + " varchar(255) NOT NULL, " - + "surname" + " varchar(255) NOT NULL, " - + "institution_organization" + " varchar(255) DEFAULT NULL, " - + "vre" + " varchar(255) NOT NULL, " - + "registration_date" + " TIMESTAMP NOT NULL)"); - - logger.debug(REGISTERED_USERS_TABLE + " created"); - - } catch (SQLException e) { - logger.error("Error while creating table", e); - } - try { - con.close(); - } catch (SQLException e1) { - logger.error("Error while closing connection", e1); - } - } - - - /** - * the current ASLSession - * @return the session - */ - private ASLSession getASLSession() { - - String sessionID = this.getThreadLocalRequest().getSession().getId(); - String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); - - if (user == null) { - - logger.warn("USER IS NULL setting " + userid + " and Running OUTSIDE PORTAL"); - user = getDevelopmentUser(); - SessionManager.getInstance().getASLSession(sessionID, user).setScope(vreID); - - } - - return SessionManager.getInstance().getASLSession(sessionID, user); - } - - /** - * Online or in development mode? - * @return true if you're running into the portal, false if in development - */ - private boolean isWithinPortal() { - try { - UserLocalServiceUtil.getService(); - return true; - } - catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) { - logger.trace("Development Mode ON"); - return false; - } - } - - /** - * when packaging test will fail if the user is not set to test.user - * @return . - */ - public String getDevelopmentUser() { - String user = userid; - // user = "costantino.perciante"; - return user; - } - - @Override - public boolean deleteInvitedUser(String email) { - - // if in dev mode return some samples - if (!isWithinPortal()) { - - logger.debug("In dev mode."); - return false; - - }else{ - - try{ - - Connection con = DataAccess.getConnection(); - boolean deletedLiferay = deleteUserFromLiferay(email); - boolean deletedTable = deleteUserFromTable(email, con); - return deletedLiferay && deletedTable; - - }catch(SQLException e){ - logger.debug("Error while trying to delete user with email = " + email, e); - } - - return false; - } - } - - @Override - public void sendEmailToUser(String email) { - - logger.debug("Sending welcome message to user with email " + email); - try{ - - PortalContext context = PortalContext.getConfiguration(); - String gatewayName = context.getGatewayName(); - String emailSender = context.getSenderEmail(); - - InternetAddress to = new InternetAddress(email); - InternetAddress from = new InternetAddress(emailSender); - - LiferayUserManager userManager = new LiferayUserManager(); - String portalUrl = PortalUtil.getPortalURL(getCompany().getVirtualHost(), 443, true); - String username = userManager.getFullNameFromEmail(email); - - MailMessage mailMessage = new MailMessage(); - mailMessage.setFrom(from); - mailMessage.setTo(to); - - String body = "

Dear " + username + ",
" + "
" + - "Welcome! You recently created an account at " + portalUrl + ". Your password is not sent by email for security purposes.
" + - "
" + "Sincerely,
" + - gatewayName + "
" + - emailSender + "
" + portalUrl; - String subject = portalUrl + ": Your New Account was created successfully!"; - - mailMessage.setBody(body); - mailMessage.setSubject(subject); - mailMessage.setHTMLFormat(true); - MailServiceUtil.sendEmail(mailMessage); - }catch(Exception e){ - logger.error("Error while sending email to user " + email, e); - } - - } - - - @Override - public VreUserBean register(String name, String surname, String institution, - String email, boolean sendEmail, boolean isMale) { - - // if in dev mode return ok - if (!isWithinPortal()) { - - logger.debug("In dev mode."); - return new VreUserBean(name, surname, institution, email, false, System.currentTimeMillis(), isMale); - - }else{ - - ASLSession session = getASLSession(); - String userName = session.getUsername(); - - //in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info) - //this check just return nothing if that happens - if (userName.compareTo("test.user") == 0) { - logger.debug("Found " + userName + " returning nothing"); - return null; - } - - String vre = session.getScopeName(); - long timestamp = System.currentTimeMillis(); - - //checking if the user has been already registered or is already in the portal - LiferayUserManager userManager = new LiferayUserManager(); - boolean exists = userManager.userExistsByEmail(email); - - if(exists){ - - logger.debug("User with this email already present in the portal."); - return null; - - } - else{ - - logger.debug("Trying to add user: " + name + ", " + surname + ", " + email + ", " + institution); - Connection con = null; - try{ - - con = DataAccess.getConnection(); - String insert = "INSERT into " + REGISTERED_USERS_TABLE + - "("+ FIELD_EMAIL + "," - + FIELD_NAME +"," - + FIELD_SURNAME + "," - + FIELD_INSTITUTION + "," - + FIELD_REGISTRATION_DATE + "," - + FIELD_VRE - + ") values(?, ?, ?, ?, ?, ?)"; - - PreparedStatement statement = con.prepareStatement(insert); - - statement.setString(1, email); - statement.setString(2, name); - statement.setString(3, surname); - statement.setString(4, institution); - statement.setTimestamp(5, new Timestamp(timestamp)); - statement.setString(6, vre); - int res = statement.executeUpdate(); - - if(res != 0){ - - logger.debug("User added in " + REGISTERED_USERS_TABLE); - - // add in liferay too - try{ - GCubeUser user = userManager.createUser( - true, - "", - email, - name, - "", - surname, - institution, - "", - isMale, - null, - null, - sendEmail, // determine if we need to send him/her an email - true); // force the password reset - - // adding to the current VRE - userManager.assignUserToGroup(getCurrentGroupID(), userManager.getUserId(user.getUsername())); - - //adding to the HL - addUserToHLGroup(user.getUsername(), session.getScope()); - - }catch(Exception e){ - - // unable to create.. we need to delete it from the list of users - logger.error("Unable to create the user " + email + " in liferay. Removing he/she from the table " + - REGISTERED_USERS_TABLE, e); - - deleteUserFromTable(email, con); - return null; - } - } - else{ - - logger.debug("User NOT added in " + REGISTERED_USERS_TABLE); - return null; - } - }catch(Exception e){ - logger.error("Unable to add user, sorry..", e); - return null; - }finally{ - try { - if(con != null) - con.close(); - } catch (SQLException e) { - logger.error("Unable to close connection to the DB"); - } - } - - return new VreUserBean(name, surname, institution, email, false, timestamp, isMale); - } - } - } - - @Override - public List getAlreadyRegisterdUsers() { - - List toReturn = new ArrayList(); - - // if in dev mode return some samples - if (!isWithinPortal()) { - - logger.debug("In dev mode."); - toReturn.add(new VreUserBean("Dylan", "Dog", "ISTI-CNR", "dylan.dog@gmail.com", true, System.currentTimeMillis(), true)); - toReturn.add(new VreUserBean("Costantino", "Perciante", "ISTI-CNR", "costantino8@gmail.com", false, System.currentTimeMillis(), true)); - return toReturn; - - }else{ - - LiferayUserManager userManager = new LiferayUserManager(); - ASLSession session = getASLSession(); - String userName = session.getUsername(); - - //in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info) - //this check just return nothing if that happens - if (userName.compareTo("test.user") == 0) { - logger.debug("Found " + userName + " returning nothing"); - return null; - } - - // evaluate current vre - String vre = session.getScopeName(); - - Connection con = null; - try{ - - con = DataAccess.getConnection(); - Statement stmt = con.createStatement(); - - String sql = "SELECT * FROM " + REGISTERED_USERS_TABLE + " WHERE " + FIELD_VRE + "='" + vre + "';"; - ResultSet rs = stmt.executeQuery(sql); - - while(rs.next()){ - - String name = rs.getString(FIELD_NAME); - String surname = rs.getString(FIELD_SURNAME); - String institution = rs.getString(FIELD_INSTITUTION); - String email = rs.getString(FIELD_EMAIL); - long registrationDate = rs.getTimestamp(FIELD_REGISTRATION_DATE).getTime(); - - // check if the password has been changed or not wrt the default one - boolean passwordChanged = userManager.isPasswordChanged(email); - - - toReturn.add(new VreUserBean(name, surname, institution, email, passwordChanged, registrationDate, false)); - - } - - // now, make sure these users are still on portal - Iterator iterator = toReturn.iterator(); - while (iterator.hasNext()) { - VreUserBean user = (VreUserBean) iterator.next(); - - if(!userManager.userExistsByEmail(user.getEmail())){ - - // remove from the table - deleteUserFromTable(user.getEmail(), con); - - // remove from this collection - iterator.remove(); - - } - } - - }catch(Exception e){ - logger.error("Unable to retrieve users list, sorry...", e); - return null; - }finally{ - try { - if(con != null) - con.close(); - } catch (SQLException e) { - logger.error("Unable to close connection to the DB"); - } - } - - return toReturn; - } - } - - /** - * Remove a row from the table of the registered users - * @param email - * @param con - */ - private boolean deleteUserFromTable(String email, Connection con) { - - try{ - - logger.debug("Going to delete user with email " + email + " from the table of registered users"); - - String remove = "DELETE FROM " + REGISTERED_USERS_TABLE + " WHERE " + FIELD_EMAIL + "= ?"; - PreparedStatement statementDelete = con.prepareStatement(remove); - statementDelete.setString(1, email); - int res = statementDelete.executeUpdate(); - - if(res == 1) - return true; - - }catch(Exception e){ - - logger.error("Error while deleting user=" + email + "from the table"); - } - - return false; - } - - /** - * Delete user from liferay - * @param email - */ - private boolean deleteUserFromLiferay(String email) { - - LiferayUserManager userManager = new LiferayUserManager(); - try { - userManager.deleteUserByEMail(email); - return true; - } catch (PortalException | SystemException - | UserManagementSystemException | UserManagementPortalException e) { - logger.error("Unable to delete user from liferay", e); - } - - return false; - } - - /** - * Add user to Home Library Group - * @param username - * @param group - */ - private void addUserToHLGroup(String username, String group) { - try { - org.gcube.common.homelibrary.home.workspace.usermanager.UserManager um = HomeLibrary.getHomeManagerFactory().getUserManager(); - um.associateUserToGroup(group, username); - } catch (Exception e) { - logger.error("Failed to get the usermanager from HL. Could not add user to the HL group"); - } - } - - /** - * Get the current group ID - * - * @return the current group ID or null if an exception is thrown - * @throws Exception - */ - private String getCurrentGroupID() { - ASLSession session = getASLSession(); - logger.debug("The current group NAME is --> " + session.getGroupName()); - String toReturn = null; - try { - toReturn = new LiferayGroupManager().getGroupId(session.getGroupName()); - } catch (UserManagementSystemException | GroupRetrievalFault e) { - logger.error("Unable to retrieve id for group " + session.getGroupName()); - } - return toReturn; - } - - public static Company getCompany() throws PortalException, SystemException { - return CompanyLocalServiceUtil.getCompanyByWebId(getDefaultCompanyWebId()); - } - /** - * - * @return the default company web-id (e.g. iMarine.eu) - */ - public static String getDefaultCompanyWebId() { - String defaultWebId = ""; - try { - defaultWebId = GetterUtil.getString(PropsUtil.get("company.default.web.id")); - } - catch (NullPointerException e) { - logger.error("Cound not find property company.default.web.id in portal.ext file returning default web id: " + DEFAULT_COMPANY_WEB_ID); - return DEFAULT_COMPANY_WEB_ID; - } - return defaultWebId; - } -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/server/portlet/CreateUsersPortlet.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/server/portlet/CreateUsersPortlet.java deleted file mode 100644 index 88b296a..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/server/portlet/CreateUsersPortlet.java +++ /dev/null @@ -1,28 +0,0 @@ - -package org.gcube.portlets.admin.createusers.server.portlet; - -import javax.portlet.GenericPortlet; -import javax.portlet.ActionRequest; -import javax.portlet.RenderRequest; -import javax.portlet.ActionResponse; -import javax.portlet.RenderResponse; -import javax.portlet.PortletException; -import java.io.IOException; -import javax.portlet.PortletRequestDispatcher; -import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; - -/** - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ - public class CreateUsersPortlet extends GenericPortlet { - public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { - response.setContentType("text/html"); - ScopeHelper.setContext(request); - PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/CreateUsers_view.jsp"); - dispatcher.include(request, response); - } - - public void processAction(ActionRequest request, ActionResponse response) - throws PortletException, IOException { - } -} diff --git a/1.0/src/main/java/org/gcube/portlets/admin/createusers/shared/VreUserBean.java b/1.0/src/main/java/org/gcube/portlets/admin/createusers/shared/VreUserBean.java deleted file mode 100644 index 95b1ec1..0000000 --- a/1.0/src/main/java/org/gcube/portlets/admin/createusers/shared/VreUserBean.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.gcube.portlets.admin.createusers.shared; - -import java.io.Serializable; - -/** - * Information of an already registered user to the VRE. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) - */ -public class VreUserBean implements Serializable{ - - private static final long serialVersionUID = -8674087530839002999L; - - private String name; - private String surname; - private String institution; - private String email; - private boolean passwordChanged; - private long regisrationDate; - private boolean isMale; - - /** - * Build a default user bean object. - */ - public VreUserBean(){ - super(); - } - - /** - * Build a user bean object. - * @param name - * @param surname - * @param institution - * @param email - * @param passwordChanged - * @param registrationDate - * @param isMale - */ - public VreUserBean(String name, String surname, String institution, - String email, boolean passwordChanged, long registrationDate, boolean isMale) { - super(); - this.name = name; - this.surname = surname; - this.institution = institution; - this.email = email; - this.passwordChanged = passwordChanged; - this.regisrationDate = registrationDate; - this.isMale = isMale; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getSurname() { - return surname; - } - - public void setSurname(String surname) { - this.surname = surname; - } - - public String getInstitution() { - return institution; - } - - public void setInstitution(String institution) { - this.institution = institution; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public boolean isPasswordChanged() { - return passwordChanged; - } - - public void setPasswordChanged(boolean passwordChanged) { - this.passwordChanged = passwordChanged; - } - - - public long getRegisrationDate() { - return regisrationDate; - } - - public void setRegisrationDate(long regisrationDate) { - this.regisrationDate = regisrationDate; - } - - - public boolean isMale() { - return isMale; - } - - public void setMale(boolean isMale) { - this.isMale = isMale; - } - - @Override - public String toString() { - return "VreUserBean [name=" + name + ", surname=" + surname - + ", institution=" + institution + ", email=" + email - + ", passwordChanged=" + passwordChanged + ", regisrationDate=" - + regisrationDate + ", isMale=" + isMale + "]"; - } -} diff --git a/1.0/src/main/resources/clientlog4j.properties b/1.0/src/main/resources/clientlog4j.properties deleted file mode 100644 index 4a2e1cd..0000000 --- a/1.0/src/main/resources/clientlog4j.properties +++ /dev/null @@ -1,12 +0,0 @@ -log4j.rootLogger=DEBUG, A1 -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout - -# Print the date in ISO 8601 format -log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n - -# Print only messages of level TRACE or above in the package org.gcube -log4j.logger.org.gcube=TRACE -log4j.logger.org.gcube.application.framework.core.session=INFO -log4j.logger.org.gcube.common.scope.impl.DefaultScopeProvider=ERROR -log4j.logger.com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor=ERROR \ No newline at end of file diff --git a/1.0/src/main/resources/org/gcube/portlets/admin/createusers/CreateUsers.gwt.xml b/1.0/src/main/resources/org/gcube/portlets/admin/createusers/CreateUsers.gwt.xml deleted file mode 100644 index e2598b2..0000000 --- a/1.0/src/main/resources/org/gcube/portlets/admin/createusers/CreateUsers.gwt.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/1.0/src/main/webapp/CreateUsers.css b/1.0/src/main/webapp/CreateUsers.css deleted file mode 100644 index 4f112f8..0000000 --- a/1.0/src/main/webapp/CreateUsers.css +++ /dev/null @@ -1,12 +0,0 @@ -/** Add css rules here for your application. */ -.portlet-title-style { - display: block; - font-size: 16px; - color: #555; - font-weight: bolder; - margin-bottom: 10px; -} - -.table-style { - margin-left: 10px; -} \ No newline at end of file diff --git a/1.0/src/main/webapp/CreateUsers.html b/1.0/src/main/webapp/CreateUsers.html deleted file mode 100644 index fbb7962..0000000 --- a/1.0/src/main/webapp/CreateUsers.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - -Create users portlet - - - - - - - - - - - - - - - - -

- Your web browser must have JavaScript enabled in order for this - application to display correctly.
- - -
- - diff --git a/1.0/src/main/webapp/WEB-INF/js/jquery.autosize.js b/1.0/src/main/webapp/WEB-INF/js/jquery.autosize.js deleted file mode 100644 index 370279e..0000000 --- a/1.0/src/main/webapp/WEB-INF/js/jquery.autosize.js +++ /dev/null @@ -1,187 +0,0 @@ -/*! - jQuery Autosize v1.16.12 - (c) 2013 Jack Moore - jacklmoore.com - updated: 2013-05-31 - license: http://www.opensource.org/licenses/mit-license.php -*/ - -(function ($) { - var - defaults = { - className: 'autosizejs', - append: '', - callback: false - }, - hidden = 'hidden', - borderBox = 'border-box', - lineHeight = 'lineHeight', - - // border:0 is unnecessary, but avoids a bug in FireFox on OSX - copy = '