Merge branch 'maint-rel-1.6' into develop

This commit is contained in:
hudajkhan 2013-12-10 15:41:52 -05:00
commit bb02a213f1
13 changed files with 230 additions and 62 deletions

View file

@ -20,6 +20,7 @@ auth:ADMIN
auth:hasPermission simplePermission:ManageUserAccounts ;
auth:hasPermission simplePermission:RebuildVClassGroupCache ;
auth:hasPermission simplePermission:RefreshVisualizationCache ;
auth:hasPermission simplePermission:SeeConfiguration ;
auth:hasPermission simplePermission:SeeStartupStatus ;
auth:hasPermission simplePermission:UseAdvancedDataToolsPages ;
auth:hasPermission simplePermission:UseMiscellaneousAdminPages ;

View file

@ -64,6 +64,8 @@ public class SimplePermission extends Permission {
NAMESPACE + "RebuildVClassGroupCache");
public static final SimplePermission REFRESH_VISUALIZATION_CACHE = new SimplePermission(
NAMESPACE + "RefreshVisualizationCache");
public static final SimplePermission SEE_CONFIGURATION = new SimplePermission(
NAMESPACE + "SeeConfiguration");
public static final SimplePermission SEE_INDVIDUAL_EDITING_PANEL = new SimplePermission(
NAMESPACE + "SeeIndividualEditingPanel");
public static final SimplePermission SEE_REVISION_INFO = new SimplePermission(

View file

@ -0,0 +1,57 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.admin;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.SortedMap;
import java.util.TreeMap;
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
/**
* Show the current ConfigurationProperties and the Java system properties.
*/
public class ShowConfiguration extends FreemarkerHttpServlet {
@Override
protected Actions requiredActions(VitroRequest vreq) {
return SimplePermission.SEE_CONFIGURATION.ACTIONS;
}
@Override
protected ResponseValues processRequest(VitroRequest vreq) {
Map<String, Object> body = new HashMap<String, Object>();
body.put("configurationProperties", getConfigurationProperties(vreq));
body.put("javaSystemProperties", getSystemProperties());
return new TemplateResponseValues("admin-showConfiguration.ftl", body);
}
private SortedMap<String, String> getConfigurationProperties(
VitroRequest vreq) {
ConfigurationProperties props = ConfigurationProperties.getBean(vreq);
TreeMap<String, String> map = new TreeMap<>(props.getPropertyMap());
for (String key : map.keySet()) {
if (key.toLowerCase().endsWith("password")) {
map.put(key, "********");
}
}
return map;
}
private SortedMap<String, String> getSystemProperties() {
Properties props = System.getProperties();
SortedMap<String, String> map = new TreeMap<>();
for (String key : props.stringPropertyNames()) {
map.put(key, props.getProperty(key));
}
return map;
}
}

View file

@ -167,40 +167,50 @@ public class DateTimeWithPrecisionVTwo extends BaseEditElementVTwo {
DateTime value = getTimeValue(editConfig,editSub);
/* This is the case where there is a precision so there should be a datetime */
if( value == null )
log.debug("Field " + getFieldName() + " has precision " + precisionUri
+ " but the date time is " + value);
/* only put the values in the map for ones which are significant based on the precision */
if( existingPrec.ordinal() >= VitroVocabulary.Precision.SECOND.ordinal() )
map.put("second", Integer.toString(value.getSecondOfMinute() )) ;
else
map.put("second", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.MINUTE.ordinal() )
map.put("minute", Integer.toString(value.getMinuteOfHour()) );
else
map.put("minute", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.HOUR.ordinal() )
map.put("hour", Integer.toString(value.getHourOfDay()) );
else
map.put("hour", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.DAY.ordinal() )
map.put("day", Integer.toString(value.getDayOfMonth()) );
else
map.put("day", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.MONTH.ordinal() )
map.put("month", Integer.toString(value.getMonthOfYear()));
else
map.put("month", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.YEAR.ordinal() )
map.put("year", Integer.toString(value.getYear()));
else
if( value == null ) {
//If there is no value, then this is an error condition
log.error("Field " + getFieldName() + " has precision " + precisionUri
+ " but the date time value is null ");
map.put("year", "");
map.put("month", "");
map.put("day", "");
map.put("hour", "");
map.put("minute", "");
map.put("second", "") ;
} else {
/* only put the values in the map for ones which are significant based on the precision */
if( existingPrec.ordinal() >= VitroVocabulary.Precision.SECOND.ordinal() )
map.put("second", Integer.toString(value.getSecondOfMinute() )) ;
else
map.put("second", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.MINUTE.ordinal() )
map.put("minute", Integer.toString(value.getMinuteOfHour()) );
else
map.put("minute", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.HOUR.ordinal() )
map.put("hour", Integer.toString(value.getHourOfDay()) );
else
map.put("hour", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.DAY.ordinal() )
map.put("day", Integer.toString(value.getDayOfMonth()) );
else
map.put("day", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.MONTH.ordinal() )
map.put("month", Integer.toString(value.getMonthOfYear()));
else
map.put("month", "");
if( existingPrec.ordinal() >= VitroVocabulary.Precision.YEAR.ordinal() )
map.put("year", Integer.toString(value.getYear()));
else
map.put("year", "");
}
}
return map;

View file

@ -70,8 +70,7 @@ public class DateTimeIntervalFormGenerator extends
"startField-value", existingStartDateQuery);
conf.addSparqlForExistingLiteral(
"endField-value", existingEndDateQuery);
conf.addSparqlForExistingUris(
getNodeVar(), existingIntervalNodeQuery);
conf.addSparqlForExistingUris("startNode", existingStartNodeQuery);
conf.addSparqlForExistingUris("endNode", existingEndNodeQuery);
conf.addSparqlForExistingUris(
@ -115,7 +114,7 @@ public class DateTimeIntervalFormGenerator extends
final String existingStartDateQuery =
"SELECT ?existingDateStart WHERE { \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
getNodeN3Var() + " a <" + intervalType + "> . \n" +
getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" +
"?startNode a <" + dateTimeValueType + "> . \n" +
@ -123,34 +122,30 @@ public class DateTimeIntervalFormGenerator extends
final String existingEndDateQuery =
"SELECT ?existingEndDate WHERE { \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
getNodeN3Var() + " a <" + intervalType + "> . \n" +
getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" +
"?endNode a <" + dateTimeValueType + "> . \n " +
"?endNode <" + dateTimeValue + "> ?existingEndDate . }";
final String existingIntervalNodeQuery =
"SELECT ?existingIntervalNode WHERE { \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
"?existingIntervalNode a <" + intervalType + "> . }";
final String existingStartNodeQuery =
"SELECT ?existingStartNode WHERE { \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
getNodeN3Var() + " a <" + intervalType + "> . \n" +
getNodeN3Var() + " <" + intervalToStart + "> ?existingStartNode . \n" +
"?existingStartNode a <" + dateTimeValueType + "> .} ";
final String existingEndNodeQuery =
"SELECT ?existingEndNode WHERE { \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
getNodeN3Var() + " a <" + intervalType + "> . \n" +
getNodeN3Var() + " <" + intervalToEnd + "> ?existingEndNode . \n" +
"?existingEndNode a <" + dateTimeValueType + "> .} ";
final String existingStartPrecisionQuery =
"SELECT ?existingStartPrecision WHERE { \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
getNodeN3Var() + " a <" + intervalType + "> . \n" +
getNodeN3Var() + " <" + intervalToStart + "> ?startNode . \n" +
"?startNode a <" + dateTimeValueType + "> . \n" +
@ -158,7 +153,7 @@ public class DateTimeIntervalFormGenerator extends
final String existingEndPrecisionQuery =
"SELECT ?existingEndPrecision WHERE { \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> ?existingIntervalNode . \n" +
"?subject <" + getToDateTimeIntervalPredicate() + "> " + getNodeN3Var() + " . \n" +
getNodeN3Var() + " a <" + intervalType + "> . \n" +
getNodeN3Var() + " <" + intervalToEnd + "> ?endNode . \n" +
"?endNode a <" + dateTimeValueType + "> . \n" +

View file

@ -0,0 +1,54 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpSession;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.XSD;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.DateTimeWithPrecisionVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode;
import edu.cornell.mannlib.vitro.webapp.utils.generators.EditModeUtils;
/**
*
* @author hjk54
*
* There are multiple date time properties in VIVO, all of which have a DateTimeValue individual as an object.
* I am extending DateTimeValueFormGenerator to enable the predicate to be utilized as the "toDateTimeValue" property, i.e.
* the property associating the subject with the date time value individual. The dateTimeValueForm template has been
* used as the basis for the general form for this generator that can be applied to multiple properties.
*/
public class DateTimePropertyGenerator extends DateTimeValueFormGenerator {
String predicate = null;
@Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq,
HttpSession session) {
predicate = EditConfigurationUtils.getPredicateUri(vreq);
EditConfigurationVTwo conf = super.getEditConfiguration(vreq, session);
return conf;
}
//isolating the predicate in this fashion allows this class to be subclassed for other date time value
//properties
@Override
protected String getToDateTimeValuePredicate() {
return predicate;
}
}

View file

@ -46,7 +46,7 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
conf.setVarNameForSubject("subject");
conf.setVarNameForPredicate("toDateTimeValue");
conf.setVarNameForObject("valueNode");
//Value node value will be in scope if we have an object uri that exists for editing
conf.setN3Optional(Arrays.asList(getN3ForValue()));
conf.addNewResource("valueNode", DEFAULT_NS_FOR_NEW_RESOURCE);
@ -55,7 +55,6 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
"dateTimeField-value", getExistingDateTimeValueQuery());
conf.addSparqlForExistingUris(
"dateTimeField-precision", getExistingPrecisionQuery());
conf.addSparqlForExistingUris("valueNode", getExistingNodeQuery());
FieldVTwo dateTimeField = new FieldVTwo().setName(this.getDateTimeFieldName());
dateTimeField.setEditElement(new DateTimeWithPrecisionVTwo(dateTimeField,
@ -84,23 +83,18 @@ public class DateTimeValueFormGenerator extends BaseEditConfigurationGenerator
protected String getExistingDateTimeValueQuery () {
return "SELECT ?existingDateTimeValue WHERE { \n" +
"?subject <" + this.getToDateTimeValuePredicate() + "> ?existingValueNode . \n" +
"?existingValueNode a <" + valueType + "> . \n" +
"?existingValueNode <" + dateTimeValue + "> ?existingDateTimeValue }";
"?subject <" + this.getToDateTimeValuePredicate() + "> ?valueNode . \n" +
"?valueNode a <" + valueType + "> . \n" +
"?valueNode <" + dateTimeValue + "> ?existingDateTimeValue }";
}
protected String getExistingPrecisionQuery() {
return "SELECT ?existingPrecision WHERE { \n" +
"?subject <" + this.getToDateTimeValuePredicate() + "> ?existingValueNode . \n" +
"?existingValueNode a <" + valueType + "> . \n" +
"?existingValueNode <" + dateTimePrecision + "> ?existingPrecision }";
"?subject <" + this.getToDateTimeValuePredicate() + "> ?valueNode . \n" +
"?valueNode a <" + valueType + "> . \n" +
"?valueNode <" + dateTimePrecision + "> ?existingPrecision }";
}
protected String getExistingNodeQuery() {
return "SELECT ?existingNode WHERE { \n" +
"?subject <" + this.getToDateTimeValuePredicate() + "> ?existingNode . \n" +
"?existingNode a <" + valueType + "> }";
}
public static String getNodeVar() {
return "valueNode";
}

View file

@ -285,7 +285,7 @@ public class FreemarkerTemplateLoader implements TemplateLoader {
}
public boolean fileQualifies(Path path) {
return Files.isReadable(path) && !Files.isDirectory(path);
return !Files.isDirectory(path);
}
public SortedSet<PathPieces> getMatches() {

View file

@ -22,9 +22,26 @@ public class JvmSmokeTests implements ServletContextListener {
ServletContext ctx = sce.getServletContext();
StartupStatus ss = StartupStatus.getBean(ctx);
checkJvmLevel(ss);
checkTempDirectory(ss);
}
/**
* We need to run at 1.7 or later.
*/
private void checkJvmLevel(StartupStatus ss) {
String specLevel = System.getProperty("java.specification.version", "");
if (specLevel.isEmpty()) {
ss.warning(this, "Can't determine the current level of Java. "
+ "VIVO requires at least Java 1.7.");
} else if (specLevel.compareTo("1.7") < 0) {
ss.warning(this, "VIVO requires at least Java 1.7 - "
+ "currently running on Java " + specLevel);
} else {
ss.info(this, "Java version is " + specLevel);
}
}
/**
* Check the Java temp directory. Make sure that it exists, it is a
* directory, we can read it, we can write to it.

View file

@ -660,6 +660,15 @@
<url-pattern>/admin/showAuth</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ShowConfiguration</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.admin.ShowConfiguration</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ShowConfiguration</servlet-name>
<url-pattern>/admin/showConfiguration</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>StartupStatus</servlet-name>
<servlet-class>edu.cornell.mannlib.vitro.webapp.controller.admin.StartupStatusController</servlet-class>

View file

@ -0,0 +1,28 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Template viewing the authorization mechanisms: current identifiers, factories, policies, etc. -->
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/showAuth.css" />')}
<h2>Configuration settings</h2>
<section id="show-auth" role="region">
<h4>Build and runtime properties:</h4>
<table summary="Build and Runtime Properties">
<#list configurationProperties?keys as key>
<tr>
<td>${key}</td>
<td>${configurationProperties[key]}</td>
</tr>
</#list>
</table>
<h4>Java system properties:</h4>
<table summary="Java System Properties">
<#list javaSystemProperties?keys as key>
<tr>
<td>${key}</td>
<td>${javaSystemProperties[key]}</td>
</tr>
</#list>
</table>
</section>

View file

@ -33,8 +33,7 @@
<a class="cancel" href="${editConfiguration.cancelUrl}" title="${i18n().cancel_title}">${i18n().cancel_link}</a>
</p>
</form>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />',
'<link rel="stylesheet" href="${urls.base}/edit/forms/css/personHasEducationalTraining.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/utils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}

View file

@ -56,6 +56,8 @@
Links
<br/>
<a href="${urls.base}/admin/log4j.jsp">Set log levels</a>
<a href="${urls.base}/admin/showConfiguration">Show Configuration</a>
<br/>
<a href="${urls.base}/admin/showAuth">Show authorization info</a>
<a href="${urls.base}/admin/showThreads">Show background threads</a>
</div>