001
014
015 package com.liferay.portal.repository.cmis;
016
017 import com.liferay.portal.InvalidRepositoryException;
018 import com.liferay.portal.kernel.exception.PortalException;
019 import com.liferay.portal.kernel.repository.cmis.CMISRepositoryHandler;
020 import com.liferay.portal.kernel.repository.cmis.Session;
021 import com.liferay.portal.kernel.util.LocaleUtil;
022 import com.liferay.portal.kernel.util.UnicodeProperties;
023 import com.liferay.portal.security.auth.PrincipalThreadLocal;
024
025 import java.util.HashMap;
026 import java.util.Locale;
027 import java.util.Map;
028
029 import org.apache.chemistry.opencmis.commons.SessionParameter;
030 import org.apache.chemistry.opencmis.commons.enums.BindingType;
031
032
035 public class CMISWebServicesRepository extends CMISRepositoryHandler {
036
037 @Override
038 public Session getSession() throws PortalException {
039 Map<String, String> parameters = new HashMap<String, String>();
040
041 parameters.put(
042 SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());
043 parameters.put(SessionParameter.COMPRESSION, Boolean.TRUE.toString());
044
045 Locale locale = LocaleUtil.getSiteDefault();
046
047 parameters.put(
048 SessionParameter.LOCALE_ISO3166_COUNTRY, locale.getCountry());
049 parameters.put(
050 SessionParameter.LOCALE_ISO639_LANGUAGE, locale.getLanguage());
051
052 String password = PrincipalThreadLocal.getPassword();
053
054 parameters.put(SessionParameter.PASSWORD, password);
055
056 String login = getLogin();
057
058 parameters.put(SessionParameter.USER, login);
059
060 parameters.put(
061 SessionParameter.WEBSERVICES_ACL_SERVICE,
062 getTypeSettingsValue(_WEBSERVICES_ACL_SERVICE));
063 parameters.put(
064 SessionParameter.WEBSERVICES_DISCOVERY_SERVICE,
065 getTypeSettingsValue(_WEBSERVICES_DISCOVERY_SERVICE));
066 parameters.put(
067 SessionParameter.WEBSERVICES_MULTIFILING_SERVICE,
068 getTypeSettingsValue(_WEBSERVICES_MULTIFILING_SERVICE));
069 parameters.put(
070 SessionParameter.WEBSERVICES_NAVIGATION_SERVICE,
071 getTypeSettingsValue(_WEBSERVICES_NAVIGATION_SERVICE));
072 parameters.put(
073 SessionParameter.WEBSERVICES_OBJECT_SERVICE,
074 getTypeSettingsValue(_WEBSERVICES_OBJECT_SERVICE));
075 parameters.put(
076 SessionParameter.WEBSERVICES_POLICY_SERVICE,
077 getTypeSettingsValue(_WEBSERVICES_POLICY_SERVICE));
078 parameters.put(
079 SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE,
080 getTypeSettingsValue(_WEBSERVICES_RELATIONSHIP_SERVICE));
081 parameters.put(
082 SessionParameter.WEBSERVICES_REPOSITORY_SERVICE,
083 getTypeSettingsValue(_WEBSERVICES_REPOSITORY_SERVICE));
084 parameters.put(
085 SessionParameter.WEBSERVICES_VERSIONING_SERVICE,
086 getTypeSettingsValue(_WEBSERVICES_VERSIONING_SERVICE));
087
088 CMISRepositoryUtil.checkRepository(
089 getRepositoryId(), parameters, getTypeSettingsProperties(),
090 _REPOSITORY_ID);
091
092 return CMISRepositoryUtil.createSession(parameters);
093 }
094
095 @Override
096 public String[] getSupportedConfigurations() {
097 return _SUPPORTED_CONFIGURATIONS;
098 }
099
100 @Override
101 public String[][] getSupportedParameters() {
102 return _SUPPORTED_PARAMETERS;
103 }
104
105 protected String getTypeSettingsValue(String typeSettingsKey)
106 throws InvalidRepositoryException {
107
108 UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
109
110 return CMISRepositoryUtil.getTypeSettingsValue(
111 typeSettingsProperties, typeSettingsKey);
112 }
113
114 private static final String _CONFIGURATION_WEBSERVICES = "WEBSERVICES";
115
116 private static final String _REPOSITORY_ID = "REPOSITORY_ID";
117
118 private static final String[] _SUPPORTED_CONFIGURATIONS = {
119 _CONFIGURATION_WEBSERVICES
120 };
121
122 private static final String[][] _SUPPORTED_PARAMETERS = new String[][] {
123 {
124 CMISWebServicesRepository._REPOSITORY_ID,
125 CMISWebServicesRepository._WEBSERVICES_ACL_SERVICE,
126 CMISWebServicesRepository._WEBSERVICES_DISCOVERY_SERVICE,
127 CMISWebServicesRepository._WEBSERVICES_MULTIFILING_SERVICE,
128 CMISWebServicesRepository._WEBSERVICES_NAVIGATION_SERVICE,
129 CMISWebServicesRepository._WEBSERVICES_OBJECT_SERVICE,
130 CMISWebServicesRepository._WEBSERVICES_POLICY_SERVICE,
131 CMISWebServicesRepository._WEBSERVICES_RELATIONSHIP_SERVICE,
132 CMISWebServicesRepository._WEBSERVICES_REPOSITORY_SERVICE,
133 CMISWebServicesRepository._WEBSERVICES_VERSIONING_SERVICE
134 }
135 };
136
137 private static final String _WEBSERVICES_ACL_SERVICE =
138 "WEBSERVICES_ACL_SERVICE";
139
140 private static final String _WEBSERVICES_DISCOVERY_SERVICE =
141 "WEBSERVICES_DISCOVERY_SERVICE";
142
143 private static final String _WEBSERVICES_MULTIFILING_SERVICE =
144 "WEBSERVICES_MULTIFILING_SERVICE";
145
146 private static final String _WEBSERVICES_NAVIGATION_SERVICE =
147 "WEBSERVICES_NAVIGATION_SERVICE";
148
149 private static final String _WEBSERVICES_OBJECT_SERVICE =
150 "WEBSERVICES_OBJECT_SERVICE";
151
152 private static final String _WEBSERVICES_POLICY_SERVICE =
153 "WEBSERVICES_POLICY_SERVICE";
154
155 private static final String _WEBSERVICES_RELATIONSHIP_SERVICE =
156 "WEBSERVICES_RELATIONSHIP_SERVICE";
157
158 private static final String _WEBSERVICES_REPOSITORY_SERVICE =
159 "WEBSERVICES_REPOSITORY_SERVICE";
160
161 private static final String _WEBSERVICES_VERSIONING_SERVICE =
162 "WEBSERVICES_VERSIONING_SERVICE";
163
164 }