diff --git a/.classpath b/.classpath
index 3a9b116..097599a 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -18,11 +18,6 @@
-
-
-
-
-
@@ -36,5 +31,10 @@
-
+
+
+
+
+
+
diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs
index e80e916..16f6052 100644
--- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs
+++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs
@@ -1,4 +1,4 @@
eclipse.preferences.version=1
-lastWarOutDir=/Users/massi/workspace/create-users-portlet/target/create-users-portlet-2.5.0-SNAPSHOT
+lastWarOutDir=/Users/massi/workspace/create-users-portlet/target/create-users-portlet-3.0.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index a5c7673..4e4a3ad 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,9 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
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.release=disabled
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 91eebdc..63a79ce 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -4,6 +4,9 @@
+
+ uses
+
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
index e9c653e..8790933 100644
--- a/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -1,10 +1,10 @@
-
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..aac4897
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,17 @@
+
+# Changelog for invites-common-livrary
+
+All notable changes to this project will be documented in this file.
+This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+
+## [v3.0.0-SNAPSHOT] - 2020-09-24
+
+Ported to git
+
+[#19812] modified to support the new IAM Keycloak based
+
+
+## [v1.0.0] - 2016-03-28
+
+First release, for changes between 1.0 version and 3 see changelog xml in distro folder.
diff --git a/distro/descriptor.xml b/distro/descriptor.xml
deleted file mode 100644
index 5e80428..0000000
--- a/distro/descriptor.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
- servicearchive
-
- tar.gz
-
- /
-
-
- ${distroDirectory}
- /
- true
-
- README
- LICENSE
- changelog.xml
- profile.xml
-
- 755
- true
-
-
-
-
-
- /${artifactId}
-
-
-
-
\ No newline at end of file
diff --git a/distro/profile.xml b/distro/profile.xml
deleted file mode 100644
index 51c3b6b..0000000
--- a/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/pom.xml b/pom.xml
index 1b0c9db..04f03a5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
org.gcube.portlets.admin
create-users-portlet
war
- 2.5.0-SNAPSHOT
+ 3.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.
@@ -28,10 +28,10 @@
- 2.7.0
+ 2.8.2
distro
6.2.5
- 1.7
+ 1.8
1.8
${project.build.directory}/${project.build.finalName}
@@ -51,7 +51,7 @@
org.gcube.distribution
maven-portal-bom
- LATEST
+ 3.6.0-SNAPSHOT
pom
import
@@ -108,12 +108,6 @@
provided
${gwtVersion}
-
- com.google.gwt
- gwt-dev
- provided
- ${gwtVersion}
-
com.github.gwtbootstrap
gwt-bootstrap
diff --git a/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.java b/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.java
index 9bc7c13..363f5ac 100644
--- a/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.java
+++ b/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.java
@@ -62,8 +62,8 @@ public class AddUserForm extends Composite{
@UiField
TextBox surnameTextbox;
- @UiField
- TextBox companyTextbox;
+// @UiField
+// TextBox companyTextbox;
@UiField
AlertBlock errorBlock;
@@ -115,7 +115,7 @@ public class AddUserForm extends Composite{
String actualName = nameTextbox.getText().trim();
String actualSurname = surnameTextbox.getText().trim();
String actualEmail = emailTextbox.getText().trim();
- String actualCompany = companyTextbox.getText().trim();
+ String actualCompany = "";//companyTextbox.getText().trim();
if(actualEmail.isEmpty() || !actualEmail.matches(EMAIL_PATTERN)){
@@ -262,10 +262,10 @@ public class AddUserForm extends Composite{
void onChangeSurnameTextbox(KeyUpEvent event){
hideAlertBlocks();
}
-
- @UiHandler("companyTextbox")
- void onChangeCompanyTextbox(KeyUpEvent event){
- hideAlertBlocks();
- }
+//
+// @UiHandler("companyTextbox")
+// void onChangeCompanyTextbox(KeyUpEvent event){
+// hideAlertBlocks();
+// }
}
diff --git a/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.ui.xml b/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.ui.xml
index f0875ae..eb3a3c0 100644
--- a/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.ui.xml
+++ b/src/main/java/org/gcube/portlets/admin/createusers/client/ui/AddUserForm.ui.xml
@@ -69,11 +69,11 @@
b:id="surname" title="User's surname" ui:field="surnameTextbox" />
- Institution/Organization:
-
-
-
+
+
+
+
+
Send mail:
diff --git a/src/main/java/org/gcube/portlets/admin/createusers/orchestrator/CreateUserAddToVre.java b/src/main/java/org/gcube/portlets/admin/createusers/orchestrator/CreateUserAddToVre.java
index dae4dd6..d1847f1 100644
--- a/src/main/java/org/gcube/portlets/admin/createusers/orchestrator/CreateUserAddToVre.java
+++ b/src/main/java/org/gcube/portlets/admin/createusers/orchestrator/CreateUserAddToVre.java
@@ -1,6 +1,7 @@
package org.gcube.portlets.admin.createusers.orchestrator;
import org.gcube.portal.event.publisher.lr62.PortalEvent;
+import org.gcube.portlets.admin.createusers.server.CreateUsersImpl;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
@@ -46,7 +47,7 @@ public class CreateUserAddToVre extends PortalEvent {
protected String computeUsername(String email) {
try {
- Long companyId = CompanyThreadLocal.getCompanyId();
+ Long companyId = CreateUsersImpl.getCompany().getCompanyId();
Long defaultUserId = UserLocalServiceUtil.getDefaultUserId(companyId);
return defaultScreenNameGenerator.generate(companyId, defaultUserId, email);
} catch (Exception e) {
diff --git a/src/main/java/org/gcube/portlets/admin/createusers/server/CreateUsersImpl.java b/src/main/java/org/gcube/portlets/admin/createusers/server/CreateUsersImpl.java
index 34b5c30..7da3d30 100644
--- a/src/main/java/org/gcube/portlets/admin/createusers/server/CreateUsersImpl.java
+++ b/src/main/java/org/gcube/portlets/admin/createusers/server/CreateUsersImpl.java
@@ -8,13 +8,14 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
import org.gcube.common.portal.PortalContext;
import org.gcube.portal.mailing.message.Recipient;
import org.gcube.portal.mailing.service.EmailTemplateService;
import org.gcube.portal.mailing.templates.TemplateWelcomeCreatedAccount;
import org.gcube.portlets.admin.createusers.client.HandleUsersService;
+import org.gcube.portlets.admin.createusers.orchestrator.CreateUserAddToVre;
+import org.gcube.portlets.admin.createusers.orchestrator.CreateUserAddToVrePublisher;
import org.gcube.portlets.admin.createusers.shared.VreUserBean;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
@@ -33,11 +34,10 @@ import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.model.Company;
-import com.liferay.portal.model.User;
+import com.liferay.portal.model.Group;
import com.liferay.portal.service.CompanyLocalServiceUtil;
-import com.liferay.portal.service.ServiceContext;
+import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
-import com.liferay.portal.util.PortalUtil;
/**
* The server side implementation of the RPC service.
@@ -48,6 +48,8 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
private final static Logger logger = LoggerFactory.getLogger(CreateUsersImpl.class);
private static final long serialVersionUID = -3124676000683430170L;
private static final String REGISTERED_USERS_TABLE = "registered_users";
+ private static final String INITIAL_PWD = "training1";
+
// SQL TABLE FIELDS
private static final String FIELD_EMAIL = "email";
@@ -233,15 +235,16 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
int res = statement.executeUpdate();
if(res != 0){
logger.debug("User added in " + REGISTERED_USERS_TABLE);
- // add in liferay too
+ // add in Keycloak too
try{
- User user = register(name, surname, email, institution, sendEmail);
- // adding to the current VRE
- long userId = userManager.getUserId(user.getScreenName());
- userManager.assignUserToGroup(getCurrentGroupID(), userId);
+ logger.debug("trying to send the event to create the account for this user to the orchestrator");
+ long currGroupId = pContext.getCurrentGroupId(getThreadLocalRequest());
+ Group theVRE = GroupLocalServiceUtil.getGroup(currGroupId);
+
+ new CreateUserAddToVrePublisher().publish(
+ CreateUserAddToVre.newEvent(name, surname, email, INITIAL_PWD, theVRE));
if (sendEmail)
sendEmailToUser(email);
-
}catch(Exception e){
// unable to create.. we need to delete it from the list of users
@@ -273,74 +276,7 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
}
}
- private User register(String firstName, String lastName, String email, String institution, boolean sendEmail) {
- User toReturn = null;
- try{
- logger.debug("Trying createuser and instatiate serviceContext" + email);
- Long defaultCompanyId = PortalUtil.getDefaultCompanyId();
- Long defaultUserId = UserLocalServiceUtil.getDefaultUserId(defaultCompanyId);
- PortalContext pContext = PortalContext.getConfiguration();
- //ServiceContext instanciated as follows is needed when the Email verification is sent
- ServiceContext serviceContext = new ServiceContext();
- serviceContext.setScopeGroupId(pContext.getCurrentGroupId(getThreadLocalRequest()));
- serviceContext.setPortalURL(pContext.getGatewayURL(getThreadLocalRequest()));
- serviceContext.setPathMain("/c");
-
- boolean autoPassword = false;
- Locale locale = new Locale("en_US");
- int prefixId = 0;
- int suffixId = 0;
- int birthdayMonth = 1;
- int birthdayDay = 1;
- int birthdayYear = 1970;
- String password1 = "training1";
- String password2 = password1;
- toReturn = UserLocalServiceUtil.addUser(
- defaultUserId,
- defaultCompanyId,
- autoPassword,
- password1,
- password2,
- true,
- "",
- email,
- 0L,
- "",
- locale,
- firstName,
- "",
- lastName,
- prefixId,
- suffixId,
- true,
- birthdayMonth,
- birthdayDay,
- birthdayYear,
- institution,
- null,
- null,
- null,
- null,
- false,
- serviceContext);
- logger.debug("CreateUser " + lastName + " SUCCESS");
- UserLocalServiceUtil.updateEmailAddressVerified(toReturn.getUserId(), true);
- UserLocalServiceUtil.updateAgreedToTermsOfUse(toReturn.getUserId(), false);
- UserLocalServiceUtil.updatePasswordReset(toReturn.getUserId(), true);
- UserLocalServiceUtil.updateReminderQuery(toReturn.getUserId(), "What was your initial password?", "training1");
- logger.debug("User " + lastName + " has agreed to ToU");
- logger.debug("User " + lastName + " has verified the Email");
- logger.debug("User " + lastName + " updatePasswordReset & updateReminderQuery");
-
-
- }
- 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.", e);
-
- }
- return toReturn;
- }
+
@Override
public List getAlreadyRegisterdUsers() {