Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2013, CloudBees Inc.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package com.cloudbees.sdk.commands.app;
 
 import  com.cloudbees.sdk.cli.BeesCommand;
 import  com.cloudbees.sdk.cli.CLICommand;
 
 import java.util.List;
 import java.util.Map;

 
 @BeesCommand(group="Application", description = "List application resources")
 @CLICommand("app:resource:list")
     private String type;
 
     public ApplicationResourceList() {
         super();
     }
 
     public String getType() {
         return ;
     }
 
     public void setType(String type) {
         this. = type;
     }
 
     @Override
     protected boolean preParseCommandLine() {
         if (super.preParseCommandLine()) {
             addOption"t""type"true"resource type" );
         }
         return true;
     }
 
     @Override
     protected boolean execute() throws Exception {
         AppClient client = getBeesClient(AppClient.class);
         List<ServiceResourceInforesources = new ArrayList<ServiceResourceInfo>();
         for (ServiceResourceInfo resourceres.getResources()) {
             if (resource.getResourceType() != null && !resource.getResourceType().equalsIgnoreCase("application")) {
                 if (getType() == null || resource.getResourceType().equalsIgnoreCase(getType()))
                     resources.add(resource);
             }
         }
         res.setResources(resources);
         displayResult(res);
         return true;
     }
 
     protected void displayResult(ServiceResourceListResponse res) {
         if (isTextOutput()) {
             List<ServiceResourceInforesources = res.getResources();
             ..println("Resources:");
             for (ServiceResourceInfo resourceresources) {
                 if (resource.getResourceType() != null)
                     ..println(resource.getResourceType() + " " + resource.getService() + ":" + resource.getId());
                 else
                     ..println(resource.getService() + ":" + resource.getId());
                 Map<StringStringconfig = resource.getConfig();
                 if(config != null && config.size() > 0) {
                     ..println("  config:");
                     for (Map.Entry<StringStringentry : config.entrySet()) {
                         ..println("    " + entry.getKey() + "=" + entry.getValue());
                     }
                 }
                 Map<StringStringsettings = resource.getSettings();
                 if(settings != null && settings.size() > 0) {
                     ..println("  settings:");
                     for (Map.Entry<StringStringentry : settings.entrySet()) {
                         ..println("    " + entry.getKey() + "=" + entry.getValue());
                     }
                 }
             }
         } else
             printOutput(resServiceResourceListResponse.classServiceResourceInfo.class);
     }
 
New to GrepCode? Check out our FAQ X