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.commons.enums.CmisVersion;
29 import org.apache.chemistry.opencmis.commons.server.CallContext;
30 import org.apache.chemistry.opencmis.commons.server.MutableCallContext;
31
32
33
34
35 public class LocalCallContext implements MutableCallContext {
36
37 private final Map<String, Object> contextMap = new HashMap<String, Object>();
38
39 public LocalCallContext(String repositoryId, String user, String password) {
40 contextMap.put(REPOSITORY_ID, repositoryId);
41 contextMap.put(USERNAME, user);
42 contextMap.put(PASSWORD, password);
43 }
44
45 public LocalCallContext(String repositoryId, String user, String password, String language, String country) {
46 this(repositoryId, user, password);
47
48 if (language != null) {
49 put(LOCALE_ISO639_LANGUAGE, language);
50 put(LOCALE, language);
51 }
52
53 if (country != null) {
54 put(LOCALE_ISO3166_COUNTRY, country);
55 put(LOCALE, language + "-" + country);
56 }
57 }
58
59 @Override
60 public String getBinding() {
61 return BINDING_LOCAL;
62 }
63
64 @Override
65 public Object get(String key) {
66 return contextMap.get(key);
67 }
68
69 @Override
70 public CmisVersion getCmisVersion() {
71 return CmisVersion.CMIS_1_1;
72 }
73
74 @Override
75 public String getRepositoryId() {
76 return (String) get(REPOSITORY_ID);
77 }
78
79 @Override
80 public String getUsername() {
81 return (String) get(USERNAME);
82 }
83
84 @Override
85 public String getPassword() {
86 return (String) get(PASSWORD);
87 }
88
89 @Override
90 public String getLocale() {
91 return (String) get(LOCALE);
92 }
93
94 @Override
95 public BigInteger getOffset() {
96 return (BigInteger) get(OFFSET);
97 }
98
99 @Override
100 public BigInteger getLength() {
101 return (BigInteger) get(LENGTH);
102 }
103
104 @Override
105 public boolean isObjectInfoRequired() {
106 return false;
107 }
108
109 @Override
110 public File getTempDirectory() {
111 return null;
112 }
113
114 @Override
115 public boolean encryptTempFiles() {
116 return false;
117 }
118
119 @Override
120 public int getMemoryThreshold() {
121 return 0;
122 }
123
124 @Override
125 public long getMaxContentSize() {
126 return -1;
127 }
128
129 @Override
130 public void put(String key, Object value) {
131 contextMap.put(key, value);
132 }
133
134 @Override
135 public Object remove(String key) {
136 return contextMap.remove(key);
137 }
138 }