01: /*
02: * DPWSRPRoleContext.java
03: *
04: * Created on March 10, 2005, 12:18 PM
05: */
06:
07: package com.sun.portal.wsrp.producer.portletmanagement.impl;
08:
09: import com.sun.portal.desktop.context.DPPropertiesContext;
10: import com.sun.portal.desktop.context.DSAMEAdminDPContext;
11: import com.sun.portal.desktop.dp.DPError;
12: import com.sun.portal.desktop.dp.xml.XMLDPFactory;
13: import com.sun.portal.providers.context.ProviderContext;
14:
15: import com.sun.portal.wsrp.producer.ISConnection;
16: import com.sun.portal.wsrp.producer.ProducerException;
17: import com.sun.portal.wsrp.producer.ProducerDN;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21: import java.util.HashMap;
22:
23: import javax.servlet.http.HttpServletRequest;
24:
25: /**
26: *
27: * @author Rajesh T
28: */
29: public class DPWSRPRoleContext extends DPPropertiesContext {
30:
31: private String roleDN = null;
32: private DSAMEAdminDPContext dpContext = null;
33:
34: public DPWSRPRoleContext(String roleDN, HttpServletRequest req)
35: throws ProducerException {
36: this .roleDN = roleDN;
37: init(req);
38: }
39:
40: public synchronized void init(HttpServletRequest req) {
41: try {
42: dpContext = new DSAMEAdminDPContext();
43: dpContext.init(req, ISConnection.getAdminToken());
44: loadDP();
45: } catch (DPError e) {
46: dpRoot = null;
47: } catch (ProducerException pe) {
48: dpRoot = null;
49: }
50: }
51:
52: public void store() {
53: if (!dpRoot.isDirty()) {
54: // don't bother to store it if the display profile hasn't changed
55: return;
56: }
57:
58: dpRoot.setDirty(false);
59: StringBuffer buff = new StringBuffer(100);
60: dpRoot.toXML(buff, 0);
61: String dpText = buff.toString();
62: dpContext.storeDPDocumentByDN(roleDN, dpText);
63:
64: // FIXME: need to log this write operation.
65: }
66:
67: public synchronized void refresh() {
68: loadDP();
69: dpChannels.clear();
70: properties.clear();
71: channelLists.clear();
72: }
73:
74: private void loadDP() throws DPError {
75: XMLDPFactory dpFactory = XMLDPFactory.getInstance();
76: dpRoot = dpFactory.createRoot(dpContext, roleDN, new HashMap());
77: }
78: }
|