This project has retired. For details please refer to its
Attic page.
AbstractLocalService xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.chemistry.opencmis.client.bindings.spi.local;
22
23 import java.io.File;
24 import java.math.BigInteger;
25 import java.util.HashMap;
26 import java.util.Map;
27
28 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
29 import org.apache.chemistry.opencmis.commons.SessionParameter;
30 import org.apache.chemistry.opencmis.commons.server.CallContext;
31 import org.apache.chemistry.opencmis.commons.server.CmisService;
32 import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
33
34
35
36
37 public abstract class AbstractLocalService {
38
39 private BindingSession session;
40 private CmisServiceFactory factory;
41
42 private String user;
43 private String password;
44
45
46
47
48 protected void setSession(BindingSession session) {
49 this.session = session;
50
51 Object userObj = session.get(SessionParameter.USER);
52 user = userObj instanceof String ? userObj.toString() : null;
53
54 Object passwordObj = session.get(SessionParameter.PASSWORD);
55 password = passwordObj instanceof String ? passwordObj.toString() : null;
56 }
57
58
59
60
61 protected BindingSession getSession() {
62 return session;
63 }
64
65
66
67
68 protected void setServiceFactory(CmisServiceFactory factory) {
69 this.factory = factory;
70 }
71
72
73
74
75 protected CmisServiceFactory getServiceFactory() {
76 return factory;
77 }
78
79
80
81
82 protected CallContext createCallContext(String repositoryId) {
83 return new LocalCallContext(repositoryId, user, password);
84 }
85
86 protected CmisService getService(String repositoryId) {
87 return factory.getService(createCallContext(repositoryId));
88 }
89
90
91
92
93
94
95 static class LocalCallContext implements CallContext {
96
97 private final Map<String, Object> contextMap = new HashMap<String, Object>();
98
99 public LocalCallContext(String repositoryId, String user, String password) {
100 contextMap.put(REPOSITORY_ID, repositoryId);
101 contextMap.put(USERNAME, user);
102 contextMap.put(PASSWORD, password);
103 }
104
105 public String getBinding() {
106 return BINDING_LOCAL;
107 }
108
109 public Object get(String key) {
110 return contextMap.get(key);
111 }
112
113 public String getRepositoryId() {
114 return (String) get(REPOSITORY_ID);
115 }
116
117 public String getUsername() {
118 return (String) get(USERNAME);
119 }
120
121 public String getPassword() {
122 return (String) get(PASSWORD);
123 }
124
125 public String getLocale() {
126 return null;
127 }
128
129 public BigInteger getOffset() {
130 return (BigInteger) get(OFFSET);
131 }
132
133 public BigInteger getLength() {
134 return (BigInteger) get(LENGTH);
135 }
136
137 public boolean isObjectInfoRequired() {
138 return false;
139 }
140
141 public File getTempDirectory() {
142 return null;
143 }
144
145 public int getMemoryThreshold() {
146 return 0;
147 }
148 }
149 }