1 package net.sourceforge.blogentis.slide;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import java.util.Hashtable;
26 import java.util.Vector;
27
28 import javax.transaction.xa.XAException;
29 import javax.transaction.xa.XAResource;
30 import javax.transaction.xa.Xid;
31
32 import org.apache.commons.logging.Log;
33 import org.apache.commons.logging.LogFactory;
34 import org.apache.slide.common.AbstractXAService;
35 import org.apache.slide.common.ServiceAccessException;
36 import org.apache.slide.common.ServiceConnectionFailedException;
37 import org.apache.slide.common.ServiceDisconnectionFailedException;
38 import org.apache.slide.common.ServiceParameterErrorException;
39 import org.apache.slide.common.ServiceParameterMissingException;
40 import org.apache.slide.common.ServiceResetFailedException;
41 import org.apache.slide.common.Uri;
42 import org.apache.slide.common.UriPath;
43 import org.apache.slide.store.NodeStore;
44 import org.apache.slide.structure.ObjectAlreadyExistsException;
45 import org.apache.slide.structure.ObjectNode;
46 import org.apache.slide.structure.ObjectNotFoundException;
47 import org.apache.slide.structure.SubjectNode;
48 import org.apache.turbine.services.security.TurbineSecurity;
49 import org.apache.turbine.util.security.DataBackendException;
50 import org.apache.turbine.util.security.UnknownEntityException;
51
52 /***
53 * @author abas
54 */
55 public class UserAdapterStore
56 extends AbstractXAService
57 implements NodeStore {
58 private static final Log log = LogFactory.getLog(UserAdapterStore.class);
59
60 public void setParameters(Hashtable parameters)
61 throws ServiceParameterErrorException,
62 ServiceParameterMissingException {}
63
64 public void connect()
65 throws ServiceConnectionFailedException {}
66
67 public void disconnect()
68 throws ServiceDisconnectionFailedException {}
69
70 public void reset()
71 throws ServiceResetFailedException {}
72
73 public boolean isConnected()
74 throws ServiceAccessException {
75 return true;
76 }
77
78 public int getTransactionTimeout()
79 throws XAException {
80 return 0;
81 }
82
83 public boolean setTransactionTimeout(int arg0)
84 throws XAException {
85 return false;
86 }
87
88 public boolean isSameRM(XAResource arg0)
89 throws XAException {
90 return false;
91 }
92
93 public Xid[] recover(int arg0)
94 throws XAException {
95 return null;
96 }
97
98 public int prepare(Xid arg0)
99 throws XAException {
100 return 0;
101 }
102
103 public void forget(Xid arg0)
104 throws XAException {}
105
106 public void rollback(Xid arg0)
107 throws XAException {}
108
109 public void end(Xid arg0, int arg1)
110 throws XAException {}
111
112 public void start(Xid arg0, int arg1)
113 throws XAException {}
114
115 public void commit(Xid arg0, boolean arg1)
116 throws XAException {}
117
118 public ObjectNode retrieveObject(Uri uri)
119 throws ServiceAccessException, ObjectNotFoundException {
120 if (log.isDebugEnabled())
121 log.debug("Looking for user path " + uri.toString());
122 if (uri.isStoreRoot())
123 return getUserList(uri);
124
125 try {
126 TurbineSecurity.getUser(new UriPath(uri.toString()).lastSegment());
127 } catch (DataBackendException e) {
128 throw new ServiceAccessException(this, e);
129 } catch (UnknownEntityException e) {
130 throw new ObjectNotFoundException(uri);
131 }
132 return new SubjectNode(uri.toString(), new Vector(), new Vector());
133 }
134
135 private ObjectNode getUserList(Uri uri) {
136 return new SubjectNode(uri.toString(), new Vector(), new Vector());
137 }
138
139 public void storeObject(Uri uri, ObjectNode object)
140 throws ServiceAccessException, ObjectNotFoundException {}
141
142 public void createObject(Uri uri, ObjectNode object)
143 throws ServiceAccessException, ObjectAlreadyExistsException {}
144
145 public void removeObject(Uri uri, ObjectNode object)
146 throws ServiceAccessException, ObjectNotFoundException {}
147 }