You are viewing a plain text version of this content. The canonical link for it is here.
Posted to photark-commits@incubator.apache.org by lr...@apache.org on 2011/07/04 19:25:21 UTC

svn commit: r1142774 [2/2] - in /incubator/photark/branches/photark-rest/photark-social: ./ src/main/java/org/apache/photark/social/ src/main/java/org/apache/photark/social/activity/ src/main/java/org/apache/photark/social/appdata/ src/main/java/org/ap...

Modified: incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/person/relationship/RelationshipManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/person/relationship/RelationshipManagerImpl.java?rev=1142774&r1=1142773&r2=1142774&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/person/relationship/RelationshipManagerImpl.java (original)
+++ incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/person/relationship/RelationshipManagerImpl.java Mon Jul  4 19:25:20 2011
@@ -19,43 +19,421 @@
 
 package org.apache.photark.social.person.relationship;
 
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import org.apache.photark.services.jcr.JCRRepositoryManager;
+import org.apache.photark.social.PhotArkSocialConstants;
 import org.apache.photark.social.exception.PhotArkSocialException;
+import org.apache.photark.social.util.PhotArkSocialUtil;
 
 public class RelationshipManagerImpl implements RelationshipManager {
 
-    public String getRelationshipStatus(String veiwer, String owner) throws PhotArkSocialException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public boolean requestRelationship(String viewer, String owner) throws PhotArkSocialException {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public boolean acceptRelationshipRequest(String viewer, String owner) throws PhotArkSocialException {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public boolean ignoreRelationship(String viewer, String owner) throws PhotArkSocialException {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public boolean removeRelationship(String owner, String viewer) throws PhotArkSocialException {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public String[] getRelationshipList(String loggedUser) throws PhotArkSocialException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String[] getPendingRelationshipRequests(String owner) throws PhotArkSocialException {
-        // TODO Auto-generated method stub
-        return null;
-    }
+	private JCRRepositoryManager repositoryManager;
+
+	private static final Logger logger = Logger
+			.getLogger(RelationshipManagerImpl.class.getName());
 
+	public RelationshipManagerImpl() throws IOException {
+		repositoryManager = new JCRRepositoryManager();
+	}
+
+	public String getRelationshipStatus(String viewer, String owner)
+			throws PhotArkSocialException {
+		Node viewerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, viewer, false);
+		Node ownerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, owner, false);
+		if (viewerProfileNode == null || ownerProfileNode == null) {
+			String user = viewerProfileNode == null ? viewer : owner;
+			throw new PhotArkSocialException("User :" + user
+					+ "'s profile does not exists");
+		} else {
+			try {
+				String[] propertyValues = null;
+				if (viewerProfileNode
+						.hasProperty(PhotArkSocialConstants.RELATIONSHIP_FRIEND)) {
+					propertyValues = convertValueToString(
+							viewerProfileNode.getProperty(
+									PhotArkSocialConstants.RELATIONSHIP_FRIEND)
+									.getValues(), false);
+					if (arrayContains(propertyValues, owner)) {
+						return PhotArkSocialConstants.RELATIONSHIP_FRIEND;
+					}
+				}
+				if (viewerProfileNode
+						.hasProperty(PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)) {
+					propertyValues = convertValueToString(
+							viewerProfileNode
+									.getProperty(
+											PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)
+									.getValues(), false);
+					if (arrayContains(propertyValues, owner)) {
+						return PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED;
+					}
+				}
+				if (ownerProfileNode
+						.hasProperty(PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)) {
+					propertyValues = convertValueToString(
+							ownerProfileNode
+									.getProperty(
+											PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)
+									.getValues(), false);
+					if (arrayContains(propertyValues, viewer)) {
+						return PhotArkSocialConstants.RELATIONSHIP_REQUEST_PENDING;
+					}
+
+				}
+			} catch (RepositoryException e) {
+				logger.log(Level.SEVERE,
+						"Error requesting relationship status between " + owner
+								+ " and " + viewer + e.getMessage(), e);
+				throw new PhotArkSocialException(
+						"Error requesting relationship between status " + owner
+								+ " and " + viewer + e.getMessage(), e);
+			}
+		}
+		return PhotArkSocialConstants.RELATIONSHIP_NONE;
+	}
+
+	public boolean requestRelationship(String viewer, String owner)
+			throws PhotArkSocialException {
+		Node ownerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, owner, false);
+		if (ownerProfileNode == null) {
+			throw new PhotArkSocialException("Owner :" + owner
+					+ "'s profile does not exists");
+		}
+		String[] newPropertyValues = null;
+		try {
+			if (!ownerProfileNode
+					.hasProperty(PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)) {
+				newPropertyValues = new String[1];
+				newPropertyValues[0] = viewer;
+			} else {
+				Value[] props = ownerProfileNode.getProperty(
+						PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)
+						.getValues();
+				newPropertyValues = convertValueToString(props, true);
+				newPropertyValues[props.length] = viewer;
+			}
+			ownerProfileNode.setProperty(
+					PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED,
+					newPropertyValues, PropertyType.STRING);
+			repositoryManager.getSession().save();
+		} catch (RepositoryException e) {
+			logger.log(Level.SEVERE, "Error requesting relationship between "
+					+ owner + " and " + viewer + e.getMessage(), e);
+			throw new PhotArkSocialException(
+					"Error requesting relationship between " + owner + " and "
+							+ viewer + e.getMessage(), e);
+		}
+		return true;
+	}
+
+	public boolean acceptRelationshipRequest(String viewer, String owner)
+			throws PhotArkSocialException {
+		Node viewerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, viewer, false);
+		Node ownerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, owner, false);
+		if (viewerProfileNode == null) {
+			throw new PhotArkSocialException("Viewer :" + viewer
+					+ "'s profile does not exists");
+		}
+		if (ownerProfileNode == null) {
+			throw new PhotArkSocialException("Owner :" + owner
+					+ "'s profile does not exists");
+		}
+		try {
+			if (!getRelationshipStatus(viewer, owner).equals(
+					PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)) {
+				throw new PhotArkSocialException(viewer
+						+ " has not received a relationship request from "
+						+ owner);
+			}
+			// remove from viewer's received relationship list
+			String[] pendingRequest = getPendingRelationshipRequests(viewer);
+			String[] newProps = new String[pendingRequest.length - 1];
+			int index = 0;
+			if (newProps.length > 0) {
+				for (String user : pendingRequest) {
+					if (!(user.equals(owner))) {
+						newProps[index++] = user;
+					}
+				}
+				viewerProfileNode.setProperty(
+						PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED,
+						newProps, PropertyType.STRING);
+			} else {
+				viewerProfileNode.setProperty(
+						PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED,
+						(String[]) null, PropertyType.STRING);
+
+			}
+
+			String[] newPropertyValues = null;
+			// create a reference between ownerProfileNode and viewerProfileNode
+			if (!ownerProfileNode
+					.hasProperty(PhotArkSocialConstants.RELATIONSHIP_FRIEND)) {
+				newPropertyValues = new String[1];
+				newPropertyValues[0] = viewer;
+				ownerProfileNode.setProperty(
+						PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+						newPropertyValues, PropertyType.STRING);
+			} else {
+				Value[] props = ownerProfileNode.getProperty(
+						RELATIONSHIP_FRIEND).getValues();
+				newPropertyValues = convertValueToString(props, true);
+				newPropertyValues[props.length] = viewer;
+				ownerProfileNode.setProperty(
+						PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+						newPropertyValues, PropertyType.STRING);
+			}
+			if (!viewerProfileNode
+					.hasProperty(PhotArkSocialConstants.RELATIONSHIP_FRIEND)) {
+				newPropertyValues = new String[1];
+				newPropertyValues[0] = owner;
+				viewerProfileNode.setProperty(
+						PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+						newPropertyValues, PropertyType.STRING);
+			} else {
+				Value[] props = viewerProfileNode.getProperty(
+						RELATIONSHIP_FRIEND).getValues();
+				newPropertyValues = convertValueToString(props, true);
+				newPropertyValues[props.length] = owner;
+				viewerProfileNode.setProperty(
+						PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+						newPropertyValues, PropertyType.STRING);
+
+			}
+			repositoryManager.getSession().save();
+		} catch (RepositoryException e) {
+			logger.log(Level.SEVERE, "Error creating relationship between "
+					+ owner + " and " + viewer + e.getMessage(), e);
+			throw new PhotArkSocialException(
+					"Error creating relationship between " + owner + " and "
+							+ viewer + e.getMessage(), e);
+		}
+		return true;
+	}
+
+	public boolean ignoreRelationship(String viewer, String owner)
+			throws PhotArkSocialException {
+		// viewer is going to ignore the request from owner
+		Node viewerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, viewer, false);
+		if (viewerProfileNode == null) {
+			throw new PhotArkSocialException("User :" + viewer
+					+ "'s profile does not exists");
+		}
+		try {
+			if (!getRelationshipStatus(viewer, owner).equals(
+					PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)) {
+				throw new PhotArkSocialException("User " + viewer
+						+ " has not received relationship request from "
+						+ owner);
+			} else {
+				String[] props = convertValueToString(
+						viewerProfileNode
+								.getProperty(
+										PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)
+								.getValues(), false);
+				List<String> propsList = Arrays.asList(props);
+				String[] newProps = new String[props.length - 1];
+				int index = 0;
+				if (newProps.length > 0) {
+					for (String prop : propsList) {
+						if (!prop.equals(owner)) {
+							newProps[index++] = prop;
+						}
+					}
+
+					viewerProfileNode
+							.setProperty(
+									PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED,
+									newProps, PropertyType.STRING);
+				} else {
+					viewerProfileNode
+							.setProperty(
+									PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED,
+									(String[]) null, PropertyType.STRING);
+				}
+
+			}
+			repositoryManager.getSession().save();
+		} catch (RepositoryException e) {
+			logger.log(Level.SEVERE, "Error ignoring relationship between "
+					+ owner + " and " + viewer + e.getMessage(), e);
+			throw new PhotArkSocialException(
+					"Error ignoring relationship between " + owner + " and "
+							+ viewer + e.getMessage(), e);
+		}
+		return true;
+	}
+
+	public boolean removeRelationship(String owner, String viewer)
+			throws PhotArkSocialException {
+		Node ownerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, owner, false);
+		Node viewerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, viewer, false);
+		if (viewerProfileNode == null || ownerProfileNode == null) {
+			String user = viewerProfileNode == null ? viewer : owner;
+			throw new PhotArkSocialException("User :" + user
+					+ "'s profile does not exists");
+		}
+		try {
+			if (!getRelationshipStatus(viewer, owner).equals(
+					PhotArkSocialConstants.RELATIONSHIP_FRIEND)) {
+				throw new PhotArkSocialException("User " + viewer
+						+ " donesn't have friend relationship with user "
+						+ owner);
+			} else {
+				String[] props = convertValueToString(
+						viewerProfileNode.getProperty(
+								PhotArkSocialConstants.RELATIONSHIP_FRIEND)
+								.getValues(), false);
+				List<String> propsList = Arrays.asList(props);
+				String[] newProps = new String[props.length - 1];
+				int index = 0;
+				if (newProps.length > 0) {
+					for (String prop : propsList) {
+						if ((!prop.equals(owner))) {
+							newProps[index++] = prop;
+						}
+					}
+					viewerProfileNode.setProperty(
+							PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+							newProps, PropertyType.STRING);
+				} else {
+					viewerProfileNode.setProperty(
+							PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+							(String[]) null, PropertyType.STRING);
+				}
+				props = convertValueToString(
+						ownerProfileNode.getProperty(
+								PhotArkSocialConstants.RELATIONSHIP_FRIEND)
+								.getValues(), false);
+				propsList = Arrays.asList(props);
+				newProps = new String[props.length - 1];
+				index = 0;
+				if (newProps.length > 0) {
+					for (String prop : propsList) {
+						if ((!prop.equals(owner))
+								&& newProps.length >= index + 1) {
+							newProps[index++] = prop;
+						}
+					}
+					ownerProfileNode.setProperty(
+							PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+							newProps, PropertyType.STRING);
+				} else {
+					ownerProfileNode.setProperty(
+							PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+							(String[]) null, PropertyType.STRING);
+				}
+
+			}
+			repositoryManager.getSession().save();
+		} catch (RepositoryException e) {
+			logger.log(Level.SEVERE, "Error removing relationship between "
+					+ owner + " and " + viewer + " " + e.getMessage(), e);
+			throw new PhotArkSocialException(
+					"Error removing relationship between " + owner + " and "
+							+ viewer + " " + e.getMessage(), e);
+		}
+		return true;
+	}
+
+	public String[] getRelationshipList(String loggedUser)
+			throws PhotArkSocialException {
+		Node userProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, loggedUser, false);
+		if (userProfileNode == null) {
+			throw new PhotArkSocialException("User :" + loggedUser
+					+ "'s profile does not exists");
+		}
+		try {
+			if (userProfileNode
+					.getProperty(PhotArkSocialConstants.RELATIONSHIP_FRIEND) == null) {
+				return new String[0];
+			} else {
+				Value[] props = userProfileNode.getProperty(
+						PhotArkSocialConstants.RELATIONSHIP_FRIEND).getValues();
+
+				return convertValueToString(props, false);
+			}
+		} catch (RepositoryException e) {
+			logger.log(Level.SEVERE,
+					"Error retrieving relationship lists of user" + loggedUser
+							+ ". " + e.getMessage(), e);
+			throw new PhotArkSocialException(
+					"Error retrieving relationship lists of user" + loggedUser
+							+ ". " + e.getMessage(), e);
+		}
+
+	}
+
+	public String[] getPendingRelationshipRequests(String owner)
+			throws PhotArkSocialException {
+		Node ownerProfileNode = PhotArkSocialUtil.getPersonProfileRootNode(
+				repositoryManager, owner, false);
+		if (ownerProfileNode == null) {
+			throw new PhotArkSocialException("Owner :" + owner
+					+ "'s profile does not exists");
+		}
+		try {
+			if (!ownerProfileNode
+					.hasProperty(PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)) {
+				return new String[0];
+			} else {
+				Value[] props = ownerProfileNode.getProperty(
+						PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED)
+						.getValues();
+				return convertValueToString(props, false);
+			}
+
+		} catch (RepositoryException e) {
+			logger.log(Level.SEVERE,
+					"Error retrieving pending relationship request for user "
+							+ owner + e.getMessage(), e);
+			throw new PhotArkSocialException(
+					"Error retrieving pending relationship request for user "
+							+ owner + e.getMessage(), e);
+		}
+
+	}
+
+	private String[] convertValueToString(Value[] valueArray,
+			boolean addOneElement) throws RepositoryException {
+		String[] returnArray = null;
+		if (addOneElement) {
+			returnArray = new String[valueArray.length + 1];
+		} else {
+			returnArray = new String[valueArray.length];
+		}
+		int index = 0;
+		for (Value value : valueArray) {
+			returnArray[index++] = value.getString();
+		}
+		return returnArray;
+	}
+
+	private boolean arrayContains(String[] array, String queryString) {
+		List<String> arrayItems = Arrays.asList(array);
+		if (arrayItems.contains(queryString)) {
+			return true;
+		} else {
+			return false;
+		}
+	}
 }

Added: incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/util/PhotArkSocialUtil.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/util/PhotArkSocialUtil.java?rev=1142774&view=auto
==============================================================================
--- incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/util/PhotArkSocialUtil.java (added)
+++ incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/util/PhotArkSocialUtil.java Mon Jul  4 19:25:20 2011
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.social.util;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jcr.LoginException;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.photark.services.PhotarkRuntimeException;
+import org.apache.photark.services.jcr.JCRRepositoryManager;
+
+public class PhotArkSocialUtil {
+
+	private static final String JCR_SOCIAL_DATA_ROOT_NODE = "socialdata";
+	private static final String JCR_PROFILE_ROOT_NODE = "profile";
+
+	private static final Logger logger = Logger
+			.getLogger(PhotArkSocialUtil.class.getName());
+
+	/**
+	 * Retrieves the "socialdata" node
+	 * 
+	 * @param repositoryManager
+	 *            JCRRepositoryManager object
+	 * @return the "socialdata" node
+	 * @throws PhotarkRuntimeException
+	 */
+	public static Node getSocialDataRoot(JCRRepositoryManager repositoryManager)
+			throws PhotarkRuntimeException {
+		Session session = null;
+		Node root = null;
+		Node socialDataRoot = null;
+		try {
+			session = repositoryManager.getSession();
+			root = session.getRootNode();
+			// check whether the social data root node exists
+			if (root.hasNode(JCR_SOCIAL_DATA_ROOT_NODE)) {
+				socialDataRoot = root.getNode(JCR_SOCIAL_DATA_ROOT_NODE);
+			} else {
+				socialDataRoot = root.addNode(JCR_SOCIAL_DATA_ROOT_NODE);
+				session.save();
+			}
+
+		} catch (LoginException e) {
+			logger.log(Level.SEVERE, "Error loging in to photark repository :"
+					+ e.getMessage(), e);
+			throw new PhotarkRuntimeException(
+					"Error loging in to photark repository  :" + e.getMessage(),
+					e);
+		} catch (RepositoryException e) {
+			logger.log(
+					Level.SEVERE,
+					"Error retrieving social data from the repository :"
+							+ e.getMessage(), e);
+			throw new PhotarkRuntimeException(
+					"Error retrieving social data from the repository :"
+							+ e.getMessage(), e);
+		}
+
+		return socialDataRoot;
+	}
+
+	/**
+	 * Retrieves the node for the given user, under the "socialdata" node
+	 * 
+	 * @param repositoryManager
+	 *            JCRRepositoryManager object
+	 * @param username
+	 *            UserId of the Person
+	 * @param create
+	 *            If true, creates the node when it doesn't exist; If false,
+	 *            return null if the node doesn't exist
+	 * @return the node for the given user name
+	 * @throws PhotarkRuntimeException
+	 */
+	public static Node getPersonRootNode(
+			JCRRepositoryManager repositoryManager, String username,
+			boolean create) throws PhotarkRuntimeException {
+		Node socialDataRootNode = null;
+		Node personRootNode = null;
+		Session session = null;
+		try {
+			session = repositoryManager.getSession();
+			socialDataRootNode = getSocialDataRoot(repositoryManager);
+			if (socialDataRootNode.hasNode(username)) {
+				personRootNode = socialDataRootNode.getNode(username);
+			} else {
+				if (create) {
+					personRootNode = socialDataRootNode.addNode(username);
+					session.save();
+				}
+			}
+		} catch (LoginException e) {
+			logger.log(Level.SEVERE, "Error loging in to photark repository :"
+					+ e.getMessage(), e);
+			throw new PhotarkRuntimeException(
+					"Error loging in to photark repository  :" + e.getMessage(),
+					e);
+		} catch (RepositoryException e) {
+			logger.log(Level.SEVERE,
+					"Error retrieving person root node from the repository :"
+							+ e.getMessage(), e);
+			throw new PhotarkRuntimeException(
+					"Error retrieving person root node from the repository :"
+							+ e.getMessage(), e);
+		}
+
+		return personRootNode;
+	}
+
+	/**
+	 * Retrieves the "profile" node for the given user
+	 * 
+	 * @param repositoryManager
+	 *            JCRRepositoryManager object
+	 * @param username
+	 *            UserId of the Person
+	 * @param create
+	 *            If true, creates the node when it doesn't exist; If false,
+	 *            return null if the node doesn't exist
+	 * @return "profile" node for the given user name
+	 * @throws PhotarkRuntimeException
+	 */
+	public static Node getPersonProfileRootNode(
+			JCRRepositoryManager repositoryManager, String username,
+			boolean create) throws PhotarkRuntimeException {
+		Session session = null;
+		Node personRootNode = null;
+		Node personProfileRootNode = null;
+		try {
+			session = repositoryManager.getSession();
+			personRootNode = getPersonRootNode(repositoryManager, username,
+					create);
+			if (personRootNode.hasNode(JCR_PROFILE_ROOT_NODE)) {
+				personProfileRootNode = personRootNode
+						.getNode(JCR_PROFILE_ROOT_NODE);
+			} else {
+				if (create) {
+					personProfileRootNode = personRootNode
+							.addNode(JCR_PROFILE_ROOT_NODE);
+					session.save();
+				}
+			}
+		} catch (LoginException e) {
+			logger.log(Level.SEVERE, "Error loging in to photark repository :"
+					+ e.getMessage(), e);
+			throw new PhotarkRuntimeException(
+					"Error loging in to photark repository  :" + e.getMessage(),
+					e);
+		} catch (RepositoryException e) {
+			logger.log(Level.SEVERE,
+					"Error retrieving person profile node from the repository :"
+							+ e.getMessage(), e);
+			throw new PhotarkRuntimeException(
+					"Error retrieving person profile node from the repository :"
+							+ e.getMessage(), e);
+		}
+
+		return personProfileRootNode;
+	}
+}

Propchange: incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/util/PhotArkSocialUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/photark/branches/photark-rest/photark-social/src/main/java/org/apache/photark/social/util/PhotArkSocialUtil.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/activity/test/ActivityManagerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/activity/test/ActivityManagerTestCase.java?rev=1142774&view=auto
==============================================================================
--- incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/activity/test/ActivityManagerTestCase.java (added)
+++ incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/activity/test/ActivityManagerTestCase.java Mon Jul  4 19:25:20 2011
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.social.activity.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+
+import javax.jcr.LoginException;
+import javax.jcr.RepositoryException;
+
+import junit.framework.Assert;
+
+import org.apache.photark.services.jcr.JCRRepositoryManager;
+import org.apache.photark.social.activity.Activity;
+import org.apache.photark.social.activity.ActivityManager;
+import org.apache.photark.social.activity.ActivityManagerImpl;
+import org.apache.photark.social.exception.PhotArkSocialException;
+import org.junit.Test;
+
+public class ActivityManagerTestCase {
+
+	@Test
+	public void testActivityManagerImpl() throws IOException,
+			PhotArkSocialException, LoginException, RepositoryException {
+		JCRRepositoryManager repositoryManager = new JCRRepositoryManager();
+		String dir = "socialtest";
+		File homeDir = File.createTempFile(dir, "");
+		homeDir.delete();
+		homeDir.mkdir();
+		repositoryManager.setRepositoryHome(dir);
+		ActivityManager activityManager = new ActivityManagerImpl(
+				repositoryManager);
+		// Test save activity & get activity methods
+		Activity activity1 = new Activity();
+		activity1.setId("1");
+		activity1.setBody("User has posted an album");
+		activity1.setPostedTime(new Date());
+		activity1.setTitle("New Album");
+		activityManager.saveActivity("user1", activity1);
+		Activity activity2 = activityManager.getActivity("user1", null, null,
+				"1");
+		Assert.assertNotNull(activity2);
+		Assert.assertEquals(activity1.getBody(), activity2.getBody());
+		Assert.assertEquals(activity1.getPostedTime(),
+				activity2.getPostedTime());
+		Activity activity3 = new Activity();
+		activity3.setId("2");
+		activity3.setBody("User has tagges a photo");
+		activity3.setPostedTime(new Date());
+		activity3.setTitle("New Phhot Tagged");
+		activityManager.saveActivity("user1", activity3);
+		// Test get activities method
+		String[] ids = new String[] { "1", "2" };
+		Activity[] activities = activityManager.getActivities("user1", null,
+				null, null, ids);
+		Assert.assertNotNull(activities);
+		Assert.assertEquals(2, activities.length);
+		// Test remove activity method
+		activityManager.deleteActivity("user1", "1");
+		activity2 = activityManager.getActivity("user1", null, null, "1");
+		Assert.assertNull(activity2);
+	}
+}

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/activity/test/ActivityManagerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/activity/test/ActivityManagerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/appdata/test/AppDataManagerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/appdata/test/AppDataManagerTestCase.java?rev=1142774&view=auto
==============================================================================
--- incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/appdata/test/AppDataManagerTestCase.java (added)
+++ incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/appdata/test/AppDataManagerTestCase.java Mon Jul  4 19:25:20 2011
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.social.appdata.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.LoginException;
+import javax.jcr.RepositoryException;
+
+import junit.framework.Assert;
+
+import org.apache.photark.services.jcr.JCRRepositoryManager;
+import org.apache.photark.social.appdata.AppDataManager;
+import org.apache.photark.social.appdata.AppDataManagerImpl;
+import org.apache.photark.social.exception.PhotArkSocialException;
+import org.junit.Test;
+
+public class AppDataManagerTestCase {
+	@Test
+	public void testAppDataManagerImpl() throws IOException,
+			PhotArkSocialException, LoginException, RepositoryException {
+		JCRRepositoryManager repositoryManager = new JCRRepositoryManager();
+		String dir = "socialtest";
+		File homeDir = File.createTempFile(dir, "");
+		homeDir.delete();
+		homeDir.mkdir();
+		repositoryManager.setRepositoryHome(dir);
+		AppDataManager appDataManager = new AppDataManagerImpl(
+				repositoryManager);
+		Map<String, String> data1 = new HashMap<String, String>();
+		data1.put("albumName", "USTrip");
+		data1.put("a", "1");
+		// Test saveData() and getData()
+		appDataManager.savePersonData("user1", data1);
+		Map<String, String> data2 = null;
+		data2 = appDataManager.getPersonData("user1", null);
+		Assert.assertNotNull(data2);
+		Assert.assertEquals(data1.size(), data2.size());
+		Assert.assertTrue(data2.containsKey("albumName"));
+		Assert.assertTrue(data2.containsValue("USTrip"));
+		Assert.assertNotNull(data2.get("albumName"));
+		Assert.assertEquals("1", data2.get("a"));
+		Assert.assertTrue(data2.containsKey("a"));
+		Assert.assertTrue(data2.containsValue("1"));
+		Assert.assertNotNull(data2.get("a"));
+		Assert.assertEquals("1", data2.get("a"));
+		Set<String> fields = new HashSet<String>();
+		fields.add("a");
+		data1.put("a", "2");
+		// Test updateData()
+		appDataManager.updatePersonData("user1", null, null, fields, data1);
+		data2 = appDataManager.getPersonData("user1", null);
+		Assert.assertNotNull(data2);
+		Assert.assertEquals(data1.size(), data2.size());
+		Assert.assertTrue(data2.containsKey("albumName"));
+		Assert.assertTrue(data2.containsValue("USTrip"));
+		Assert.assertNotNull(data2.get("albumName"));
+		Assert.assertEquals("2", data2.get("a"));
+		Assert.assertTrue(data2.containsKey("a"));
+		Assert.assertTrue(data2.containsValue("2"));
+		Assert.assertFalse(data2.containsValue("1"));
+		// Test deleteData()
+		appDataManager.deletePersonData("user1", null, fields);
+		data2 = appDataManager.getPersonData("user1", null);
+		Assert.assertFalse(data2.containsKey("a"));
+		Assert.assertFalse(data2.containsValue("2"));
+		Assert.assertEquals(1, data2.size());
+
+	}
+}

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/appdata/test/AppDataManagerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/appdata/test/AppDataManagerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/message/test/MessageManagerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/message/test/MessageManagerTestCase.java?rev=1142774&view=auto
==============================================================================
--- incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/message/test/MessageManagerTestCase.java (added)
+++ incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/message/test/MessageManagerTestCase.java Mon Jul  4 19:25:20 2011
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.social.message.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.jcr.LoginException;
+import javax.jcr.RepositoryException;
+
+import junit.framework.Assert;
+
+import org.apache.photark.services.jcr.JCRRepositoryManager;
+import org.apache.photark.social.exception.PhotArkSocialException;
+import org.apache.photark.social.message.Message;
+import org.apache.photark.social.message.MessageCollection;
+import org.apache.photark.social.message.MessageManager;
+import org.apache.photark.social.message.MessageManagerImpl;
+import org.junit.Test;
+
+public class MessageManagerTestCase {
+	@Test
+	public void testMessageManagerImpl() throws IOException,
+			PhotArkSocialException, LoginException, RepositoryException {
+		JCRRepositoryManager repositoryManager = new JCRRepositoryManager();
+		String dir = "socialtest";
+		File homeDir = File.createTempFile(dir, "");
+		if (homeDir.exists()) {
+			homeDir.delete();
+		}
+		homeDir.mkdir();
+		repositoryManager.setRepositoryHome(dir);
+		MessageManager msgManager = new MessageManagerImpl(repositoryManager);
+		// Test creating message collection
+		MessageCollection msgColl1 = new MessageCollection();
+		msgColl1.setId("INBOX");
+		msgColl1.setTitle("INBOX");
+		msgColl1.setTotalCount(10);
+		msgColl1.setLastUpdated(new Date());
+		msgManager.createMessageCollection("userm", msgColl1);
+		MessageCollection msgColl3 = new MessageCollection();
+		msgColl3.setId("OUTBOX");
+		msgColl3.setTitle("OUTBOX");
+		msgColl3.setTotalCount(2);
+		msgColl3.setLastUpdated(new Date());
+		msgManager.createMessageCollection("userm", msgColl3);
+		// Test retrieving message collection
+		List<MessageCollection> msgCollList = msgManager.getMessageCollections(
+				"userm", null, null);
+		Assert.assertNotNull(msgCollList);
+		Assert.assertEquals(2, msgCollList.size());
+		MessageCollection msgColl2 = msgCollList.get(0);
+		Assert.assertNotNull(msgColl2);
+		Assert.assertEquals(10, msgColl2.getTotalCount());
+		Assert.assertEquals("INBOX", msgColl2.getId());
+		msgColl2 = msgCollList.get(1);
+		Assert.assertNotNull(msgColl2);
+		Assert.assertEquals("OUTBOX", msgColl2.getId());
+		Assert.assertEquals(msgColl3.getLastUpdated(),
+				msgColl2.getLastUpdated());
+		// Test deleting message collection
+		msgManager.deleteMessageCollection("userm", "OUTBOX");
+		msgCollList = msgManager.getMessageCollections("userm", null, null);
+		Assert.assertNotNull(msgCollList);
+		Assert.assertEquals(1, msgCollList.size());
+		msgColl2 = msgCollList.get(0);
+		Assert.assertNotNull(msgColl2);
+		Assert.assertEquals("INBOX", msgColl2.getId());
+
+		// Test creating & retrieving messages
+		Message msg1 = new Message();
+		msg1.setBody("test message 1");
+		msg1.setTitle("Title");
+		msg1.setStatus("pending");
+		msgManager.createMessage("userm", "INBOX", msg1);
+		List<String> msgIds = new ArrayList<String>();
+		msgIds.add("0");
+		List<Message> msgList = msgManager.getMessages("userm", "INBOX", null,
+				msgIds, null);
+		Assert.assertNotNull(msgList);
+		Assert.assertEquals(msgIds.size(), msgList.size());
+		Message msg2 = msgList.get(0);
+		Assert.assertNotNull(msg2);
+		Assert.assertEquals(msg1.getTitle(), msg2.getTitle());
+		Assert.assertEquals(msg1.getBody(), msg2.getBody());
+		// Test deleting messages
+		msgManager.deleteMessages("userm", "INBOX", msgIds);
+		msgList = msgManager.getMessages("userm", "INBOX", null, msgIds, null);
+		Assert.assertNotNull(msgList);
+		Assert.assertEquals(0, msgList.size());
+
+	}
+}

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/message/test/MessageManagerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/message/test/MessageManagerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/PersonManagerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/PersonManagerTestCase.java?rev=1142774&view=auto
==============================================================================
--- incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/PersonManagerTestCase.java (added)
+++ incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/PersonManagerTestCase.java Mon Jul  4 19:25:20 2011
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.social.person.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import javax.jcr.LoginException;
+import javax.jcr.RepositoryException;
+
+import org.apache.photark.services.jcr.JCRRepositoryManager;
+import org.apache.photark.social.exception.PhotArkSocialException;
+import org.apache.photark.social.person.Person;
+import org.apache.photark.social.person.PersonManager;
+import org.apache.photark.social.person.PersonManagerImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PersonManagerTestCase {
+	@Test
+	public void testPersonManagerImpl() throws IOException,
+			PhotArkSocialException, LoginException, RepositoryException {
+		JCRRepositoryManager repositoryManager = new JCRRepositoryManager();
+		String dir = "socialtest";
+		File homeDir = File.createTempFile(dir, "");
+		homeDir.delete();
+		homeDir.mkdir();
+		repositoryManager.setRepositoryHome(dir);
+		PersonManager pm = new PersonManagerImpl(repositoryManager);
+		Person person = new Person();
+		person.setId("testuser1");
+		person.setDisplayName("TestUser1");
+		person.setFirstName("test");
+		person.setLastName("user1");
+		Calendar calendar = new GregorianCalendar(10, 9, 10);
+		person.setBirthday(calendar.getTime());
+		List<String> activities = new ArrayList<String>();
+		activities.add("Movies");
+		activities.add("Cricket");
+		person.setActivities(activities);
+		pm.savePerson("testuser1", person);
+		Person person2 = pm.getPerson("testuser1");
+		Assert.assertNotNull(person2);
+		Assert.assertEquals("testuser1", person2.getId());
+		Assert.assertEquals(person.getDisplayName(), person2.getDisplayName());
+		Assert.assertNotNull(person2.getBirthday());
+		Assert.assertEquals(calendar.getTime(), person2.getBirthday());
+		Assert.assertNotNull(person2.getActivities());
+		Assert.assertEquals("Movies", person2.getActivities().get(0));
+		pm.removePerson("testuser1");
+		person2 = pm.getPerson("testuser1");
+		Assert.assertNull(person2);
+
+	}
+}

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/PersonManagerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/PersonManagerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/RelationshipManagerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/RelationshipManagerTestCase.java?rev=1142774&view=auto
==============================================================================
--- incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/RelationshipManagerTestCase.java (added)
+++ incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/RelationshipManagerTestCase.java Mon Jul  4 19:25:20 2011
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.social.person.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.photark.services.jcr.JCRRepositoryManager;
+import org.apache.photark.social.PhotArkSocialConstants;
+import org.apache.photark.social.exception.PhotArkSocialException;
+import org.apache.photark.social.person.Person;
+import org.apache.photark.social.person.PersonManager;
+import org.apache.photark.social.person.PersonManagerImpl;
+import org.apache.photark.social.person.relationship.RelationshipManager;
+import org.apache.photark.social.person.relationship.RelationshipManagerImpl;
+import org.junit.Test;
+
+public class RelationshipManagerTestCase {
+	@Test
+	public void testRelationshipManager() throws IOException,
+			PhotArkSocialException {
+		JCRRepositoryManager repositoryManager = new JCRRepositoryManager();
+		String dir = "socialtest";
+		File homeDir = new File(dir);
+		if (homeDir.exists()) {
+			deleteDir(homeDir);
+		}
+		homeDir.mkdir();
+		repositoryManager.setRepositoryHome(dir);
+		RelationshipManager relationshipManager = new RelationshipManagerImpl();
+		PersonManager pm = new PersonManagerImpl(repositoryManager);
+		Person person = new Person();
+		person.setId("user1");
+		person.setDisplayName("TestUser1");
+		person.setFirstName("test");
+		person.setLastName("user1");
+		pm.savePerson("user1", person);
+		Person person2 = new Person();
+		person2.setId("user2");
+		person2.setDisplayName("TestUser2");
+		person2.setFirstName("test");
+		person2.setLastName("user2");
+		pm.savePerson("user2", person2);
+		Person person3 = new Person();
+		person3.setId("user3");
+		person3.setDisplayName("TestUser3");
+		person3.setFirstName("test");
+		person3.setLastName("user3");
+		pm.savePerson("user3", person3);
+		// Test acceptReationship()
+		relationshipManager.requestRelationship("user2", "user1");
+		// Test getPendingRelationship()
+		Assert.assertEquals(
+				1,
+				relationshipManager.getPendingRelationshipRequests("user1").length);
+		Assert.assertEquals("user2",
+				relationshipManager.getPendingRelationshipRequests("user1")[0]);
+		relationshipManager.acceptRelationshipRequest("user1", "user2");
+		// Test getRealtionshipList()
+		Assert.assertNotNull(relationshipManager.getRelationshipList("user1"));
+		Assert.assertEquals(1,
+				relationshipManager.getRelationshipList("user1").length);
+		Assert.assertEquals("user2",
+				relationshipManager.getRelationshipList("user1")[0]);
+		// Test getRelationshipStatus()
+		Assert.assertEquals(PhotArkSocialConstants.RELATIONSHIP_FRIEND,
+				relationshipManager.getRelationshipStatus("user1", "user2"));
+		// Test requestRelationship()
+		relationshipManager.requestRelationship("user1", "user3");
+		Assert.assertEquals(
+				PhotArkSocialConstants.RELATIONSHIP_REQUEST_PENDING,
+				relationshipManager.getRelationshipStatus("user1", "user3"));
+		Assert.assertEquals(
+				PhotArkSocialConstants.RELATIONSHIP_REQUEST_RECEIVED,
+				relationshipManager.getRelationshipStatus("user3", "user1"));
+		Assert.assertEquals(PhotArkSocialConstants.RELATIONSHIP_NONE,
+				relationshipManager.getRelationshipStatus("user2", "user3"));
+		// Test ignoreRelationship()
+		relationshipManager.ignoreRelationship("user3", "user1");
+		Assert.assertEquals(PhotArkSocialConstants.RELATIONSHIP_NONE,
+				relationshipManager.getRelationshipStatus("user3", "user1"));
+		// Test removeRelationship()
+		relationshipManager.removeRelationship("user1", "user2");
+		Assert.assertEquals(PhotArkSocialConstants.RELATIONSHIP_NONE,
+				relationshipManager.getRelationshipStatus("user1", "user2"));
+
+	}
+
+	/* If the repository home directory already exists, delete it */
+	private static boolean deleteDir(File dir) {
+
+		if (dir.isDirectory()) {
+			String[] children = dir.list();
+			for (int i = 0; i < children.length; i++) {
+				boolean success = deleteDir(new File(dir, children[i]));
+				if (!success) {
+					return false;
+				}
+			}
+		}
+		// The directory is now empty so now it can be smoked
+		return dir.delete();
+	}
+}

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/RelationshipManagerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/photark/branches/photark-rest/photark-social/src/test/java/org/apache/photark/social/person/test/RelationshipManagerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date