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; 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 'install 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 SurfCommands implements CommandMarker { 36 37 private SurfOperations surfOperations; 38 39 public SurfCommands(SurfOperations surfOperations) { 40 Assert.notNull(surfOperations, "Surf operations required."); 41 this.surfOperations = surfOperations; 42 } 43 44 /** 45 * Checks availability of the "surf install" command. 46 * @return true if the "surf install" command is available at this moment. 47 */ 48 @CliAvailabilityIndicator("surf install") 49 public boolean isInstallSurfAvailable() { 50 return surfOperations.isInstallSurfAvailable(); 51 } 52 53 /** 54 * Checks availability of the "surf addon install" command. 55 * @return true if the "surf addon install" command is available at this moment. 56 */ 57 @CliAvailabilityIndicator("surf addon install") 58 public boolean isInstallSurfAddonAvailable() { 59 return surfOperations.isManageSurfAvailable(); 60 } 61 62 /** 63 * Installs all required Surf artifacts. 64 * @param siteName Site name for the new Surf project (last segment of package name used as default). 65 */ 66 @CliCommand(value="surf install", help="Installs Surf artifacts into your project.") 67 public void installSurf( 68 @CliOption(key="siteName", mandatory=false, help="Specifies site name for your Surf project (last segment of package name used as default).") String siteName 69 ) { 70 surfOperations.installSurf(siteName); 71 } 72 73 /** 74 * Installs an addon into the Surf project. 75 * @param packageName Addon package name. 76 */ 77 @CliCommand(value="surf addon install", help="Installs a Surf addon into your Surf project.") 78 public void installSurfPackage( 79 @CliOption(key={"id"}, mandatory=true, help="Specifies id of the addon to be installed.") String packageName 80 ) { 81 if (packageName.equals("php")) { 82 surfOperations.installSurfPHP(); 83 } else if (packageName.equals("groovy")){ 84 surfOperations.installSurfGroovy(); 85 } else if (packageName.equals("studio")) { 86 surfOperations.installSurfStudio(); 87 } else { 88 surfOperations.installSurfPackage(packageName); 89 } 90 } 91 92 /** 93 * Installs Studio into the Surf project. 94 */ 95 /* 96 @CliCommand(value="surf studio install", help="Installs Studio into your Surf project.") 97 public void installSurfStudio() { 98 surfOperations.installSurfStudio(); 99 } 100 */ 101 /* 102 @CliCommand(value="install surf php", help="Installs PHP Scripting for Surf") 103 public void installSurfPHP() { 104 surfOperations.installSurfPHP(); 105 } 106 107 @CliCommand(value="install surf groovy", help="Installs PHP Scripting for Surf") 108 public void installSurfGroovy() { 109 surfOperations.installSurfGroovy(); 110 } 111 112 @CliCommand(value="install surf cmis-samples", help="Installs Sample Surf CMIS Components") 113 public void installSurfCmisSamples() { 114 surfOperations.installSurfCmisSamples(); 115 } 116 117 @CliCommand(value="install surf alfresco-samples", help="Installs Sample Surf CMIS Components") 118 public void installSurfAlfrescoSamples() { 119 surfOperations.installSurfAlfrescoSamples(); 120 } 121 */ 122 123 }