1 package net.sf.invicta.handler; 2 3 import java.util.Map ; 4 5 import net.sf.invicta.InvictaException; 6 import net.sf.invicta.api.Product; 7 8 9 14 public class ProductNameHandler extends InvictaBasicHandler { 15 public final static boolean DEFAULT_APP_NAME = false; 16 public final static String DEFAULT_TYPE = "jar"; 17 18 21 public String handle(Map paramsMap) throws InvictaException { 22 String type = getParameter("type", DEFAULT_TYPE); 23 boolean appName = getBooleanParameter("appName", DEFAULT_APP_NAME); 24 25 Product product = getComponent().getSelfProduct(type, null); 26 if (product == null) 27 throw new InvictaHandlerException(this, 28 "No product defined for component '" + 29 getComponent().getName() + 30 "' with type=" + type); 31 String name; 32 if (appName) 33 name = product.getAppName(); 34 else 35 name = product.getName(); 36 37 if (name == null) 38 throw new InvictaHandlerException(this, 39 "No name defined for " + type + " product of component '" + 40 getComponent().getName() + "'"); 41 42 return name; 43 } 44 45 46 49 public String getName() { 50 return "productName"; 51 } 52 53 } 54 | Popular Tags |