001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.repository.cmis;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.repository.RepositoryException;
020    import com.liferay.portal.kernel.util.MethodKey;
021    import com.liferay.portal.kernel.util.PortalClassInvoker;
022    import com.liferay.portal.kernel.util.UnicodeProperties;
023    
024    import java.util.Map;
025    
026    /**
027     * @author Alexander Chow
028     */
029    public class CMISRepositoryUtil {
030    
031            public static void checkRepository(
032                    long repositoryId, Map<String, String> parameters,
033                    UnicodeProperties typeSettingsProperties, String typeSettingsKey) {
034    
035                    try {
036                            PortalClassInvoker.invoke(
037                                    false, _checkRepository, repositoryId, parameters,
038                                    typeSettingsProperties, typeSettingsKey);
039                    }
040                    catch (Exception e) {
041                            _log.error(e, e);
042                    }
043            }
044    
045            public static Session createSession(Map<String, String> parameters)
046                    throws RepositoryException {
047    
048                    Session session = null;
049    
050                    try {
051                            Object returnObj = PortalClassInvoker.invoke(
052                                    false, _createSession, parameters);
053    
054                            if (returnObj != null) {
055                                    session = (Session)returnObj;
056                            }
057                    }
058                    catch (RepositoryException re) {
059                            throw re;
060                    }
061                    catch (Exception e) {
062                            _log.error(e, e);
063                    }
064    
065                    return session;
066            }
067    
068            public static String getTypeSettingsValue(
069                    UnicodeProperties typeSettingsProperties, String typeSettingsKey) {
070    
071                    String value = null;
072    
073                    try {
074                            Object returnObj = PortalClassInvoker.invoke(
075                                    false, _getTypeSettingsValue, typeSettingsProperties,
076                                    typeSettingsKey);
077    
078                            if (returnObj != null) {
079                                    value = (String)returnObj;
080                            }
081                    }
082                    catch (Exception e) {
083                            _log.error(e, e);
084                    }
085    
086                    return value;
087            }
088    
089            private static final String _CLASS_NAME =
090                    "com.liferay.portal.repository.cmis.CMISRepositoryUtil";
091    
092            private static Log _log = LogFactoryUtil.getLog(CMISRepositoryUtil.class);
093    
094            private static MethodKey _checkRepository = new MethodKey(
095                    _CLASS_NAME, "checkRepository", long.class, Map.class,
096                    UnicodeProperties.class, String.class);
097    
098            private static MethodKey _createSession = new MethodKey(
099                    _CLASS_NAME, "createSession", Map.class);
100    
101            private static MethodKey _getTypeSettingsValue = new MethodKey(
102                    _CLASS_NAME, "getTypeSettingsValue", UnicodeProperties.class,
103                    String.class);
104    
105    }