diff --git a/solr/homeDirectoryTemplate/conf/schema.xml b/solr/homeDirectoryTemplate/conf/schema.xml index 95b616d3e..25517dd91 100644 --- a/solr/homeDirectoryTemplate/conf/schema.xml +++ b/solr/homeDirectoryTemplate/conf/schema.xml @@ -192,9 +192,11 @@ - + + + @@ -218,16 +220,10 @@ - - - - - diff --git a/webapp/lib/httpclient-4.2.5.jar b/webapp/lib/httpclient-4.2.5.jar new file mode 100644 index 000000000..5310588ef Binary files /dev/null and b/webapp/lib/httpclient-4.2.5.jar differ diff --git a/webapp/lib/httpcore-4.2.4.jar b/webapp/lib/httpcore-4.2.4.jar new file mode 100644 index 000000000..9f45bd91c Binary files /dev/null and b/webapp/lib/httpcore-4.2.4.jar differ diff --git a/webapp/lib/httpmime-4.2.5.jar b/webapp/lib/httpmime-4.2.5.jar new file mode 100644 index 000000000..e63b24d70 Binary files /dev/null and b/webapp/lib/httpmime-4.2.5.jar differ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java index 4cf4d889a..2737dacf0 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java @@ -26,6 +26,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess; +import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.FactoryID; import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginEvent; @@ -263,12 +264,7 @@ public class BasicAuthenticator extends Authenticator { * Get a reference to the UserAccountsDao, or null. */ private UserAccountsDao getUserAccountsDao() { - WebappDaoFactory wadf = getWebappDaoFactory(); - if (wadf == null) { - return null; - } - - UserAccountsDao userAccountsDao = wadf.getUserAccountsDao(); + UserAccountsDao userAccountsDao = getWebappDaoFactory().getUserAccountsDao(); if (userAccountsDao == null) { log.error("getUserAccountsDao: no UserAccountsDao"); } @@ -280,12 +276,7 @@ public class BasicAuthenticator extends Authenticator { * Get a reference to the IndividualDao, or null. */ private IndividualDao getIndividualDao() { - WebappDaoFactory wadf = getWebappDaoFactory(); - if (wadf == null) { - return null; - } - - IndividualDao individualDao = wadf.getIndividualDao(); + IndividualDao individualDao = getWebappDaoFactory().getIndividualDao(); if (individualDao == null) { log.error("getIndividualDao: no IndividualDao"); } @@ -297,13 +288,7 @@ public class BasicAuthenticator extends Authenticator { * Get a reference to the WebappDaoFactory, or null. */ private WebappDaoFactory getWebappDaoFactory() { - HttpSession session = request.getSession(false); - if (session == null) { - return null; - } - - ServletContext servletContext = session.getServletContext(); - return ModelAccess.on(servletContext).getWebappDaoFactory(); + return ModelAccess.on(request).getWebappDaoFactory(); } @Override diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/FileUploadServletRequest.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/FileUploadServletRequest.java index 6ecba1d70..ae34cabf8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/FileUploadServletRequest.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/FileUploadServletRequest.java @@ -3,8 +3,15 @@ package edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; @@ -12,6 +19,8 @@ import javax.servlet.http.HttpServletRequestWrapper; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.servlet.ServletFileUpload; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** *

@@ -44,21 +53,39 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; */ @SuppressWarnings("deprecation") public abstract class FileUploadServletRequest extends HttpServletRequestWrapper { + + private static final Log log = LogFactory + .getLog(FileUploadServletRequest.class); + public static final String FILE_ITEM_MAP = "file_item_map"; public static final String FILE_UPLOAD_EXCEPTION = "file_upload_exception"; + private Map> parameters; + private Map> files; + private FileUploadException fileUploadException; + + private static final String[] EMPTY_ARRAY = new String[0]; + // ---------------------------------------------------------------------- // The factory method // ---------------------------------------------------------------------- /** * Wrap this {@link HttpServletRequest} in an appropriate wrapper class. + * set maxTempFileSize to 0 or -1 if streaming is desired. Set it to > 0 if + * you want any parts uploaded to a temporary directory */ - public static FileUploadServletRequest parseRequest( - HttpServletRequest request, int maxFileSize) throws IOException { + public static FileUploadServletRequest parseRequest( + HttpServletRequest request, int maxTempFileSize) throws IOException { + boolean isMultipart = ServletFileUpload.isMultipartContent(request); + if (isMultipart) { - return new MultipartHttpServletRequest(request, maxFileSize); + if( maxTempFileSize <= 0 ){ + return new StreamingMultipartHttpServletRequest(request); + }else{ + return new MultipartHttpServletRequest(request, maxTempFileSize); + } } else { return new SimpleHttpServletRequestWrapper(request); } @@ -85,29 +112,184 @@ public abstract class FileUploadServletRequest extends HttpServletRequestWrapper /** Was this a multipart HTTP request? */ public abstract boolean isMultipart(); + + protected void stashParametersInRequest(HttpServletRequest request, ServletFileUpload upload){ + Map> parameters = new HashMap>(); + Map> files = new HashMap>(); + + parseQueryString(request.getQueryString(), parameters); + + try { + List items = upload.parseRequest( request ); + + for (FileItem item : items) { + // Process a regular form field + if (item.isFormField()) { + addToParameters(parameters, item.getFieldName(), item + .getString("UTF-8")); + log.debug("Form field (parameter) " + item.getFieldName() + + "=" + item.getString()); + } else { + addToFileItems(files, item); + log.debug("File " + item.getFieldName() + ": " + + item.getName()); + } + } + } catch (FileUploadException e) { + fileUploadException = e; + request.setAttribute( + FileUploadServletRequest.FILE_UPLOAD_EXCEPTION, e); + } catch (UnsupportedEncodingException e) { + log.error("could not convert to UTF-8",e); + } + + this.parameters = Collections.unmodifiableMap(parameters); + log.debug("Parameters are: " + this.parameters); + this.files = Collections.unmodifiableMap(files); + log.debug("Files are: " + this.files); + request.setAttribute(FILE_ITEM_MAP, this.files); + } + + /** - * Get the map of file items, by name. + * Pull any parameters out of the URL. */ - public abstract Map> getFiles(); + private void parseQueryString(String queryString, + Map> parameters) { + log.debug("Query string is : '" + queryString + "'"); + if (queryString != null) { + String[] pieces = queryString.split("&"); + + for (String piece : pieces) { + int equalsHere = piece.indexOf('='); + if (piece.trim().isEmpty()) { + // Ignore an empty piece. + } else if (equalsHere <= 0) { + // A parameter without a value. + addToParameters(parameters, decode(piece), ""); + } else { + // A parameter with a value. + String key = piece.substring(0, equalsHere); + String value = piece.substring(equalsHere + 1); + addToParameters(parameters, decode(key), decode(value)); + } + } + } + log.debug("Parameters from query string are: " + parameters); + } /** - * Find a non-empty file item with this name. - * - * @return the first such file item, or null if no matching, - * non-empty items were found. + * Remove any special URL-style encoding. */ - public abstract FileItem getFileItem(String string); + private String decode(String encoded) { + try { + return URLDecoder.decode(encoded, "UTF-8"); + } catch (UnsupportedEncodingException e) { + log.error(e, e); + return encoded; + } + } - /** - * Was there an exception when uploading the file items? - */ - public abstract boolean hasFileUploadException(); - /** - * Get the exception that occurred when uploading the file items. If no such - * exception, return null. - */ - public abstract FileUploadException getFileUploadException(); + /** Either create a new List for the value, or add to an existing List. */ + private void addToParameters(Map> map, String name, + String value) { + if (!map.containsKey(name)) { + map.put(name, new ArrayList()); + } + map.get(name).add(value); + } + + /** Either create a new List for the file, or add to an existing List. */ + private void addToFileItems(Map> map, FileItem file) { + String name = file.getFieldName(); + if (!map.containsKey(name)) { + map.put(name, new ArrayList()); + } + map.get(name).add(file); + } + + + public FileUploadException getFileUploadException() { + return fileUploadException; + } + + public boolean hasFileUploadException() { + return fileUploadException != null; + } + + // ---------------------------------------------------------------------- + // Parameter-related methods won't find anything on the delegate request, + // since parsing consumed the parameters. So we need to look to the parsed + // info for the answers. + // ---------------------------------------------------------------------- + + @Override + public String getParameter(String name) { + if (parameters.containsKey(name)) { + return parameters.get(name).get(0); + } else { + return null; + } + } + + @Override + public Enumeration getParameterNames() { + return Collections.enumeration(parameters.keySet()); + } + + @Override + public String[] getParameterValues(String name) { + if (parameters.containsKey(name)) { + return parameters.get(name).toArray(EMPTY_ARRAY); + } else { + return null; + } + } + + @Override + public Map getParameterMap() { + Map result = new HashMap(); + for (Entry> entry : parameters.entrySet()) { + result.put(entry.getKey(), entry.getValue().toArray(EMPTY_ARRAY)); + } + log.debug("resulting parameter map: " + result); + return result; + } + + + /** + * {@inheritDoc} + *

+ * There may be more than one file item with the given name. If the first + * one is empty (size is zero), keep looking for a non-empty one. + *

+ */ + public FileItem getFileItem(String name) { + List items = files.get(name); + if (items == null) { + return null; + } + + for (FileItem item : items) { + if (item.getSize() > 0L) { + return item; + } + } + + return null; + } + + /** + * Gets a map of parameter names to files. + * This will should return null. + */ + public Map> getFiles() { + if( files == null ) + return Collections.emptyMap(); + else + return files; + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/MultipartHttpServletRequest.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/MultipartHttpServletRequest.java index 76f90a174..a276e2275 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/MultipartHttpServletRequest.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/MultipartHttpServletRequest.java @@ -33,32 +33,8 @@ public class MultipartHttpServletRequest extends FileUploadServletRequest { private static final Log log = LogFactory .getLog(MultipartHttpServletRequest.class); - private static final String[] EMPTY_ARRAY = new String[0]; - - private Map> parameters; - private Map> files; - private FileUploadException fileUploadException; - - private boolean storeFilesToTempDir = false; private int maxFileSize = 0; - private File tempDir = null; - - /** - * Parse the multipart request. Store the info about the request parameters. - * Don't store the uploaded files to a temporary directory to allow streaming. - * - * Only use this constructor if you plan to consume the FileItems using streaming - * to deal with inputs of very large sizes. - * - * In all other case you should use the maxFileSize constructor to deal with - * the size of the uploaded file in a safe way. - */ - public MultipartHttpServletRequest(HttpServletRequest request) - throws IOException{ - super(request); - storeFilesToTempDir = false; - - } + private File tempDir = null; /** * Parse the multipart request. Store the info about the request parameters @@ -70,92 +46,16 @@ public class MultipartHttpServletRequest extends FileUploadServletRequest { public MultipartHttpServletRequest(HttpServletRequest request, int maxFileSize) throws IOException { super(request); - storeFilesToTempDir = true; + this.maxFileSize = maxFileSize; this.tempDir = figureTemporaryDirectory(request); + + //use an upload handler that will stash the file items in a temporary directory. + ServletFileUpload upload = createUploadHandler( this.maxFileSize, this.tempDir ); + stashParametersInRequest( request , upload ); } - private void setup(HttpServletRequest request){ - Map> parameters = new HashMap>(); - Map> files = new HashMap>(); - - ServletFileUpload upload = createUploadHandler(); - - //File tempDir = figureTemporaryDirectory(request); - //ServletFileUpload upload = createUploadHandler(maxFileSize, tempDir); - - parseQueryString(request.getQueryString(), parameters); - - try { - List items = parseRequestIntoFileItems(request, upload); - - for (FileItem item : items) { - // Process a regular form field - if (item.isFormField()) { - addToParameters(parameters, item.getFieldName(), item - .getString("UTF-8")); - log.debug("Form field (parameter) " + item.getFieldName() - + "=" + item.getString()); - } else { - addToFileItems(files, item); - log.debug("File " + item.getFieldName() + ": " - + item.getName()); - } - } - } catch (FileUploadException e) { - fileUploadException = e; - request.setAttribute( - FileUploadServletRequest.FILE_UPLOAD_EXCEPTION, e); - } catch (UnsupportedEncodingException e) { - log.error("could not convert to UTF-8",e); - } - - this.parameters = Collections.unmodifiableMap(parameters); - log.debug("Parameters are: " + this.parameters); - this.files = Collections.unmodifiableMap(files); - log.debug("Files are: " + this.files); - request.setAttribute(FILE_ITEM_MAP, this.files); - } - - /** - * Pull any parameters out of the URL. - */ - private void parseQueryString(String queryString, - Map> parameters) { - log.debug("Query string is : '" + queryString + "'"); - if (queryString != null) { - String[] pieces = queryString.split("&"); - - for (String piece : pieces) { - int equalsHere = piece.indexOf('='); - if (piece.trim().isEmpty()) { - // Ignore an empty piece. - } else if (equalsHere <= 0) { - // A parameter without a value. - addToParameters(parameters, decode(piece), ""); - } else { - // A parameter with a value. - String key = piece.substring(0, equalsHere); - String value = piece.substring(equalsHere + 1); - addToParameters(parameters, decode(key), decode(value)); - } - } - } - log.debug("Parameters from query string are: " + parameters); - } - - /** - * Remove any special URL-style encoding. - */ - private String decode(String encoded) { - try { - return URLDecoder.decode(encoded, "UTF-8"); - } catch (UnsupportedEncodingException e) { - log.error(e, e); - return encoded; - } - } - + /** * Find the temporary storage directory for this webapp. */ @@ -163,19 +63,7 @@ public class MultipartHttpServletRequest extends FileUploadServletRequest { return (File) request.getSession().getServletContext().getAttribute( "javax.servlet.context.tempdir"); } - - /** - * Create an upload handler based on this.storeFilesToTempDir. - */ - private ServletFileUpload createUploadHandler(){ - if( storeFilesToTempDir ){ - return createUploadHandler( this.maxFileSize, this.tempDir ); - }else{ - return new ServletFileUpload(); - } - } - /** * Create an upload handler that will throw an exception if the file is too * large. @@ -191,116 +79,10 @@ public class MultipartHttpServletRequest extends FileUploadServletRequest { return upload; } - /** Either create a new List for the value, or add to an existing List. */ - private void addToParameters(Map> map, String name, - String value) { - if (!map.containsKey(name)) { - map.put(name, new ArrayList()); - } - map.get(name).add(value); - } - - /** Either create a new List for the file, or add to an existing List. */ - private void addToFileItems(Map> map, FileItem file) { - String name = file.getFieldName(); - if (!map.containsKey(name)) { - map.put(name, new ArrayList()); - } - map.get(name).add(file); - } - - /** Minimize the code that uses the unchecked cast. */ - @SuppressWarnings("unchecked") - private List parseRequestIntoFileItems(HttpServletRequest req, - ServletFileUpload upload) throws FileUploadException { - return upload.parseRequest(req); - } - - // ---------------------------------------------------------------------- - // This is a multipart request, so make the file info available. If there - // was an exception during parsing, make that available too. - // ---------------------------------------------------------------------- - - @Override - public boolean isMultipart() { - return true; - } - - @Override - public Map> getFiles() { - return files; - } - - /** - * {@inheritDoc} - *

- * There may be more than one file item with the given name. If the first - * one is empty (size is zero), keep looking for a non-empty one. - *

- */ - @Override - public FileItem getFileItem(String name) { - List items = files.get(name); - if (items == null) { - return null; - } - - for (FileItem item : items) { - if (item.getSize() > 0L) { - return item; - } - } - - return null; - } - - @Override - public FileUploadException getFileUploadException() { - return fileUploadException; - } - - @Override - public boolean hasFileUploadException() { - return fileUploadException != null; - } - - // ---------------------------------------------------------------------- - // Parameter-related methods won't find anything on the delegate request, - // since parsing consumed the parameters. So we need to look to the parsed - // info for the answers. - // ---------------------------------------------------------------------- - - @Override - public String getParameter(String name) { - if (parameters.containsKey(name)) { - return parameters.get(name).get(0); - } else { - return null; - } - } - - @Override - public Enumeration getParameterNames() { - return Collections.enumeration(parameters.keySet()); - } - - @Override - public String[] getParameterValues(String name) { - if (parameters.containsKey(name)) { - return parameters.get(name).toArray(EMPTY_ARRAY); - } else { - return null; - } - } - - @Override - public Map getParameterMap() { - Map result = new HashMap(); - for (Entry> entry : parameters.entrySet()) { - result.put(entry.getKey(), entry.getValue().toArray(EMPTY_ARRAY)); - } - log.debug("resulting parameter map: " + result); - return result; - } + @Override + public boolean isMultipart() { + return true; + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/SimpleHttpServletRequestWrapper.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/SimpleHttpServletRequestWrapper.java index 246377048..754226317 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/SimpleHttpServletRequestWrapper.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/SimpleHttpServletRequestWrapper.java @@ -33,26 +33,7 @@ class SimpleHttpServletRequestWrapper extends FileUploadServletRequest { return false; } - @Override - public Map> getFiles() { - return Collections.emptyMap(); - } - - @Override - public FileItem getFileItem(String string) { - return null; - } - - @Override - public FileUploadException getFileUploadException() { - return null; - } - - @Override - public boolean hasFileUploadException() { - return false; - } - + // ---------------------------------------------------------------------- // Since this is not a multipart request, the parameter methods can be // delegated. @@ -64,7 +45,7 @@ class SimpleHttpServletRequestWrapper extends FileUploadServletRequest { } @Override - public Map getParameterMap() { + public Map getParameterMap() { return getDelegate().getParameterMap(); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/StreamingMultipartHttpServletRequest.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/StreamingMultipartHttpServletRequest.java new file mode 100644 index 000000000..7b74a2041 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/uploadrequest/StreamingMultipartHttpServletRequest.java @@ -0,0 +1,43 @@ +package edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.servlet.ServletFileUpload; + +/** + * Wrapping ServletRequest that does multipart. In order to allow + * streaming, this class does NOT save the parts to a temporary directory. + * + * + */ +public class StreamingMultipartHttpServletRequest extends + FileUploadServletRequest { + /** + * Parse the multipart request. Store the info about the request parameters. + * Don't store the uploaded files to a temporary directory to allow streaming. + * + * Only use this if you plan to consume the FileItems using streaming + * to deal with inputs of very large sizes. + * + */ + public StreamingMultipartHttpServletRequest(HttpServletRequest request) + throws IOException{ + super(request); + + //use a file uploader that does not save the files to a temporary directory. + stashParametersInRequest( request , new ServletFileUpload()); + } + + @Override + public boolean isMultipart() { + return true; + } + + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/RequestModelsPrep.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/RequestModelsPrep.java index a3fec2eaa..4d53fa058 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/RequestModelsPrep.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/RequestModelsPrep.java @@ -153,7 +153,7 @@ public class RequestModelsPrep implements Filter { addLanguageAwarenessToRequestModel(req, ModelID.BASE_FULL); WebappDaoFactory unfilteredWadf = new WebappDaoFactorySDB(rdfService, - ModelAccess.on(ctx).getUnionOntModelSelector(), config); + ModelAccess.on(vreq).getUnionOntModelSelector(), config); ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.UNFILTERED_UNION, unfilteredWadf); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java index 059b7ce3c..c46783f5a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java @@ -3,33 +3,35 @@ package edu.cornell.mannlib.vitro.webapp.search; public class VitroSearchTermNames { + /** Id of entity, vclass or tab */ public static String URI = "URI"; /** search document id */ public static String DOCID = "DocId"; - /** java class of the object that the Doc represents. */ - public static String JCLASS = "JCLASS"; + /** rdf:type */ public static String RDFTYPE = "type"; - /** rdf:type */ - public static String CLASSGROUP_URI = "classgroup"; - /** Modtime from db */ - public static String MODTIME = "modTime"; - + /** class names in human readable form of an individual*/ + public static final String CLASSLOCALNAME = "classLocalName"; + /** classgroups from the individual's rdf:types */ + public static String CLASSGROUP_URI = "classgroup"; + /** Most specific types for individual*/ + public static String MOST_SPECIFIC_TYPE_URIS = "mostSpecificTypeURIs"; + /** time of index in msec since epoc */ public static String INDEXEDTIME= "indexedTime"; + /** text for 'full text' search, this is stemmed */ public static String ALLTEXT = "ALLTEXT"; /** text for 'full text' search, this is unstemmed for * use with wildcards and prefix queries */ - public static String ALLTEXTUNSTEMMED = "ALLTEXTUNSTEMMED"; + public static String ALLTEXTUNSTEMMED = "ALLTEXTUNSTEMMED"; + /** Does the individual have a thumbnail image? 1=yes 0=no */ public static final String THUMBNAIL = "THUMBNAIL"; - /** class names in human readable form of an individual*/ - public static final String CLASSLOCALNAMELOWERCASE = "classLocalNameLowerCase"; - /** class names in human readable form of an individual*/ - public static final String CLASSLOCALNAME = "classLocalName"; - + /** download url location for thumbnail */ + public static final String THUMBNAIL_URL = "THUMBNAIL_URL"; + // Fields derived from rdfs:label /** Raw rdfs:label: no lowercasing, no tokenizing, no stop words, no stemming **/ public static String NAME_RAW = "nameRaw"; // @@ -46,6 +48,11 @@ public class VitroSearchTermNames { /** rdfs:label lowercased, tokenized, stop words, stemmed **/ public static String NAME_STEMMED = "nameStemmed"; + + /** preferred title */ + public static final String PREFERRED_TITLE = "PREFERRED_TITLE"; + + public static final String NAME_PHONETIC = "NAME_PHONETIC"; /** rdfs:label lowercased, untokenized, edge-n-gram-filtered for autocomplete on people names **/ public static String AC_NAME_UNTOKENIZED = "acNameUntokenized"; @@ -57,24 +64,13 @@ public class VitroSearchTermNames { /* There is currently no use case for an autocomplete search field that is tokenized but not stemmed. public static String AC_NAME_UNSTEMMED = "acNameUnstemmed"; */ - /** field for beta values of all documents **/ + /** Beta values used in weighting **/ public static final String BETA = "BETA"; - public static final String PHI = "PHI"; - public static final String ADJACENT_NODES = "ADJACENT_NODES"; - - /** adding phonetic field **/ - public static final String ALLTEXT_PHONETIC = "ALLTEXT_PHONETIC"; - public static final String NAME_PHONETIC = "NAME_PHONETIC"; - - /** download url location for thumbnail */ - public static final String THUMBNAIL_URL = "THUMBNAIL_URL"; - - /** source institution url */ + + /** Source institution URL */ public static final String SITE_URL = "siteURL"; - - /** source institution name */ + + /** Source institution name */ public static final String SITE_NAME = "siteName"; - /** preferred title */ - public static final String PREFERRED_TITLE = "PREFERRED_TITLE"; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/SearchServiceController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/SearchServiceController.java index 61c23afc2..1d82546a6 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/SearchServiceController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/SearchServiceController.java @@ -25,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.FileUploadServletRequest; import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.MultipartHttpServletRequest; import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder; @@ -45,7 +46,7 @@ public class SearchServiceController extends FreemarkerHttpServlet { protected Actions requiredActions(VitroRequest vreq) { try{ // Works by side effect: parse the multi-part request and stash FileItems in request - new MultipartHttpServletRequest( vreq ); + FileUploadServletRequest.parseRequest(vreq, 0); //first figure out if the password and email login to an account with a password String pw = vreq.getParameter("password"); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java index 3c7fd9c06..d8f72363c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java @@ -11,8 +11,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import org.apache.solr.client.solrj.SolrServer; -import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; -import org.apache.solr.client.solrj.impl.XMLResponseParser; +import org.apache.solr.client.solrj.impl.HttpSolrServer; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.rdf.model.Model; @@ -90,22 +89,12 @@ public class SolrSetup implements javax.servlet.ServletContextListener{ "It should be something like http://localhost:${port}" + context.getContextPath() + "solr" ); return; - } - - URL solrServerUrl = null; - try { - solrServerUrl = new URL(solrServerUrlString); - } catch (MalformedURLException e) { - ss.fatal(this, "Can't connect with the solr server. " + - "The value for vitro.local.solr.url in runtime.properties is not a valid URL: " + solrServerUrlString); - return; - } + } try { - CommonsHttpSolrServer server; + HttpSolrServer server; boolean useMultiPartPost = true; - //It would be nice to use the default binary handler but there seem to be library problems - server = new CommonsHttpSolrServer(solrServerUrl,null,new XMLResponseParser(),useMultiPartPost); + server = new HttpSolrServer( solrServerUrlString ); server.setSoTimeout(10000); // socket read timeout server.setConnectionTimeout(10000); server.setDefaultMaxConnectionsPerHost(100); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/documentBuilding/IndividualToSolrDocument.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/documentBuilding/IndividualToSolrDocument.java index b42527190..17cf5e15c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/documentBuilding/IndividualToSolrDocument.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/documentBuilding/IndividualToSolrDocument.java @@ -69,6 +69,7 @@ public class IndividualToSolrDocument { //add classes, classgroups get if prohibited because of its class StringBuffer classPublicNames = new StringBuffer(""); addClasses(ind, doc, classPublicNames); + addMostSpecificTypeUris( ind, doc ); log.debug(ind.getURI() + " post class boost: " + doc.getDocumentBoost()); @@ -202,7 +203,6 @@ public class IndividualToSolrDocument { doc.addField(term.ALLTEXT, alltext); doc.addField(term.ALLTEXTUNSTEMMED, alltext); - doc.addField(term.ALLTEXT_PHONETIC, alltext); } @@ -256,7 +256,7 @@ public class IndividualToSolrDocument { if( vclasses == null || vclasses.isEmpty() ){ throw new SkipIndividualException("Not indexing because individual has no classes"); } - + for(VClass clz : vclasses){ if(clz.getURI() == null){ continue; @@ -272,7 +272,6 @@ public class IndividualToSolrDocument { if(clz.getLocalName() != null){ doc.addField(term.CLASSLOCALNAME, clz.getLocalName()); - doc.addField(term.CLASSLOCALNAMELOWERCASE, clz.getLocalName().toLowerCase()); } if(clz.getName() != null){ @@ -287,6 +286,16 @@ public class IndividualToSolrDocument { } } } + + protected void addMostSpecificTypeUris(Individual ind, SolrInputDocument doc){ + List mstURIs = ind.getMostSpecificTypeURIs(); + if( mstURIs != null ){ + for( String typeURI : mstURIs ){ + if( typeURI != null && ! typeURI.trim().isEmpty() ) + doc.addField(term.MOST_SPECIFIC_TYPE_URIS, typeURI); + } + } + } protected void addLabel(Individual ind, SolrInputDocument doc) { String value = ""; diff --git a/webapp/web/css/individual/individual.css b/webapp/web/css/individual/individual.css index f819213b8..2725db1c7 100644 --- a/webapp/web/css/individual/individual.css +++ b/webapp/web/css/individual/individual.css @@ -268,11 +268,6 @@ input#uriLink { width: 350px; font-size: .8em; } -a.close { - float: right; - margin-right: .3em; - font-size: .8em; -} .rdf-url { display: block; padding-top: 0.8em; diff --git a/webapp/web/css/search.css b/webapp/web/css/search.css index b3717888a..6f00b95e4 100644 --- a/webapp/web/css/search.css +++ b/webapp/web/css/search.css @@ -83,18 +83,11 @@ span#searchHelp { font-size:.825em; padding-right:32px } - -span#downloadResults { - float:left; - margin-top:10px; - font-size:.825em; - padding-left:10px -} - img#downloadIcon { cursor: pointer; + margin-left: 6px; + vertical-align: top; } - .download-url { padding: 5px 25px 5px; } \ No newline at end of file diff --git a/webapp/web/css/vitro.css b/webapp/web/css/vitro.css index c2001d95b..b2570e013 100644 --- a/webapp/web/css/vitro.css +++ b/webapp/web/css/vitro.css @@ -140,9 +140,22 @@ .searchTOC ul span { float:right; padding-right: 10px; - color:grey; + color:gray; font-size:smaller; } +.contentsBrowseGroup { + clear:both; + padding-top: 5px; +} +.searchResultsHeader { + width: 675px; + float:left; +} +a.close { + float: right; + margin-right: .3em; + font-size: .8em; +} /* -------------------------------------------------> */ /* DROP DOWN USER MENU ----------------------------> */ diff --git a/webapp/web/jenaIngest/exportSelection.jsp b/webapp/web/jenaIngest/exportSelection.jsp index 4c78bebfb..bda276f30 100644 --- a/webapp/web/jenaIngest/exportSelection.jsp +++ b/webapp/web/jenaIngest/exportSelection.jsp @@ -18,7 +18,7 @@
  • Entire ontology (TBox) for the application
  • All Instance data (ABox) for the application
  • <%VitroRequest vreq = new VitroRequest(request); - OntologyDao daoObj = vreq.getFullWebappDaoFactory().getOntologyDao(); + OntologyDao daoObj = vreq.getUnfilteredWebappDaoFactory().getOntologyDao(); List ontologiesObj = daoObj.getAllOntologies(); if(ontologiesObj !=null && ontologiesObj.size()>0){ Iterator ontItr = ontologiesObj.iterator(); diff --git a/webapp/web/js/searchDownload.js b/webapp/web/js/searchDownload.js index 1bcec1607..889bf9c2f 100644 --- a/webapp/web/js/searchDownload.js +++ b/webapp/web/js/searchDownload.js @@ -3,21 +3,21 @@ $(document).ready(function(){ // This function creates and styles the "qTip" tooltip that displays the resource uri and the rdf link when the user clicks the uri/rdf icon. - $('span#downloadResults').children('img#downloadIcon').each(function() + $('img#downloadIcon').each(function() { $(this).qtip( { content: { prerender: true, // We need this for the .click() event listener on 'a.close' - text: '
    ' + text: '
    ' +'

    ' +'

    ' +'
    ' - +'
    ' - +'
    Download the results from this search
    ' + +'
    close
    ' + +'
    Download the results from this search
    ' +'
    download results in XML format
    ' +'
    download results in CSV format
    ' - +'
    close
    ' + +'
    ' }, position: { diff --git a/webapp/web/templates/freemarker/body/search/search-pagedResults.ftl b/webapp/web/templates/freemarker/body/search/search-pagedResults.ftl index a0946ed23..aa3cdf39c 100644 --- a/webapp/web/templates/freemarker/body/search/search-pagedResults.ftl +++ b/webapp/web/templates/freemarker/body/search/search-pagedResults.ftl @@ -2,10 +2,7 @@ <#-- Template for displaying paged search results --> - - - -

    +

    <#escape x as x?html> ${i18n().search_results_for} '${querytext}' <#if classGroupName?has_content>${i18n().limited_to_type} '${classGroupName}' @@ -22,11 +19,10 @@ var urlsBase = '${urls.base}'; -

    - - Download Results - + Download Results +<#-- --> + ${i18n().not_expected_results}