AquaLogic User Interaction Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Creating Collaboration Projects Using IDK Remote APIs

To create a new Collaboration project from a remote application, use the IProjectManager interface in the IDK.

The IProjectManager interface provides a factory method for creating new projects that takes in a name and description, and returns an IProject object with a corresponding object ID and associated properties. The sample code below provides a simple example of creating a new project.
The IProjectManager interface also provides methods for copying content and metadata from existing collaboration projects. Prior to the call, both the source and target project must be a persisted IProject, and both projects must have a set start date. The user must be a Project Leader and have READ access in both the source and target projects.
Method Description Copies
copyProjectContent Copies all project content from the source project to the target project. The copied project will be stored permanently. Security is mapped isomorphically from the source project to the target project; if the ProjectMember role in the source project has access level 1 on object X, and object X is copied to object Y, then the ProjectMember role in the target project will have access level 1 on object Y.
  • All document folders
  • All documents
  • All discussions (not messages)
  • All task lists
  • All tasks
copyProjectMetadata Copies the basic metadata and all IRole objects from the source project to the target project. The copied project will be stored permanently. No store method is required. The old roles in the target project will be overwritten with the copied roles from the source project.
  • Project description
  • All IRole objects
  • Start date information (if the target project's start date is not set and the source project's start date is available)
For details on these methods, see the IDK API documentation.
Note: Before writing any code, you must prepare a custom development project that references the standard IDK library (idk.jar/idk.dll).
The code samples below implement the following steps:
  1. Initiate a PRC session. This example retrieves a login token using IPortletContext; you can also use IRemoteSession. (For details, see Initiating a PRC Session to Use IDK Remote APIs.)
  2. Get the Project Manager.
  3. Create a project with name and description.
  4. Get the ID for the new project.

Java

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

<%
//get 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;

}

//create a project and print out the project id
name = (null == name) ? "ExampleProject" : name;
description = (null == description) ? "ExampleProjectDescription" : description;

//create the project
IProjectManager projectManager = getProjectManager(request, response, out);
IProject project = projectManager.createProject(name, description);

//to set additional properties, you must call store() after making changes
//for example:
/*
project.setStatus(ProjectStatus.NOT_STARTED);
project.setStartDate(new Date());
*/

//call store before asking for the ID.
project.store();

//get the new project ID
project.getID()

%>

.NET (C# - Project Page)

<%@ Page language="c#" Codebehind="ProjectSample.aspx.cs" AutoEventWireup="false"
Inherits="WebProjectSample.ProjectSample" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<body>

//create a project and print out the project id
<%
{
	name = (null == name) ? "ExampleProject" : name;
	description = (null == description) ? "ExampleProjectDescription" : description;

	//create the project
	Plumtree.Remote.PRC.Collaboration.Project.IProjectManager projectManager = GetProjectManager(Request, Response);
	Plumtree.Remote.PRC.Collaboration.Project.IProject project =
	projectManager.CreateProject(name, description);

	//to set additional properties, you must call store() after making changes
	//for example:
	/*
	project.Status = ProjectStatus.NotStarted;
	project.StartDate = new Date();
	*/

	//call store before asking for the id.
	project.Store();
}
%>

<table>
	<tr>
		<td>
		<%
		Response.Write("ID of newly created project is " + project.ID);
		%>
		</td>
	</tr>
</table>
</body>
</html>

.NET (C# - Code-Behind Page)

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Plumtree.Remote.PRC;
using Plumtree.Remote.PRC.Collaboration;
using Plumtree.Remote.PRC.Collaboration.Project;
using Plumtree.Remote.Portlet;

namespace WebProjectSample
{

	public class ProjectSample: System.Web.UI.Page
	{
		//name and description for new project
		public String name = "ExampleProject";
		public String description = "ExampleProjectDescription";

		//get the Project Manager
		public IProjectManager GetProjectManager(HttpRequest req, HttpResponse res)
		{

			IProjectManager projectManager = null;
			IPortletContext portletContext = PortletContextFactory.CreatePortletContext(req, res);
			IPortletRequest portletRequest = portletContext.GetRequest();
			String loginToken = portletRequest.GetLoginToken();
			if (null == loginToken)
			{
				res.Write("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
			Plumtree.Remote.PRC.IRemoteSession portalSession = portletContext.GetRemotePortalSession();

			//get a collab factory and a project manager
			ICollaborationFactory collabFactory = portalSession.GetCollaborationFactory();
			projectManager = collabFactory.GetProjectManager();
			return projectManager;
		}
	}
}

.NET (VB - Project Page)

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ProjectSample.aspx.vb"
Inherits="TestProjectVB.ProjectSample"%>
<!DOCTYPE HTML PUBLIC "-'W3C'DTD HTML 4.0 Transitional'EN" >
<html>
<body>
<%

	'create a project and print out the project id
	name = "ExampleProject"
	description = "ExampleProjectDescription"

	'create the project
	dim projectManager as Plumtree.Remote.PRC.Collaboration.Project.IProjectManager =
	GetProjectManager(Request, Response)
	dim project as Plumtree.Remote.PRC.Collaboration.Project.IProject = projectManager.CreateProject(name, description)

	'to set additional properties, you must call store() after making changes
	'for example:
	'project.Status = ProjectStatus.NotStarted
	'project.StartDate = new Date()

	'call store before asking for the id.
	project.Store()

%>

<table>
	<tr>
		<td>
		<%
			Response.Write("ID of newly created project is " + Cstr(project.ID))
		%>
		</td>
	</tr>
</table>
</body>
</html>

.NET (VB - Code-Behind Page)

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Plumtree.Remote.PRC
Imports Plumtree.Remote.PRC.Collaboration
Imports Plumtree.Remote.PRC.Collaboration.Project
Imports Plumtree.Remote.Portlet 

Public Class ProjectSample
Inherits System.Web.UI.Page

	'get the project manager
	Public Function GetProjectManager(ByVal req As HttpRequest, ByVal res As HttpResponse)
	As IProjectManager
	Dim projectManager As IProjectManager = Nothing
	Dim portletContext As IPortletContext = PortletContextFactory.CreatePortletContext(req, res)
	Dim portletRequest As IPortletRequest = portletContext.GetRequest()
	Dim loginToken As String = portletRequest.GetLoginToken()
	If loginToken Is Nothing Then
		res.Write("Unable to retrieve the login token. Confirm that the login token has been checked in the Advanced Settings page of the Web Service.")
	End If

	'get the remote session
	Dim portalSession As Plumtree.Remote.PRC.IRemoteSession = portletContext.GetRemotePortalSession()

	'get a collab factory and a project manager
	Dim collabFactory As ICollaborationFactory = portalSession.GetCollaborationFactory()
	projectManager = collabFactory.GetProjectManager()

	Return projectManager

End Function

End Class
The IProjectManager also allows you to remove projects. The removeProject method takes in an IProject object and removes the associated project from the system.
Note: This action cannot be undone. No call to store is required.

  Back to Top      Previous Next