1 19 20 package com.sslexplorer.applications; 21 22 import java.util.Iterator ; 23 import java.util.List ; 24 import java.util.Map ; 25 26 import javax.servlet.http.HttpServletRequest ; 27 28 import com.sslexplorer.boot.Util; 29 import com.sslexplorer.core.CoreUtil; 30 import com.sslexplorer.extensions.ExtensionDescriptor; 31 import com.sslexplorer.navigation.RequiresSessionPasswordAbstractFavoriteItem; 32 33 38 39 public class ApplicationShortcutItem extends RequiresSessionPasswordAbstractFavoriteItem { 40 41 private ExtensionDescriptor application; 43 private int navigationContext; 44 45 54 public ApplicationShortcutItem(ExtensionDescriptor application,ApplicationShortcut resource, List policies, int navigationContext, boolean requiresSessionPassword) { 55 super(resource, policies, requiresSessionPassword); 56 this.application = application; 57 this.navigationContext = navigationContext; 58 } 59 60 65 public ExtensionDescriptor getExtensionDescriptor() { 66 return application; 67 } 68 69 74 public String getLink(int policy, String referer, HttpServletRequest request) { 75 return "/launchApplication.do?resourceId=" + getResource().getResourceId() + "&policy=" + policy + 76 "&returnTo=" + Util.urlEncode(Util.isNullOrTrimmedBlank(referer) ? CoreUtil.getRealRequestURI(request) : referer); 77 } 78 79 84 public String getSmallIconPath(HttpServletRequest request) { 85 if (application.getSmallIcon() == null) { 86 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/runApplication.gif"; 87 } else { 88 return "/fs/apps/" + application.getApplicationBundle().getId() + "/" + application.getSmallIcon(); 89 } 90 } 91 92 97 public String getLargeIconPath(HttpServletRequest request) { 98 if (application.getSmallIcon() == null) { 99 return CoreUtil.getThemePath(request.getSession()) + "/images/actions/runApplicationLarge.gif"; 100 } else { 101 return "/fs/apps/" + application.getApplicationBundle().getId() + "/" + application.getLargeIcon(); 102 } 103 } 104 105 110 public String getParameterString() { 111 StringBuffer buf = new StringBuffer (); 112 for (Iterator i = ((ApplicationShortcut) getResource()).getParameters().entrySet().iterator(); i.hasNext();) { 113 if (buf.length() > 0) { 114 buf.append("&"); 115 } 116 Map.Entry entry = (Map.Entry ) i.next(); 117 buf.append(entry.getKey()); 118 buf.append("="); 119 buf.append(Util.urlEncode(String.valueOf(entry.getValue()))); 120 } 121 return buf.toString(); 122 } 123 124 129 public String getFavoriteName() { 130 return getResource().getResourceName(); 131 } 132 133 138 public String getFavoriteSubType() { 139 return getExtensionDescriptor().getName(); 140 } 141 142 147 public String getTarget() { 148 return "_self"; 149 } 150 151 154 public String getOnClick(int policy, HttpServletRequest request) { 155 return ""; 156 } 157 } | Popular Tags |