diff --git a/webapp/config/web.xml b/webapp/config/web.xml index 0ecff7247..16435bfbd 100644 --- a/webapp/config/web.xml +++ b/webapp/config/web.xml @@ -235,15 +235,6 @@ /* - - Portal Picker Filter - edu.cornell.mannlib.vitro.webapp.filters.PortalPickerFilter - - - Portal Picker Filter - /* - - VitroRequestPrep edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep @@ -695,15 +686,6 @@ /propertyEdit - - PortalEditController - edu.cornell.mannlib.vitro.webapp.controller.edit.PortalEditController - - - PortalEditController - /portalEdit - - EntityRetryController edu.cornell.mannlib.vitro.webapp.controller.edit.EntityRetryController @@ -794,15 +776,6 @@ /addRestriction - - PortalsListingController - edu.cornell.mannlib.vitro.webapp.controller.edit.listing.PortalsListingController - - - PortalsListingController - /listPortals - - UsersListingController edu.cornell.mannlib.vitro.webapp.controller.edit.listing.UsersListingController diff --git a/webapp/src/edu/cornell/mannlib/vedit/beans/UserSession.java b/webapp/src/edu/cornell/mannlib/vedit/beans/UserSession.java deleted file mode 100644 index 2797141e5..000000000 --- a/webapp/src/edu/cornell/mannlib/vedit/beans/UserSession.java +++ /dev/null @@ -1,194 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vedit.beans; - -/** - * User Session information - * @author John Fereira - * @since 29.06.2004 - */ -public class UserSession { - private int currentEntityId; - private int currentPortalId; - private int currentTabId; - private String lastSearchURL; - private boolean isPatronAuthenticated; - private boolean isAdminAuthenticated; - private String referer; - private String lastSearchTerm; - - private String flag1Pref; - public void setFlag1Pref(String s) { flag1Pref=s; } - public String getFlag1Pref() { return flag1Pref; } - - private String flag2Pref; - public void setFlag2Pref(String s) { flag2Pref=s; } - public String getFlag2Pref() { return flag2Pref; } - - private String flag3Pref; - public void setFlag3Pref(String s) { flag3Pref=s; } - public String getFlag3Pref() { return flag3Pref; } - -//search wrapper was part of the mysql full text search, no longer in use. -// private SearchWrapper searchWrapper; -// public void setSearchWrapper(SearchWrapper sw) { searchWrapper=sw; } -// public SearchWrapper getSearchWrapper() { return searchWrapper; } -// public void disposeOf(SearchWrapper sw) { -// if (sw!=null){ -// sw.dispose(); -// } -// this.searchWrapper=null; -// } - - /** constructor */ - public UserSession() { - this.isPatronAuthenticated = false; - this.isAdminAuthenticated = false; - } - - /** - * set current entity id - * @param currentEntityId : unique id - */ - public void setCurrentEntityId(int currentEntityId) { - this.currentEntityId = currentEntityId; - } - - /** - * get Current entity Id - * @return : the entity Id - */ - public int getCurrentEntityId() { - return currentEntityId; - } - - /** - * set current portal id - * @param currentPortalId : unique id - */ - public void setCurrentPortalId(int currentPortalId) { - this.currentPortalId = currentPortalId; - } - - /** - * get Current portal Id - * @return : the portal Id - */ - public int getCurrentPortalId() { - return currentPortalId; - } - - /** - * set current tab id - * @param currentTabId : unique id - */ - public void setCurrentTabId(int currentTabId) { - this.currentTabId = currentTabId; - } - - /** - * get current tab id - * @return : the tab Id - */ - public int getCurrentTabId() { - return currentTabId; - } - - - /** - * set last SearchURL in session - * @param lastSearchURL : a url string - */ - public void setLastSearchURL(String lastSearchURL) { - this.lastSearchURL = lastSearchURL; - } - - /** - * get last Search URL - * @return : last search url string - */ - public String getLastSearchURL() { - return lastSearchURL; - } - - /** - * Set boolen flag to indicated if patron has authenticated - * @param isPatronAuthenticated : true or false - */ - public void setIsPatronAuthenticated(boolean isPatronAuthenticated) { - this.isPatronAuthenticated = isPatronAuthenticated; - } - - /** - * get boolean flag indicating whethor or not patron has authenticated - * @return : true or false - */ - public boolean getIsPatronAuthenticated() { - return isPatronAuthenticated; - } - - /** - * set boolean flag indicating whether or not an Administrator has - * authenticated - * @param isAdminAuthenticated : true or false - */ - public void setIsAdminAuthenticated(boolean isAdminAuthenticated) { - this.isAdminAuthenticated = isAdminAuthenticated; - } - - /** - * get boolean flag indicating whether or not an Administrator has - * authenticated - * @return : true or false - */ - public boolean getIsAdminAuthenticated() { - return isAdminAuthenticated; - } - - /** - * set referer url in session - * @param referer : a referer url string - */ - public void setReferer(String referer) { - this.referer = referer; - } - - /** - * get referer url in session - * @return : a referer url string - */ - public String getReferer() { - return referer; - } - - /** - * set lastSearchTerm in session - * @param lastSearchTerm : a lastSearchTerm string - */ - public void setLastSearchTerm(String lastSearchTerm) { - this.lastSearchTerm = lastSearchTerm; - } - - /** - * get lastSearchTerm in session - * @return : a lastSearchTerm string - */ - public String getLastSearchTerm() { - return lastSearchTerm; - } - - - /** - * @param isAdminAuthenticated The isAdminAuthenticated to set. - */ - public void setAdminAuthenticated(boolean isAdminAuthenticated) { - this.isAdminAuthenticated = isAdminAuthenticated; - } - - /** - * @param isPatronAuthenticated The isPatronAuthenticated to set. - */ - public void setPatronAuthenticated(boolean isPatronAuthenticated) { - this.isPatronAuthenticated = isPatronAuthenticated; - } -} diff --git a/webapp/src/edu/cornell/mannlib/vedit/controller/BaseEditController.java b/webapp/src/edu/cornell/mannlib/vedit/controller/BaseEditController.java index f9681aca1..707f67bde 100644 --- a/webapp/src/edu/cornell/mannlib/vedit/controller/BaseEditController.java +++ b/webapp/src/edu/cornell/mannlib/vedit/controller/BaseEditController.java @@ -22,9 +22,9 @@ import com.hp.hpl.jena.ontology.OntModel; import edu.cornell.mannlib.vedit.beans.EditProcessObject; import edu.cornell.mannlib.vedit.util.FormUtils; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; import edu.cornell.mannlib.vitro.webapp.controller.Controllers; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; public class BaseEditController extends VitroHttpServlet { @@ -107,13 +107,12 @@ public class BaseEditController extends VitroHttpServlet { return Long.toHexString(cal.getTimeInMillis()); } - protected void setRequestAttributes(HttpServletRequest request, EditProcessObject epo){ - Portal portal = (Portal)request.getAttribute("portalBean"); + protected void setRequestAttributes(HttpServletRequest request, EditProcessObject epo){ + VitroRequest vreq = new VitroRequest(request); request.setAttribute("epoKey",epo.getKey()); request.setAttribute("epo",epo); request.setAttribute("globalErrorMsg",epo.getAttribute("globalErrorMsg")); - request.setAttribute("portalBean",portal); - request.setAttribute("css", ""); + request.setAttribute("css", ""); } protected void populateBeanFromParams(Object bean, HttpServletRequest request) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java index 3422f69ae..be39f759f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java @@ -16,18 +16,12 @@ package edu.cornell.mannlib.vitro.webapp.beans; * */ -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.StringTokenizer; +import java.io.File; import javax.servlet.ServletContext; -import javax.sql.DataSource; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.RowMapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * This object is intended to represent the single row of data in the table application. @@ -36,65 +30,40 @@ import org.springframework.jdbc.core.RowMapper; * */ public class ApplicationBean { - public final static int FILTER_SECURITY_LEVEL = 4; - public final static int CALS_SEARCHBOX_SIZE = 25; - public final static int VIVO_SEARCHBOX_SIZE = 20; - - private static ApplicationBean singleAppBean = null; + + private static final Log log = LogFactory.getLog(ApplicationBean.class); + + public final static int CALS_SEARCHBOX_SIZE = 25; + public final static int VIVO_SEARCHBOX_SIZE = 20; private final static String DEFAULT_APPLICATION_NAME = "Vitro"; - private final static String DEFAULT_FLAG1_NAME = "portal"; - private final static int DEFAULT_MAX_PORTAL_ID = 15; - private final static int ALL_PORTAL_FOR_MAX_OF_15 = 65535; - private final static int DEFAULT_MIN_SHARED_PORTAL = 2; - private final static int DEFAULT_MAX_SHARED_PORTAL = 5; - private final static String DEFAULT_ROOT_LOGOTYPE_IMAGE = ""; + private final static String DEFAULT_ROOT_LOGOTYPE_IMAGE = ""; private final static int DEFAULT_ROOT_LOGOTYPE_WIDTH = 0; private final static int DEFAULT_ROOT_LOGOTYPE_HEIGHT = 0; private final static String DEFAULT_ROOT_LOGOTYPE_TITLE = ""; - private final static String DEFAULT_SEARCH_DOMAIN = ""; - // private final static String DEFAULT_ROOT_LOGOTYPE_IMAGE = "CornellSeal.69x65.transparent.clipped.gif"; - // private final static int DEFAULT_ROOT_LOGOTYPE_WIDTH = 65; - // private final static int DEFAULT_ROOT_LOGOTYPE_HEIGHT = 65; - //private final static int DEFAULT_HEADER_IMAGE_WIDTH = 69; - //private final static int DEFAULT_HEADER_IMAGE_HEIGHT = 65; - //private final static String DEFAULT_ROOT_LOGOTYPE_TITLE = "Cornell University"; - //private final static String DEFAULT_SEARCH_DOMAIN = "http://www.cornell.edu"; - private final static boolean DEFAULT_ONLY_CURRENT = true; - private final static boolean DEFAULT_ONLY_PUBLIC = true; - + + // Value gets set in default theme setup context listener at application startup + public static String DEFAULT_THEME_DIR_FROM_CONTEXT = null; // Default initializations, which may be overwritten in the AppBeanMapper // but are otherwise not changed there private boolean initialized = false; private String sessionIdStr = null; private String applicationName = DEFAULT_APPLICATION_NAME; - private String flag1Name = DEFAULT_FLAG1_NAME; - private String flag2Name = null; - private String flag3Name = null; - private ArrayList flag1List = null; - private ArrayList flag2List = null; - private ArrayList flag3List = null; - private int maxPortalId = DEFAULT_MAX_PORTAL_ID; - private int allPortalFlagNumeric = ALL_PORTAL_FOR_MAX_OF_15; // this is calculated dynamically and becomes the way to search the entire database (all portals) - private int minSharedPortalId = DEFAULT_MIN_SHARED_PORTAL; - private int maxSharedPortalId = DEFAULT_MAX_SHARED_PORTAL; - private int sharedPortalFlagNumeric = 60; // was 0; this is calculated dynamically and becomes the id of the ALL CALS RESEARCH portal - private String keywordHeading = null; + private String rootLogotypeImage = DEFAULT_ROOT_LOGOTYPE_IMAGE; private int rootLogotypeWidth = DEFAULT_ROOT_LOGOTYPE_WIDTH; private int rootLogotypeHeight = DEFAULT_ROOT_LOGOTYPE_HEIGHT; private String rootLogotypeTitle = DEFAULT_ROOT_LOGOTYPE_TITLE; - private boolean onlyCurrent = DEFAULT_ONLY_CURRENT; - private boolean onlyPublic = DEFAULT_ONLY_PUBLIC; - - /** for internal use only */ - private int minUsedToCalcualteShared = -1; - /** for internal use only */ - private int maxUsedToCalculateShared = -1; - /** for internal use only */ - private int maxPortalUsedToCalculateAllPortal = DEFAULT_MAX_PORTAL_ID; + private String aboutText; + private String acknowledgeText; + private String contactMail; + private String correctionMail; + private String copyrightURL; + private String copyrightAnchor; + private String themeDir; + public static ApplicationBean getAppBean(ServletContext sc){ if( sc != null ){ Object obj = sc.getAttribute("applicationBean"); @@ -103,64 +72,21 @@ public class ApplicationBean { } return new ApplicationBean(); } - - public static int calculateAllPortalFlagNumeric(int max_portal_id) { - int returnVal=0; - if (max_portal_id>0) { - for (int i=0; imin_shared_portal_id) { - for (int i=min_shared_portal_id; i<=max_shared_portal_id; i++) { - returnVal+=(int)Math.pow(2.0,i); - } - } else if (min_shared_portal_id==max_shared_portal_id) { - returnVal=(int)Math.pow(2.0,min_shared_portal_id); - } else { - returnVal=(int)Math.pow(2.0,(min_shared_portal_id+1)); //max in this case - for (int i=min_shared_portal_id; i>=max_shared_portal_id; i--) { - returnVal-=(int)Math.pow(2.0,i); - } - } - return returnVal; - } - public String toString() { String output = "Application Bean Contents:\n"; output += " initialized from DB: [" + initialized + "]\n"; output += " session id: [" + sessionIdStr + "]\n"; output += " application name: [" + applicationName + "]\n"; - output += " flag1 name: [" + flag1Name + "]\n"; - output += " flag2 name: [" + flag2Name + "]\n"; - output += " flag3 name: [" + flag3Name + "]\n"; - output += " max portal id: [" + maxPortalId + "]\n"; - output += " allPortalFlagNumeric [" + allPortalFlagNumeric + "]\n"; - output += " min shared portal: [" + minSharedPortalId + "]\n"; - output += " max shared portal: [" + maxSharedPortalId + "]\n"; - output += " sharedPortalFlagNumeric [" + sharedPortalFlagNumeric + "]\n"; - output += " keyword table: [" + keywordHeading + "]\n"; output += " root logotype image: [" + rootLogotypeImage + "]\n"; output += " root logotype width: [" + rootLogotypeWidth + "]\n"; output += " root logotype height: [" + rootLogotypeHeight + "]\n"; output += " root logotype title: [" + rootLogotypeTitle + "]\n"; - output += " only current entities: [" + onlyCurrent + "]\n"; - output += " only public entities: [" + onlyPublic + "]\n"; return output; } /*************************** SET functions ****************************/ - public void setInitialized( boolean boolean_val) { - initialized=boolean_val; - } - public void setSessionIdStr( String string_val ) { sessionIdStr = string_val; } @@ -169,42 +95,6 @@ public class ApplicationBean { applicationName = string_val; } - public void setFlag1Name( String string_val ) { - flag1Name = string_val; - } - - public void setFlag2Name( String string_val ) { - flag2Name = string_val; - } - - public void setFlag3Name( String string_val ) { - flag3Name = string_val; - } - - public void setMaxPortalId( int int_val ) { - maxPortalId = int_val; - } - -// public void setAllPortalFlagNumeric( int int_val ) { -// allPortalFlagNumeric=int_val; -// } - - public void setMinSharedPortalId( int int_val ) { - minSharedPortalId = int_val; - } - - public void setMaxSharedPortalId( int int_val ) { - maxSharedPortalId = int_val; - } - -// public void setSharedPortalFlagNumeric( int int_val ) { -// sharedPortalFlagNumeric=int_val; -// } - - public void setKeywordHeading(String string_val) { - keywordHeading=string_val; - } - public void setRootLogotypeImage(String string_val) { rootLogotypeImage=string_val; } @@ -220,36 +110,45 @@ public class ApplicationBean { public void setRootLogotypeTitle(String string_val) { rootLogotypeTitle=string_val; } - - - public void setOnlyCurrent(boolean boolean_val) { - onlyCurrent=boolean_val; + + public void setAboutText(String string_val) { + aboutText = string_val; } - public void setOnlyPublic(boolean boolean_val) { - onlyPublic=boolean_val; + public void setAcknowledgeText(String string_val) { + acknowledgeText = string_val; + } + + public void setContactMail(String string_val) { + contactMail = string_val; } - public void setFlag1List(ArrayList h) { - flag1List=h; + public void setCorrectionMail(String string_val) { + correctionMail = string_val; + } + + public void setCopyrightURL(String string_val) { + copyrightURL = string_val; } - public void setFlag2List(ArrayList h) { - flag2List=h; + public void setCopyrightAnchor(String string_val) { + copyrightAnchor = string_val; } - - public void setFlag3List(ArrayList h) { - flag3List=h; + + public void setThemeDir(String string_val) { + if( string_val == null || string_val.length() == 0 + || "default".equalsIgnoreCase(string_val) + || "portal".equalsIgnoreCase(string_val) + || "null".equalsIgnoreCase(string_val) + || " ".equalsIgnoreCase(string_val) ) + themeDir = DEFAULT_THEME_DIR_FROM_CONTEXT; + else + themeDir = string_val; } - /*************************** GET functions ****************************/ - public boolean isInitialized() { - return initialized; - } - public String getSessionIdStr() { return sessionIdStr; } @@ -258,65 +157,6 @@ public class ApplicationBean { return applicationName; } - public String getFlag1Name() { - return flag1Name; - } - - public boolean isFlag1Active() { - return (maxPortalId>1); - } - - public String getFlag2Name() { - return flag2Name; - } - - public boolean isFlag2Active() { - return (flag2Name!=null && !flag2Name.equals("")); - } - - public String getFlag3Name() { - return flag3Name; - } - - public boolean isFlag3Active() { - return (flag3Name!=null && !flag3Name.equals("")); - } - - public int getMaxPortalId() { - return maxPortalId; - } - - public int getAllPortalFlagNumeric() { - if( this.maxPortalId != this.maxPortalUsedToCalculateAllPortal ){ - this.allPortalFlagNumeric = calculateAllPortalFlagNumeric( this.maxPortalId ); - this.maxPortalUsedToCalculateAllPortal = this.maxPortalId; - } - return this.allPortalFlagNumeric; - } - - public int getMinSharedPortalId() { - return minSharedPortalId; - } - - public int getMaxSharedPortalId() { - return maxSharedPortalId; - } - - public int getSharedPortalFlagNumeric() { - if( minSharedPortalId != minUsedToCalcualteShared || - maxSharedPortalId != maxUsedToCalculateShared ){ - this.sharedPortalFlagNumeric - = calculateSharedPortalFlagNumeric(minSharedPortalId, maxSharedPortalId); - minUsedToCalcualteShared = minSharedPortalId; - maxUsedToCalculateShared = maxSharedPortalId; - } - return sharedPortalFlagNumeric; - } - - public String getKeywordHeading() { - return keywordHeading; - } - public String getRootLogotypeImage() { return rootLogotypeImage; } @@ -332,88 +172,84 @@ public class ApplicationBean { public String getRootLogotypeTitle() { return rootLogotypeTitle; } - - - - public boolean isOnlyCurrent() { - return onlyCurrent; + + public String getAboutText() { + return aboutText; } - public boolean isOnlyPublic() { - return onlyPublic; + public String getAcknowledgeText() { + return acknowledgeText; + } + + public String getContactMail() { + return contactMail; } - public ArrayList getFlag1List() { - return flag1List; + public String getCorrectionMail() { + return correctionMail; + } + + public String getCopyrightURL() { + return copyrightURL; } -/* public int getFlag1NumericFromString(String flagSet) { - return getFlagNumericValue(flag1List,flagSet); - } */ - - public ArrayList getFlag2List() { - return flag2List; + public String getCopyrightAnchor() { + return copyrightAnchor; + } + + public String getRootBreadCrumbURL() { + return ""; + //TODO implement me + } + + public String getRootBreadCrumbAnchor() { + return ""; + //TODO implement me + } + + public String getShortHand() { + return "implement ApplicationBean.getShortHand()"; + // TODO implement me } -/* public int getFlag2NumericFromString(String flagSet) { - return getFlagNumericValue(flag2List,flagSet); - } */ - - public ArrayList getFlag3List() { - return flag3List; + /** + * Directory to find the images. Subdirectories include css, jsp and site_icons. + * Example: "themes/enhanced/" + * @return + */ + public String getThemeDir(){ + return (themeDir != null && themeDir.length()>0) + ? themeDir + : DEFAULT_THEME_DIR_FROM_CONTEXT; } - - public int removeMarkedFlagListEntries(ArrayList flagList,String status) { - int removeCount=0; - if (flagList!=null && flagList.size()>0){ - Object[] removals = new Object[flagList.size()]; - for(int i=0; i0) { - if (flagSet!=null && !flagSet.equals("")) { - StringTokenizer sTokens = new StringTokenizer(flagSet,","); - int sCount = sTokens.countTokens(); - for (int s=0; s getKeywords(); void setKeywords(List keywords); String getKeywordString(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/IndividualImpl.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/IndividualImpl.java index c6fd97c76..c9a3a9c4b 100755 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/IndividualImpl.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/IndividualImpl.java @@ -334,51 +334,6 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp primaryLink = link; } - - /* look at PortalFlag.numeric2numerics if you want to know which - * bits are set in a numeric flag. - * - * NOTICE: - * Values set Entity.getFlagXNumeric() will NOT be saved to the model. - * - * Also, changes to an entity flag state using Entity.setFlagXNumeric() - * are not reflected in Entity.getFlagXSet() and vice versa. - */ - protected String flag1Set = null; - public String getFlag1Set(){return flag1Set;} - public void setFlag1Set(String in){flag1Set=in;} - - protected int flag1Numeric = -1; - public int getFlag1Numeric(){return flag1Numeric;} - public void setFlag1Numeric(int i){flag1Numeric=i;} - - /* Consider the flagBitMask as a mask to & with flags. - if flagBitMask bit zero is set then return true if - the individual is in portal 2, - if flagBitMask bit 1 is set then return true if - the individua is in portal 4 - etc. - */ - public boolean doesFlag1Match(int flagBitMask) { - return (flagBitMask & getFlag1Numeric()) != 0; - } - - protected String flag2Set = null; - public String getFlag2Set(){return flag2Set;} - public void setFlag2Set(String in){flag2Set=in;} - - protected int flag2Numeric = -1; - public int getFlag2Numeric(){return flag2Numeric;} - public void setFlag2Numeric(int i){flag2Numeric=i;} - - protected String flag3Set = null; - public String getFlag3Set(){return flag3Set;} - public void setFlag3Set(String in){flag3Set=in;} - - protected int flag3Numeric = -1; - public int getFlag3Numeric(){return flag3Numeric;} - public void setFlag3Numeric(int i){flag3Numeric=i;} - public List getKeywords() { return keywords; } public void setKeywords(List keywords) {this.keywords = keywords;} public String getKeywordString(){ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Portal.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Portal.java deleted file mode 100644 index 88cc7dce2..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Portal.java +++ /dev/null @@ -1,544 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.beans; - -import java.io.File; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; - -/** - * This class is intended to store the information from one row off the portals table. - * It is not intended to store any sort of user or request state. - * - * @author bdc34 - * - */ -public class Portal implements Comparable { - // defaults for empty constructor or if database values are missing in a newly created clone or new portal, so something appears on web pages - public static int DEFAULT_PORTAL_ID = 1; - // DEFAULT_PORTAL_ID is not final (at the moment) because we don't yet have an RDF configuration for this, - // and certain clones might use a ServletContextListener to change the default at context startup. - final public static int DEFAULT_ROOT_TAB_ID = 23; - final public static String DEFAULT_APPNAME = "VITRO"; // signals bean is not being initialized correctly - - //final public static String DEFAULT_STYLESHEET = "portal"; // has .css.jsp added to it when file is retrieved - - final public static String DEFAULT_COPYRIGHT_URL = "http://www.library.cornell.edu"; - final public static String DEFAULT_COPYRIGHT_ANCHOR = "Cornell University Library"; - - final public static String DEFAULT_ROOT_BREADCRUMB_URL = "http://www.library.cornell.edu"; // may want to be null except for CALS portals, but used to provide URL behind logo - final public static String DEFAULT_ROOT_BREADCRUMB_ANCHOR = "Cornell University Library"; // may want to be null except for CALS portals, but used to provide URL behind logo - - final public static String DEFAULT_CONTACT_MAIL = "jc55@cornell.edu"; - - final public static int DEFAULT_IMAGE_THUMB_WIDTH = 150; - - final public static String DEFAULT_BANNER_IMAGE = null; // "pamlogo.328x76.transparent.gif"; - final public static int DEFAULT_BANNER_WIDTH = 328; - final public static int DEFAULT_BANNER_HEIGHT = 76; - - final public static String DEFAULT_LOGOTYPE_IMAGE = "libraryOnly_2color.transparent.181x76.gif"; - final public static int DEFAULT_LOGOTYPE_WIDTH = 181; - final public static int DEFAULT_LOGOTYPE_HEIGHT = 65; - - // Value gets set in default theme setup context listener at application startup - public static String DEFAULT_THEME_DIR_FROM_CONTEXT = null; - - final static boolean NOISY = false; - private final static boolean DEFAULT_FLAG1_FILTERING = true; - - // NOT STATIC, applying to each instance of the class that is created -//This is the start of fields that are from actual columns on the database - private int portalId; - private int rootTabId; - private String appName; - //stylesheet - private String bannerImage; - //oldname -// private String flag1Values; -// private String flag2Values; - private String contactMail; - private String correctionMail; - private String shortHand; - private String aboutText; - private String acknowledgeText; - private int bannerWidth; - private int bannerHeight; -// private String flag3Values; - private int flag2Numeric; - private int flag3Numeric; - private String copyrightURL; - private String copyrightAnchor; - private String rootBreadCrumbURL; - private String rootBreadCrumbAnchor; - private String logotypeImage; - private int logotypeWidth; - private int logotypeHeight; - private int imageThumbWidth; - private int displayRank; - private boolean flag1SearchFiltering; - private boolean flag2SearchFiltering; - private boolean flag3SearchFiltering; - private String urlprefix; - - /** If true, then this portal will be filtered by flag1 so that only individuals in the - * owl class Flag1Value${portalId}Thing will be displayed */ - private boolean flag1Filtering = DEFAULT_FLAG1_FILTERING; - -//END of fields that are from columns on database - - - private boolean initialized; - private String searchOptions; - private String navigationChoices; - private String themeDir; - private WebappDaoFactory webappDaoFactory; - - private static final Log log = LogFactory.getLog(Portal.class.getName()); - - /************************** Default Constructor ********************************/ - - /* - public Portal() { - initialized = false; - portalId = DEFAULT_PORTAL_ID; - displayRank = portalId; - rootTabId = DEFAULT_ROOT_TAB_ID; - appName = DEFAULT_APPNAME; - shortHand = DEFAULT_APPNAME; - imageThumbWidth = DEFAULT_IMAGE_THUMB_WIDTH; - bannerImage = DEFAULT_BANNER_IMAGE; - bannerWidth = DEFAULT_BANNER_WIDTH; - bannerHeight = DEFAULT_BANNER_HEIGHT; - logotypeImage = DEFAULT_LOGOTYPE_IMAGE; - logotypeWidth = DEFAULT_LOGOTYPE_WIDTH; - logotypeHeight = DEFAULT_LOGOTYPE_HEIGHT; - flag2Numeric = 0; - flag3Numeric = 0; - flag1SearchFiltering = true; - flag2SearchFiltering = true; - flag3SearchFiltering = true; - aboutText = null; - acknowledgeText = null; - contactMail = DEFAULT_CONTACT_MAIL; - copyrightURL = DEFAULT_COPYRIGHT_URL; - copyrightAnchor = DEFAULT_COPYRIGHT_ANCHOR; - rootBreadCrumbURL = null; // don't always want to display a root breadcrumb URL from outside the site - rootBreadCrumbAnchor = null; - searchOptions = null; - navigationChoices = null; - themeDir = DEFAULT_THEME_DIR; - urlprefix = null; - } - */ - - - /* - public PortalBean(String session_id_str,int portal_id,int root_tab_id,String app_name,String short_hand,String style_sheet, - int image_thumb_width,String banner_image,int banner_width,int banner_height, - String logotype_image,int logotype_width,int logotype_height,String contact_mail, - int flag2_numeric,int flag3_numeric,String copyright_url,String copyright_anchor,String root_breadcrumb_url,String root_breadcrumb_anchor) { - initialized = true; - sessionIdStr = session_id_str; - portalId = portal_id; - rootTabId = root_tab_id; - appName = app_name; - shortHand = short_hand; - stylesheet = style_sheet; - imageThumbWidth = image_thumb_width; - bannerImage = banner_image; - bannerWidth = banner_width; - bannerHeight = banner_height; - logotypeImage = logotype_image; - logotypeWidth = logotype_width; - logotypeHeight = logotype_height; - flag2Numeric = flag2_numeric; - flag3Numeric = flag3_numeric; - contactMail = contact_mail; - copyrightURL = copyright_url; - copyrightAnchor = copyright_anchor; - rootBreadCrumbURL = root_breadcrumb_url; - rootBreadCrumbAnchor = root_breadcrumb_anchor; - //displayRank = display_rank; // not set from JSP - } */ - - - - - - public String toHTML() { - String output = "

Portal Info:

    "; - output += "
  • portal id: [" + portalId + "]
  • "; - output += "
  • root tab id: [" + rootTabId + "]
  • "; - output += "
  • portal app name: [" + appName + "]
  • "; - output += "
  • portal shortHand: [" + shortHand + "]
  • "; - output += "
  • contact email: [" + contactMail + "]
  • "; - output += "
  • correction email: [" + contactMail + "]
  • "; - output += "
  • portal theme directory: [" + themeDir + "]
  • "; - output += "
  • image thumb width [" + imageThumbWidth + "]
  • "; - output += "
  • banner image: [" + bannerImage + "]
  • "; - output += "
  • banner image width: [" + bannerWidth + "]
  • "; - output += "
  • banner image height: [" + bannerHeight + "]
  • "; - output += "
  • logotype image: [" + logotypeImage + "]
  • "; - output += "
  • logotype image width: [" + logotypeWidth + "]
  • "; - output += "
  • logotype image height:[" + logotypeHeight + "]
  • "; -// output += "
  • flag 1 values: [" + flag1Values + "]
  • "; -// output += "
  • flag 2 values: [" + flag2Values + "]
  • "; - output += "
  • flag 2 numeric [" + flag2Numeric + "]
  • "; -// output += "
  • flag 3 values: [" + flag3Values + "]
  • "; - output += "
  • flag 3 numeric [" + flag3Numeric + "]
  • "; - output += "
  • flag1 search filters [" + flag1SearchFiltering + "]
  • "; - output += "
  • flag2 search filters [" + flag2SearchFiltering + "]
  • "; - output += "
  • flag3 search filters [" + flag3SearchFiltering + "]
  • "; - output += "
  • About text [" + aboutText + "]
  • "; - output += "
  • Acknowledge text [" + acknowledgeText + "]
  • "; - output += "
  • copyright URL: [" + copyrightURL + "]
  • "; - output += "
  • copyright anchor: [" + copyrightAnchor + "]
  • "; - output += "
  • breadcrumb URL: [" + rootBreadCrumbURL + "]
  • "; - output += "
  • breadcrumb anchor: [" + rootBreadCrumbAnchor + "]
  • "; - output += "
  • display rank: [" + displayRank + "]
  • "; - output += "
  • search options [" + searchOptions + "]
  • "; - output += "
  • navigation choices [" + navigationChoices + "]
  • "; - output += "
  • urlprefix [" + urlprefix + "]
  • "; - output += "

"; - return output; - } - - /*************************** SET functions ****************************/ - - public void setInitialized( boolean boolean_val ) { - initialized=boolean_val; - } - - public void setPortalId(int int_val) { - portalId=int_val; - } - - public void setRootTabId(int int_val) { - rootTabId=int_val; - } - - public void setAppName(String string_val) { - appName = string_val; - } - - public void setShortHand(String string_val) { - shortHand = string_val; - } - - public void setContactMail(String string_val) { - contactMail = string_val; - } - - public void setCorrectionMail(String string_val) { - correctionMail = string_val; - } - - public void setImageThumbWidth(int int_val) { - imageThumbWidth = int_val; - } - - public void setBannerImage(String string_val) { - bannerImage = string_val; - } - - public void setBannerWidth(int int_val) { - bannerWidth = int_val; - } - - public void setBannerHeight(int int_val) { - bannerHeight = int_val; - } - - public void setLogotypeImage(String string_val) { - logotypeImage = string_val; - } - - public void setLogotypeWidth(int int_val) { - logotypeWidth = int_val; - } - - public void setLogotypeHeight(int int_val) { - logotypeHeight = int_val; - } - -/* public void setFlag1Values(String string_val) { - flag1Values = string_val; - } - - public void setFlag2Values(String string_val) { - flag2Values = string_val; - } */ - - public void setFlag2Numeric(int int_val) { - flag2Numeric = int_val; - } - -/* public void setFlag3Values(String string_val) { - flag3Values = string_val; - } */ - - public void setFlag3Numeric(int int_val) { - flag3Numeric = int_val; - } - - public void setFlag1SearchFilters(boolean b_val) { - flag1SearchFiltering=b_val; - } - - public void setFlag2SearchFilters(boolean b_val) { - flag2SearchFiltering=b_val; - } - - public void setFlag3SearchFilters(boolean b_val) { - flag3SearchFiltering=b_val; - } - - public void setAboutText(String string_val) { - aboutText = string_val; - } - - public void setAcknowledgeText(String string_val) { - acknowledgeText = string_val; - } - - public void setCopyrightURL(String string_val) { - copyrightURL = string_val; - } - - public void setCopyrightAnchor(String string_val) { - copyrightAnchor = string_val; - } - - public void setRootBreadCrumbURL(String string_val) { - rootBreadCrumbURL = string_val; - } - - public void setRootBreadCrumbAnchor(String string_val) { - rootBreadCrumbAnchor = string_val; - } - - public void setDisplayRank(int int_val) { - displayRank=int_val; - } - - public void setSearchOptions(String string_val) { - searchOptions=string_val; - } - - public void setNavigationChoices(String string_val) { - navigationChoices=string_val; - } - - public void setUrlprefix(String in){ - this.urlprefix = in; - } - public void setFlag1Filtering(String b){ - flag1Filtering = "true".equalsIgnoreCase(b); - } - - public void setWebappDaoFactory (WebappDaoFactory wdf) { - this.webappDaoFactory = wdf; - } - - /*************************** GET functions ****************************/ - - public boolean isInitialized() { - return initialized; - } - - public int getPortalId() { - return portalId; - } - - public int getRootTabId() { - return rootTabId; - } - - public String getAppName() { - return appName; - } - - public String getShortHand() { - return shortHand; - } - - public String getContactMail() { - return contactMail; - } - - public String getCorrectionMail() { - return correctionMail; - } - - public int getImageThumbWidth() { - return imageThumbWidth; - } - - public String getBannerImage() { - return bannerImage; - } - - public int getBannerWidth() { - return bannerWidth; - } - - public int getBannerHeight() { - return bannerHeight; - } - - public String getLogotypeImage() { - return logotypeImage; - } - - public int getLogotypeWidth() { - return logotypeWidth; - } - - public int getLogotypeHeight() { - return logotypeHeight; - } - -/* public String getFlag1Values() { - return flag1Values; - } - - public String getFlag2Values() { - return flag2Values; - } */ - - public int getFlag2Numeric() { - return flag2Numeric; - } - -/* public String getFlag3Values() { - return flag3Values; - } */ - - public int getFlag3Numeric() { - return flag3Numeric; - } - - public boolean isFlag1SearchFiltering() { - return flag1SearchFiltering; - } - - public boolean isFlag2SearchFiltering() { - return flag2SearchFiltering; - } - - public boolean isFlag3SearchFiltering() { - return flag3SearchFiltering; - } - - public String getAboutText() { - return aboutText; - } - - public String getAcknowledgeText() { - return acknowledgeText; - } - - public String getCopyrightURL() { - return copyrightURL; - } - - public String getCopyrightAnchor() { - return copyrightAnchor; - - } - public String getRootBreadCrumbURL() { - return rootBreadCrumbURL; - } - - public String getRootBreadCrumbAnchor() { - return rootBreadCrumbAnchor; - } - - public int getDisplayRank() { - return displayRank; - } - - public String getSearchOptions() { - return searchOptions; - } - - public String getNavigationChoices() { - return navigationChoices; - } - - public String getUrlprefix(){ - return this.urlprefix; - } - - public boolean isFlag1Filtering(){ - return flag1Filtering; - } - - /** - * Directory to find the images. Subdirectories include css, jsp and site_icons. - * Example: "themes/enhanced/" - * @return - */ - public String getThemeDir(){ - return (themeDir != null && themeDir.length()>0) ? themeDir : DEFAULT_THEME_DIR_FROM_CONTEXT; - } - public void setThemeDir(String string_val) { - if( string_val == null || string_val.length() == 0 - || "default".equalsIgnoreCase(string_val) - || "portal".equalsIgnoreCase(string_val) - || "null".equalsIgnoreCase(string_val) - || " ".equalsIgnoreCase(string_val) ) - themeDir = DEFAULT_THEME_DIR_FROM_CONTEXT; - else - themeDir = string_val; - } - - public boolean themeDirExists(){ - String themeDir = this.getThemeDir(); - if( themeDir == null || themeDir.length() < 1 ){ - log.error("Portal id: " + this.getPortalId() + " has no themeDir/stylesheet set in the db." ); - return false; - } - - File dir = new File(themeDir); - if( !dir.exists() ){ - log.error("Portal id: " + getPortalId() + ", the themeDir/stylesheet " - + dir.getAbsolutePath()+ " does not exist."); - return false; - } - if( !dir.isDirectory() ){ - log.error("Portal id: " + getPortalId() + ", themeDir/stylesheet " - + dir.getAbsolutePath() + " is not a directory."); - return false; - } - if( !dir.canRead() ){ - log.error("Portal id: " + getPortalId() + ", themeDir/stylesheet " - + dir.getAbsolutePath() + " is not readable."); - return false; - } - return true; - } - - public int compareTo(Object o1) { - return this.portalId - ((Portal)o1).getPortalId(); - } - - // nac26: 20080618 - no longer used as we are not switching themes as part of self editing - //public String getDefaultEditThemeDir() { - // return "themes/editdefault/"; - //} - - public WebappDaoFactory getWebappDaoFactory() { - return this.webappDaoFactory; - } - - public String getTypeUri(){ - return VitroVocabulary.vitroURI + "Flag1Value" - + getPortalId() + "Thing"; - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Tab.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Tab.java index 91df8f382..e8ba9d570 100755 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Tab.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/Tab.java @@ -6,11 +6,8 @@ package edu.cornell.mannlib.vitro.webapp.beans; * @version 1 2005-08-27 * @authors Jon Corson-Rikert, Brian Caruso * - * A tab is a browsing facet within a single portal. While it might sometimes be - * convenient to share tabs across portals, curators often prefer to be able to - * tweak display controls on their own, as for example to adjust the dayLimit field - * to control how many news releases show up in a given portal during busy or dry news spells - * + * A tab is a browsing facet within the application. + * * UPDATES * BDC 2005-12-02 : updated to work with refactored db * 2005-10-19 jc55 changed test on date of entity sunrise field to <= from < when looking at sunrise (a negative value in tab dayLimit) @@ -83,10 +80,6 @@ public class Tab implements java.io.Serializable, Comparable { // class to public void setTabId(int val) {tabId=val;} public int getTabId() {return tabId;} - private int portalId=0; // each tab belongs to a different portal - public void setPortalId(int val) {portalId=val;} - public int getPortalId() {return portalId;} - private int tabtypeId=0; // 0 unspecified, 28 primary tab,26 primary tab content,24 secondary tab,22 collection,20 subcollection,18 subcollection category public void setTabtypeId(int val) {tabtypeId=val;} @@ -272,7 +265,6 @@ public class Tab implements java.io.Serializable, Comparable { // class to public Tab() { // identifiers tabId = -1; // primary key of tabs table is auto_increment so this could be 0; - portalId = 0; tabtypeId = 0; userId = 0; statusId = 0; @@ -316,7 +308,6 @@ public class Tab implements java.io.Serializable, Comparable { // class to public String toHTML() { String output = "

Tab:

    "; output += "
  • tab id: [" + tabId + "]
  • "; - output += "
  • portal id: [" + portalId + "]
  • "; output += "
  • tabtype id: [" + tabtypeId + "]
  • "; output += "
  • user id: [" + userId + "]
  • "; output += "
  • day limit: [" + dayLimit + "]
  • "; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/ContactMailServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/ContactMailServlet.java index aa98579d2..cee5748d8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/ContactMailServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/ContactMailServlet.java @@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; +import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; public class ContactMailServlet extends VitroHttpServlet { @@ -64,13 +64,15 @@ public class ContactMailServlet extends VitroHttpServlet { throws ServletException, IOException { VitroRequest vreq = new VitroRequest(request); - Portal portal = vreq.getPortal(); + + ApplicationBean appBean = vreq.getAppBean(); + String statusMsg = null; // holds the error status if (smtpHost==null || smtpHost.equals("")){ statusMsg = "This application has not yet been configured to send mail " + "-- smtp host has not been identified in the Configuration Properties file."; - redirectToError(response, statusMsg, portal); + redirectToError(response, statusMsg); return; } @@ -81,7 +83,7 @@ public class ContactMailServlet extends VitroHttpServlet { String validationMessage = validateInput(webusername, webuseremail, comments); if (validationMessage != null) { - redirectToError(response, validationMessage, portal); + redirectToError(response, validationMessage); return; } webusername = webusername.trim(); @@ -121,29 +123,29 @@ public class ContactMailServlet extends VitroHttpServlet { String deliveryfrom = null; if ("comment".equals(formType)) { - if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) { - log.error("No contact mail address defined in current portal "+portal.getPortalId()); + if (appBean.getContactMail() == null || appBean.getContactMail().trim().length()==0) { + log.error("No contact mail address defined in current application"); throw new Error( "To establish the Contact Us mail capability the system administrators must " + "specify an email address in the current portal."); } else { - deliverToArray = portal.getContactMail().split(","); + deliverToArray = appBean.getContactMail().split(","); } - deliveryfrom = "Message from the "+portal.getAppName()+" Contact Form"; + deliveryfrom = "Message from the "+appBean.getApplicationName()+" Contact Form"; } else if ("correction".equals(formType)) { - if (portal.getCorrectionMail() == null || portal.getCorrectionMail().trim().length()==0) { - log.error("Expecting one or more correction email addresses to be specified in current portal "+portal.getPortalId()+"; will attempt to use contact mail address"); - if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) { - log.error("No contact mail address or correction mail address defined in current portal "+portal.getPortalId()); + if (appBean.getCorrectionMail() == null || appBean.getCorrectionMail().trim().length()==0) { + log.error("Expecting one or more correction email addresses to be specified in current application; will attempt to use contact mail address"); + if (appBean.getContactMail() == null || appBean.getContactMail().trim().length()==0) { + log.error("No contact mail address or correction mail address defined in current application"); } else { - deliverToArray = portal.getContactMail().split(","); + deliverToArray = appBean.getContactMail().split(","); } } else { - deliverToArray = portal.getCorrectionMail().split(","); + deliverToArray = appBean.getCorrectionMail().split(","); } - deliveryfrom = "Message from the "+portal.getAppName()+" Correction Form (ARMANN-nospam)"; + deliveryfrom = "Message from the "+appBean.getApplicationName()+" Correction Form (ARMANN-nospam)"; } else { - deliverToArray = portal.getContactMail().split(","); + deliverToArray = appBean.getContactMail().split(","); statusMsg = SPAM_MESSAGE ; spamReason = "The form specifies no delivery type."; } @@ -197,10 +199,10 @@ public class ContactMailServlet extends VitroHttpServlet { // Redirect to the appropriate confirmation page if (statusMsg == null && spamReason == null) { // message was sent successfully - redirectToConfirmation(response, statusMsg, portal); + redirectToConfirmation(response, statusMsg); } else { // exception occurred - redirectToError( response, statusMsg, portal); + redirectToError( response, statusMsg); } } @@ -213,15 +215,13 @@ public class ContactMailServlet extends VitroHttpServlet { } private void redirectToConfirmation(HttpServletResponse response, - String statusMsg, Portal portal) throws IOException { - response.sendRedirect( "test?bodyJsp=" + CONFIRM_PAGE + "&home=" + - portal.getPortalId() ); + String statusMsg) throws IOException { + response.sendRedirect( "test?bodyJsp=" + CONFIRM_PAGE + "&home=" ); } - private void redirectToError(HttpServletResponse response, String statusMsg, - Portal portal) throws IOException { - response.sendRedirect( "test?bodyJsp=" + ERR_PAGE + "&ERR=" + statusMsg - + "&home=" + portal.getPortalId() ); + private void redirectToError(HttpServletResponse response, String statusMsg) + throws IOException { + response.sendRedirect("test?bodyJsp=" + ERR_PAGE + "&ERR=" + statusMsg); } /** Intended to mangle url so it can get through spam filtering diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityURLController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityURLController.java index 0f4cbdc93..8b67cb98b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityURLController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityURLController.java @@ -1,21 +1,13 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ package edu.cornell.mannlib.vitro.webapp.controller; import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; -import java.util.ListIterator; -import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,30 +21,13 @@ import org.apache.lucene.search.Sort; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; -import com.hp.hpl.jena.ontology.OntClass; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.ontology.OntProperty; -import com.hp.hpl.jena.ontology.OntResource; -import com.hp.hpl.jena.query.QueryExecutionFactory; -import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.ResourceFactory; -import com.hp.hpl.jena.shared.Lock; -import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.RDF; -import com.hp.hpl.jena.vocabulary.RDFS; -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; -import edu.cornell.mannlib.vitro.webapp.beans.VClass; -import edu.cornell.mannlib.vitro.webapp.dao.Classes2ClassesDao; -import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; -import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc; import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory; import edu.cornell.mannlib.vitro.webapp.web.ContentType; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONReconcileServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONReconcileServlet.java index 4697eb15b..276e0af4e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONReconcileServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONReconcileServlet.java @@ -38,7 +38,6 @@ import org.json.JSONObject; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; -import edu.cornell.mannlib.vitro.webapp.flags.PortalFlag; import edu.cornell.mannlib.vitro.webapp.search.SearchException; import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc; import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames; @@ -233,7 +232,6 @@ public class JSONReconcileServlet extends VitroHttpServlet { VitroRequest vreq) throws ServletException { JSONObject qJson = new JSONObject(); try { - PortalFlag portalFlag = vreq.getPortalFlag(); Analyzer analyzer = getAnalyzer(getServletContext()); IndexSearcher searcherForRequest = LuceneIndexFactory .getIndexSearcher(getServletContext()); @@ -275,7 +273,7 @@ public class JSONReconcileServlet extends VitroHttpServlet { // begin search JSONArray resultJsonArr = new JSONArray(); - Query query = getReconcileQuery(vreq, portalFlag, analyzer, + Query query = getReconcileQuery(vreq, analyzer, queryVal, searchType, propertiesList); TopDocs topDocs = searcherForRequest.search(query, null, limit); @@ -438,8 +436,8 @@ public class JSONReconcileServlet extends VitroHttpServlet { return qp; } - private Query getReconcileQuery(VitroRequest request, PortalFlag portalState, - Analyzer analyzer, String querystr, String typeParam, ArrayList propertiesList) throws SearchException{ + private Query getReconcileQuery(VitroRequest request, Analyzer analyzer, + String querystr, String typeParam, ArrayList propertiesList) throws SearchException{ Query query = null; try { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java index 697a7e905..35defa3b0 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java @@ -98,7 +98,7 @@ public class JSONServlet extends VitroHttpServlet { } VClassGroupCache vcgc = VClassGroupCache.getVClassGroupCache(getServletContext()); - VClassGroup vcg = vcgc.getGroup(vreq.getPortalId(), vcgUri); + VClassGroup vcg = vcgc.getGroup(vcgUri); if( vcg == null ){ log.debug("Could not find vclassgroup: " + vcgUri); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); @@ -226,8 +226,6 @@ public class JSONServlet extends VitroHttpServlet { vclass.getURI(), page, alpha, - vreq.getPortal(), - vreq.getWebappDaoFactory().getPortalDao().isSinglePortal(), vreq.getWebappDaoFactory().getIndividualDao(), context); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java index 50b65834f..b016b176f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/MailUsersServlet.java @@ -23,7 +23,6 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.UserDao; @@ -50,7 +49,6 @@ public class MailUsersServlet extends VitroHttpServlet { public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { VitroRequest vreq = new VitroRequest(request); - Portal portal = vreq.getPortal(); String confirmpage = "/confirmUserMail.jsp"; String errpage = "/contact_err.jsp"; @@ -59,7 +57,7 @@ public class MailUsersServlet extends VitroHttpServlet { if (smtpHost==null || smtpHost.equals("")){ status = "This application has not yet been configured to send mail " + "-- smtp host has not been identified in the Configuration Properties file."; - response.sendRedirect( "test?bodyJsp=" + errpage + "&ERR=" + status + "&home=" + portal.getPortalId() ); + response.sendRedirect( "test?bodyJsp=" + errpage + "&ERR=" + status ); return; } @@ -219,10 +217,10 @@ public class MailUsersServlet extends VitroHttpServlet { // Redirect to the appropriate confirmation page if (status == null && !probablySpam) { // message was sent successfully - response.sendRedirect( "test?bodyJsp=" + confirmpage + "&home=" + portal.getPortalId() ); + response.sendRedirect( "test?bodyJsp=" + confirmpage ); } else { // exception occurred - response.sendRedirect( "test?bodyJsp=" + errpage + "&ERR=" + status + "&home=" + portal.getPortalId() ); + response.sendRedirect( "test?bodyJsp=" + errpage + "&ERR=" + status ); } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java index fd0bcc61b..498454afc 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java @@ -2,8 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.controller; import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -11,7 +9,6 @@ import java.util.regex.Pattern; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -19,28 +16,16 @@ import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.ontology.OntProperty; import com.hp.hpl.jena.ontology.OntResource; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.hp.hpl.jena.rdf.model.Property; -import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.shared.Lock; -import com.hp.hpl.jena.vocabulary.RDF; -import com.hp.hpl.jena.vocabulary.RDFS; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; -import edu.cornell.mannlib.vitro.webapp.beans.VClass; -import edu.cornell.mannlib.vitro.webapp.dao.Classes2ClassesDao; -import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; -import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.web.ContentType; public class OntologyController extends VitroHttpServlet{ @@ -238,80 +223,15 @@ public class OntologyController extends VitroHttpServlet{ private void doNotFound(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { VitroRequest vreq = new VitroRequest(req); - Portal portal = vreq.getPortal(); - ApplicationBean appBean = ApplicationBean.getAppBean(getServletContext()); - int allPortalId = appBean.getAllPortalFlagNumeric(); - //If an Individual is not found, there is possibility that it - //was requested from a portal where it was not visible. - //In this case redirect to the all portal. - try{ - Portal allPortal = - vreq.getWebappDaoFactory().getPortalDao().getPortal(allPortalId); - // there must be a portal defined with the ID of the all portal - // for this to work - if( portal.getPortalId() != allPortalId && allPortal != null ) { - - //bdc34: - // this is hard coded to get the all portal - // I didn't find a way to get the id of the all portal - // it is likely that redirecting will not work in non VIVO clones - String portalPrefix = null; - String portalParam = null; - if( allPortal != null && allPortal.getUrlprefix() != null ) - portalPrefix = allPortal.getUrlprefix(); - else - portalParam = "home=" + allPortalId; - - String queryStr = req.getQueryString(); - if( queryStr == null && portalParam != null && !"".equals(portalParam)){ - queryStr = portalParam; - } else { - if( portalParam != null && !"".equals(portalParam)) - queryStr = queryStr + "&" + portalParam; - } - if( queryStr != null && !queryStr.startsWith("?") ) - queryStr = "?" + queryStr; - - StringBuilder url = new StringBuilder(); - url.append( req.getContextPath() ); - if( req.getContextPath() != null && !req.getContextPath().endsWith("/")) - url.append('/'); - - if( portalPrefix != null && !"".equals(portalPrefix)) - url.append( portalPrefix ).append('/'); - - String servletPath = req.getServletPath(); - String spath = ""; - if( servletPath != null ){ - if( servletPath.startsWith("/") ) - spath = servletPath.substring(1); - else - spath = servletPath; - } - - if( spath != null && !"".equals(spath)) - url.append( spath ); - - if( req.getPathInfo() != null ) - url.append( req.getPathInfo() ); - - if( queryStr != null && !"".equals(queryStr )) - url.append( queryStr ); - - res.sendRedirect(url.toString()); - return; - } - }catch(Throwable th){ - log.error("could not do a redirect", th); - } + ApplicationBean appBean = ApplicationBean.getAppBean(getServletContext()); //set title before we do the highlighting so we don't get markup in it. req.setAttribute("title","not found"); res.setStatus(HttpServletResponse.SC_NOT_FOUND); String css = "" + + appBean.getThemeDir() + "css/entity.css\"/>" + ""; req.setAttribute("css",css); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java index 3b6748ef2..e09f84d91 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryBuilderServlet.java @@ -21,8 +21,6 @@ import com.hp.hpl.jena.sparql.resultset.ResultSetFormat; import edu.cornell.mannlib.vedit.controller.BaseEditController; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.UseAdvancedDataToolsPages; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; - /** * This servlet works as a RequestDispatcher to direct to the sparl query builder page. @@ -106,11 +104,9 @@ public class SparqlQueryBuilderServlet extends BaseEditController { //res.setStatus(HttpServletResponse.SC_BAD_REQUEST); VitroRequest vreq = new VitroRequest(req); - Portal portal = vreq.getPortal(); /* Code change completed */ - req.setAttribute("portalBean",portal); // nac26: 2009-09-25 - this was causing problems in safari on localhost installations because the href did not include the context. The edit.css is not being used here anyway (or anywhere else for that matter) // req.setAttribute("css", ""); req.setAttribute("title","SPARQL Query Builder"); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryServlet.java index ae738550b..69521e6b5 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/SparqlQueryServlet.java @@ -49,7 +49,6 @@ import edu.cornell.mannlib.vedit.controller.BaseEditController; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.UseAdvancedDataToolsPages; import edu.cornell.mannlib.vitro.webapp.beans.Ontology; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; @@ -326,7 +325,6 @@ public class SparqlQueryServlet extends BaseEditController { private void doHelp(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { VitroRequest vreq = new VitroRequest(req); - Portal portal = vreq.getPortal(); OntologyDao daoObj = vreq.getFullWebappDaoFactory().getOntologyDao(); List ontologiesObj = daoObj.getAllOntologies(); @@ -345,7 +343,6 @@ public class SparqlQueryServlet extends BaseEditController { req.setAttribute("prefixList", prefixList); - req.setAttribute("portalBean",portal); // nac26: 2009-09-25 - this was causing problems in safari on localhost installations because the href did not include the context. The edit.css is not being used here anyway (or anywhere else for that matter) // req.setAttribute("css", ""); req.setAttribute("title","SPARQL Query"); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabController.java index 6e4fcff2b..9474980af 100755 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabController.java @@ -2,21 +2,20 @@ package edu.cornell.mannlib.vitro.webapp.controller; -import java.io.IOException; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.jsp.JspException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; -import edu.cornell.mannlib.vitro.webapp.beans.Tab; -import edu.cornell.mannlib.vitro.webapp.web.TabWebUtil; +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.jsp.JspException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.beans.Tab; +import edu.cornell.mannlib.vitro.webapp.web.TabWebUtil; public class TabController extends VitroHttpServlet { private static final long serialVersionUID = -5340982482787800013L; @@ -48,10 +47,9 @@ public class TabController extends VitroHttpServlet { //get tab and subtabs. Tab leadingTab = populateLeadingTab(request); - request.setAttribute("leadingTab",leadingTab); - - Portal portal = vreq.getPortal(); - + request.setAttribute("leadingTab",leadingTab); + + /* if (leadingTab.getTabId()==portal.getRootTabId()) { request.setAttribute("homePageRequested", "true"); request.setAttribute("title", portal.getAppName()); @@ -59,9 +57,9 @@ public class TabController extends VitroHttpServlet { rd.forward(request, response); return; } - else { + else { */ request.setAttribute("title",leadingTab.getTitle()); - } + /* } */ String body = leadingTab.getBody(); if( body != null && body.startsWith("JSPBody:") ) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java index 0f3ca13ef..29320f477 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/TabEntitiesController.java @@ -37,9 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.TabDao; import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc; import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory; import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexer; -import edu.cornell.mannlib.vitro.webapp.utils.FlagMathUtils; import edu.cornell.mannlib.vitro.webapp.web.TabWebUtil; -import freemarker.template.TemplateModel; /** * Produces the entity lists for tabs. @@ -213,14 +211,14 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) //try to get the URIs of the required individuals from the lucene index IndexSearcher index = LuceneIndexFactory.getIndexSearcher(getServletContext()); - boolean isSinglePortal = request.getWebappDaoFactory().getPortalDao().isSinglePortal(); + BooleanQuery query = null; if( tab.isAutoLinked() ){ - query = getQuery(tab, autoLinkedUris, null, alpha, isSinglePortal); + query = getQuery(tab, autoLinkedUris, null, alpha); }else if (tab.isManualLinked() ){ - query = getQuery(tab, null, manuallyLinkedUris, alpha, isSinglePortal); + query = getQuery(tab, null, manuallyLinkedUris, alpha); }else if ( tab.isMixedLinked() ){ - query = getQuery(tab, autoLinkedUris, manuallyLinkedUris, alpha, isSinglePortal); + query = getQuery(tab, autoLinkedUris, manuallyLinkedUris, alpha); }else{ log.error("Tab " + tab.getTabId() + " is neither manually, auto nor mixed. "); } @@ -390,7 +388,7 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) * get their individuals using lucene, see doManual(). * */ - private BooleanQuery getQuery(Tab tab, List vclassUris, List manualUris, String alpha , boolean isSinglePortal){ + private BooleanQuery getQuery(Tab tab, List vclassUris, List manualUris, String alpha){ BooleanQuery query = new BooleanQuery(); try{ @@ -408,25 +406,7 @@ public void doGet( HttpServletRequest req, HttpServletResponse response ) } } typeQuery.add(queryForTypes, BooleanClause.Occur.MUST); - - //check for portal filtering only on auto linked queries - if( ! isSinglePortal ){ - int tabPortal = tab.getPortalId(); - if( tabPortal < 16 ){ //could be a normal portal - typeQuery.add( - new TermQuery( new Term(Entity2LuceneDoc.term.PORTAL, Integer.toString(1 << tab.getPortalId() ))), - BooleanClause.Occur.MUST); - }else{ //could be a combined portal - BooleanQuery tabQueries = new BooleanQuery(); - Long[] ids= FlagMathUtils.numeric2numerics(tabPortal); - for( Long id : ids){ - tabQueries.add( - new TermQuery( new Term(Entity2LuceneDoc.term.PORTAL,id.toString()) ), - BooleanClause.Occur.SHOULD); - } - typeQuery.add(tabQueries,BooleanClause.Occur.MUST); - } - } + } //make query for manually linked individuals diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/UserMailController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/UserMailController.java index 4a2572ba3..ce55a1c6c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/UserMailController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/UserMailController.java @@ -10,8 +10,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; -import edu.cornell.mannlib.vitro.webapp.controller.ContactMailServlet; /** * Controller for comments ("contact us") page @@ -41,24 +39,8 @@ public class UserMailController extends VitroHttpServlet{ errd.forward(request, response); } ApplicationBean appBean=vreq.getAppBean(); - Portal portalBean=vreq.getPortal(); - if ( (appBean.getMaxSharedPortalId()-appBean.getMinSharedPortalId()) > 1 - && ( (portalBean.getPortalId() >= appBean.getMinSharedPortalId() - && portalBean.getPortalId() <= appBean.getMaxSharedPortalId() ) - || portalBean.getPortalId() == appBean.getSharedPortalFlagNumeric() ) - ) { - request.setAttribute("portalType","CALSResearch"); - } else - if (portalBean.getAppName().equalsIgnoreCase("CALS Impact")){ - request.setAttribute("portalType", "CALSImpact"); - } else if (portalBean.getAppName().equalsIgnoreCase("VIVO")) { - request.setAttribute("portalType", "VIVO"); - } else { - request.setAttribute("portalType", "clone"); - } - - request.setAttribute("siteName",portalBean.getAppName()); + request.setAttribute("siteName", appBean.getApplicationName()); request.setAttribute("scripts","/js/commentsForm.js"); if (request.getHeader("Referer") == null) @@ -66,12 +48,8 @@ public class UserMailController extends VitroHttpServlet{ else request.getSession().setAttribute("commentsFormReferer",request.getHeader("Referer")); - - request.setAttribute("portalId",Integer.valueOf(portalBean.getPortalId())); - - request.setAttribute("title", portalBean.getAppName()+" Mail Users Form"); + request.setAttribute("title", appBean.getApplicationName()+" Mail Users Form"); request.setAttribute("bodyJsp", "/templates/parts/emailUsers.jsp");// <<< this is where the body gets set - request.setAttribute("portalBean",portalBean); RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java index b85d50f8f..3b495a8b0 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java @@ -22,11 +22,8 @@ import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.query.Dataset; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao; -import edu.cornell.mannlib.vitro.webapp.flags.PortalFlag; -import edu.cornell.mannlib.vitro.webapp.flags.SunsetFlag; public class VitroRequest implements HttpServletRequest { @@ -139,50 +136,9 @@ public class VitroRequest implements HttpServletRequest { return jenaOntModel; } - public Portal getPortal(){ - return(Portal) getAttribute("portalBean"); - } - public void setPortal(Portal p){ - setAttribute("portalBean", p); - setAttribute("portal", p); - } - - public int getPortalId(){ - String idstr = (String)getAttribute("home"); - - if( idstr == null ){ - WebappDaoFactory wdf = getWebappDaoFactory(); - Portal[] portals = wdf.getPortalDao().getAllPortals().toArray(new Portal[0]); - return portals[0].getPortalId(); - } - - try{ - return Integer.parseInt(idstr); - }catch( Throwable th){ - throw new Error("home parameter was not set in request"); - } - - } - public void setPortalId(String in){ - setAttribute("home",in); - } - - public PortalFlag getPortalFlag(){ - return(PortalFlag) getAttribute("portalFlag"); - } - public void setPortalFlag(PortalFlag pf){ - setAttribute("portalFlag", pf); - } - - public SunsetFlag getSunsetFlag(){ - return (SunsetFlag) getAttribute("sunsetFlag"); - } - public void setSunsetFlag(SunsetFlag sf){ - setAttribute("sunsetFlag",sf); - } - public ApplicationBean getAppBean(){ - return (ApplicationBean) getAttribute("appBean"); + //return (ApplicationBean) getAttribute("appBean"); + return getWebappDaoFactory().getApplicationDao().getApplicationBean(); } public void setAppBean(ApplicationBean ab){ setAttribute("appBean",ab); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/ApplicationBeanRetryController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/ApplicationBeanRetryController.java new file mode 100644 index 000000000..36ed0ce55 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/ApplicationBeanRetryController.java @@ -0,0 +1,140 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.edit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import edu.cornell.mannlib.vedit.beans.EditProcessObject; +import edu.cornell.mannlib.vedit.beans.FormObject; +import edu.cornell.mannlib.vedit.beans.Option; +import edu.cornell.mannlib.vedit.controller.BaseEditController; +import edu.cornell.mannlib.vedit.util.FormUtils; +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.EditSiteInformation; +import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.controller.Controllers; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao; +import edu.cornell.mannlib.vitro.webapp.utils.ThemeUtils; + +public class ApplicationBeanRetryController extends BaseEditController { + + private static final Log log = LogFactory.getLog(ApplicationBeanRetryController.class.getName()); + + public void doPost (HttpServletRequest req, HttpServletResponse response) { + + if (!isAuthorizedToDisplayPage(req, response, new Actions(new EditSiteInformation()))) { + return; + } + + VitroRequest request = new VitroRequest(req); + + try { + super.doGet(request,response); + } catch (Exception e) { + log.error("PortalRetryController encountered exception calling super.doGet()"); + } + + //create an EditProcessObject for this and put it in the session + EditProcessObject epo = super.createEpo(request); + + epo.setBeanClass(ApplicationBean.class); + + String action = "update"; + + ApplicationDao aDao = request.getFullWebappDaoFactory().getApplicationDao(); + ApplicationBean applicationForEditing = aDao.getApplicationBean(); + epo.setDataAccessObject(aDao); + + if (!epo.getUseRecycledBean()){ + action = "update"; + epo.setOriginalBean(applicationForEditing); + } else { + applicationForEditing = (ApplicationBean) epo.getNewBean(); + action = "update"; + log.debug("using newBean"); + } + + //set the getMethod so we can retrieve a new bean after we've inserted it + try { + epo.setGetMethod(aDao.getClass().getDeclaredMethod("getApplicationBean")); + } catch (NoSuchMethodException e) { + log.error("could not find the getApplicationBean method in the facade"); + } + + FormObject foo = new FormObject(); + foo.setErrorMap(epo.getErrMsgMap()); + + HashMap optionMap = new HashMap(); + + List