Skip to Content
0
Former Member
Feb 27, 2009 at 08:52 AM

Steps for create tasks when create new room...?

32 Views

Hi,

I want create tasks when i create a new room, how can do it?

I do a project in NWDS:

package com.sap.tasjs;

import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;


//imports for User Management
import com.sap.security.api.IUser;
import com.sap.security.api.UMFactory;


//imports for Portal
import com.sapportals.portal.prt.runtime.PortalRuntime;

//imports for Collaboration Rooms
import com.sap.ip.collaboration.room.api.IRoomInfo;
import com.sap.ip.collaboration.room.api.IRooms;
//import com.sap.ip.collaboration.room.api.IRoom;
import com.sap.ip.collaboration.room.api.IRoomCategoryFactory;
import com.sap.ip.collaboration.room.api.IRoomCategory;
import com.sap.ip.collaboration.room.api.template.IRoomRole;
import com.sap.ip.collaboration.room.api.template.ITemplate;
import com.sap.ip.collaboration.room.api.types.RoomPrivacyType;



public class test extends AbstractPortalComponent
{
IRoomInfo roomInfo; 

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {



try {


String templateName = "test";
String roleName1 = "Admin";
String roleName2 = "Member";



IRooms roomsAPI = (IRooms) PortalRuntime.getRuntimeResources().getService(IRooms.PORTAL_SERVICE_ID); 


IRoomCategoryFactory categoryName = roomsAPI.getRoomCategoryFactory();
IRoomCategory[] categoryInfo= categoryName.getRoomCategories(); 


//Get Template Related Infos
ITemplate template = roomsAPI.getRoomTemplate(templateName);
IRoomRole role1= template.getRoomRole(roleName1);
IRoomRole role2= template.getRoomRole(roleName2);

//Get an empty RoomInfo object
roomInfo = roomsAPI.getRoomCreationInfo();


//Fill RoomInfo object with values
roomInfo.setName("Programme ROOM_withDoc");
roomInfo.setDescription("New Room Description");
roomInfo.setTemplateName(templateName);
roomInfo.setCategories(categoryInfo); 
roomInfo.addRoomParameter("Objectives","desc1","objective", false);
roomInfo.addRoomParameter("Start Date","desc2", "s date", false);
roomInfo.addRoomParameter("Target Date", "desc3","t date", false);
roomInfo.addRoomParameter("Initiatives", "desc4","initiatives", false);
roomInfo.addRoomParameter("Mission", "desc5", "mission", false);
roomInfo.addRoomParameter("Goal", "desc6","goal", false);





roomInfo.setPrivacy(RoomPrivacyType.DEFAULT); 


//Set User Role Assignments
IUser owner = UMFactory.getUserFactory().getUserByLogonID("vishal");
IUser owner2 = UMFactory.getUserFactory().getUserByUniqueName("aditya");
roomInfo.setOwnerId(owner.getUniqueID());
roomInfo.addUserToRole(owner.getUniqueID(), role1); 
roomInfo.addUserToRole(owner2.getUniqueID(), role2); 
//Finally Create the Room
if(roomInfo.validate())
{ 


roomsAPI.createRoom(roomInfo, false); 
response.write("/////room created sucessfully////");


//from here i want to create tasks 
} 


} catch ( Throwable e ) {
// Display exception
//response.write(roomInfo.g);
response.write("Application encountered an internal exception:" );
response.write(e.getMessage() );
e.printStackTrace( System.err );
response.write(e.toString());
//response.write(System.err);
} // catch 
}


}

Have I modify anything in teh xml? If i upload this ear project, don´t appear nothing, how can continue?

Thanks in advance,

Regards,