Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public class RootUserPolicy implements PolicyIface {
private static final Log log = LogFactory.getLog(RootUserPolicy.class);

private static final String PROPERTY_ROOT_USER_EMAIL = "rootUser.emailAddress";
/*
* UQAM For parameterization of rootUser
*/
private static final String PROPERTY_ROOT_USER_PASSWORD = "rootUser.password";
private static final String PROPERTY_ROOT_USER_PASSWORD_CHANGE_REQUIRED = "rootUser.passwordChangeRequired";

private static final String ROOT_USER_INITIAL_PASSWORD = "rootPassword";
private static final String ROOT_USER_INITIAL_PASSWORD_CHANGE_REQUIRED = "true";

/**
* This is the entire policy. If you are a root user, you are authorized.
Expand Down Expand Up @@ -150,10 +157,13 @@ private void createRootUser() {
ua.setEmailAddress(configuredRootUser);
ua.setFirstName("root");
ua.setLastName("user");
// UQAM using getRootPasswordFromConfig()
ua.setArgon2Password(Authenticator.applyArgon2iEncoding(
ROOT_USER_INITIAL_PASSWORD));
getRootPasswordFromConfig()));
ua.setMd5Password("");
ua.setPasswordChangeRequired(true);
Boolean toto;
// UQAM using getRootPasswdChangeRequiredFromConfig()
ua.setPasswordChangeRequired(getRootPasswdChangeRequiredFromConfig().booleanValue());
ua.setStatus(Status.ACTIVE);
ua.setRootUser(true);

Expand Down Expand Up @@ -191,7 +201,31 @@ private void complainAboutWrongRootUsers() {
ss.warning(this, "For security, "
+ "it is best to delete unneeded root user accounts.");
}
/*
* UQAM
* Add for getting rootUser.password property value from runtime.properties
*/
private String getRootPasswordFromConfig() {
String passwd = ConfigurationProperties.getBean(ctx).getProperty(
PROPERTY_ROOT_USER_PASSWORD);
if (passwd == null) {
passwd = ROOT_USER_INITIAL_PASSWORD;
}
return passwd;
}

/*
* UQAM
* Add for getting rootUser.passwordChangeRequired property value from runtime.properties
*/
private Boolean getRootPasswdChangeRequiredFromConfig() {
String passwdCR = ConfigurationProperties.getBean(ctx).getProperty(
PROPERTY_ROOT_USER_PASSWORD_CHANGE_REQUIRED);
if (passwdCR == null) {
passwdCR = ROOT_USER_INITIAL_PASSWORD_CHANGE_REQUIRED;
}
return new Boolean(passwdCR);
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
// Nothing to destroy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -42,6 +44,8 @@ protected ResponseValues processRequest(VitroRequest vreq) {
List<VClassGroup> groups = null;
VClassGroupsForRequest vcgc = VClassGroupCache.getVClassGroups(vreq);
groups =vcgc.getGroups();
Collections.sort(groups, publicNameComparator);
// sortGroupListByPublicName(groups);
List<VClassGroupTemplateModel> vcgroups = new ArrayList<VClassGroupTemplateModel>(groups.size());
for (VClassGroup group : groups) {
vcgroups.add(new VClassGroupTemplateModel(group));
Expand All @@ -50,4 +54,35 @@ protected ResponseValues processRequest(VitroRequest vreq) {

return new TemplateResponseValues(templateName, body);
}
public Comparator<VClassGroup> publicNameComparator = new Comparator<VClassGroup>() {

public int compare(VClassGroup s1, VClassGroup s2) {
String groupName1 = s1.getPublicName().toUpperCase();
String groupName2 = s2.getPublicName().toUpperCase();

//ascending order
return groupName1.compareTo(groupName2);

//descending order
//return groupName2.compareTo(groupName1);
}};

//
// public void sortGroupListByPublicName(List<VClassGroup> groupList) {
// groupList.sort(new Comparator<VClassGroup>() {
// public int compare(VClassGroup first, VClassGroup second) {
// if (first != null) {
// if (second != null) {
// return (first.getDisplayRank() - second.getDisplayRank());
// } else {
// log.error("error--2nd VClassGroup is null in VClassGroupDao.getGroupList().compare()");
// }
// } else {
// log.error("error--1st VClassGroup is null in VClassGroupDao.getGroupList().compare()");
// }
// return 0;
// }
// });
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
Expand All @@ -17,7 +18,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.cornell.mannlib.vitro.webapp.dao.jena.MenuDaoJena;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -93,6 +93,8 @@ public void doGet( HttpServletRequest request, HttpServletResponse response )
throws IOException, ServletException {

super.doGet(request,response);
//UQAM set for UTF-8
response.setCharacterEncoding("UTF-8");

VitroRequest vreq = new VitroRequest(request);
ResponseValues responseValues = null;
Expand All @@ -103,8 +105,8 @@ public void doGet( HttpServletRequest request, HttpServletResponse response )
if (!isAuthorizedToDisplayPage(request, response, requiredActions(vreq))) {
return;
}

responseValues = processRequest(vreq);

doResponse(vreq, response, responseValues);

} catch (Throwable e) {
Expand Down Expand Up @@ -256,7 +258,7 @@ private void doNotAuthorized(VitroRequest vreq,
protected void doTemplate(VitroRequest vreq, HttpServletResponse response,
ResponseValues values) throws TemplateProcessingException {

Map<String, Object> templateDataModel = new HashMap<String, Object>();
Map<String, Object> templateDataModel = new HashMap<String, Object>();
templateDataModel.putAll(getPageTemplateValues(vreq));

// Add the values that we got from the subcontroller processRequest() method, and merge to the template.
Expand All @@ -276,8 +278,14 @@ protected void doTemplate(VitroRequest vreq, HttpServletResponse response,
// is specified in the main page template.
bodyString = "";
}

//UQAM Add linguistic control management
// String bodyStringUTF = new String(bodyString.getBytes(), Charset.forName("UTF-8"));
templateDataModel.put("body", bodyString);

String lang = vreq.getLocale().getLanguage() + "-"+vreq.getLocale().getCountry();
templateDataModel.put("country", lang);

// Tell the template and any directives it uses that we're processing a page template.
templateDataModel.put("templateType", PAGE_TEMPLATE_TYPE);

Expand Down Expand Up @@ -462,7 +470,7 @@ private String normalizeServletName(String name) {

protected MainMenu getDisplayModelMenu(VitroRequest vreq){
String url = vreq.getRequestURI().substring(vreq.getContextPath().length());
return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(vreq, url);
return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(url);
}

// NIHVIVO-3307: we need this here instead of FreemarkerConfiguration.java so that updates to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ private void processTemplate(Template template, Map<String, Object> map, Writer

try {
Environment env = template.createProcessingEnvironment(map, writer);
/*
* UQAM Set encoding to UTF-8 for i18n special character
*/
// env.setOutputEncoding("utf-8");

// Define a setup template to be included by every page template
String templateType = (String) map.get("templateType");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import com.fasterxml.jackson.databind.node.ArrayNode;
Expand All @@ -15,6 +16,7 @@
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService.ShortViewContext;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup;
Expand Down Expand Up @@ -73,7 +75,8 @@ private String renderShortView(String individualUri, String vclassName) {
modelMap.put("individual",
IndividualTemplateModelBuilder.build(individual, vreq));
modelMap.put("vclass", vclassName);

String langCtx = vreq.getLocale().getLanguage() + "-"+vreq.getLocale().getCountry(); //UQAM build the linguistic context
modelMap.put("langCtx", langCtx); // UQAM add the linguistic context to map
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
return svs.renderShortView(individual, ShortViewContext.BROWSE,
modelMap, vreq);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* $This file is distributed under the terms of the license in LICENSE$ */

//
package edu.cornell.mannlib.vitro.webapp.dao.jena;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -780,6 +782,13 @@ private Literal getLabel(String lang, List<RDFNode>labelList) {
}
if ((lang != null) && (lang.equals(labelLanguage))) {
return labelLit;
} else
/*
* UQAM
* Check for country-part of lang (ex: 'en' for default consideration of labelLanguage in english but not encoded by 'en-US' most case of labels in vivo.owl)
*/
if ((lang != null) && (Arrays.asList(lang.split("-")).get(0).equals(labelLanguage))) {
return labelLit;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,15 @@ public static String sparqlNode(Node node, String varName) {
literalBuff.append("\"");
pyString(literalBuff, node.getLiteralLexicalForm());
literalBuff.append("\"");
if (node.getLiteralDatatypeURI() != null) {
literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
} else if (!StringUtils.isEmpty(node.getLiteralLanguage())) {
/*
* UQAM
* reversing the condition tests.
* It is important to prioritize the language typology test in order to exploit the linguistic context in testing the type of data
*/
if (!StringUtils.isEmpty(node.getLiteralLanguage())) {
literalBuff.append("@").append(node.getLiteralLanguage());
} else if (node.getLiteralDatatypeURI() != null) {
literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
}
return literalBuff.toString();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,20 @@ public static String sparqlNode(Node node, String varName) {
literalBuff.append("\"");
pyString(literalBuff, node.getLiteralLexicalForm());
literalBuff.append("\"");
if (node.getLiteralDatatypeURI() != null) {
literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
} else if (!StringUtils.isEmpty(node.getLiteralLanguage())) {
/*
* UQAM
* reversing the condition tests.
* It is important to prioritize the language typology test in order to exploit the linguistic context in testing the type of data
*/
// if (node.getLiteralDatatypeURI() != null) {
// literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
// } else if (node.getLiteralLanguage() != null && node.getLiteralLanguage().length() > 0) {
// literalBuff.append("@").append(node.getLiteralLanguage());
// }
if (!StringUtils.isEmpty(node.getLiteralLanguage())) {
literalBuff.append("@").append(node.getLiteralLanguage());
} else if (node.getLiteralDatatypeURI() != null) {
literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
}
return literalBuff.toString();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ public String toString(){
str += "\nadditions:[";
if( getAdditions() != null ) {
StringWriter writer = new StringWriter();
getAdditions().write(writer, "N3-PP");
// UQAM Replacing N3-PP by N3 (N3-PP does not exist in Jena
getAdditions().write(writer, "N3");
str += "\n" + writer.toString() + "\n";
}
str += "],\n";

str += "\nretractions:[";
if( getRetractions() != null ) {
StringWriter writer = new StringWriter();
getRetractions().write(writer, "N3-PP");
getRetractions().write(writer, "N3");
str += "\n" + writer.toString() + "\n";
}
str += "],\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfiguration;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
import freemarker.template.Configuration;

public class EditConfigurationUtils {
Expand Down Expand Up @@ -62,6 +63,7 @@ public static String getRangeUri(VitroRequest vreq) {
}

public static VClass getRangeVClass(VitroRequest vreq) {

// This needs a WebappDaoFactory with no filtering/RDFService
// funny business because it needs to be able to retrieve anonymous union
// classes by their "pseudo-bnode URIs".
Expand All @@ -71,6 +73,17 @@ public static VClass getRangeVClass(VitroRequest vreq) {
return ctxDaoFact.getVClassDao().getVClassByURI(getRangeUri(vreq));
}

public static VClass getLangAwardRangeVClass(VitroRequest vreq) {
// UQAM
//

// This needs a WebappDaoFactory with linguistic context filtering/RDFService
// funny business because it needs to be able to retrieve anonymous union
// classes by their "pseudo-bnode URIs".
// Someday we'll need to figure out a different way of doing this.
WebappDaoFactory ctxDaoFact = ModelAccess.on(vreq).getWebappDaoFactory(LanguageOption.LANGUAGE_AWARE);
return ctxDaoFact.getVClassDao().getVClassByURI(getRangeUri(vreq));
}
//get individual

public static Individual getSubjectIndividual(VitroRequest vreq) {
Expand Down Expand Up @@ -122,12 +135,24 @@ public static ObjectProperty getObjectPropertyForPredicate(VitroRequest vreq,

public static ObjectProperty getObjectPropertyForPredicate(VitroRequest vreq,
String predicateUri, String domainUri, String rangeUri) {
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
// WebappDaoFactory wdf = vreq.getWebappDaoFactory();
// UQAM Use linguistic context
WebappDaoFactory wdf = ModelAccess.on(vreq).getWebappDaoFactory(LanguageOption.LANGUAGE_AWARE);
ObjectProperty objectProp = wdf.getObjectPropertyDao().getObjectPropertyByURIs(
predicateUri, domainUri, rangeUri);
return objectProp;
}

// UQAM Use linguistic context
public static ObjectProperty getObjectPropertyForPredicateLangAware(VitroRequest vreq,
String predicateUri, String domainUri, String rangeUri) {
// WebappDaoFactory wdf = vreq.getWebappDaoFactory();
// UQAM Use linguistic context
WebappDaoFactory wdf = ModelAccess.on(vreq).getWebappDaoFactory(LanguageOption.LANGUAGE_AWARE);
ObjectProperty objectProp = wdf.getObjectPropertyDao().getObjectPropertyByURIs(
predicateUri, domainUri, rangeUri);
return objectProp;
}
public static DataProperty getDataPropertyForPredicate(VitroRequest vreq, String predicateUri) {
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
//TODO: Check reason for employing unfiltered webapp dao factory and note if using a different version
Expand Down Expand Up @@ -205,6 +230,7 @@ public static boolean isObjectProperty(String predicateUri, VitroRequest vreq) {
return (op != null && dp == null);
}


private static boolean isVitroLabel(String predicateUri) {
return predicateUri.equals(VitroVocabulary.LABEL);
}
Expand Down Expand Up @@ -281,6 +307,12 @@ public static Map<String, List<String>> getExistingUriValues(EditConfigurationVT
public static String generateHTMLForElement(VitroRequest vreq, String fieldName, EditConfigurationVTwo editConfig) {
String html = "";
Configuration fmConfig = FreemarkerConfiguration.getConfig(vreq);
/*
* UQAM, encoded ftl to UTF-8
*/
// fmConfig.setDefaultEncoding("utf-8");
// fmConfig.setOutputEncoding("utf-8");
// fmConfig.setURLEscapingCharset("UTF-8");

FieldVTwo field = editConfig == null ? null : editConfig.getField(fieldName);
MultiValueEditSubmission editSub = EditSubmissionUtils.getEditSubmissionFromSession(vreq.getSession(), editConfig);
Expand Down
Loading