	<%@page import="java.io.*,com.plumtree.remote.prc.IRemoteSession, com.plumtree.remote.prc.RemoteSessionFactory, com.plumtree.remote.prc.collaboration.*,com.plumtree.remote.prc.collaboration.project.*,com.plumtree.remote.prc.collaboration.discussion.*, com.plumtree.remote.portlet.*,java.util.*,java.text.*" %>

	<%!

		//key for discussion
		public static final String SESSION_DISCUSSION_KEY = "discussionID";

   //key for discussion message
		public static final String SESSION_DISCUSSION_MESSAGE_KEY = "discussionMessageID";
		
		//key for parameter map
		public static final String SESSION_PARAMETER_MAP = "parameterMap";
		
		public static final String SESSION_PROJECT_KEY = "edk_sample_project";
    public static final String PROJECT_NAME = "EDK Sample Project";
		

	//gets the project manager
	private IProjectManager getProjectManager(HttpServletRequest req, HttpServletResponse res, JspWriter pout) throws Exception 
	{
		IProjectManager projectManager = null;
		IPortletContext portletContext = PortletContextFactory.createPortletContext(req, res);
		IPortletRequest portletRequest = portletContext.getRequest();
		String loginToken = portletRequest.getLoginToken();
		if (null == loginToken)
		{
			pout.println("Unable to retrieve the login token. Confirm that the login token has been checked in the Advanced Settings page of the Web Service.");
		}

		//get the remote session
		com.plumtree.remote.prc.IRemoteSession portalSession = portletContext.getRemotePortalSession();

		//get a collab factory and a project manager
		ICollaborationFactory collabFactory = portalSession.getCollaborationFactory();
		projectManager = collabFactory.getProjectManager();

		return projectManager;
	}		

		//gets the discussion manager
		public  IDiscussionManager getDiscussionManager( HttpServletRequest req, HttpServletResponse res) throws Exception  
		{
			IDiscussionManager discussionManager = null;
			IPortletContext portletContext = PortletContextFactory.createPortletContext(req, res);
			IPortletRequest portletRequest = portletContext.getRequest();
			String loginToken = portletRequest.getLoginToken();
			if (null == loginToken)
			{
				res.setContentType("text/html");
				PrintWriter out = res.getWriter();
				out.println("Unable to retrieve the login token. Confirm that the login token has been checked in the Advanced Settings page of the Web Service.");
			}

			//get the remote session
     IRemoteSession portalSession = portletContext.getRemotePortalSession();

			//get a collab factory and a discussion manager
			ICollaborationFactory collabFactory = portalSession.getCollaborationFactory();
			discussionManager = collabFactory.getDiscussionManager();

			return discussionManager;
		}

	
		
		//gets a value from the parameter map
		public String getParameter(Map parameterMap, String key)
		{
		   String value = null;
		   if (null != parameterMap)
		   {
		      String[] values = (String[]) parameterMap.get(key);
		      if (null != values && values.length > 0)
		      {
		        value = values[0];
		      }
		   }
		   return value;
		}
		
		%>