|
|
@ -13,13 +13,12 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.gcube.common.portal.PortalContext;
|
|
|
|
import org.gcube.common.portal.PortalContext;
|
|
|
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
|
|
|
import org.gcube.social_networking.social_networking_client_library.LibClient;
|
|
|
|
import org.gcube.portal.databook.server.DatabookStore;
|
|
|
|
import org.gcube.social_networking.socialnetworking.model.shared.Invite;
|
|
|
|
import org.gcube.portal.databook.shared.Invite;
|
|
|
|
import org.gcube.social_networking.socialnetworking.model.shared.InviteOperationResult;
|
|
|
|
import org.gcube.portal.databook.shared.InviteOperationResult;
|
|
|
|
import org.gcube.social_networking.socialnetworking.model.shared.InviteStatus;
|
|
|
|
import org.gcube.portal.databook.shared.InviteStatus;
|
|
|
|
import org.gcube.social_networking.socialnetworking.model.shared.exceptions.InviteIDNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
|
|
|
|
import org.gcube.social_networking.socialnetworking.model.shared.exceptions.InviteStatusNotFoundException;
|
|
|
|
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
|
|
|
|
|
|
|
|
import org.gcube.portal.mailing.message.EmailAddress;
|
|
|
|
import org.gcube.portal.mailing.message.EmailAddress;
|
|
|
|
import org.gcube.portal.mailing.message.Recipient;
|
|
|
|
import org.gcube.portal.mailing.message.Recipient;
|
|
|
|
import org.gcube.portal.mailing.message.RecipientType;
|
|
|
|
import org.gcube.portal.mailing.message.RecipientType;
|
|
|
@ -52,7 +51,7 @@ public class InvitesManager {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static InvitesManager instance;
|
|
|
|
private static InvitesManager instance;
|
|
|
|
private static DatabookStore store;
|
|
|
|
private static LibClient libClient;
|
|
|
|
|
|
|
|
|
|
|
|
private InvitesManager() { }
|
|
|
|
private InvitesManager() { }
|
|
|
|
|
|
|
|
|
|
|
@ -65,11 +64,15 @@ public class InvitesManager {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return the unique instance of the store
|
|
|
|
* @return the unique instance of the store
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static synchronized DatabookStore initStore() {
|
|
|
|
public static synchronized LibClient initStore() {
|
|
|
|
if (store == null) {
|
|
|
|
if (libClient == null) {
|
|
|
|
store = new DBCassandraAstyanaxImpl();
|
|
|
|
try {
|
|
|
|
|
|
|
|
libClient = new LibClient();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return store;
|
|
|
|
}
|
|
|
|
|
|
|
|
return libClient;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public InviteOperationResult sendInvite(
|
|
|
|
public InviteOperationResult sendInvite(
|
|
|
@ -101,22 +104,18 @@ public class InvitesManager {
|
|
|
|
boolean emailResult = false;
|
|
|
|
boolean emailResult = false;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String vreName = PortalContext.getConfiguration().getCurrentGroupName(request);
|
|
|
|
String vreName = PortalContext.getConfiguration().getCurrentGroupName(request);
|
|
|
|
result = store.saveInvite(invite);
|
|
|
|
result = libClient.saveInviteLib(invite);
|
|
|
|
if (result == InviteOperationResult.ALREADY_INVITED) {
|
|
|
|
if (result == InviteOperationResult.ALREADY_INVITED) {
|
|
|
|
//if the invite existed already the id and temp passwd has to be the same of the original invite (in the persistence)
|
|
|
|
//if the invite existed already the id and temp passwd has to be the same of the original invite (in the persistence)
|
|
|
|
String inviteid = store.isExistingInvite(currScope, email);
|
|
|
|
String inviteid = libClient.isExistingInviteLib(currScope, email);
|
|
|
|
invite.setKey(inviteid);
|
|
|
|
invite.setKey(inviteid);
|
|
|
|
String tempPwd = store.readInvite(inviteid).getControlCode();
|
|
|
|
String tempPwd = libClient.readInviteLib(inviteid).getControlCode();
|
|
|
|
invite.setControlCode(tempPwd);;
|
|
|
|
invite.setControlCode(tempPwd);;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
emailResult = sendInviteEmail(request, invite, currUser, vreName, name, email, vreDescription, accountExists);
|
|
|
|
emailResult = sendInviteEmail(request, invite, currUser, vreName, name, email, vreDescription, accountExists);
|
|
|
|
notifyInviteSent(request, currUser, currScope, invite, vreName);
|
|
|
|
notifyInviteSent(request, currUser, currScope, invite, vreName);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (AddressException e) {
|
|
|
|
|
|
|
|
_log.error("Email not valid " + e.getMessage());
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
return InviteOperationResult.FAILED;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
_log.error("Something wrong happened retrieving the invite which seemd to be existing already " + e.getMessage());
|
|
|
|
_log.error("Something wrong happened retrieving the invite which seemd to be existing already " + e.getMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|