cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve room’s info from a customer's class for Room UI Command

Former Member
0 Kudos

Hi, everyone

I have developed a class for our own UI Command in a room on the basis of the example code SimpleOneStepScreenflow at https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/kmc/implementing flexible ui one-step-screenflow.article.

This class can be executed by our own label that has been added in the Hover Menu Encapsulating Command. The hover menu is attached to each document that has been uploaded under directory Documents in a collaboration room.

Now I need to implement retrieving the current room’s info, like room’s name, room’s owner etc,

How can I get RID object for the current room?

Any hint will be appreciated.

Best regards.

Wang

Message was edited by: Yantong Wang

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

I'm not sure (and have no time to check out) if there is an officially-to-be-used API to get back the way from a room's folder ID to the room ID. At least, you could do it "manually":

Under room_structures/<RoomRID> you'll find links to the corresponding folders under room_extensions/cm_stores/documents/workspaces. From your command you will have some Resource RID path like /room_extensions/cm_stores/documents/workspaces/48a118fe-0101-0010-5780-8d175b3669a6/...; searching through the first repository given above for a link pointing to such a folder would return the corresponding room (from the room repositories, the rooms are linked to the folders, but not back from the folders to the rooms.

UPDATE: Just saw that on the folder /room_extensions/cm_stores/documents/workspaces/48a118fe-0101-0010-5780-8d175b3669a6 you'll find a property consumer_id, having the room RID (and beneath this, the consumer_name with the room DisplayName). Sometimes things are relatively easy

Hope it helps

Detlev

PS: The question isn't marked as question, did yoe de-mark it or is it a system failure?!

Former Member
0 Kudos

Hi, Detlev, thanks for your quick reply. It is very interesting. I am going to try and get back with reward point.

Best regards.

Wang

P.S. I did not de-mark anything.

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

> I am going to try and get back with reward point.

You won't be able to, unless you edit your original posting - there you should be able to switch on/off the question-flag.

Best regards

Detlev

Former Member
0 Kudos

Hi Detlev, I have tried with your solution but I am not as lucky as you are.

On our system EP 6.0 Sp2 P31 I can find the target document log.html in a room under room_extensions>cm_stores>comname>comdocuments>workspaces>608eed7b-0401-0010-d6b0-fd2f1e9bece6, ID is log.html

Physically it is a folder called Documents under the workspaces, its ID is

608eed7b-0401-0010-d6b0-fd2f1e9bece6, All the documents in this room are stored under it.

The room's path is room, ID is 608eed7b-0401-0010-d6b0-fd2f1e9bece6

You said find a property consumer_id, having the room RID.

I do not get it, could you please explain ?

I can not find where it is.

From those two RID objects how can I get the room's RID?

Thanks for reply.

By the way probably it is my fault to de select the question, I own you at least 6 points.

Best regards.

Wang

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

> under

> room_extensions>cm_stores>comname>comdocuments>workspaces>608eed7b-0401-0010-d6b0-fd2f1e9bece6

Choose this folder, choose Folder -> Details, choose Settings -> Properties, choose Miscellaneous, look at consumer_id => This is the Room RID.

Technically, it is the following PropertyName:

new PropertyName("http://sap.com/xmlns/collaboration/rooms/structure", "consumer_id")

> The room's path is room,

> ID is 608eed7b-0401-0010-d6b0-fd2f1e9bece6

The room's ID is the same ID as the ID of the doc's folder?! Maybe I misunderstood you?!

Hope it helps

Detlev

PS: About the points: Within the thread, look at your original post, choose the pencil picture to edit it, then mark the question as question. This should do it...

Former Member
0 Kudos

Hi Detlev, I find out. Now I can move on my manual work. Thank you so much for your great discovery.

Best regards.

Wang

Former Member
0 Kudos

Hi Detlev, I can get the folder's info in the Details like

Name: Documents (not long digit numbers on our system)

System -> Type: http://sap.com/xmlns/collaboration/rooms/structure/workspace

Access Links -> Path:

room_extensions > cm_stores > comnane > comdocuments > workspaces

ID:a0a8ed7b-0401-0010-82ae-da44c0b5c9b8

How to implement retrieving folder's consumer_id under Miscellaneous by the info above like ID and path?

Thanks for reply.

Best regards.

Wang

Former Member
0 Kudos

Hi, probably I need to retrieve the comsumer_name by starting from the path room_extensions/cm_stores/comnane/comdocuments/ workspaces/a0a8ed7b-0401-0010-82ae-da44c0b5c9b8, then RID or Property ? I have no idea, help please.

Best regards.

Wang

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

> I can get the folder's info in the Details like

To be concrete - what Tab's are offered? There should be: System | Custom | Rendering | Miscellaneous | Access Links. consumer_id and _name should be found under Miscellaneous.

Even if not, for whatever reason - programatically, you should be able to access this property by

RID rid = RID.getRID("/room_extensions/cm_stores/comnane/comdocuments/ workspaces/a0a8ed7b-0401-0010-82ae-da44c0b5c9b8");
IResource res = ResourceFactory.getInstance().getResource(rid, someResCtx);
IProperty prop = res.getProperty(new PropertyName("http://sap.com/xmlns/collaboration/rooms/structure", "consumer_id"));
String roomRID = prop.getStringValue();

This should work; give it a try, and if it doesn't work, check carefully what's the problem.

Some additional remark: I'm watching all these things on SP32, but I would be astonished, if it behaves different on SP31.

Hope it helps

Detlev

Former Member
0 Kudos

Hi, Detlev, thanks a lot for reply. The major problem for me is I can not define object of IResourceContext someResCtx = new ResourceContext(user) in this case. To my knowledge in AbstractPortalComponent or Dynpage class,

It can be implemented like

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

IUser user = (IUser) request.getUser().getUser();

IResourceContext someResCtx = new ResourceContext(user)

But in this case how can I define the IUser user? Any hint please ? Thanks.

Best regards.

Wang

Former Member
0 Kudos

Hi Wang,

i actually stole this idea from Detlev, but you can do the following:


private String SERVICE_USER = "ice_service";
private String DIR 		  = "/documents/";	

IResource res = null;
try {
      resFactory = ResourceFactory.getInstance();
} catch (Exception e) {
      e.printStackTrace();
}

Object serviceContext = null;
try {
serviceContext = AccessController.doPrivileged(new PrivilegedExceptionAction(){
public Object run() throws WcmException{
return ResourceFactory.getInstance().getServiceContext(SERVICE_USER);
	}
}
);
} catch (PrivilegedActionException e) {
throw new ResourceException("could not instantiate the system user");
}
IResourceContext resContext = (IResourceContext) serviceContext;
RID rid = RID.getRID(dir);
res = resFactory.getResource(rid, resContext);

this will get you the IResource.

regards,

ds

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

a) From within which method/class are you trying to access these things?

b) If you have an IResource object at hand (for example on file within the folder), you can get the corresponding context directly by resource.getContext().

c) I hope that it does not even more irritation; but: It is a very nice trick to use service users (and contexts derived from them) to do things within KM programatically when you don't have the need to care about security issues (where your program just should have the right to move within KM).

This can be done as follows:

Object serviceContext = null;
try {
  serviceContext = AccessController.doPrivileged(new PrivilegedExceptionAction(){
    public Object run() throws WcmException{
      return ResourceFactory.getInstance().getServiceContext("cmadmin_service");
    }
  });
} catch (PrivilegedActionException e) {
  e.printStackTrace();
}
IResourceContext serviceResCtx = (IResourceContext) serviceContext;

Hope it helps

Detlev

Former Member
0 Kudos

Hi Dimitry and Detlev, thanks so much for your reply. I am going to try with yours.

I am working in the class SimnpleUICommand extends AbstractCommand implements ISimpleExecution, provided in the documentation mentioned above.

Before reading these reply I have tried to use the code

IRooms roomsAPI = (IRooms) ServiceFactory.getInstance().getService(IRooms.KM_SERVICE_ID);

or

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

String ss = roomsAPI.getRoomCreationInfo().toString();

in IRenderingEvent execute(IScreenflowData sfd) of class SimnpleUICommand, and did the corresponding configuration in portalapp.xml,

I thought the room's info can be retrieved because the document has been in this room. But I got com.sap.ip.collaboration.room.impl.RoomInfo@6d9199

and System Error - caused by Exception class java.lang.NullPointerException for

String ss = roomsAPI.getRoomCreationInfo().getName().toString();

Detlev , Might IRooms or IRoomInfo be the "official API" for retrieving room's info, you mentioned before ?

Best regards.

Wang

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

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

... is right.

> roomsAPI.getRoomCreationInfo

... is for creating a new room, so this is not applicable here.

> thought the room's info can be retrieved

> because the document has been in this room.

See, roomsAPI has no idea of which room you are talking if you don't pass for example the room RID...

> Might IRooms or IRoomInfo be the "official API"

> for retrieving room's info, you mentioned before ?

Yes, for details see https://media.sdn.sap.com/html/submitted_docs/nw_kmc/howto/coll/Collaboration%20Rooms%20API%20Cookbo... for example.

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev, thanks for reply.

Best regards.

Wang

Former Member
0 Kudos

Hi Detlev and Dimitry, finally with your help I got the job done. Thanks you so much for the quick reply and very effective help.

Have a nice weekend.

Best regards.

Wang

Answers (0)