001    /**
002     * Copyright (c) 2000-2013 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.service.impl;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    import com.liferay.portal.kernel.util.StringUtil;
019    import com.liferay.portal.model.ClusterGroup;
020    import com.liferay.portal.service.base.ClusterGroupLocalServiceBaseImpl;
021    
022    import java.util.List;
023    
024    /**
025     * @author Shuyang Zhou
026     * @author Brian Wing Shun Chan
027     */
028    public class ClusterGroupLocalServiceImpl
029            extends ClusterGroupLocalServiceBaseImpl {
030    
031            @Override
032            public ClusterGroup addClusterGroup(
033                            String name, List<String> clusterNodeIds)
034                    throws SystemException {
035    
036                    long clusterGroupId = counterLocalService.increment();
037    
038                    ClusterGroup clusterGroup = clusterGroupPersistence.create(
039                            clusterGroupId);
040    
041                    clusterGroup.setName(name);
042                    clusterGroup.setClusterNodeIds(StringUtil.merge(clusterNodeIds));
043    
044                    return clusterGroupPersistence.update(clusterGroup, false);
045            }
046    
047            @Override
048            public ClusterGroup addWholeClusterGroup(String name)
049                    throws SystemException {
050    
051                    long clusterGroupId = counterLocalService.increment();
052    
053                    ClusterGroup clusterGroup = clusterGroupPersistence.create(
054                            clusterGroupId);
055    
056                    clusterGroup.setName(name);
057                    clusterGroup.setWholeCluster(true);
058    
059                    return clusterGroupPersistence.update(clusterGroup, false);
060            }
061    
062    }