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.getDefault();
047
048 parameters.put(
049 SessionParameter.LOCALE_ISO3166_COUNTRY, locale.getCountry());
050 parameters.put(SessionParameter.LOCALE_ISO639_LANGUAGE,
051 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 public String[] getSupportedConfigurations() {
097 return _SUPPORTED_CONFIGURATIONS;
098 }
099
100 public String[][] getSupportedParameters() {
101 return _SUPPORTED_PARAMETERS;
102 }
103
104 protected String getTypeSettingsValue(String typeSettingsKey)
105 throws InvalidRepositoryException {
106
107 UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
108
109 return CMISRepositoryUtil.getTypeSettingsValue(
110 typeSettingsProperties, typeSettingsKey);
111 }
112
113 private static final String _CONFIGURATION_WEBSERVICES = "WEBSERVICES";
114
115 private static final String _REPOSITORY_ID = "REPOSITORY_ID";
116
117 private static final String[] _SUPPORTED_CONFIGURATIONS = {
118 _CONFIGURATION_WEBSERVICES
119 };
120
121 private static final String[][] _SUPPORTED_PARAMETERS = new String[][] {
122 {
123 CMISWebServicesRepository._REPOSITORY_ID,
124 CMISWebServicesRepository._WEBSERVICES_ACL_SERVICE,
125 CMISWebServicesRepository._WEBSERVICES_DISCOVERY_SERVICE,
126 CMISWebServicesRepository._WEBSERVICES_MULTIFILING_SERVICE,
127 CMISWebServicesRepository._WEBSERVICES_NAVIGATION_SERVICE,
128 CMISWebServicesRepository._WEBSERVICES_OBJECT_SERVICE,
129 CMISWebServicesRepository._WEBSERVICES_POLICY_SERVICE,
130 CMISWebServicesRepository._WEBSERVICES_RELATIONSHIP_SERVICE,
131 CMISWebServicesRepository._WEBSERVICES_REPOSITORY_SERVICE,
132 CMISWebServicesRepository._WEBSERVICES_VERSIONING_SERVICE
133 }
134 };
135
136 private static final String _WEBSERVICES_ACL_SERVICE =
137 "WEBSERVICES_ACL_SERVICE";
138
139 private static final String _WEBSERVICES_DISCOVERY_SERVICE =
140 "WEBSERVICES_DISCOVERY_SERVICE";
141
142 private static final String _WEBSERVICES_MULTIFILING_SERVICE =
143 "WEBSERVICES_MULTIFILING_SERVICE";
144
145 private static final String _WEBSERVICES_NAVIGATION_SERVICE =
146 "WEBSERVICES_NAVIGATION_SERVICE";
147
148 private static final String _WEBSERVICES_OBJECT_SERVICE =
149 "WEBSERVICES_OBJECT_SERVICE";
150
151 private static final String _WEBSERVICES_POLICY_SERVICE =
152 "WEBSERVICES_POLICY_SERVICE";
153
154 private static final String _WEBSERVICES_RELATIONSHIP_SERVICE =
155 "WEBSERVICES_RELATIONSHIP_SERVICE";
156
157 private static final String _WEBSERVICES_REPOSITORY_SERVICE =
158 "WEBSERVICES_REPOSITORY_SERVICE";
159
160 private static final String _WEBSERVICES_VERSIONING_SERVICE =
161 "WEBSERVICES_VERSIONING_SERVICE";
162
163 }