diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/FedoraDatastreamController.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/FedoraDatastreamController.java deleted file mode 100644 index 110f6f873..000000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/controller/FedoraDatastreamController.java +++ /dev/null @@ -1,713 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.security.MessageDigest; -import java.text.SimpleDateFormat; -import java.util.List; -import java.util.Properties; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler; -import org.apache.commons.fileupload.FileItem; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.joda.time.DateTime; - -import org.apache.jena.datatypes.xsd.XSDDatatype; -import org.apache.jena.ontology.DatatypeProperty; -import org.apache.jena.ontology.ObjectProperty; -import org.apache.jena.ontology.OntModel; -import org.apache.jena.rdf.model.Resource; -import org.apache.jena.rdf.model.Statement; -import org.apache.jena.vocabulary.RDFS; -import org.apache.jena.vocabulary.XSD; -import com.ibm.icu.util.Calendar; - -import edu.cornell.mannlib.vedit.beans.LoginStatusBean; -import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; -import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; -import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; -import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; -import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; -import fedora.client.FedoraClient; -import fedora.common.Constants; -import fedora.server.management.FedoraAPIM; -import fedora.server.types.gen.Datastream; - - -/** - * Handles a request to change a datastream in a fedora repository. - * Some of this code is copied from N3MultiPartUpload.java - * - * @author bdc34 - * - */ -public class FedoraDatastreamController extends VitroHttpServlet implements Constants{ - private static String FEDORA_PROPERTIES = "/WEB-INF/fedora.properties"; - private static String DEFAULT_DSID = "DS1"; - - private String fedoraUrl = null; - private String adminUser = null; - private String adminPassword = null; - private String pidNamespace = null; - private String configurationStatus = "
Fedora configuration not yet loaded
"; - private boolean configured = false; - private boolean connected = false; - - private static final int DEFAULT_MAX_SIZE = 1024 * 1024 * 50;//Shoudl this be changed to 1 GB to be consistent - private static final String DEFAULT_BASE_DIR = "/usr/local/vitrofiles"; - private static String baseDirectoryForFiles = DEFAULT_BASE_DIR; - private static int maxFileSize = DEFAULT_MAX_SIZE; - - protected String contentTypeProperty = VitroVocabulary.CONTENT_TYPE; - protected String fileSizeProperty = VitroVocabulary.FILE_SIZE; - protected String fileNameProperty = VitroVocabulary.FILE_NAME; - protected String fileLocationProperty = VitroVocabulary.FILE_LOCATION; - protected String fileLabelProperty = RDFS.label.getURI(); - protected String checksumNodeProperty = "";//Object property linking file to check sum node object - protected String checksumNodeDateTimeProperty = ""; - protected String checksumNodeValueProperty = ""; - protected String checksumDataProperty = ""; //is there a vitro equivalent? - - protected String deleteNs = ""; - protected String individualPrefix = ""; - protected String fedoraNs = VitroVocabulary.VITRO_FEDORA; - - - /** - * The get will present a form to the user. - */ - @Override - public void doGet(HttpServletRequest req, HttpServletResponse res) - throws IOException, ServletException { - try { - super.doGet(req, res); - log.debug("In doGet"); - - VitroRequest vreq = new VitroRequest(req); - OntModel sessionOntModel = ModelAccess.on(getServletContext()).getOntModel(); - - synchronized (FedoraDatastreamController.class) { - if( fedoraUrl == null ){ - setup( sessionOntModel, getServletContext() ); - if( fedoraUrl == null ) - throw new FdcException("Connection to the file repository is " + - "not setup correctly. Could not read fedora.properties file"); - }else{ - if( !canConnectToFedoraServer() ){ - fedoraUrl = null; - throw new FdcException("Could not connect to Fedora."); - } - } - } - FedoraClient fedora; - try { fedora = new FedoraClient(fedoraUrl,adminUser,adminPassword); } - catch (MalformedURLException e) { - throw new FdcException("Malformed URL for fedora Repository location: " + fedoraUrl); - } - - FedoraAPIM apim; - try { apim = fedora.getAPIM(); } catch (Exception e) { - throw new FdcException("could not create fedora APIM:" + e.getMessage()); - } - - //check if logged in - - //get URI for file individual - if( req.getParameter("uri") == null || "".equals(req.getParameter("uri"))) - throw new FdcException("No file uri specified in request"); - - boolean isDelete = (req.getParameter("delete") != null && "true".equals(req.getParameter("delete"))); - - String fileUri = req.getParameter("uri"); - //check if file individual has a fedora:PID for a data stream - IndividualDao iwDao = vreq.getWebappDaoFactory().getIndividualDao(); - Individual entity = iwDao.getIndividualByURI(fileUri); - - - - if( entity == null ) - throw new FdcException( "No entity found in system for file uri " + fileUri); - //System.out.println("Entity == null:" + (entity == null)); - //get the fedora PID - //System.out.println("entity data property " + entity.getDataPropertyMap().get(VitroVocabulary.FEDORA_PID)); - if( entity.getDataPropertyMap().get(VitroVocabulary.FEDORA_PID ) == null ) - throw new FdcException( "No fedora:pid found in system for file uri " + fileUri); - List'fedoraUrl' not found in properties file.
\n"); - } - if( adminUser == null ) { - log.error("'adminUser' was not found in properties file, the " + - "user name of the fedora admin is needed to access the " + - "fedora API-M services."); - status.append("'adminUser' was not found in properties file, the " + - "user name of the fedora admin is needed to access the " + - "fedora API-M services.
\n"); - } - if( adminPassword == null ){ - log.error("'adminPassword' was not found in properties file, the " + - "admin password is needed to access the fedora API-M services."); - status.append("'adminPassword' was not found in properties file, the " + - "admin password is needed to access the fedora API-M services.
\n"); - } - if( pidNamespace == null ){ - log.error("'pidNamespace' was not found in properties file, the " + - "PID namespace indicates which namespace to use when creating " + - "new fedor digital objects."); - status.append("'pidNamespace' was not found in properties file, the " + - "PID namespace indicates which namespace to use when creating " + - "new fedor digital objects.
\n"); - } - fedoraUrl = null; adminUser = null; adminPassword = null; - configured = false; - } else { - configured = true; - } - }catch(FileNotFoundException e) { - log.error("No fedora.properties file found,"+ - "it should be located at " + path); - status.append("No fedora.properties file found,"+ - "it should be located at " + path + "
\n"); - configured = false; - return; - }catch(Exception ex){ - status.append("Fedora configuration failed.
\n"); - status.append("Exception while loading" + path + "
\n"); - status.append("" + ex.getMessage() + "
\n"); - log.error("could not load fedora properties", ex); - fedoraUrl = null; adminUser = null; adminPassword = null; - configured = false; - return; - } - - - status.append(RELOAD_MSG); - this.configurationStatus += status.toString(); -// else{ -// status.append("fedoraUrl: ").append(fedoraUrl).append("
\n"); -// checkFedoraServer(); -// } - } - - private boolean canConnectToFedoraServer( ){ - try{ - FedoraClient fc = new FedoraClient(fedoraUrl,adminUser, adminPassword); - String fedoraVersion = fc.getServerVersion(); - if( fedoraVersion != null && fedoraVersion.length() > 0 ){ - configurationStatus += "Fedora server is live and is running " + - "fedora version " + fedoraVersion + "
\n"; - connected = true; - return true; - } else { - configurationStatus += "Unable to reach fedora server
\n"; - connected = false; - return false; - } - }catch (Exception e) { - configurationStatus += "There was an error while checking the " + - "fedora server version
\n"+ e.getMessage() + "
\n"; - connected = false; - return false; - } - } - - public boolean isConfigured(){ return configured; } - public boolean isConnected(){ return connected; } - - private class FdcException extends Exception { - public FdcException(String message) { - super(message); - } - } - - private static final String RELOAD_MSG = - "The fedora configuartion file will be reloaded if " + - "you edit the properties file and check the status.
\n"; - - public static String md5hashForFile(File file){ - try { - InputStream fin = new FileInputStream(file); - java.security.MessageDigest md5er = - MessageDigest.getInstance("MD5"); - byte[] buffer = new byte[1024]; - int read; - do { - read = fin.read(buffer); - if (read > 0) - md5er.update(buffer, 0, read); - } while (read != -1); - fin.close(); - byte[] digest = md5er.digest(); - if (digest == null) - return null; - String strDigest = "0x"; - for (int i = 0; i < digest.length; i++) { - strDigest += Integer.toString((digest[i] & 0xff) - + 0x100, 16).substring(1); - } - return strDigest; - } catch (Exception e) { - return null; - } - } - - private static final Log log = LogFactory.getLog(FedoraDatastreamController.class.getName()); -} diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/FedoraConfiguration.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/FedoraConfiguration.java deleted file mode 100644 index d014e0688..000000000 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/FedoraConfiguration.java +++ /dev/null @@ -1,198 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.utils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.Properties; - -import javax.servlet.ServletContext; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.joda.time.format.DateTimeFormatter; -import org.joda.time.format.ISODateTimeFormat; - -import org.apache.jena.rdf.model.Property; -import org.apache.jena.rdf.model.ResourceFactory; - -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import fedora.client.FedoraClient; - -public class FedoraConfiguration { - - private static String FEDORA_PROPERTIES = "/WEB-INF/fedora.properties"; - - public String fedoraUrl = null; - private String adminUser = null; - private String adminPassword = null; - private String pidNamespace = null; - private String configurationStatus = "Fedora configuration not yet loaded
"; - private boolean configured = false; - private boolean connected = false; - - public FedoraConfiguration(ServletContext context){ - setup( context ); - } - - public boolean isConfigured(){ return configured; } - public boolean isConnected(){ return connected; } - - public String setup(ServletContext context ){ - internalSetup( context); - if( ! configured ) - return configurationStatus; - canConnectToFedoraServer(); - return configurationStatus; - } - - private void internalSetup(ServletContext context) { - this.configurationStatus = ""; - StringBuffer status = new StringBuffer(""); - - if( connected && configured ) - return; - - Properties props = new Properties(); - String path = context.getRealPath(FEDORA_PROPERTIES); - try{ - InputStream in = new FileInputStream(new File( path )); - props.load( in ); - fedoraUrl = props.getProperty("fedoraUrl"); - adminUser = props.getProperty("adminUser"); - adminPassword = props.getProperty("adminPassword"); - pidNamespace = props.getProperty("pidNamespace"); - if( fedoraUrl == null || adminUser == null || adminPassword == null ){ - if( fedoraUrl == null ){ - log.error("'fedoraUrl' not found in properties file"); - status.append("'fedoraUrl' not found in properties file.
\n"); - } - if( adminUser == null ) { - log.error("'adminUser' was not found in properties file, the " + - "user name of the fedora admin is needed to access the " + - "fedora API-M services."); - status.append("'adminUser' was not found in properties file, the " + - "user name of the fedora admin is needed to access the " + - "fedora API-M services.
\n"); - } - if( adminPassword == null ){ - log.error("'adminPassword' was not found in properties file, the " + - "admin password is needed to access the fedora API-M services."); - status.append("'adminPassword' was not found in properties file, the " + - "admin password is needed to access the fedora API-M services.
\n"); - } - if( pidNamespace == null ){ - log.error("'pidNamespace' was not found in properties file, the " + - "PID namespace indicates which namespace to use when creating " + - "new fedor digital objects."); - status.append("'pidNamespace' was not found in properties file, the " + - "PID namespace indicates which namespace to use when creating " + - "new fedor digital objects.
\n"); - } - fedoraUrl = null; adminUser = null; adminPassword = null; - configured = false; - } else { - configured = true; - } - }catch(FileNotFoundException e){ - log.error("No fedora.properties file found,"+ - "it should be located at " + path); - status.append("No fedora.properties file found,"+ - "it should be located at " + path + "
\n"); - configured = false; - return; - }catch(Exception ex){ - status.append("Fedora configuration failed.
\n"); - status.append("Exception while loading" + path + "
\n"); - status.append("" + ex.getMessage() + "
\n"); - log.error("could not load fedora properties", ex); - fedoraUrl = null; adminUser = null; adminPassword = null; - configured = false; - return; - } - - status.append(RELOAD_MSG); - this.configurationStatus += status.toString(); - } - - public boolean canConnectToFedoraServer( ){ - try{ - FedoraClient fc = new FedoraClient(fedoraUrl,adminUser, adminPassword); - String fedoraVersion = fc.getServerVersion(); - if( fedoraVersion != null && fedoraVersion.length() > 0 ){ - configurationStatus += "Fedora server is live and is running " + - "fedora version " + fedoraVersion + "
\n"; - connected = true; - return true; - } else { - configurationStatus += "Unable to reach fedora server
\n"; - connected = false; - return false; - } - }catch (Exception e) { - configurationStatus += "There was an error while checking the " + - "fedora server version
\n"+ e.getMessage() + "
\n"; - connected = false; - return false; - } - } - - - - public static final Property FILE_NAME = ResourceFactory.createProperty(VitroVocabulary.FILE_NAME); - public static final Property CONTENT_TYPE = ResourceFactory.createProperty(VitroVocabulary.CONTENT_TYPE); - public static final Property FILE_LOCATION = ResourceFactory.createProperty(VitroVocabulary.FILE_LOCATION); - //public static final Property FEDORA_ID = ResourceFactory.createProperty(VitroVocabulary.FEDORA_PID); - - DateTimeFormatter isoFormatter = ISODateTimeFormat.dateTime(); - - private static Log log = LogFactory.getLog(FedoraConfiguration.class); - - private static final String RELOAD_MSG = - "The fedora configuartion file will be reloaded if " + - "you edit the properties file and check the status.
\n"; - - public String getFedoraUrl() { - return fedoraUrl; - } - - public void setFedoraUrl(String fedoraUrl) { - this.fedoraUrl = fedoraUrl; - } - - public String getAdminUser() { - return adminUser; - } - - public void setAdminUser(String adminUser) { - this.adminUser = adminUser; - } - - public String getAdminPassword() { - return adminPassword; - } - - public void setAdminPassword(String adminPassword) { - this.adminPassword = adminPassword; - } - - public String getPidNamespace() { - return pidNamespace; - } - - public void setPidNamespace(String pidNamespace) { - this.pidNamespace = pidNamespace; - } - - public String getConfigurationStatus() { - return configurationStatus; - } - - public void setConfigurationStatus(String configurationStatus) { - this.configurationStatus = configurationStatus; - } - -} diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 79a9ff0e0..d5717f500 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -248,11 +248,6 @@File
- - <%/*- use existing file name
-- rename file to name of file being uploaded
*/%> - - - - - - - - diff --git a/webapp/src/main/webapp/fileupload/datastreamModificationSuccess.jsp b/webapp/src/main/webapp/fileupload/datastreamModificationSuccess.jsp deleted file mode 100644 index 663991cbe..000000000 --- a/webapp/src/main/webapp/fileupload/datastreamModificationSuccess.jsp +++ /dev/null @@ -1,16 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - -