001    /**
002     * Copyright (c) 2000-2013 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.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);
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);
060            }
061    
062    }