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