Merge branch 'develop' into issue-vivo-101-sparqlupdate

This commit is contained in:
Brian Caruso 2013-07-31 13:53:39 -04:00
commit 6a3e6f4f5b
20 changed files with 335 additions and 374 deletions

View file

@ -192,9 +192,11 @@
<field name="type" type="string" indexed="true" stored="true" omitNorms="true" multiValued="true"/>
<field name="classLocalName" type="text" indexed="true" stored="true" multiValued="true"/>
<field name="classLocalNameLowerCase" type="text" indexed="true" stored="false" multiValued="true"/>
<field name="classgroup" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="mostSpecificTypeURIs" type="string" indexed="true" stored="true" omitNorms="true" multiValued="true"/>
<field name="PROHIBITED_FROM_TEXT_RESULTS" type="string" indexed="true" stored="false" omitNorms="true" multiValued="true"/>
<field name="URI" type="string" indexed="true" stored="true" multiValued="false" omitNorms="true"/>
@ -218,16 +220,10 @@
<field name="ALLTEXT" type="text" indexed="true" stored="true" multiValued="true"/>
<field name="ALLTEXTUNSTEMMED" type="textgen" indexed="true" stored="false" multiValued="true"/>
<field name="ALLTEXT_PHONETIC" type="phonetic" indexed="true" stored="false" multiValued="true"/>
<field name="THUMBNAIL" type="string" indexed="true" stored="true"/>
<field name="BETA" type="float" indexed="true" stored="true" multiValued="false"/>
<!-- <field name="PHI" type="float" indexed="true" stored="true" multiValued="false"/>
<field name="ADJACENT_NODES" type="string" indexed="true" stored="true" multiValued="true"/> -->
<field name="modType" type="ignored"/>
<field name="JCLASS" type="ignored"/>
<!-- field for storing locations of thumbnails -->
<field name="THUMBNAIL_URL" type="string" indexed="false" stored="true"/>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -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

View file

@ -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;
/**
* <p>
@ -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<String, List<String>> parameters;
private Map<String, List<FileItem>> 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 {
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);
}
@ -86,28 +113,183 @@ public abstract class FileUploadServletRequest extends HttpServletRequestWrapper
/** Was this a multipart HTTP request? */
public abstract boolean isMultipart();
/**
* Get the map of file items, by name.
*/
public abstract Map<String, List<FileItem>> getFiles();
protected void stashParametersInRequest(HttpServletRequest request, ServletFileUpload upload){
Map<String, List<String>> parameters = new HashMap<String, List<String>>();
Map<String, List<FileItem>> files = new HashMap<String, List<FileItem>>();
parseQueryString(request.getQueryString(), parameters);
try {
List<FileItem> 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);
}
/**
* Find a non-empty file item with this name.
*
* @return the first such file item, or <code>null</code> if no matching,
* non-empty items were found.
* Pull any parameters out of the URL.
*/
public abstract FileItem getFileItem(String string);
private void parseQueryString(String queryString,
Map<String, List<String>> 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);
}
/**
* Was there an exception when uploading the file items?
* Remove any special URL-style encoding.
*/
public abstract boolean hasFileUploadException();
private String decode(String encoded) {
try {
return URLDecoder.decode(encoded, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error(e, e);
return encoded;
}
}
/**
* Get the exception that occurred when uploading the file items. If no such
* exception, return <code>null</code>.
*/
public abstract FileUploadException getFileUploadException();
/** Either create a new List for the value, or add to an existing List. */
private void addToParameters(Map<String, List<String>> map, String name,
String value) {
if (!map.containsKey(name)) {
map.put(name, new ArrayList<String>());
}
map.get(name).add(value);
}
/** Either create a new List for the file, or add to an existing List. */
private void addToFileItems(Map<String, List<FileItem>> map, FileItem file) {
String name = file.getFieldName();
if (!map.containsKey(name)) {
map.put(name, new ArrayList<FileItem>());
}
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<String, String[]> getParameterMap() {
Map<String, String[]> result = new HashMap<String, String[]>();
for (Entry<String, List<String>> entry : parameters.entrySet()) {
result.put(entry.getKey(), entry.getValue().toArray(EMPTY_ARRAY));
}
log.debug("resulting parameter map: " + result);
return result;
}
/**
* {@inheritDoc}
* <p>
* 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.
* </p>
*/
public FileItem getFileItem(String name) {
List<FileItem> 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<String, List<FileItem>> getFiles() {
if( files == null )
return Collections.emptyMap();
else
return files;
}
}

View file

@ -33,33 +33,9 @@ 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<String, List<String>> parameters;
private Map<String, List<FileItem>> 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;
}
/**
* Parse the multipart request. Store the info about the request parameters
* and the uploaded files to a temporary directory.
@ -70,91 +46,15 @@ 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<String, List<String>> parameters = new HashMap<String, List<String>>();
Map<String, List<FileItem>> files = new HashMap<String, List<FileItem>>();
ServletFileUpload upload = createUploadHandler();
//File tempDir = figureTemporaryDirectory(request);
//ServletFileUpload upload = createUploadHandler(maxFileSize, tempDir);
parseQueryString(request.getQueryString(), parameters);
try {
List<FileItem> 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<String, List<String>> 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.
@ -164,18 +64,6 @@ public class MultipartHttpServletRequest extends FileUploadServletRequest {
"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<String, List<String>> map, String name,
String value) {
if (!map.containsKey(name)) {
map.put(name, new ArrayList<String>());
}
map.get(name).add(value);
}
@Override
public boolean isMultipart() {
return true;
}
/** Either create a new List for the file, or add to an existing List. */
private void addToFileItems(Map<String, List<FileItem>> map, FileItem file) {
String name = file.getFieldName();
if (!map.containsKey(name)) {
map.put(name, new ArrayList<FileItem>());
}
map.get(name).add(file);
}
/** Minimize the code that uses the unchecked cast. */
@SuppressWarnings("unchecked")
private List<FileItem> 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<String, List<FileItem>> getFiles() {
return files;
}
/**
* {@inheritDoc}
* <p>
* 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.
* </p>
*/
@Override
public FileItem getFileItem(String name) {
List<FileItem> 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<String, String[]> getParameterMap() {
Map<String, String[]> result = new HashMap<String, String[]>();
for (Entry<String, List<String>> entry : parameters.entrySet()) {
result.put(entry.getKey(), entry.getValue().toArray(EMPTY_ARRAY));
}
log.debug("resulting parameter map: " + result);
return result;
}
}

View file

@ -33,25 +33,6 @@ class SimpleHttpServletRequestWrapper extends FileUploadServletRequest {
return false;
}
@Override
public Map<String, List<FileItem>> 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
@ -64,7 +45,7 @@ class SimpleHttpServletRequestWrapper extends FileUploadServletRequest {
}
@Override
public Map<?, ?> getParameterMap() {
public Map<String, String[]> getParameterMap() {
return getDelegate().getParameterMap();
}

View file

@ -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;
}
}

View file

@ -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);

View file

@ -3,32 +3,34 @@
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 */
/** 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";
/** Modtime from db */
public static String MODTIME = "modTime";
/** 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";
/** 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 **/
@ -47,6 +49,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";
}

View file

@ -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");

View file

@ -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;
@ -92,20 +91,10 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
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);

View file

@ -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);
}
@ -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){
@ -288,6 +287,16 @@ public class IndividualToSolrDocument {
}
}
protected void addMostSpecificTypeUris(Individual ind, SolrInputDocument doc){
List<String> 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 = "";
String label = ind.getRdfsLabel();

View file

@ -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;

View file

@ -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;
}

View file

@ -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 ----------------------------> */

View file

@ -18,7 +18,7 @@
<li style="list-style-type:none;"><input type="radio" name="subgraph" value="tbox"/> Entire ontology (TBox) for the application</li>
<li style="list-style-type:none;"><input type="radio" name="subgraph" value="abox"/> All Instance data (ABox) for the application</li>
<%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();

View file

@ -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: '<div style="float:right; width:150px">'
text: '<div style="float:right; width:150px;border-left: 1px solid #A6B1B0; padding: 3px 0 0 20px">'
+'<p><label for="amount" style="font-size:14px;">Maximum Records:</label>'
+'<input disabled type="text" id="amount" style="margin-left:35px; border: 0; color: #f6931f; font-weight: bold; width:45px" /></p>'
+'<div id="slider-vertical" style="margin-left:60px; margin-top: -20px; height: 100px; background-color:white"></div>'
+'</div>'
+'<div style="float:left; width:300px"><h5>Download the results from this search</h5> '
+'<br /><a class="close" href="#">close</a></div>'
+'<div style="float:left; width:280px"><h5>Download the results from this search</h5> '
+'<h5 class ="download-url"><a id=xmlDownload href="' + urlsBase + '/search?' + queryText +'&amp;xml=1&amp;hitsPerPage=500">download results in XML format</a></h5>'
+'<h5 class ="download-url"><a id=csvDownload href="' + urlsBase + '/search?' + queryText +'&amp;csv=1&amp;hitsPerPage=500">download results in CSV format</a></h5>'
+'<br /><a class="close" href="#">close</a></div>'
+'</div>'
},
position: {

View file

@ -2,10 +2,7 @@
<#-- Template for displaying paged search results -->
<h2 style="float:left">
<h2 class="searchResultsHeader">
<#escape x as x?html>
${i18n().search_results_for} '${querytext}'
<#if classGroupName?has_content>${i18n().limited_to_type} '${classGroupName}'</#if>
@ -22,11 +19,10 @@
var urlsBase = '${urls.base}';
</script>
</h2>
<span id="downloadResults" title="Download Results">
<img id="downloadIcon" src="images/download-icon.png" alt="Download Results" />
</span>
<img id="downloadIcon" src="images/download-icon.png" alt="Download Results" title="Download Results" />
<#-- <span id="downloadResults" style="float:left"></span> -->
</h2>
<span id="searchHelp"><a href="${urls.base}/searchHelp" title="${i18n().search_help}">${i18n().not_expected_results}</a></span>
<div class="contentsBrowseGroup">