1 19 20 package com.sslexplorer.properties.forms; 21 22 import java.util.Arrays ; 23 import java.util.List ; 24 25 import javax.servlet.http.HttpServletRequest ; 26 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 import org.apache.struts.action.ActionMapping; 30 31 import com.sslexplorer.boot.PropertyClass; 32 import com.sslexplorer.boot.PropertyClassManager; 33 import com.sslexplorer.core.CoreServlet; 34 import com.sslexplorer.properties.ProfilesFactory; 35 import com.sslexplorer.properties.PropertyProfile; 36 import com.sslexplorer.properties.impl.profile.ProfileProperties; 37 import com.sslexplorer.security.Constants; 38 39 42 public class ProfilePropertiesForm extends AbstractPropertiesForm { 43 44 static Log log = LogFactory.getLog(ProfilePropertiesForm.class); 45 46 private List propertyProfiles; 47 private int selectedPropertyProfile; 48 private String profileScope; 49 50 public ProfilePropertiesForm() { 51 super(Arrays.asList(new PropertyClass[] { PropertyClassManager.getInstance().getPropertyClass(ProfileProperties.NAME) } ), true); 52 } 53 54 public boolean getEnabled() { 55 try { 56 PropertyProfile profile = ProfilesFactory.getInstance() 57 .getPropertyProfile(getSelectedPropertyProfile()); 58 boolean global = profile.getOwnerUsername() == null || profile.getOwnerUsername().equals(""); 59 return (Constants.SCOPE_PERSONAL.equals(getProfileScope()) && !global) || (Constants.SCOPE_GLOBAL.equals(getProfileScope()) && global); 60 } catch (Exception e) { 61 log.error("Failed to get property profile details. Disabling form.", e); 62 return false; 63 } 64 65 } 66 67 public void reset(ActionMapping mapping, HttpServletRequest request) { 68 super.reset(mapping, request); 69 } 71 72 public void setPropertyProfiles(List propertyProfiles) { 73 this.propertyProfiles = propertyProfiles; 74 } 75 76 public List getPropertyProfiles() { 77 return propertyProfiles; 78 } 79 80 public void setSelectedPropertyProfile(int id) { 81 selectedPropertyProfile = id; 82 } 83 84 public int getSelectedPropertyProfile() { 85 return selectedPropertyProfile; 86 } 87 88 public boolean getHasProfiles() { 89 return propertyProfiles != null && !Constants.SCOPE_SETUP.equals(profileScope); 90 } 91 public String getProfileScope() { 92 return profileScope; 93 } 94 95 public void setProfileScope(String profileScope) { 96 this.profileScope = profileScope; 97 } 98 } | Popular Tags |