partially implemented invites handling, still to implement get methods for checking who was invited in a given environment
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@115559 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c770098865
commit
d211f7f879
|
@ -20,7 +20,7 @@
|
|||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
|
Binary file not shown.
14
pom.xml
14
pom.xml
|
@ -22,11 +22,11 @@
|
|||
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<gwtVersion>2.5.1</gwtVersion>
|
||||
<gwtVersion>2.7.0</gwtVersion>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<!-- GWT needs at least java 1.6 -->
|
||||
<maven.compiler.source>1.6</maven.compiler.source>
|
||||
<maven.compiler.target>1.6</maven.compiler.target>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
@ -59,6 +59,11 @@
|
|||
<groupId>com.google</groupId>
|
||||
<artifactId>gwt-jsonmaker</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
|
@ -73,11 +78,10 @@
|
|||
<artifactId>junit</artifactId>
|
||||
<version>4.8</version>
|
||||
</dependency>
|
||||
<!-- Google Web Toolkit (GWT) -->
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
<!-- "provided" so that we don't deploy -->
|
||||
<version>${gwtVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -10,10 +10,16 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
import org.apache.commons.lang.NullArgumentException;
|
||||
import org.gcube.portal.databook.shared.Comment;
|
||||
import org.gcube.portal.databook.shared.Feed;
|
||||
import org.gcube.portal.databook.shared.FeedType;
|
||||
import org.gcube.portal.databook.shared.Invite;
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
import org.gcube.portal.databook.shared.InviteStatus;
|
||||
import org.gcube.portal.databook.shared.Like;
|
||||
import org.gcube.portal.databook.shared.Notification;
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
|
@ -24,6 +30,8 @@ import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
|
|||
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
|
||||
|
@ -44,8 +52,6 @@ import com.netflix.astyanax.query.PreparedIndexExpression;
|
|||
import com.netflix.astyanax.serializers.StringSerializer;
|
||||
/**
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @version 1.0 Dec 2012
|
||||
*
|
||||
*
|
||||
* This class is used for querying and adding data to Cassandra via Astyanax High Level API
|
||||
*
|
||||
|
@ -65,6 +71,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public static final String FEEDS = "Feeds";
|
||||
public static final String COMMENTS = "Comments";
|
||||
public static final String LIKES = "Likes";
|
||||
public static final String INVITES = "Invites";
|
||||
public static final String VRE_TIMELINE_FEEDS = "VRETimeline";
|
||||
public static final String USER_TIMELINE_FEEDS = "USERTimeline";
|
||||
public static final String APP_TIMELINE_FEEDS = "AppTimeline";
|
||||
|
@ -74,6 +81,8 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
public static final String USER_NOTIFICATIONS_PREFERENCES = "USERNotificationsPreferences"; // preferences for notifications
|
||||
public static final String HASHTAGS_COUNTER = "HashtagsCounter"; // count the hashtags per group and type
|
||||
public static final String HASHTAGGED_FEEDS = "HashtaggedFeeds"; // contains hashtags per type associated with vre and feed
|
||||
public static final String VRE_INVITES = "VREInvites"; //contains the emails that were invited per VRE
|
||||
public static final String EMAIL_INVITES = "EMAILInvites"; //contains the list of invitation per email
|
||||
|
||||
|
||||
private static ColumnFamily<String, String> cf_Connections = new ColumnFamily<String, String>(
|
||||
|
@ -111,6 +120,10 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
LIKES, // Column Family Name
|
||||
StringSerializer.get(), // Key Serializer
|
||||
StringSerializer.get()); // Column Serializer
|
||||
private static ColumnFamily<String, String> cf_Invites = new ColumnFamily<String, String>(
|
||||
INVITES, // Column Family Name
|
||||
StringSerializer.get(), // Key Serializer
|
||||
StringSerializer.get()); // Column Serializer
|
||||
private static ColumnFamily<String, String> cf_UserLikedFeeds = new ColumnFamily<String, String>(
|
||||
USER_LIKED_FEEDS, // Column Family Name
|
||||
StringSerializer.get(), // Key Serializer
|
||||
|
@ -140,6 +153,15 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
StringSerializer.get(), // Key Serializer
|
||||
StringSerializer.get()); // Column Serializer
|
||||
|
||||
private static ColumnFamily<String, String> cf_VREInvites = new ColumnFamily<String, String>(
|
||||
VRE_INVITES, // Column Family Name
|
||||
StringSerializer.get(), // Key Serializer
|
||||
StringSerializer.get()); // Column Serializer
|
||||
protected static ColumnFamily<String, String> cf_EmailInvites = new ColumnFamily<String, String>(
|
||||
EMAIL_INVITES, // Column Family Name
|
||||
StringSerializer.get(), // Key Serializer
|
||||
StringSerializer.get()); // Column Serializer
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1528,6 +1550,157 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
toReturn = getFeedsByIds(feedIds);
|
||||
return toReturn;
|
||||
}
|
||||
/*
|
||||
*
|
||||
********************** Invites ***********************
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* common part to save a feed
|
||||
* @param feed
|
||||
* @return the partial mutation batch instance
|
||||
*/
|
||||
private MutationBatch initSaveInvite(Invite invite) {
|
||||
if (invite == null)
|
||||
throw new NullArgumentException("Invite instance is null");
|
||||
// Inserting data
|
||||
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
|
||||
//an entry in the feed CF
|
||||
m.withRow(cf_Invites, invite.getKey().toString())
|
||||
.putColumn("SenderUserId", invite.getSenderUserId(), null)
|
||||
.putColumn("Vreid", invite.getVreid(), null)
|
||||
.putColumn("InvitedEmail", invite.getInvitedEmail(), null)
|
||||
.putColumn("ControlCode", invite.getControlCode(), null)
|
||||
.putColumn("Status", invite.getStatus().toString(), null)
|
||||
.putColumn("Time", invite.getTime().getTime()+"", null)
|
||||
.putColumn("SenderFullName", invite.getSenderFullName(), null);
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String isExistingInvite(String vreid, String email) {
|
||||
OperationResult<Rows<String, String>> result = null;
|
||||
try {
|
||||
result = conn.getKeyspace().prepareQuery(cf_EmailInvites)
|
||||
.getKeySlice(email)
|
||||
.execute();
|
||||
} catch (ConnectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Iterate rows and their columns
|
||||
for (Row<String, String> row : result.getResult()) {
|
||||
for (Column<String> column : row.getColumns()) {
|
||||
if (column.getName().compareTo(vreid)==0)
|
||||
return column.getStringValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public InviteOperationResult saveInvite(Invite invite) throws AddressException, NullArgumentException {
|
||||
if (invite == null)
|
||||
throw new NullArgumentException("Invite instance is null");
|
||||
String email = invite.getInvitedEmail();
|
||||
if (! verifyEmail(email))
|
||||
throw new AddressException("Email is not valid ->" + email);
|
||||
if (invite.getVreid() == null || invite.getVreid().equals(""))
|
||||
throw new NullArgumentException("VREId is null or empty");
|
||||
_log.debug("isExistingInvite? " + invite.getInvitedEmail() + " in " + invite.getVreid());
|
||||
if (isExistingInvite(invite.getVreid(), invite.getInvitedEmail()) != null)
|
||||
return InviteOperationResult.ALREADY_INVITED;
|
||||
_log.debug("Invite not found, proceed to save it ...");
|
||||
|
||||
MutationBatch m = initSaveInvite(invite);
|
||||
//an entry in the VRE Invites
|
||||
m.withRow(cf_VREInvites, invite.getVreid())
|
||||
.putColumn(invite.getKey().toString(), InviteStatus.PENDING.toString(), null);
|
||||
|
||||
//an entry in the EMAIL Invites
|
||||
m.withRow(cf_EmailInvites, email)
|
||||
.putColumn(invite.getVreid(), invite.getKey().toString(), null);
|
||||
boolean result = execute(m);
|
||||
return result ? InviteOperationResult.SUCCESS : InviteOperationResult.FAILED;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
||||
Invite toReturn = new Invite();
|
||||
OperationResult<ColumnList<String>> result;
|
||||
try {
|
||||
result = conn.getKeyspace().prepareQuery(cf_Invites)
|
||||
.getKey(inviteid)
|
||||
.execute();
|
||||
|
||||
ColumnList<String> columns = result.getResult();
|
||||
if (columns.size() == 0) {
|
||||
throw new InviteStatusNotFoundException("The requested inviteid: " + inviteid + " is not existing");
|
||||
}
|
||||
|
||||
toReturn.setKey(inviteid);
|
||||
toReturn.setSenderUserId(columns.getColumnByName("SenderUserId").getStringValue());
|
||||
toReturn.setVreid(columns.getColumnByName("Vreid").getStringValue());
|
||||
toReturn.setInvitedEmail(columns.getColumnByName("InvitedEmail").getStringValue());
|
||||
toReturn.setControlCode(columns.getColumnByName("ControlCode").getStringValue());
|
||||
InviteStatus status = getInviteStatusType(columns.getColumnByName("Status").getStringValue());
|
||||
toReturn.setStatus(status);
|
||||
toReturn.setTime(getDateFromTimeInMillis(columns.getColumnByName("Time").getStringValue()));
|
||||
toReturn.setSenderFullName(columns.getColumnByName("SenderFullName").getStringValue());
|
||||
|
||||
} catch (ConnectionException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws InviteStatusNotFoundException
|
||||
*/
|
||||
@Override
|
||||
public boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException {
|
||||
String inviteid = isExistingInvite(vreid, email);
|
||||
Invite toSet = readInvite(inviteid);
|
||||
if (toSet == null)
|
||||
throw new InviteIDNotFoundException("The specified invite to set with id: " + inviteid + " does not exist");
|
||||
|
||||
MutationBatch m = conn.getKeyspace().prepareMutationBatch();
|
||||
//update in the Invites Static CF
|
||||
m.withRow(cf_Invites, inviteid).putColumn("Status", status.toString(), null);
|
||||
//updated in the VREInvites Dynamic CF
|
||||
m.withRow(cf_VREInvites, toSet.getVreid()).putColumn(inviteid, status.toString(), null);
|
||||
try {
|
||||
m.execute();
|
||||
} catch (ConnectionException e) {
|
||||
_log.error("ERROR while setting Invite " + inviteid + " to " + status.toString());
|
||||
return false;
|
||||
}
|
||||
_log.trace("Invite Status Set to " + status.toString() + " OK");
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Invite> getAllInvitedEmailsByVRE(String vreid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Invite> getPendingInvitedEmailsByVRE(String vreid) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -1610,6 +1783,26 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
throw new FeedTypeNotFoundException("The Feed Type was not recognized should be one of " + FeedType.values() + " asked for: " + type);
|
||||
}
|
||||
|
||||
/**
|
||||
* simply return an enum representing the invite status type
|
||||
* @param type .
|
||||
* @return correct enum representing the feed type
|
||||
* @throws TypeNotFoundException .
|
||||
*/
|
||||
private InviteStatus getInviteStatusType(String type) throws InviteStatusNotFoundException {
|
||||
if (type.compareTo("PENDING") == 0) {
|
||||
return InviteStatus.PENDING;
|
||||
}
|
||||
else if (type.compareTo("ACCEPTED") == 0) {
|
||||
return InviteStatus.ACCEPTED;
|
||||
}
|
||||
else if (type.compareTo("REJECTED") == 0) {
|
||||
return InviteStatus.REJECTED;
|
||||
}
|
||||
else
|
||||
throw new InviteStatusNotFoundException("The Invite Status was not recognized should be one of " + InviteStatus.values() + " asked for: " + type);
|
||||
}
|
||||
|
||||
/**
|
||||
* simply return an enum representing the feed type
|
||||
* @param type .
|
||||
|
@ -1835,6 +2028,23 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
_log.debug("Hashtag Count update OK to: " + newCount);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* verify an email address
|
||||
* @param email
|
||||
* @return true or false
|
||||
*/
|
||||
private boolean verifyEmail(String email) {
|
||||
boolean isValid = false;
|
||||
try {
|
||||
InternetAddress internetAddress = new InternetAddress(email);
|
||||
internetAddress.validate();
|
||||
isValid = true;
|
||||
} catch (AddressException e) {
|
||||
_log.error("Validation Exception Occurred for email: " + email);
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,13 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
|
||||
import org.gcube.portal.databook.shared.Feed;
|
||||
import org.gcube.portal.databook.shared.FeedType;
|
||||
import org.gcube.portal.databook.shared.Invite;
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
import org.gcube.portal.databook.shared.InviteStatus;
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
import org.gcube.portal.databook.shared.NotificationType;
|
||||
import org.gcube.portal.databook.shared.PrivacyLevel;
|
||||
|
@ -23,13 +28,16 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gwt.thirdparty.javascript.jscomp.Result;
|
||||
import com.netflix.astyanax.connectionpool.OperationResult;
|
||||
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
|
||||
import com.netflix.astyanax.ddl.ColumnDefinition;
|
||||
import com.netflix.astyanax.ddl.ColumnFamilyDefinition;
|
||||
import com.netflix.astyanax.model.ColumnFamily;
|
||||
import com.netflix.astyanax.model.Row;
|
||||
import com.netflix.astyanax.model.Rows;
|
||||
import com.netflix.astyanax.serializers.StringSerializer;
|
||||
import com.netflix.astyanax.thrift.ddl.ThriftColumnDefinitionImpl;
|
||||
import com.netflix.astyanax.thrift.ddl.ThriftColumnFamilyDefinitionImpl;
|
||||
|
||||
public class DatabookCassandraTest {
|
||||
|
@ -46,52 +54,94 @@ public class DatabookCassandraTest {
|
|||
System.out.println("End");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHashTag() {
|
||||
public void testInvites() {
|
||||
String controlCode = UUID.randomUUID().toString();
|
||||
String vreid = "/gcube/devsec/devVRE";
|
||||
String email = "m.assante@gmail.com";
|
||||
Invite invite = new Invite(UUID.randomUUID().toString(), "massimiliano.assante", vreid, email, controlCode, InviteStatus.PENDING, new Date(), "Massimiliano Assante");
|
||||
try {
|
||||
final String VREID = "/gcube/devsec/devVRE";
|
||||
final String HASHTAG1 = "#testHashTag";
|
||||
final String HASHTAG2 = "#testHashTag3";
|
||||
List<String> hashtags = new LinkedList<String>();
|
||||
hashtags.add(HASHTAG1);
|
||||
hashtags.add(HASHTAG2);
|
||||
|
||||
// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "massimiliano.assante", new Date(), VREID,
|
||||
// "www.d4science.org/monitor", "thumbUri", "This is a feed with " + HASHTAG1 + " and " + HASHTAG2, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||
// assertTrue(store.saveUserFeed(feed));
|
||||
// assertTrue(store.saveHashTags(feed.getKey(), VREID, hashtags));
|
||||
// assertTrue(store.deleteHashTags("d0c64e42-9616-4e24-a65a-7a63a280d676", VREID, hashtags));
|
||||
// System.out.println(feed);
|
||||
//
|
||||
System.out.println("\ngetting getVREHashtagsWithOccurrence for " + VREID);
|
||||
Map<String, Integer> hashtagsWithOcc = store.getVREHashtagsWithOccurrence(VREID);
|
||||
for (String hashtag : hashtagsWithOcc.keySet()) {
|
||||
System.out.println(hashtag + ":" + hashtagsWithOcc.get(hashtag));
|
||||
}
|
||||
|
||||
System.out.println("\ngetting getVREFeedsByHashtag for " + VREID + " and " + HASHTAG1);
|
||||
for (Feed theFeed : store.getVREFeedsByHashtag(VREID, HASHTAG1)) {
|
||||
System.out.println(theFeed);
|
||||
}
|
||||
|
||||
InviteOperationResult result = store.saveInvite(invite);
|
||||
System.out.println(result);
|
||||
String inviteid = store.isExistingInvite(vreid, email);
|
||||
System.out.println(store.readInvite(inviteid));
|
||||
store.setInviteStatus(vreid, email, InviteStatus.ACCEPTED);
|
||||
System.out.println(store.readInvite(inviteid));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testHashTag() {
|
||||
// try {
|
||||
// final String VREID = "/gcube/devsec/devVRE";
|
||||
// final String HASHTAG1 = "#testHashTag";
|
||||
// final String HASHTAG2 = "#testHashTag3";
|
||||
// List<String> hashtags = new LinkedList<String>();
|
||||
// hashtags.add(HASHTAG1);
|
||||
// hashtags.add(HASHTAG2);
|
||||
//
|
||||
//// Feed feed = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, "massimiliano.assante", new Date(), VREID,
|
||||
//// "www.d4science.org/monitor", "thumbUri", "This is a feed with " + HASHTAG1 + " and " + HASHTAG2, PrivacyLevel.VRES, "Massimiliano Assante", "massimiliano.assante@isti.cnr.it", "thumburl", "linkTitle", "linkDesc", "host");
|
||||
//// assertTrue(store.saveUserFeed(feed));
|
||||
//// assertTrue(store.saveHashTags(feed.getKey(), VREID, hashtags));
|
||||
//// assertTrue(store.deleteHashTags("d0c64e42-9616-4e24-a65a-7a63a280d676", VREID, hashtags));
|
||||
//// System.out.println(feed);
|
||||
////
|
||||
// System.out.println("\ngetting getVREHashtagsWithOccurrence for " + VREID);
|
||||
// Map<String, Integer> hashtagsWithOcc = store.getVREHashtagsWithOccurrence(VREID);
|
||||
// for (String hashtag : hashtagsWithOcc.keySet()) {
|
||||
// System.out.println(hashtag + ":" + hashtagsWithOcc.get(hashtag));
|
||||
// }
|
||||
//
|
||||
// System.out.println("\ngetting getVREFeedsByHashtag for " + VREID + " and " + HASHTAG1);
|
||||
// for (Feed theFeed : store.getVREFeedsByHashtag(VREID, HASHTAG1)) {
|
||||
// System.out.println(theFeed);
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * use exclusively to add a new (Static) CF to a keyspace
|
||||
// */
|
||||
// @Test
|
||||
// public void addInvitesStaticColumnFamilies() {
|
||||
// ColumnFamily<String, String> CF_INVITES = ColumnFamily.newColumnFamily(DBCassandraAstyanaxImpl.INVITES, StringSerializer.get(), StringSerializer.get());
|
||||
//
|
||||
// try {
|
||||
// new CassandraClusterConnection(false).getKeyspace().createColumnFamily(CF_INVITES, ImmutableMap.<String, Object>builder()
|
||||
// .put("default_validation_class", "UTF8Type")
|
||||
// .put("key_validation_class", "UTF8Type")
|
||||
// .put("comparator_type", "UTF8Type")
|
||||
// .build());
|
||||
//
|
||||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("addInvitesStaticColumnFamily END");
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * use exclusively to add a new (Dynamic) CF to a keyspace
|
||||
// */
|
||||
// @Test
|
||||
// public void addHashtagsColumnFamilies() {
|
||||
// public void addInvitesDynamicColumnFamilies() {
|
||||
// System.out.println("addInvitesColumnFamilies");
|
||||
// ColumnFamily<String, String> cf_HashtagsCounter = new ColumnFamily<String, String>(
|
||||
// DBCassandraAstyanaxImpl.HASHTAGS_COUNTER, // Column Family Name
|
||||
// DBCassandraAstyanaxImpl.VRE_INVITES, // Column Family Name
|
||||
// StringSerializer.get(), // Key Serializer
|
||||
// StringSerializer.get()); // Column Serializer
|
||||
// ColumnFamily<String, String> cf_HashtagTimeline = new ColumnFamily<String, String>(
|
||||
// DBCassandraAstyanaxImpl.HASHTAGGED_FEEDS, // Column Family Name
|
||||
// DBCassandraAstyanaxImpl.EMAIL_INVITES, // Column Family Name
|
||||
// StringSerializer.get(), // Key Serializer
|
||||
// StringSerializer.get()); // Column Serializer
|
||||
//
|
||||
|
@ -111,6 +161,7 @@ public class DatabookCassandraTest {
|
|||
// } catch (ConnectionException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// System.out.println("addInvitesColumnFamilies END");
|
||||
// }
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,14 @@ package org.gcube.portal.databook.server;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
|
||||
import org.apache.commons.lang.NullArgumentException;
|
||||
import org.gcube.portal.databook.shared.Comment;
|
||||
import org.gcube.portal.databook.shared.Feed;
|
||||
import org.gcube.portal.databook.shared.Invite;
|
||||
import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||
import org.gcube.portal.databook.shared.InviteStatus;
|
||||
import org.gcube.portal.databook.shared.Like;
|
||||
import org.gcube.portal.databook.shared.Notification;
|
||||
import org.gcube.portal.databook.shared.NotificationChannelType;
|
||||
|
@ -14,6 +20,8 @@ import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
|
|||
import org.gcube.portal.databook.shared.ex.CommentIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.InviteStatusNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.LikeIDNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
|
||||
import org.gcube.portal.databook.shared.ex.NotificationIDNotFoundException;
|
||||
|
@ -352,6 +360,38 @@ public interface DatabookStore {
|
|||
* @return all the feeds having the hashtag passed as parameter
|
||||
*/
|
||||
List<Feed> getVREFeedsByHashtag(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
|
||||
/**
|
||||
* Save the invite for a given email into a given vre
|
||||
* @param invite the invite object instanc to save
|
||||
* @return {@link InviteOperationResult} SUCCESS, FAILED or ALREADY_INVITED (if an invite is sent to en existing email in the same environment more than once)
|
||||
*/
|
||||
InviteOperationResult saveInvite(Invite invite) throws AddressException, NullArgumentException;
|
||||
/**
|
||||
*
|
||||
* @param vreid the environment where you want to check the invite
|
||||
* @param email the email of the invite to check in the environmnet
|
||||
* @return the InviteId if present, null otherwise
|
||||
*/
|
||||
String isExistingInvite(String vreid, String email);
|
||||
/**
|
||||
* read an invite from a given id
|
||||
* @throws InviteIDNotFoundException
|
||||
* @throws InviteIDNotFoundException
|
||||
*/
|
||||
Invite readInvite(String inviteid) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
* set the status of an invite, see {@link InviteStatus}
|
||||
* @throws InviteIDNotFoundException
|
||||
*/
|
||||
boolean setInviteStatus(String vreid, String email, InviteStatus status) throws InviteIDNotFoundException, InviteStatusNotFoundException;
|
||||
/**
|
||||
* return the list of invites
|
||||
* @param vreid
|
||||
* @return
|
||||
*/
|
||||
List<Invite> getAllInvitedEmailsByVRE(String vreid);
|
||||
|
||||
List<Invite> getPendingInvitedEmailsByVRE(String vreid);
|
||||
/**
|
||||
* close the connection to the underlying database
|
||||
*/
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.Date;
|
|||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @version 0.1 July 2012
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Invite implements Serializable {
|
||||
|
||||
private String key;
|
||||
private String senderUserId;
|
||||
private String vreid;
|
||||
private String invitedEmail;
|
||||
private String controlCode;
|
||||
private InviteStatus status;
|
||||
private Date time;
|
||||
private String senderFullName;
|
||||
|
||||
|
||||
public Invite() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Invite(String key, String senderUserId, String vreid,
|
||||
String invitedEmail, String controlCode, InviteStatus status,
|
||||
Date time, String senderFullName) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.senderUserId = senderUserId;
|
||||
this.vreid = vreid;
|
||||
this.invitedEmail = invitedEmail;
|
||||
this.controlCode = controlCode;
|
||||
this.status = status;
|
||||
this.time = time;
|
||||
this.senderFullName = senderFullName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getSenderUserId() {
|
||||
return senderUserId;
|
||||
}
|
||||
|
||||
|
||||
public void setSenderUserId(String senderUserId) {
|
||||
this.senderUserId = senderUserId;
|
||||
}
|
||||
|
||||
|
||||
public String getVreid() {
|
||||
return vreid;
|
||||
}
|
||||
|
||||
|
||||
public void setVreid(String vreid) {
|
||||
this.vreid = vreid;
|
||||
}
|
||||
|
||||
|
||||
public String getInvitedEmail() {
|
||||
return invitedEmail;
|
||||
}
|
||||
|
||||
|
||||
public void setInvitedEmail(String invitedEmail) {
|
||||
this.invitedEmail = invitedEmail;
|
||||
}
|
||||
|
||||
|
||||
public String getControlCode() {
|
||||
return controlCode;
|
||||
}
|
||||
|
||||
|
||||
public void setControlCode(String controlCode) {
|
||||
this.controlCode = controlCode;
|
||||
}
|
||||
|
||||
|
||||
public InviteStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public void setStatus(InviteStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
||||
public String getSenderFullName() {
|
||||
return senderFullName;
|
||||
}
|
||||
|
||||
|
||||
public void setSenderFullName(String senderFullName) {
|
||||
this.senderFullName = senderFullName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Invite [key=" + key + ", senderUserId=" + senderUserId
|
||||
+ ", vreid=" + vreid + ", invitedEmail=" + invitedEmail
|
||||
+ ", controlCode=" + controlCode + ", status=" + status
|
||||
+ ", time=" + time + ", senderFullName=" + senderFullName + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
public enum InviteOperationResult {
|
||||
SUCCESS,
|
||||
FAILED,
|
||||
//If I send an invite the same email in the same environment more than once
|
||||
ALREADY_INVITED;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.gcube.portal.databook.shared;
|
||||
|
||||
public enum InviteStatus {
|
||||
PENDING,
|
||||
ACCEPTED,
|
||||
REJECTED;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class InviteIDNotFoundException extends Exception {
|
||||
public InviteIDNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portal.databook.shared.ex;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class InviteStatusNotFoundException extends Exception {
|
||||
public InviteStatusNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue