1 package org.jahia.services.applications; 2 3 import org.jahia.data.applications.ApplicationBean; 4 import org.jahia.data.applications.ApplicationContext; 5 import org.jahia.data.applications.ServletBean; 6 import org.jahia.registries.ServicesRegistry; 7 import org.jahia.services.usermanager.JahiaGroup; 8 import org.jahia.services.usermanager.JahiaUser; 9 10 import java.util.*; 11 import java.io.Serializable ; 12 13 18 public class PersistantServletRequest extends ServletBean implements Serializable { 19 20 private String appUniqueIDStr; 21 private String appURL; 22 private String appMethod; 23 private String appContextID; 24 private String servletMappingPattern; 25 private ApplicationBean appBean; 26 27 28 public PersistantServletRequest (ApplicationBean stdAppBean, 29 ServletBean servletBean, 30 String appUniqueIDStr, 31 String applicationURL, 32 String applicationMethod, 33 String applicationContextID) { 34 35 super ( 36 servletBean.getWebAppType (), 37 servletBean.getName (), 38 servletBean.getServletName (), 39 servletBean.getservletsrc (), 40 servletBean.getContext (), 41 servletBean.getdesc () 42 ); 43 44 super.setLoaded (servletBean.isLoaded ()); 45 super.setUrlMappingPattern (servletBean.getUrlMappingPattern ()); 46 super.setWebAppType (servletBean.getWebAppType ()); 47 48 this.appUniqueIDStr = appUniqueIDStr; 49 this.appURL = applicationURL; 50 this.appMethod = applicationMethod; 51 this.appContextID = applicationContextID; 52 this.appBean = stdAppBean; 53 this.servletMappingPattern = servletBean.getUrlMappingPattern (); 54 } 55 56 public String getUniqueIDStr () { 57 return appUniqueIDStr; 58 } 59 60 public String getURL () { 61 return appURL; 62 } 63 64 public void setURL (String value) { 65 appURL = value; 66 } 67 68 public String getMethod () { 69 return appMethod; 70 } 71 72 public String getContextID () { 73 return appContextID; 74 } 75 76 public String getServletMappingPattern () { 77 return servletMappingPattern; 78 } 79 80 public int getVisibleStatus () { 81 return appBean.getVisibleStatus (); 82 } 83 84 public ApplicationBean getApplicationBean () { 85 return appBean; 86 } 87 88 97 public Vector getAppContextUsers () { 98 99 Vector users = new Vector (); 100 Set addedUsers = new HashSet (); 101 102 if (appBean == null) { 103 return users; 104 } 105 106 Enumeration appRoles = null; 107 try { 108 ApplicationContext appContext = ServicesRegistry.getInstance () 109 .getJahiaApplicationContextService () 110 .getApplicationContext (appBean.getID ()); 111 112 appRoles = appContext.getRoles ().elements (); 113 } catch (Throwable t) { 114 t.printStackTrace (); 115 return users; 116 } 117 118 if (appRoles == null) { 119 return users; 120 } 121 122 JahiaGroup roleGroup = null; 123 String role = null; 124 while (appRoles.hasMoreElements ()) { 125 126 role = (String ) appRoles.nextElement (); 127 128 StringBuffer buff = new StringBuffer (Integer.toString (appBean.getID ())); 130 buff.append ("_"); 131 buff.append (this.appContextID); 132 buff.append ("_"); 133 buff.append (role); 134 135 roleGroup = ServicesRegistry.getInstance () 136 .getJahiaGroupManagerService () 137 .lookupGroup (0, buff.toString ()); if (roleGroup != null) { 139 140 Set userMembers = roleGroup.getRecursiveUserMembers (); 141 Iterator userIterator = userMembers.iterator (); 142 while (userIterator.hasNext ()) { 143 JahiaUser curUser = (JahiaUser) userIterator.next (); 144 if (!addedUsers.contains (curUser.getUserKey ())) { 145 addedUsers.add (curUser.getUserKey ()); 146 users.add (curUser.getUsername ()); 147 } 148 } 149 } 150 } 151 152 return users; 153 } 154 155 } 156 | Popular Tags |