001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.events;
016    
017    import com.liferay.portal.kernel.events.ActionException;
018    import com.liferay.portal.kernel.events.SimpleAction;
019    import com.liferay.portal.kernel.log.Log;
020    import com.liferay.portal.kernel.log.LogFactoryUtil;
021    import com.liferay.portal.kernel.notifications.ChannelHubManagerUtil;
022    import com.liferay.portal.kernel.notifications.DuplicateChannelHubException;
023    import com.liferay.portal.kernel.util.GetterUtil;
024    
025    /**
026     * @author Edward Han
027     * @author Brian Wing Shun Chan
028     */
029    public class ChannelHubAppStartupAction extends SimpleAction {
030    
031            @Override
032            public void run(String[] ids) throws ActionException {
033                    try {
034                            long companyId = GetterUtil.getLong(ids[0]);
035    
036                            if (_log.isDebugEnabled()) {
037                                    _log.debug("Creating channel hub " + companyId);
038                            }
039    
040                            ChannelHubManagerUtil.createChannelHub(companyId);
041                    }
042                    catch (DuplicateChannelHubException dche) {
043                            if (_log.isWarnEnabled()) {
044                                    _log.warn(dche.getMessage());
045                            }
046                    }
047                    catch (Exception e) {
048                            throw new ActionException(e);
049                    }
050            }
051    
052            private static Log _log = LogFactoryUtil.getLog(
053                    ChannelHubAppStartupAction.class);
054    
055    }