View Javadoc

1   /**
2    * Copyright (C) 2005-2009 Alfresco Software Limited.
3    *
4    * This file is part of the Spring Surf Extension project.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *  http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.springframework.roo.addon.surf.site;
20  
21  import org.springframework.roo.shell.CliAvailabilityIndicator;
22  import org.springframework.roo.shell.CliCommand;
23  import org.springframework.roo.shell.CliOption;
24  import org.springframework.roo.shell.CommandMarker;
25  import org.springframework.roo.support.lifecycle.ScopeDevelopmentShell;
26  import org.springframework.roo.support.util.Assert;
27  
28  /**
29   * Commands for the 'alfresco surf' add-on to be used by the ROO shell.
30   *
31   * @author Yong Qu
32   * @since 1.0
33   */
34  @ScopeDevelopmentShell
35  public class SiteCommands implements CommandMarker {
36  
37  	private SiteOperations siteOperations;
38  
39  	/**
40  	 * @param siteOperations
41  	 */
42  	public SiteCommands(SiteOperations siteOperations) {
43  		Assert.notNull(siteOperations, "SiteOperations instance required");
44  		this.siteOperations = siteOperations;
45  	}
46  
47  	/**
48  	 * Check availability of site related commands.
49  	 * @return true if site related commands are available at this moment.
50  	 */
51  	@CliAvailabilityIndicator({"surf site create"})
52  	public boolean isSiteOperationAvailable() {
53  		return siteOperations.isSiteOperationAvailable();
54  	}
55  
56  	/**
57  	 * Creates a new Surf site configuration.
58  	 * @param siteName Site name.
59  	 * @param rootPageId Root page id.
60  	 */
61  	@CliCommand(value="surf site create", help="Creates a new Surf site configuration.")
62  	public void listSurfSiteRegions(
63  			@CliOption(key={"name",""}, mandatory=false, help="Specifies name of the Surf site.") String siteName,
64  			@CliOption(key={"rootPageId",""}, mandatory=true, help="Specifies root page id of the Surf site.") String rootPageId
65  		) {
66  		siteOperations.newSite(siteName,rootPageId);
67  	}
68  
69  }