Various code improvements from IntelliJ inspections

This commit is contained in:
Graham Triggs 2017-09-18 00:21:04 +01:00
parent 0ae8d005e4
commit 4859eb7da1
267 changed files with 879 additions and 1400 deletions

View file

@ -134,10 +134,7 @@ public class XMLUtils {
Transformer transformer = null; Transformer transformer = null;
try { try {
transformer = TransformerFactory.newInstance().newTransformer(); transformer = TransformerFactory.newInstance().newTransformer();
} catch (TransformerConfigurationException e) { } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@ -164,10 +161,7 @@ public class XMLUtils {
Transformer transformer = null; Transformer transformer = null;
try { try {
transformer = TransformerFactory.newInstance().newTransformer(); transformer = TransformerFactory.newInstance().newTransformer();
} catch (TransformerConfigurationException e) { } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vedit.beans; package edu.cornell.mannlib.vedit.beans;
import java.util.List; import java.util.List;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
public class DynamicField { public class DynamicField {

View file

@ -32,7 +32,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class BaseEditController extends VitroHttpServlet { public class BaseEditController extends VitroHttpServlet {

View file

@ -129,27 +129,31 @@ public class OperationController extends BaseEditController {
notifyChangeListeners(epo, action); notifyChangeListeners(epo, action);
/* send the user somewhere */ /* send the user somewhere */
if (action.equals("insert")){ switch (action) {
case "insert":
// Object[] args = new Object[1]; // Object[] args = new Object[1];
// args[0] = result; // args[0] = result;
// epo.setNewBean(epo.getGetMethod().invoke(facade,args)); // epo.setNewBean(epo.getGetMethod().invoke(facade,args));
PageForwarder pipf = epo.getPostInsertPageForwarder(); PageForwarder pipf = epo.getPostInsertPageForwarder();
if (pipf != null){ if (pipf != null) {
pipf.doForward(request,response,epo); pipf.doForward(request, response, epo);
return; return;
} }
} else if (action.equals("update")){ break;
case "update":
PageForwarder pupf = epo.getPostUpdatePageForwarder(); PageForwarder pupf = epo.getPostUpdatePageForwarder();
if (pupf != null) { if (pupf != null) {
pupf.doForward(request,response,epo); pupf.doForward(request, response, epo);
return; return;
} }
} else if (action.equals("delete")){ break;
case "delete":
PageForwarder pdpf = epo.getPostDeletePageForwarder(); PageForwarder pdpf = epo.getPostDeletePageForwarder();
if (pdpf != null) { if (pdpf != null) {
pdpf.doForward(request,response,epo); pdpf.doForward(request, response, epo);
return; return;
} }
break;
} }
//if no page forwarder was set, just go back to referring page: //if no page forwarder was set, just go back to referring page:
@ -170,7 +174,6 @@ public class OperationController extends BaseEditController {
try { try {
retry(request, response, epo); retry(request, response, epo);
return;
} catch (IOException ioe) { } catch (IOException ioe) {
log.error(this.getClass().getName() + " IOError on redirect: ", ioe); log.error(this.getClass().getName() + " IOError on redirect: ", ioe);
} }
@ -198,7 +201,6 @@ public class OperationController extends BaseEditController {
} else { } else {
response.sendRedirect(getDefaultLandingPage(request)); response.sendRedirect(getDefaultLandingPage(request));
} }
return;
} }
private void runPreprocessors(EditProcessObject epo, Object newObj) { private void runPreprocessors(EditProcessObject epo, Object newObj) {
@ -256,14 +258,14 @@ public class OperationController extends BaseEditController {
List validatorList = (List) epo.getValidatorMap().get(currParam); List validatorList = (List) epo.getValidatorMap().get(currParam);
if (validatorList != null) { if (validatorList != null) {
Iterator valIt = validatorList.iterator(); Iterator valIt = validatorList.iterator();
String errMsg = ""; StringBuilder errMsg = new StringBuilder();
while (valIt.hasNext()){ while (valIt.hasNext()){
Validator val = (Validator)valIt.next(); Validator val = (Validator)valIt.next();
ValidationObject vo = val.validate(currValue); ValidationObject vo = val.validate(currValue);
if (!vo.getValid()){ if (!vo.getValid()){
valid = false; valid = false;
fieldValid = false; fieldValid = false;
errMsg += vo.getMessage() + " "; errMsg.append(vo.getMessage()).append(" ");
epo.getBadValueMap().put(currParam,currValue); epo.getBadValueMap().put(currParam,currValue);
} else { } else {
try { try {
@ -273,7 +275,7 @@ public class OperationController extends BaseEditController {
} }
} }
if (errMsg.length()>0) { if (errMsg.length()>0) {
epo.getErrMsgMap().put(currParam,errMsg); epo.getErrMsgMap().put(currParam, errMsg.toString());
log.info("doPost() putting error message "+errMsg+" for "+currParam); log.info("doPost() putting error message "+errMsg+" for "+currParam);
} }
} }
@ -330,12 +332,17 @@ public class OperationController extends BaseEditController {
Iterator<ChangeListener> changeIt = changeListeners.iterator(); Iterator<ChangeListener> changeIt = changeListeners.iterator();
while (changeIt.hasNext()) { while (changeIt.hasNext()) {
ChangeListener cl = changeIt.next(); ChangeListener cl = changeIt.next();
if (action.equals("insert")) switch (action) {
cl.doInserted(epo.getNewBean(),epo); case "insert":
else if (action.equals("update")) cl.doInserted(epo.getNewBean(), epo);
cl.doUpdated(epo.getOriginalBean(),epo.getNewBean(),epo); break;
else if (action.equals("delete")) case "update":
cl.doDeleted(epo.getOriginalBean(),epo); cl.doUpdated(epo.getOriginalBean(), epo.getNewBean(), epo);
break;
case "delete":
cl.doDeleted(epo.getOriginalBean(), epo);
break;
}
} }
} }
} }
@ -499,8 +506,6 @@ public class OperationController extends BaseEditController {
} catch (InvocationTargetException f) { } catch (InvocationTargetException f) {
log.error(f.getTargetException().getMessage()); log.error(f.getTargetException().getMessage());
} }
} catch (NoSuchMethodException e) {
//log.error("doPost() could not find setId() method for "+partialClassName);
} catch (Exception f) { } catch (Exception f) {
//log.error("doPost() could not set id of new bean."); //log.error("doPost() could not set id of new bean.");
} }

View file

@ -4,11 +4,8 @@ package edu.cornell.mannlib.vedit.forwarder.impl;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder;
import edu.cornell.mannlib.vedit.forwarder.PageForwarder; import edu.cornell.mannlib.vedit.forwarder.PageForwarder;
import edu.cornell.mannlib.vedit.beans.EditProcessObject; import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;

View file

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Iterator; import java.util.Iterator;
import java.io.File; import java.io.File;
import java.io.BufferedOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
@ -16,18 +15,14 @@ import java.io.InputStreamReader;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.JspWriter;
import javax.servlet.ServletException;
import edu.cornell.mannlib.vedit.beans.FormObject; import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.beans.DynamicField; import edu.cornell.mannlib.vedit.beans.DynamicField;
import edu.cornell.mannlib.vedit.beans.DynamicFieldRow; import edu.cornell.mannlib.vedit.beans.DynamicFieldRow;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringEscapeUtils;
import edu.cornell.mannlib.vedit.tags.EditTag; import edu.cornell.mannlib.vedit.tags.EditTag;
public class DynamicFieldsTag extends EditTag { public class DynamicFieldsTag extends EditTag {
@ -63,7 +58,7 @@ public class DynamicFieldsTag extends EditTag {
int templateStart = -1; int templateStart = -1;
int postStart = -1; int postStart = -1;
InputStream fis = new FileInputStream (pageContext.getServletContext().getRealPath(new String())+PATH_SEP+MARKUP_FILE_PATH+usePage); InputStream fis = new FileInputStream (pageContext.getServletContext().getRealPath("")+PATH_SEP+MARKUP_FILE_PATH+usePage);
InputStream bis = new BufferedInputStream(fis); InputStream bis = new BufferedInputStream(fis);
BufferedReader in = new BufferedReader(new InputStreamReader(bis)); BufferedReader in = new BufferedReader(new InputStreamReader(bis));
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<String>();
@ -83,9 +78,9 @@ public class DynamicFieldsTag extends EditTag {
} }
in.close(); in.close();
StringBuffer preMarkupB = new StringBuffer(); StringBuilder preMarkupB = new StringBuilder();
StringBuffer postMarkupB = new StringBuffer(); StringBuilder postMarkupB = new StringBuilder();
StringBuffer templateMarkupB = new StringBuffer(); StringBuilder templateMarkupB = new StringBuilder();
if (templateStart>preStart && preStart>0) { if (templateStart>preStart && preStart>0) {
for (int i=preStart+1; i<templateStart; i++) { for (int i=preStart+1; i<templateStart; i++) {
@ -119,16 +114,16 @@ public class DynamicFieldsTag extends EditTag {
postMarkup = postMarkupB.toString(); postMarkup = postMarkupB.toString();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.out.println("DynamicFieldsTag could not find markup file at "+pageContext.getServletContext().getRealPath(new String())+"\\"+MARKUP_FILE_PATH+usePage); System.out.println("DynamicFieldsTag could not find markup file at "+pageContext.getServletContext().getRealPath("")+"\\"+MARKUP_FILE_PATH+usePage);
} catch (IOException ioe) { } catch (IOException ioe) {
System.out.println("DynamicFieldsTag encountered IOException reading "+pageContext.getServletContext().getRealPath(new String())+"\\"+MARKUP_FILE_PATH+usePage); System.out.println("DynamicFieldsTag encountered IOException reading "+pageContext.getServletContext().getRealPath("")+"\\"+MARKUP_FILE_PATH+usePage);
} }
} }
public String strReplace(String input, String pattern, String replacement) { public String strReplace(String input, String pattern, String replacement) {
String[] piece = input.split(pattern); String[] piece = input.split(pattern);
StringBuffer output = new StringBuffer(); StringBuilder output = new StringBuilder();
for (int i=0; i<piece.length; i++) { for (int i=0; i<piece.length; i++) {
output.append(piece[i]); output.append(piece[i]);
if (i<piece.length-1) if (i<piece.length-1)
@ -149,7 +144,7 @@ public class DynamicFieldsTag extends EditTag {
int i = 9899; int i = 9899;
while (dynIt.hasNext()) { while (dynIt.hasNext()) {
DynamicField dynf = dynIt.next(); DynamicField dynf = dynIt.next();
StringBuffer genTaName = new StringBuffer().append("_").append(dynf.getTable()).append("_"); StringBuilder genTaName = new StringBuilder().append("_").append(dynf.getTable()).append("_");
genTaName.append("-1").append("_"); genTaName.append("-1").append("_");
Iterator pparamIt = dynf.getRowTemplate().getParameterMap().keySet().iterator(); Iterator pparamIt = dynf.getRowTemplate().getParameterMap().keySet().iterator();
while(pparamIt.hasNext()) { while(pparamIt.hasNext()) {
@ -160,7 +155,7 @@ public class DynamicFieldsTag extends EditTag {
} }
String preWithVars = new String(preMarkup); String preWithVars = preMarkup;
preWithVars = strReplace(preWithVars,type+"NN",Integer.toString(i)); preWithVars = strReplace(preWithVars,type+"NN",Integer.toString(i));
preWithVars = strReplace(preWithVars,"\\$genTaName",genTaName.toString()); preWithVars = strReplace(preWithVars,"\\$genTaName",genTaName.toString());
preWithVars = strReplace(preWithVars,"\\$fieldName",dynf.getName()); preWithVars = strReplace(preWithVars,"\\$fieldName",dynf.getName());
@ -174,7 +169,7 @@ public class DynamicFieldsTag extends EditTag {
if (row.getValue()==null) if (row.getValue()==null)
row.setValue(""); row.setValue("");
if (row.getValue().length()>0) { if (row.getValue().length()>0) {
StringBuffer taName = new StringBuffer().append("_").append(dynf.getTable()).append("_"); StringBuilder taName = new StringBuilder().append("_").append(dynf.getTable()).append("_");
taName.append(row.getId()).append("_"); taName.append(row.getId()).append("_");
Iterator paramIt = row.getParameterMap().keySet().iterator(); Iterator paramIt = row.getParameterMap().keySet().iterator();
while(paramIt.hasNext()) { while(paramIt.hasNext()) {
@ -184,7 +179,7 @@ public class DynamicFieldsTag extends EditTag {
taName.append(key).append(":").append(new String(valueInBase64)).append(";"); taName.append(key).append(":").append(new String(valueInBase64)).append(";");
} }
if (row.getValue().length()>0) { if (row.getValue().length()>0) {
String templateWithVars = new String(templateMarkup); String templateWithVars = templateMarkup;
templateWithVars = strReplace(templateWithVars,type+"NN",Integer.toString(i)); templateWithVars = strReplace(templateWithVars,type+"NN",Integer.toString(i));
templateWithVars = strReplace(templateWithVars,"\\$taName",taName.toString()); templateWithVars = strReplace(templateWithVars,"\\$taName",taName.toString());
templateWithVars = strReplace(templateWithVars,"\\$\\$",row.getValue()); templateWithVars = strReplace(templateWithVars,"\\$\\$",row.getValue());
@ -199,14 +194,14 @@ public class DynamicFieldsTag extends EditTag {
// output the row template for the javascript to clone // output the row template for the javascript to clone
out.println("<!-- row template inserted by DynamicFieldsTag -->"); out.println("<!-- row template inserted by DynamicFieldsTag -->");
String hiddenTemplatePreMarkup = new String(preMarkup); String hiddenTemplatePreMarkup = preMarkup;
// bit of a hack to hide the template from the user: // bit of a hack to hide the template from the user:
hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:none\\;",""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:none\\;","");
hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:block\\;",""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:block\\;","");
hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:inline\\;",""); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"display\\:inline\\;","");
hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"style\\=\\\"","style=\"display:none;"); hiddenTemplatePreMarkup = strReplace(hiddenTemplatePreMarkup,"style\\=\\\"","style=\"display:none;");
out.print(hiddenTemplatePreMarkup); out.print(hiddenTemplatePreMarkup);
String hiddenTemplateTemplateMarkup = new String(templateMarkup); String hiddenTemplateTemplateMarkup = templateMarkup;
hiddenTemplateTemplateMarkup = strReplace(hiddenTemplateTemplateMarkup, "\\$\\$", ""); hiddenTemplateTemplateMarkup = strReplace(hiddenTemplateTemplateMarkup, "\\$\\$", "");
out.print(hiddenTemplateTemplateMarkup); out.print(hiddenTemplateTemplateMarkup);
out.print(postMarkup); out.print(postMarkup);

View file

@ -5,13 +5,10 @@ package edu.cornell.mannlib.vedit.tags;
import java.util.HashMap; import java.util.HashMap;
import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter;
import edu.cornell.mannlib.vedit.beans.EditProcessObject; import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.FormObject; import edu.cornell.mannlib.vedit.beans.FormObject;
import org.apache.commons.lang3.StringEscapeUtils;
public class EditTag extends TagSupport { public class EditTag extends TagSupport {
private String name = null; private String name = null;

View file

@ -3,9 +3,8 @@
package edu.cornell.mannlib.vedit.tags; package edu.cornell.mannlib.vedit.tags;
import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.JspWriter;
import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.tags.EditTag; import edu.cornell.mannlib.vedit.tags.EditTag;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vedit.tags;
import java.util.HashMap; import java.util.HashMap;
import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.JspWriter;
import edu.cornell.mannlib.vedit.beans.FormObject; import edu.cornell.mannlib.vedit.beans.FormObject;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;

View file

@ -226,7 +226,7 @@ public class FormUtils {
Option sOpt = new Option(); Option sOpt = new Option();
sOpt.setValue(selectedValue); sOpt.setValue(selectedValue);
if (selectedBody == null || selectedBody.length() == 0) if (selectedBody == null || selectedBody.length() == 0)
sOpt.setBody(selectedValue.toString()); sOpt.setBody(selectedValue);
else else
sOpt.setBody(selectedBody); sOpt.setBody(selectedBody);
sOpt.setSelected(true); sOpt.setSelected(true);

View file

@ -71,7 +71,7 @@ class Stemmer
public void add(char ch) public void add(char ch)
{ if (i == b.length) { if (i == b.length)
{ char[] new_b = new char[i+INC]; { char[] new_b = new char[i+INC];
for (int c = 0; c < i; c++) new_b[c] = b[c]; System.arraycopy(b, 0, new_b, 0, i);
b = new_b; b = new_b;
} }
b[i++] = ch; b[i++] = ch;
@ -86,7 +86,7 @@ class Stemmer
public void add(char[] w, int wLen) public void add(char[] w, int wLen)
{ if (i+wLen >= b.length) { if (i+wLen >= b.length)
{ char[] new_b = new char[i+wLen+INC]; { char[] new_b = new char[i+wLen+INC];
for (int c = 0; c < i; c++) new_b[c] = b[c]; System.arraycopy(b, 0, new_b, 0, i);
b = new_b; b = new_b;
} }
for (int c = 0; c < wLen; c++) b[i++] = w[c]; for (int c = 0; c < wLen; c++) b[i++] = w[c];
@ -116,7 +116,7 @@ class Stemmer
private final boolean cons(int i) private final boolean cons(int i)
{ switch (b[i]) { switch (b[i])
{ case 'a': case 'e': case 'i': case 'o': case 'u': return false; { case 'a': case 'e': case 'i': case 'o': case 'u': return false;
case 'y': return (i==0) ? true : !cons(i-1); case 'y': return (i == 0) || !cons(i - 1);
default: return true; default: return true;
} }
} }
@ -368,7 +368,7 @@ class Stemmer
public static String StemString( String inputStr, int maxLength ) public static String StemString( String inputStr, int maxLength )
{ {
String outputStr=""; StringBuilder outputStr= new StringBuilder();
int previousCh=0; int previousCh=0;
char[] w = new char[maxLength]; char[] w = new char[maxLength];
@ -396,19 +396,19 @@ class Stemmer
{ {
String u; String u;
u = s.toString(); u = s.toString();
outputStr += u; outputStr.append(u);
if ( ch == '-' ) { // replace - with space if ( ch == '-' ) { // replace - with space
outputStr += " "; outputStr.append(" ");
} else if ( ch == '.' ) { } else if ( ch == '.' ) {
if ( Character.isDigit( (char) previousCh )) { if ( Character.isDigit( (char) previousCh )) {
outputStr += "."; outputStr.append(".");
} else { } else {
outputStr += " "; outputStr.append(" ");
//previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass //previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass
} }
} else { } else {
Character Ch = new Character((char) ch); Character Ch = new Character((char) ch);
outputStr += Ch.toString(); outputStr.append(Ch.toString());
} }
stemmerInputBufferIndex=0; // to avoid repeats after ) stemmerInputBufferIndex=0; // to avoid repeats after )
} }
@ -422,7 +422,7 @@ class Stemmer
if ( !Character.isWhitespace((char) previousCh ) ) { if ( !Character.isWhitespace((char) previousCh ) ) {
if ( previousCh != '.' ) { if ( previousCh != '.' ) {
Character Ch = new Character((char) ch); Character Ch = new Character((char) ch);
outputStr += Ch.toString(); outputStr.append(Ch.toString());
} }
} }
} else if ( ch == '(' ) { // open paren; copy all characters until close paren } else if ( ch == '(' ) { // open paren; copy all characters until close paren
@ -449,21 +449,21 @@ class Stemmer
stemmerInputBufferIndex=0; stemmerInputBufferIndex=0;
} else if ( ch == ')' ) { // when is last character of input string } else if ( ch == ')' ) { // when is last character of input string
Character Ch = new Character((char) ch); Character Ch = new Character((char) ch);
outputStr += Ch.toString(); outputStr.append(Ch.toString());
log.trace( Ch.toString() ); log.trace( Ch.toString() );
log.trace("found close paren at position: " + inputArrayIndex + " of input term " + inputStr ); log.trace("found close paren at position: " + inputArrayIndex + " of input term " + inputStr );
} else if ( ch == '-' ) { // replace - with space } else if ( ch == '-' ) { // replace - with space
outputStr += " "; outputStr.append(" ");
} else if ( ch == '.' ) { } else if ( ch == '.' ) {
if ( Character.isDigit( (char) previousCh )) { if ( Character.isDigit( (char) previousCh )) {
outputStr += "."; outputStr.append(".");
} else { } else {
outputStr += " "; outputStr.append(" ");
//previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass //previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass
} }
} else { } else {
Character Ch = new Character((char) ch); Character Ch = new Character((char) ch);
outputStr += Ch.toString(); outputStr.append(Ch.toString());
} }
previousCh = ch; previousCh = ch;
if (ch < 0) break; if (ch < 0) break;
@ -477,10 +477,10 @@ class Stemmer
String u; String u;
u = s.toString(); u = s.toString();
outputStr += u; outputStr.append(u);
} }
return outputStr == null ? ( outputStr.equals("") ? null : outputStr.trim() ) : outputStr.trim(); return outputStr == null || outputStr.length() == 0 ? null : outputStr.toString().trim();
} }
/* /*

View file

@ -3,6 +3,8 @@
package edu.cornell.mannlib.vedit.validator.impl; package edu.cornell.mannlib.vedit.validator.impl;
import edu.cornell.mannlib.vedit.validator.*; import edu.cornell.mannlib.vedit.validator.*;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -17,17 +19,17 @@ public class EnumValuesValidator implements Validator {
} else { } else {
vo.setValid(false); vo.setValid(false);
if (legalValues.size()<7){ if (legalValues.size()<7){
String msgString = "Please enter one of "; StringBuilder msgString = new StringBuilder("Please enter one of ");
Iterator valuesIt = legalValues.iterator(); Iterator valuesIt = legalValues.iterator();
while (valuesIt.hasNext()) { while (valuesIt.hasNext()) {
String legalValue = (String) valuesIt.next(); String legalValue = (String) valuesIt.next();
msgString += "'"+legalValue+"'"; msgString.append("'").append(legalValue).append("'");
if (valuesIt.hasNext()) if (valuesIt.hasNext())
msgString += ", "; msgString.append(", ");
else else
msgString += "."; msgString.append(".");
} }
vo.setMessage(msgString); vo.setMessage(msgString.toString());
} }
else { else {
vo.setMessage("Please enter a legal value."); vo.setMessage("Please enter a legal value.");
@ -38,7 +40,6 @@ public class EnumValuesValidator implements Validator {
} }
public EnumValuesValidator (String[] legalValues){ public EnumValuesValidator (String[] legalValues){
for (int i=0; i<legalValues.length; i++) Collections.addAll(this.legalValues, legalValues);
this.legalValues.add(legalValues[i]);
} }
} }

View file

@ -24,10 +24,10 @@ public class UrlValidator implements Validator {
IRIFactory factory = IRIFactory.jenaImplementation(); IRIFactory factory = IRIFactory.jenaImplementation();
IRI iri = factory.create((String) obj); IRI iri = factory.create((String) obj);
if (iri.hasViolation(false) ) { if (iri.hasViolation(false) ) {
String errorStr = ""; StringBuilder errorStr = new StringBuilder();
Iterator<Violation> violIt = iri.violations(false); Iterator<Violation> violIt = iri.violations(false);
while(violIt.hasNext()) { while(violIt.hasNext()) {
errorStr += violIt.next().getShortMessage() + " "; errorStr.append(violIt.next().getShortMessage()).append(" ");
} }
vo.setValid(false); vo.setValid(false);
vo.setMessage("Please enter a valid URL. " + errorStr); vo.setMessage("Please enter a valid URL. " + errorStr);

View file

@ -159,8 +159,8 @@ public class VitroHomeDirectory {
VHD_BUILD_PROPERTY); VHD_BUILD_PROPERTY);
throw new IllegalStateException(message); throw new IllegalStateException(message);
} else if (foundLocations.size() > 1) { } else if (foundLocations.size() > 1) {
String message = String.format("Found multiple values for the " String message = "Found multiple values for the "
+ "Vitro home directory: " + foundLocations); + "Vitro home directory: " + foundLocations;
log.warn(message); log.warn(message);
} }
} }

View file

@ -145,11 +145,8 @@ public class PropertyRestrictionBeanImpl extends PropertyRestrictionBean {
if (resourceUri == null || userRole == null) { if (resourceUri == null || userRole == null) {
return false; return false;
} }
if (prohibitedNamespaces.contains(namespace(resourceUri)) return !prohibitedNamespaces.contains(namespace(resourceUri))
&& !permittedExceptions.contains(resourceUri)) { || permittedExceptions.contains(resourceUri);
return false;
}
return true;
} }
@Override @Override
@ -241,9 +238,7 @@ public class PropertyRestrictionBeanImpl extends PropertyRestrictionBean {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
for (FullPropertyKey key : keys) { for (FullPropertyKey key : keys) {
buffer.append(key + " " + thresholdMap.get(key).getLevel(DISPLAY) buffer.append(key).append(" ").append(thresholdMap.get(key).getLevel(DISPLAY)).append(" ").append(thresholdMap.get(key).getLevel(MODIFY)).append(" ").append(thresholdMap.get(key).getLevel(PUBLISH)).append("\n");
+ " " + thresholdMap.get(key).getLevel(MODIFY) + " "
+ thresholdMap.get(key).getLevel(PUBLISH) + "\n");
} }
return buffer.toString(); return buffer.toString();

View file

@ -6,7 +6,6 @@ import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAct
import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction;
import edu.cornell.mannlib.vitro.webapp.beans.Property; import edu.cornell.mannlib.vitro.webapp.beans.Property;

View file

@ -7,8 +7,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;

View file

@ -51,7 +51,7 @@ public class DataPropertyComparator implements Comparator<Individual> {
if (XSD.xint.toString().equals(datatype)) { if (XSD.xint.toString().equals(datatype)) {
int i1 = Integer.valueOf(dps1.getData()); int i1 = Integer.valueOf(dps1.getData());
int i2 = Integer.valueOf(dps2.getData()); int i2 = Integer.valueOf(dps2.getData());
result = ((Integer) i1).compareTo(i2); result = Integer.compare(i1, i2);
} }
else if (XSD.xstring.toString().equals(datatype)) { else if (XSD.xstring.toString().equals(datatype)) {
result = dps1.getData().compareTo(dps2.getData()); result = dps1.getData().compareTo(dps2.getData());

View file

@ -2,10 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.beans; package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
import org.apache.jena.rdf.model.Property;
/** /**
* a class representing a particular instance of a data property * a class representing a particular instance of a data property
* *

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.beans; package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
/** /**
* a class representing an particular instance of a data property * a class representing an particular instance of a data property
* *

View file

@ -576,16 +576,16 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
* @return Readable text identifying this property's attributes * @return Readable text identifying this property's attributes
*/ */
public String toString(){ public String toString(){
String list = "null"; StringBuilder list = new StringBuilder("null");
if( getObjectPropertyStatements() != null ){ if( getObjectPropertyStatements() != null ){
Iterator it = getObjectPropertyStatements().iterator(); Iterator it = getObjectPropertyStatements().iterator();
if( !it.hasNext() ) list = " none"; if( !it.hasNext() ) list = new StringBuilder(" none");
while(it.hasNext()){ while(it.hasNext()){
Object obj = it.next(); Object obj = it.next();
if( obj != null && obj instanceof ObjectPropertyStatement){ if( obj != null && obj instanceof ObjectPropertyStatement){
list += "\n\t\t" + ((ObjectPropertyStatement)obj).toString(); list.append("\n\t\t").append(((ObjectPropertyStatement) obj).toString());
}else{ }else{
list += "\n\t\t" + obj.toString(); list.append("\n\t\t").append(obj.toString());
} }
} }
} }

View file

@ -1,7 +1,6 @@
/* $This file is distributed under the terms of the license in LICENSE$ */ /* $This file is distributed under the terms of the license in LICENSE$ */
package edu.cornell.mannlib.vitro.webapp.beans; package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
public interface ObjectPropertyStatement { public interface ObjectPropertyStatement {

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.beans; package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
/** /**
* a class representing a particular instance of an object property * a class representing a particular instance of an object property

View file

@ -45,8 +45,7 @@ public class PermissionSet {
} }
public void setForNewUsers(Boolean forNewUsers) { public void setForNewUsers(Boolean forNewUsers) {
this.forNewUsers = (forNewUsers == null) ? false this.forNewUsers = (forNewUsers != null) && forNewUsers.booleanValue();
: forNewUsers.booleanValue();
} }
public boolean isForPublic() { public boolean isForPublic() {
@ -54,8 +53,7 @@ public class PermissionSet {
} }
public void setForPublic(Boolean forPublic) { public void setForPublic(Boolean forPublic) {
this.forPublic = (forPublic == null) ? false this.forPublic = (forPublic != null) && forPublic.booleanValue();
: forPublic.booleanValue();
} }
public Set<String> getPermissionUris() { public Set<String> getPermissionUris() {

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.beans; package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
/** /**
Represents a Vitro object property instance. It includes values Represents a Vitro object property instance. It includes values
from the entities, object property statements, properties, and ent2relationships tables from the entities, object property statements, properties, and ent2relationships tables

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.beans; package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
public interface PropertyInstanceIface { public interface PropertyInstanceIface {
//needed for PropertyInstance //needed for PropertyInstance
//object property statements //object property statements

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.config; package edu.cornell.mannlib.vitro.webapp.config;
import java.io.File;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;

View file

@ -104,30 +104,30 @@ public class MailUsersServlet extends VitroHttpServlet {
comments=comments.trim(); comments=comments.trim();
//Removed spam filtering code //Removed spam filtering code
StringBuffer msgBuf = new StringBuffer(); // contains the intro copy for the body of the email message StringBuilder msgBuf = new StringBuilder(); // contains the intro copy for the body of the email message
String lineSeparator = System.getProperty("line.separator"); // \r\n on windows, \n on unix String lineSeparator = System.getProperty("line.separator"); // \r\n on windows, \n on unix
// from MyLibrary // from MyLibrary
msgBuf.setLength(0); msgBuf.setLength(0);
//msgBuf.append("Content-Type: text/html; charset='us-ascii'" + lineSeparator); //msgBuf.append("Content-Type: text/html; charset='us-ascii'" + lineSeparator);
msgBuf.append("<html>" + lineSeparator ); msgBuf.append("<html>").append(lineSeparator);
msgBuf.append("<head>" + lineSeparator ); msgBuf.append("<head>").append(lineSeparator);
msgBuf.append("<style>a {text-decoration: none}</style>" + lineSeparator ); msgBuf.append("<style>a {text-decoration: none}</style>").append(lineSeparator);
msgBuf.append("<title>" + deliveryfrom + "</title>" + lineSeparator ); msgBuf.append("<title>").append(deliveryfrom).append("</title>").append(lineSeparator);
msgBuf.append("</head>" + lineSeparator ); msgBuf.append("</head>").append(lineSeparator);
msgBuf.append("<body>" + lineSeparator ); msgBuf.append("<body>").append(lineSeparator);
msgBuf.append("<h4>" + deliveryfrom + "</h4>" + lineSeparator ); msgBuf.append("<h4>").append(deliveryfrom).append("</h4>").append(lineSeparator);
msgBuf.append("<h4>From: "+webusername +" (" + webuseremail + ")"+" at IP address "+request.getRemoteAddr()+"</h4>"+lineSeparator); msgBuf.append("<h4>From: ").append(webusername).append(" (").append(webuseremail).append(")").append(" at IP address ").append(request.getRemoteAddr()).append("</h4>").append(lineSeparator);
//Don't need any 'likely viewing page' portion to be emailed out to the others //Don't need any 'likely viewing page' portion to be emailed out to the others
msgBuf.append(lineSeparator + "</i></p><h3>Comments:</h3>" + lineSeparator ); msgBuf.append(lineSeparator).append("</i></p><h3>Comments:</h3>").append(lineSeparator);
if (comments==null || comments.equals("")) { if (comments==null || comments.equals("")) {
msgBuf.append("<p>BLANK MESSAGE</p>"); msgBuf.append("<p>BLANK MESSAGE</p>");
} else { } else {
msgBuf.append("<p>"+comments+"</p>"); msgBuf.append("<p>").append(comments).append("</p>");
} }
msgBuf.append("</body>" + lineSeparator ); msgBuf.append("</body>").append(lineSeparator);
msgBuf.append("</html>" + lineSeparator ); msgBuf.append("</html>").append(lineSeparator);
String msgText = msgBuf.toString(); String msgText = msgBuf.toString();

View file

@ -58,7 +58,6 @@ public class OntologyController extends VitroHttpServlet{
if( rdfFormat != null ){ if( rdfFormat != null ){
doRdf(req, res, rdfFormat ); doRdf(req, res, rdfFormat );
return;
} }
} }
@ -159,7 +158,6 @@ public class OntologyController extends VitroHttpServlet{
if( ! found ){ if( ! found ){
//respond to HTTP outside of critical section //respond to HTTP outside of critical section
doNotFound(req,res); doNotFound(req,res);
return;
} else { } else {
JenaOutputUtils.setNameSpacePrefixes(newModel,vreq.getWebappDaoFactory()); JenaOutputUtils.setNameSpacePrefixes(newModel,vreq.getWebappDaoFactory());
res.setContentType(rdfFormat.getMediaType()); res.setContentType(rdfFormat.getMediaType());
@ -172,7 +170,6 @@ public class OntologyController extends VitroHttpServlet{
format ="TTL"; format ="TTL";
newModel.write( res.getOutputStream(), format ); newModel.write( res.getOutputStream(), format );
return;
} }
} }

View file

@ -87,7 +87,6 @@ public class SparqlQueryBuilderServlet extends BaseEditController {
} }
doHelp(request,response); doHelp(request,response);
return;
} }
private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res){ private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res){

View file

@ -127,7 +127,6 @@ public class UserAccountsEditPage extends UserAccountsPage {
+ "but is not authorized to do so. Logged in as: " + "but is not authorized to do so. Logged in as: "
+ LoginStatusBean.getCurrentUser(vreq)); + LoginStatusBean.getCurrentUser(vreq));
bogusMessage = getBogusStandardMessage(vreq); bogusMessage = getBogusStandardMessage(vreq);
return;
} }
} }
} }

View file

@ -126,7 +126,6 @@ public class UserAccountsFirstTimeExternalPage extends UserAccountsPage {
} }
if (!Authenticator.getInstance(vreq).isUserPermittedToLogin(null)) { if (!Authenticator.getInstance(vreq).isUserPermittedToLogin(null)) {
bogusMessage = i18n.text("logins_disabled_for_maintenance"); bogusMessage = i18n.text("logins_disabled_for_maintenance");
return;
} }
} }

View file

@ -121,7 +121,6 @@ public abstract class UserAccountsPasswordBasePage extends UserAccountsPage {
+ "' when already logged in as '" + currentUserEmail + "' when already logged in as '" + currentUserEmail
+ "'"); + "'");
bogusMessage = alreadyLoggedInMessage(currentUserEmail); bogusMessage = alreadyLoggedInMessage(currentUserEmail);
return;
} }
} }
} }

View file

@ -61,7 +61,6 @@ public class SparqlQueryAjaxController extends VitroAjaxController {
String queryParam = locateQueryParam(vreq); String queryParam = locateQueryParam(vreq);
Query query = SparqlUtils.createQuery(queryParam); Query query = SparqlUtils.createQuery(queryParam);
SparqlUtils.executeQuery(response, query, model); SparqlUtils.executeQuery(response, query, model);
return;
} catch (AjaxControllerException e) { } catch (AjaxControllerException e) {
log.error(e.getMessage()); log.error(e.getMessage());
response.sendError(e.getStatusCode()); response.sendError(e.getStatusCode());

View file

@ -9,7 +9,6 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.api.sparqlquery;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Collection; import java.util.Collection;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;

View file

@ -197,11 +197,7 @@ public abstract class Authenticator {
// InternetAddress permits a localname without hostname. // InternetAddress permits a localname without hostname.
// Guard against that. // Guard against that.
if (emailAddress.indexOf('@') == -1) { return emailAddress.indexOf('@') != -1;
return false;
}
return true;
} catch (AddressException e) { } catch (AddressException e) {
return false; return false;
} }

View file

@ -104,13 +104,11 @@ public class LoginExternalAuthReturn extends BaseLoginServlet {
getAuthenticator(req).recordLoginAgainstUserAccount(userAccount, getAuthenticator(req).recordLoginAgainstUserAccount(userAccount,
AuthenticationSource.EXTERNAL); AuthenticationSource.EXTERNAL);
new LoginRedirector(req, afterLoginUrl).redirectLoggedInUser(resp); new LoginRedirector(req, afterLoginUrl).redirectLoggedInUser(resp);
return;
} catch (LoginNotPermitted e) { } catch (LoginNotPermitted e) {
// should have been caught by isUserPermittedToLogin() // should have been caught by isUserPermittedToLogin()
log.debug("Logins disabled for " + userAccount); log.debug("Logins disabled for " + userAccount);
complainAndReturnToReferrer(req, resp, ATTRIBUTE_REFERRER, complainAndReturnToReferrer(req, resp, ATTRIBUTE_REFERRER,
messageLoginDisabled(req)); messageLoginDisabled(req));
return;
} }
} }

View file

@ -144,7 +144,6 @@ public class ProgramLogin extends HttpServlet {
} }
recordLoginWithPasswordChange(); recordLoginWithPasswordChange();
sendSuccess(MESSAGE_SUCCESS_FIRST_TIME); sendSuccess(MESSAGE_SUCCESS_FIRST_TIME);
return;
} }
} }

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore; package edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -22,7 +21,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServ
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; 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.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ResultFormat;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
/** /**

View file

@ -95,11 +95,7 @@ class NQuadLineSplitter {
while (!atEnd() && isWhiteSpace()) { while (!atEnd() && isWhiteSpace()) {
i++; i++;
} }
if (atEnd()) { if (!atEnd() && line.charAt(i) != '#') {
return;
} else if (line.charAt(i) == '#') {
return;
} else {
throw new BadNodeException( throw new BadNodeException(
"Period was not followed by end of line: '" + line + "'"); "Period was not followed by end of line: '" + line + "'");
} }

View file

@ -351,7 +351,6 @@ public class Authenticate extends VitroHttpServlet {
// This should have been caught by isUserPermittedToLogin() // This should have been caught by isUserPermittedToLogin()
bean.setMessage(request, ERROR, bean.setMessage(request, ERROR,
"logins_disabled_for_maintenance"); "logins_disabled_for_maintenance");
return;
} }
} }
} }
@ -413,7 +412,6 @@ public class Authenticate extends VitroHttpServlet {
} catch (LoginNotPermitted e) { } catch (LoginNotPermitted e) {
// This should have been caught by isUserPermittedToLogin() // This should have been caught by isUserPermittedToLogin()
bean.setMessage(request, ERROR, "logins_disabled_for_maintenance"); bean.setMessage(request, ERROR, "logins_disabled_for_maintenance");
return;
} }
} }
@ -497,7 +495,6 @@ public class Authenticate extends VitroHttpServlet {
String loginProcessPage = LoginProcessBean.getBean(vreq) String loginProcessPage = LoginProcessBean.getBean(vreq)
.getLoginPageUrl(); .getLoginPageUrl();
response.sendRedirect(loginProcessPage); response.sendRedirect(loginProcessPage);
return;
} }
/** /**

View file

@ -73,15 +73,19 @@ public class Classes2ClassesOperationController extends BaseEditController {
String superclassURIstr = request.getParameter("SuperclassURI"); String superclassURIstr = request.getParameter("SuperclassURI");
if (superclassURIstr != null) { if (superclassURIstr != null) {
for (int i=0; i<subclassURIstrs.length; i++) { for (int i=0; i<subclassURIstrs.length; i++) {
if (modeStr.equals("disjointWith")) { switch (modeStr) {
case "disjointWith":
vcDao.removeDisjointWithClass(superclassURIstr, subclassURIstrs[i]); vcDao.removeDisjointWithClass(superclassURIstr, subclassURIstrs[i]);
} else if (modeStr.equals("equivalentClass")) { break;
case "equivalentClass":
vcDao.removeEquivalentClass(superclassURIstr, subclassURIstrs[i]); vcDao.removeEquivalentClass(superclassURIstr, subclassURIstrs[i]);
} else { break;
default:
Classes2Classes c2c = new Classes2Classes(); Classes2Classes c2c = new Classes2Classes();
c2c.setSubclassURI(subclassURIstrs[i]); c2c.setSubclassURI(subclassURIstrs[i]);
c2c.setSuperclassURI(superclassURIstr); c2c.setSuperclassURI(superclassURIstr);
vcDao.deleteClasses2Classes(c2c); vcDao.deleteClasses2Classes(c2c);
break;
} }
} }
} }
@ -90,29 +94,37 @@ public class Classes2ClassesOperationController extends BaseEditController {
String[] superclassURIstrs = request.getParameterValues("SuperclassURI"); String[] superclassURIstrs = request.getParameterValues("SuperclassURI");
if (superclassURIstrs != null) { if (superclassURIstrs != null) {
for (int i=0; i<superclassURIstrs.length; i++) { for (int i=0; i<superclassURIstrs.length; i++) {
if (modeStr.equals("disjointWith")) { switch (modeStr) {
vcDao.removeDisjointWithClass(superclassURIstrs[i],subclassURIstr); case "disjointWith":
} else if (modeStr.equals("equivalentClass")) { vcDao.removeDisjointWithClass(superclassURIstrs[i], subclassURIstr);
vcDao.removeEquivalentClass(subclassURIstr,superclassURIstrs[i]); break;
} else { case "equivalentClass":
vcDao.removeEquivalentClass(subclassURIstr, superclassURIstrs[i]);
break;
default:
Classes2Classes c2c = new Classes2Classes(); Classes2Classes c2c = new Classes2Classes();
c2c.setSuperclassURI(superclassURIstrs[i]); c2c.setSuperclassURI(superclassURIstrs[i]);
c2c.setSubclassURI(subclassURIstr); c2c.setSubclassURI(subclassURIstr);
vcDao.deleteClasses2Classes(c2c); vcDao.deleteClasses2Classes(c2c);
break;
} }
} }
} }
} }
} else if (request.getParameter("operation").equals("add")) { } else if (request.getParameter("operation").equals("add")) {
if (modeStr.equals("disjointWith")) { switch (modeStr) {
case "disjointWith":
vcDao.addDisjointWithClass(request.getParameter("SuperclassURI"), request.getParameter("SubclassURI")); vcDao.addDisjointWithClass(request.getParameter("SuperclassURI"), request.getParameter("SubclassURI"));
} else if (modeStr.equals("equivalentClass")) { break;
case "equivalentClass":
vcDao.addEquivalentClass(request.getParameter("SuperclassURI"), request.getParameter("SubclassURI")); vcDao.addEquivalentClass(request.getParameter("SuperclassURI"), request.getParameter("SubclassURI"));
} else { break;
default:
Classes2Classes c2c = new Classes2Classes(); Classes2Classes c2c = new Classes2Classes();
c2c.setSuperclassURI(request.getParameter("SuperclassURI")); c2c.setSuperclassURI(request.getParameter("SuperclassURI"));
c2c.setSubclassURI(request.getParameter("SubclassURI")); c2c.setSubclassURI(request.getParameter("SubclassURI"));
vcDao.insertNewClasses2Classes(c2c); vcDao.insertNewClasses2Classes(c2c);
break;
} }
} }
} catch (Exception e) { } catch (Exception e) {

View file

@ -68,7 +68,7 @@ public class ClassgroupRetryController extends BaseEditController {
} }
if (vclassGroupForEditing == null) { if (vclassGroupForEditing == null) {
//UTF-8 expected due to URIEncoding on Connector in server.xml //UTF-8 expected due to URIEncoding on Connector in server.xml
String uriToFind = new String(request.getParameter("uri")); String uriToFind = request.getParameter("uri");
vclassGroupForEditing = (VClassGroup)cgDao.getGroupByURI(uriToFind); vclassGroupForEditing = (VClassGroup)cgDao.getGroupByURI(uriToFind);
} }
} else { } else {

View file

@ -95,7 +95,7 @@ public class EntityEditController extends BaseEditController {
} }
results.add(rName); results.add(rName);
String classStr = ""; StringBuilder classStr = new StringBuilder();
List<VClass> classList = inferredEnt.getVClasses(false); List<VClass> classList = inferredEnt.getVClasses(false);
sortForPickList(classList, vreq); sortForPickList(classList, vreq);
if (classList != null) { if (classList != null) {
@ -109,13 +109,13 @@ public class EntityEditController extends BaseEditController {
} catch (Exception e) { } catch (Exception e) {
rClassName = vc.getLocalNameWithPrefix(); rClassName = vc.getLocalNameWithPrefix();
} }
classStr += rClassName; classStr.append(rClassName);
if (classIt.hasNext()) { if (classIt.hasNext()) {
classStr += ", "; classStr.append(", ");
} }
} }
} }
results.add(classStr); results.add(classStr.toString());
results.add(ent.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified" results.add(ent.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified"
: ent.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel()); : ent.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel());
@ -147,7 +147,7 @@ public class EntityEditController extends BaseEditController {
Iterator<DataPropertyStatement> externalIdIt = ent.getExternalIds().iterator(); Iterator<DataPropertyStatement> externalIdIt = ent.getExternalIds().iterator();
while (externalIdIt.hasNext()) { while (externalIdIt.hasNext()) {
DataPropertyStatement eid = externalIdIt.next(); DataPropertyStatement eid = externalIdIt.next();
String multiplexedString = new String ("DatapropURI:" + new String(Base64.encodeBase64(eid.getDatapropURI().getBytes())) + ";" + "Data:" + new String(Base64.encodeBase64(eid.getData().getBytes()))); String multiplexedString = "DatapropURI:" + new String(Base64.encodeBase64(eid.getDatapropURI().getBytes())) + ";" + "Data:" + new String(Base64.encodeBase64(eid.getData().getBytes()));
externalIdOptionList.add(new Option(multiplexedString, eid.getData())); externalIdOptionList.add(new Option(multiplexedString, eid.getData()));
} }
} }
@ -172,7 +172,7 @@ public class EntityEditController extends BaseEditController {
Iterator<PropertyInstance> epiIt = epiColl.iterator(); Iterator<PropertyInstance> epiIt = epiColl.iterator();
while (epiIt.hasNext()) { while (epiIt.hasNext()) {
PropertyInstance pi = epiIt.next(); PropertyInstance pi = epiIt.next();
String multiplexedString = new String ("PropertyURI:" + new String(Base64.encodeBase64(pi.getPropertyURI().getBytes())) + ";" + "ObjectEntURI:" + new String(Base64.encodeBase64(pi.getObjectEntURI().getBytes()))); String multiplexedString = "PropertyURI:" + new String(Base64.encodeBase64(pi.getPropertyURI().getBytes())) + ";" + "ObjectEntURI:" + new String(Base64.encodeBase64(pi.getObjectEntURI().getBytes()));
epiOptionList.add(new Option(multiplexedString, pi.getDomainPublic()+" "+pi.getObjectName())); epiOptionList.add(new Option(multiplexedString, pi.getDomainPublic()+" "+pi.getObjectName()));
} }
OptionMap.put("ExistingPropertyInstances", epiOptionList); OptionMap.put("ExistingPropertyInstances", epiOptionList);

View file

@ -102,12 +102,9 @@ public class Properties2PropertiesOperationController extends
} }
} }
} catch (RuntimeException e) { } catch (RuntimeException | Error e) {
log.error("Unable to perform edit operation: ", e); log.error("Unable to perform edit operation: ", e);
throw e; throw e;
} catch (Error err) {
log.error("Unable to perform edit operation: ", err);
throw err;
} }
} }

View file

@ -67,7 +67,7 @@ public class PropertyGroupRetryController extends BaseEditController {
} }
if (propertyGroupForEditing == null) { if (propertyGroupForEditing == null) {
// UTF-8 expected due to URIEncoding on Connector element in server.xml // UTF-8 expected due to URIEncoding on Connector element in server.xml
String uriToFind = new String(request.getParameter("uri")); String uriToFind = request.getParameter("uri");
propertyGroupForEditing = (PropertyGroup)pgDao.getGroupByURI(uriToFind); propertyGroupForEditing = (PropertyGroup)pgDao.getGroupByURI(uriToFind);
} }
} else { } else {

View file

@ -493,12 +493,16 @@ public class RefactorOperationController extends BaseEditController {
if (vreq.getParameter("_cancel") == null) { if (vreq.getParameter("_cancel") == null) {
if (modeStr != null) { if (modeStr != null) {
if (modeStr.equals("renameResource")) { switch (modeStr) {
case "renameResource":
redirectStr = doRenameResource(vreq, response, epo); redirectStr = doRenameResource(vreq, response, epo);
} else if (modeStr.equals("movePropertyStatements")) { break;
case "movePropertyStatements":
doMovePropertyStatements(vreq, response, epo); doMovePropertyStatements(vreq, response, epo);
} else if (modeStr.equals("moveInstances")) { break;
case "moveInstances":
doMoveInstances(vreq, response, epo); doMoveInstances(vreq, response, epo);
break;
} }
} }
} }

View file

@ -108,12 +108,16 @@ public class RefactorRetryController extends BaseEditController {
String modeStr = request.getParameter("mode"); String modeStr = request.getParameter("mode");
if (modeStr != null) { if (modeStr != null) {
if (modeStr.equals("renameResource")) { switch (modeStr) {
case "renameResource":
doRenameResource(vreq, response, epo); doRenameResource(vreq, response, epo);
} else if (modeStr.equals("movePropertyStatements")) { break;
case "movePropertyStatements":
doMovePropertyStatements(vreq, response, epo); doMovePropertyStatements(vreq, response, epo);
} else if (modeStr.equals("moveInstances")) { break;
case "moveInstances":
doMoveInstances(vreq, response, epo); doMoveInstances(vreq, response, epo);
break;
} }
} }

View file

@ -83,7 +83,6 @@ public class RestrictionOperationController extends BaseEditController {
log.error(e, e); log.error(e, e);
try { try {
response.sendRedirect(defaultLandingPage); response.sendRedirect(defaultLandingPage);
return;
} catch (Exception f) { } catch (Exception f) {
log.error(f, f); log.error(f, f);
throw new RuntimeException(f); throw new RuntimeException(f);
@ -177,11 +176,14 @@ public class RestrictionOperationController extends BaseEditController {
cardinality = Integer.decode(cardinalityStr); cardinality = Integer.decode(cardinalityStr);
} }
if (restrictionTypeStr.equals("allValuesFrom")) { switch (restrictionTypeStr) {
rest = ontModel.createAllValuesFromRestriction(null,onProperty,roleFiller); case "allValuesFrom":
} else if (restrictionTypeStr.equals("someValuesFrom")) { rest = ontModel.createAllValuesFromRestriction(null, onProperty, roleFiller);
rest = ontModel.createSomeValuesFromRestriction(null,onProperty,roleFiller); break;
} else if (restrictionTypeStr.equals("hasValue")) { case "someValuesFrom":
rest = ontModel.createSomeValuesFromRestriction(null, onProperty, roleFiller);
break;
case "hasValue":
String valueURI = request.getParameter("ValueIndividual"); String valueURI = request.getParameter("ValueIndividual");
if (valueURI != null) { if (valueURI != null) {
Resource valueRes = ontModel.getResource(valueURI); Resource valueRes = ontModel.getResource(valueURI);
@ -198,7 +200,7 @@ public class RestrictionOperationController extends BaseEditController {
try { try {
dtype = TypeMapper.getInstance().getSafeTypeByName(valueDatatype); dtype = TypeMapper.getInstance().getSafeTypeByName(valueDatatype);
} catch (Exception e) { } catch (Exception e) {
log.warn ("Unable to get safe type " + valueDatatype + " using TypeMapper"); log.warn("Unable to get safe type " + valueDatatype + " using TypeMapper");
} }
if (dtype != null) { if (dtype != null) {
value = ontModel.createTypedLiteral(valueLexicalForm, dtype); value = ontModel.createTypedLiteral(valueLexicalForm, dtype);
@ -211,12 +213,16 @@ public class RestrictionOperationController extends BaseEditController {
rest = ontModel.createHasValueRestriction(null, onProperty, value); rest = ontModel.createHasValueRestriction(null, onProperty, value);
} }
} }
} else if (restrictionTypeStr.equals("minCardinality")) { break;
rest = ontModel.createMinCardinalityRestriction(null,onProperty,cardinality); case "minCardinality":
} else if (restrictionTypeStr.equals("maxCardinality")) { rest = ontModel.createMinCardinalityRestriction(null, onProperty, cardinality);
rest = ontModel.createMaxCardinalityRestriction(null,onProperty,cardinality); break;
} else if (restrictionTypeStr.equals("cardinality")) { case "maxCardinality":
rest = ontModel.createCardinalityRestriction(null,onProperty,cardinality); rest = ontModel.createMaxCardinalityRestriction(null, onProperty, cardinality);
break;
case "cardinality":
rest = ontModel.createCardinalityRestriction(null, onProperty, cardinality);
break;
} }
if (conditionTypeStr.equals("necessary")) { if (conditionTypeStr.equals("necessary")) {

View file

@ -67,27 +67,36 @@ public class RestrictionRetryController extends BaseEditController {
epo.setFormObject(new FormObject()); epo.setFormObject(new FormObject());
epo.getFormObject().getOptionLists().put("onProperty", onPropertyList); epo.getFormObject().getOptionLists().put("onProperty", onPropertyList);
if (restrictionTypeStr.equals("someValuesFrom")) { switch (restrictionTypeStr) {
request.setAttribute("specificRestrictionForm","someValuesFromRestriction_retry.jsp"); case "someValuesFrom": {
request.setAttribute("specificRestrictionForm", "someValuesFromRestriction_retry.jsp");
List<Option> optionList = (propertyType == OBJECT) List<Option> optionList = (propertyType == OBJECT)
? getValueClassOptionList(request) ? getValueClassOptionList(request)
: getValueDatatypeOptionList(request) ; : getValueDatatypeOptionList(request);
epo.getFormObject().getOptionLists().put("ValueClass",optionList); epo.getFormObject().getOptionLists().put("ValueClass", optionList);
} else if (restrictionTypeStr.equals("allValuesFrom")) { break;
request.setAttribute("specificRestrictionForm","allValuesFromRestriction_retry.jsp"); }
case "allValuesFrom": {
request.setAttribute("specificRestrictionForm", "allValuesFromRestriction_retry.jsp");
List<Option> optionList = (propertyType == OBJECT) List<Option> optionList = (propertyType == OBJECT)
? getValueClassOptionList(request) ? getValueClassOptionList(request)
: getValueDatatypeOptionList(request) ; : getValueDatatypeOptionList(request);
epo.getFormObject().getOptionLists().put("ValueClass",optionList); epo.getFormObject().getOptionLists().put("ValueClass", optionList);
} else if (restrictionTypeStr.equals("hasValue")) { break;
}
case "hasValue":
request.setAttribute("specificRestrictionForm", "hasValueRestriction_retry.jsp"); request.setAttribute("specificRestrictionForm", "hasValueRestriction_retry.jsp");
if (propertyType == OBJECT) { if (propertyType == OBJECT) {
request.setAttribute("propertyType", "object"); request.setAttribute("propertyType", "object");
} else { } else {
request.setAttribute("propertyType", "data"); request.setAttribute("propertyType", "data");
} }
} else if (restrictionTypeStr.equals("minCardinality") || restrictionTypeStr.equals("maxCardinality") || restrictionTypeStr.equals("cardinality")) { break;
case "minCardinality":
case "maxCardinality":
case "cardinality":
request.setAttribute("specificRestrictionForm", "cardinalityRestriction_retry.jsp"); request.setAttribute("specificRestrictionForm", "cardinalityRestriction_retry.jsp");
break;
} }
request.setAttribute("formJsp","/templates/edit/specific/restriction_retry.jsp"); request.setAttribute("formJsp","/templates/edit/specific/restriction_retry.jsp");

View file

@ -179,7 +179,7 @@ public class VclassEditController extends BaseEditController {
foo.setOptionLists(OptionMap); foo.setOptionLists(OptionMap);
epo.setFormObject(foo); epo.setFormObject(foo);
boolean instantiable = (vcl.getURI().equals(OWL.Nothing.getURI())) ? false : true; boolean instantiable = !vcl.getURI().equals(OWL.Nothing.getURI());
request.setAttribute("epoKey",epo.getKey()); request.setAttribute("epoKey",epo.getKey());
request.setAttribute("vclassWebapp", vcl); request.setAttribute("vclassWebapp", vcl);

View file

@ -29,17 +29,17 @@ public class ListingControllerWebUtils {
} }
public static synchronized String formatVClassLinks(List<VClass> vList) { public static synchronized String formatVClassLinks(List<VClass> vList) {
String linksStr=""; StringBuilder linksStr= new StringBuilder();
if (vList!=null) { if (vList!=null) {
int count=0; int count=0;
for (Object obj : vList) { for (Object obj : vList) {
try { try {
if (count>0) linksStr += " | "; if (count>0) linksStr.append(" | ");
VClass vclass = (VClass) obj; VClass vclass = (VClass) obj;
try { try {
linksStr += "<a href=\"vclassEdit?uri="+URLEncoder.encode(vclass.getURI(),"UTF-8")+"\">"+vclass.getName()+"</a>"; linksStr.append("<a href=\"vclassEdit?uri=").append(URLEncoder.encode(vclass.getURI(), "UTF-8")).append("\">").append(vclass.getName()).append("</a>");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
linksStr += vclass.getName(); linksStr.append(vclass.getName());
} }
++count; ++count;
} catch (Exception e) { } catch (Exception e) {
@ -49,7 +49,7 @@ public class ListingControllerWebUtils {
} }
} }
} }
return linksStr; return linksStr.toString();
} }
} }

View file

@ -2,14 +2,10 @@
package edu.cornell.mannlib.vitro.webapp.controller.edit.utils; package edu.cornell.mannlib.vitro.webapp.controller.edit.utils;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology; import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.beans.ResourceBean;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;

View file

@ -6,6 +6,7 @@ import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -172,9 +173,7 @@ public class DumpTestController extends FreemarkerHttpServlet {
} }
public void setFavoriteColors(String...colors) { public void setFavoriteColors(String...colors) {
for (String color : colors) { Collections.addAll(favoriteColors, colors);
favoriteColors.add(color);
}
} }
float getSalary() { float getSalary() {

View file

@ -250,7 +250,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
// This method does a redirect if the required authorizations are // This method does a redirect if the required authorizations are
// not met (and they won't be), so just return. // not met (and they won't be), so just return.
isAuthorizedToDisplayPage(vreq, response, values.getUnauthorizedAction()); isAuthorizedToDisplayPage(vreq, response, values.getUnauthorizedAction());
return;
} }
protected void doTemplate(VitroRequest vreq, HttpServletResponse response, protected void doTemplate(VitroRequest vreq, HttpServletResponse response,

View file

@ -164,9 +164,6 @@ public class ImageUploadHelper {
fileInfo); fileInfo);
return fileInfo; return fileInfo;
} catch (FileAlreadyExistsException e) {
throw new IllegalStateException("Can't create the new image file.",
e);
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException("Can't create the new image file.", throw new IllegalStateException("Can't create the new image file.",
e); e);

View file

@ -50,60 +50,60 @@ public class ListClassGroupsController extends FreemarkerHttpServlet {
List<VClassGroup> groups = dao.getPublicGroupsWithVClasses(); List<VClassGroup> groups = dao.getPublicGroupsWithVClasses();
String json = new String(); StringBuilder json = new StringBuilder();
int counter = 0; int counter = 0;
if (groups != null) { if (groups != null) {
for(VClassGroup vcg: groups) { for(VClassGroup vcg: groups) {
if ( counter > 0 ) { if ( counter > 0 ) {
json += ", "; json.append(", ");
} }
String publicName = vcg.getPublicName(); String publicName = vcg.getPublicName();
if ( StringUtils.isBlank(publicName) ) { if ( StringUtils.isBlank(publicName) ) {
publicName = "(unnamed group)"; publicName = "(unnamed group)";
} }
try { try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(vcg.getURI())+"&amp;controller=Classgroup'>"+publicName+"</a>") + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./editForm?uri=" + URLEncoder.encode(vcg.getURI()) + "&amp;controller=Classgroup'>" + publicName + "</a>")).append(", ");
} catch (Exception e) { } catch (Exception e) {
json += "{ \"name\": " + JacksonUtils.quote(publicName) + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote(publicName)).append(", ");
} }
Integer t; Integer t;
json += "\"data\": { \"displayRank\": \"" + (((t = Integer.valueOf(vcg.getDisplayRank())) != -1) ? t.toString() : "") + "\"}, "; json.append("\"data\": { \"displayRank\": \"").append(((t = Integer.valueOf(vcg.getDisplayRank())) != -1) ? t.toString() : "").append("\"}, ");
List<VClass> classList = vcg.getVitroClassList(); List<VClass> classList = vcg.getVitroClassList();
if (classList != null && classList.size()>0) { if (classList != null && classList.size()>0) {
json += "\"children\": ["; json.append("\"children\": [");
Iterator<VClass> classIt = classList.iterator(); Iterator<VClass> classIt = classList.iterator();
while (classIt.hasNext()) { while (classIt.hasNext()) {
VClass vcw = classIt.next(); VClass vcw = classIt.next();
if (vcw.getName() != null && vcw.getURI() != null) { if (vcw.getName() != null && vcw.getURI() != null) {
try { try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='vclassEdit?uri="+URLEncoder.encode(vcw.getURI())+"'>"+vcw.getName()+"</a>") + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='vclassEdit?uri=" + URLEncoder.encode(vcw.getURI()) + "'>" + vcw.getName() + "</a>")).append(", ");
} catch (Exception e) { } catch (Exception e) {
json += "" + JacksonUtils.quote(vcw.getName()) + ", "; json.append("").append(JacksonUtils.quote(vcw.getName())).append(", ");
} }
} else { } else {
json += "\"\", "; json.append("\"\", ");
} }
String shortDefStr = (vcw.getShortDef() == null) ? "" : vcw.getShortDef(); String shortDefStr = (vcw.getShortDef() == null) ? "" : vcw.getShortDef();
json += "\"data\": { \"shortDef\": " + JacksonUtils.quote(shortDefStr) + "}, \"children\": [] "; json.append("\"data\": { \"shortDef\": ").append(JacksonUtils.quote(shortDefStr)).append("}, \"children\": [] ");
if (classIt.hasNext()) if (classIt.hasNext())
json += "} , "; json.append("} , ");
else else
json += "}] "; json.append("}] ");
} }
} }
else { else {
json += "\"children\": [] "; json.append("\"children\": [] ");
} }
json += "} "; json.append("} ");
counter += 1; counter += 1;
} }
} }
body.put("jsonTree",json); body.put("jsonTree", json.toString());
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();

View file

@ -100,27 +100,27 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
sortForPickList(props, vreq); sortForPickList(props, vreq);
} }
String json = new String(); StringBuilder json = new StringBuilder();
int counter = 0; int counter = 0;
if (props != null) { if (props != null) {
if (props.size()==0) { if (props.size()==0) {
json = "{ \"name\": \"" + noResultsMsgStr + "\" }"; json = new StringBuilder("{ \"name\": \"" + noResultsMsgStr + "\" }");
} else { } else {
for (DataProperty prop: props) { for (DataProperty prop: props) {
if ( counter > 0 ) { if ( counter > 0 ) {
json += ", "; json.append(", ");
} }
String nameStr = prop.getPickListName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPickListName(); String nameStr = prop.getPickListName()==null ? prop.getName()==null ? prop.getURI()==null ? "(no name)" : prop.getURI() : prop.getName() : prop.getPickListName();
try { try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='datapropEdit?uri="+ URLEncoder.encode(prop.getURI())+"'>" + nameStr + "</a>") + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='datapropEdit?uri=" + URLEncoder.encode(prop.getURI()) + "'>" + nameStr + "</a>")).append(", ");
} catch (Exception e) { } catch (Exception e) {
json += "{ \"name\": " + JacksonUtils.quote(nameStr) + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote(nameStr)).append(", ");
} }
json += "\"data\": { \"internalName\": " + JacksonUtils.quote(prop.getPickListName()) + ", "; json.append("\"data\": { \"internalName\": ").append(JacksonUtils.quote(prop.getPickListName())).append(", ");
/* VClass vc = null; /* VClass vc = null;
String domainStr=""; String domainStr="";
@ -140,22 +140,22 @@ public class ListDatatypePropertiesController extends FreemarkerHttpServlet {
dpLangNeut = prop; dpLangNeut = prop;
} }
String domainStr = getVClassNameFromURI(dpLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut); String domainStr = getVClassNameFromURI(dpLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);
json += "\"domainVClass\": " + JacksonUtils.quote(domainStr) + ", " ; json.append("\"domainVClass\": ").append(JacksonUtils.quote(domainStr)).append(", ");
Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI()); Datatype rangeDatatype = dDao.getDatatypeByURI(prop.getRangeDatatypeURI());
String rangeDatatypeStr = (rangeDatatype==null)?prop.getRangeDatatypeURI():rangeDatatype.getName(); String rangeDatatypeStr = (rangeDatatype==null)?prop.getRangeDatatypeURI():rangeDatatype.getName();
json += "\"rangeVClass\": " + JacksonUtils.quote(rangeDatatypeStr) + ", " ; json.append("\"rangeVClass\": ").append(JacksonUtils.quote(rangeDatatypeStr)).append(", ");
if (prop.getGroupURI() != null) { if (prop.getGroupURI() != null) {
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI()); PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
json += "\"group\": " + JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName()) + " } } " ; json.append("\"group\": ").append(JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName())).append(" } } ");
} else { } else {
json += "\"group\": \"unspecified\" } }" ; json.append("\"group\": \"unspecified\" } }");
} }
counter += 1; counter += 1;
} }
} }
body.put("jsonTree",json); body.put("jsonTree", json.toString());
} }
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();

View file

@ -51,30 +51,30 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
PropertyGroupDao dao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao(); PropertyGroupDao dao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();
List<PropertyGroup> groups = dao.getPublicGroups(WITH_PROPERTIES); List<PropertyGroup> groups = dao.getPublicGroups(WITH_PROPERTIES);
String json = new String(); StringBuilder json = new StringBuilder();
int counter = 0; int counter = 0;
if (groups != null) { if (groups != null) {
for(PropertyGroup pg: groups) { for(PropertyGroup pg: groups) {
if ( counter > 0 ) { if ( counter > 0 ) {
json += ", "; json.append(", ");
} }
String publicName = pg.getName(); String publicName = pg.getName();
if ( StringUtils.isBlank(publicName) ) { if ( StringUtils.isBlank(publicName) ) {
publicName = "(unnamed group)"; publicName = "(unnamed group)";
} }
try { try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='./editForm?uri="+URLEncoder.encode(pg.getURI(),"UTF-8")+"&amp;controller=PropertyGroup'>" + publicName + "</a>") + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./editForm?uri=" + URLEncoder.encode(pg.getURI(), "UTF-8") + "&amp;controller=PropertyGroup'>" + publicName + "</a>")).append(", ");
} catch (Exception e) { } catch (Exception e) {
json += "{ \"name\": " + JacksonUtils.quote(publicName) + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote(publicName)).append(", ");
} }
Integer t; Integer t;
json += "\"data\": { \"displayRank\": \"" + (((t = Integer.valueOf(pg.getDisplayRank())) != -1) ? t.toString() : "") + "\"}, "; json.append("\"data\": { \"displayRank\": \"").append(((t = Integer.valueOf(pg.getDisplayRank())) != -1) ? t.toString() : "").append("\"}, ");
List<Property> propertyList = pg.getPropertyList(); List<Property> propertyList = pg.getPropertyList();
if (propertyList != null && propertyList.size()>0) { if (propertyList != null && propertyList.size()>0) {
json += "\"children\": ["; json.append("\"children\": [");
Iterator<Property> propIt = propertyList.iterator(); Iterator<Property> propIt = propertyList.iterator();
while (propIt.hasNext()) { while (propIt.hasNext()) {
Property prop = propIt.next(); Property prop = propIt.next();
@ -91,31 +91,31 @@ public class ListPropertyGroupsController extends FreemarkerHttpServlet {
} }
if (prop.getURI() != null) { if (prop.getURI() != null) {
try { try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='" + controllerStr json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='" + controllerStr
+ "?uri="+URLEncoder.encode(prop.getURI(),"UTF-8")+"'>"+ nameStr +"</a>") + ", "; + "?uri=" + URLEncoder.encode(prop.getURI(), "UTF-8") + "'>" + nameStr + "</a>")).append(", ");
} catch (Exception e) { } catch (Exception e) {
json += JacksonUtils.quote(nameStr) + ", "; json.append(JacksonUtils.quote(nameStr)).append(", ");
} }
} else { } else {
json += "\"\", "; json.append("\"\", ");
} }
json += "\"data\": { \"shortDef\": \"\"}, \"children\": [] "; json.append("\"data\": { \"shortDef\": \"\"}, \"children\": [] ");
if (propIt.hasNext()) if (propIt.hasNext())
json += "} , "; json.append("} , ");
else else
json += "}] "; json.append("}] ");
} }
} }
else { else {
json += "\"children\": [] "; json.append("\"children\": [] ");
} }
json += "} "; json.append("} ");
counter += 1; counter += 1;
} }
} }
body.put("jsonTree",json); body.put("jsonTree", json.toString());
log.debug("json = " + json); log.debug("json = " + json);
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();

View file

@ -139,51 +139,51 @@ public class ListPropertyWebappsController extends FreemarkerHttpServlet {
sortForPickList(props, vreq); sortForPickList(props, vreq);
} }
String json = new String(); StringBuilder json = new StringBuilder();
int counter = 0; int counter = 0;
if (props != null) { if (props != null) {
if (props.size()==0) { if (props.size()==0) {
json = "{ \"name\": \"" + noResultsMsgStr + "\" }"; json = new StringBuilder("{ \"name\": \"" + noResultsMsgStr + "\" }");
} else { } else {
Iterator<ObjectProperty> propsIt = props.iterator(); Iterator<ObjectProperty> propsIt = props.iterator();
while (propsIt.hasNext()) { while (propsIt.hasNext()) {
if ( counter > 0 ) { if ( counter > 0 ) {
json += ", "; json.append(", ");
} }
ObjectProperty prop = propsIt.next(); ObjectProperty prop = propsIt.next();
String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop); String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop);
try { try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='./propertyEdit?uri="+URLEncoder.encode(prop.getURI())+"'>" json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./propertyEdit?uri=" + URLEncoder.encode(prop.getURI()) + "'>"
+ propNameStr + "</a>") + ", "; + propNameStr + "</a>")).append(", ");
} catch (Exception e) { } catch (Exception e) {
json += "{ \"name\": \"" + propNameStr + "\", "; json.append("{ \"name\": \"").append(propNameStr).append("\", ");
} }
json += "\"data\": { \"internalName\": " + JacksonUtils.quote(prop.getLocalNameWithPrefix()) + ", "; json.append("\"data\": { \"internalName\": ").append(JacksonUtils.quote(prop.getLocalNameWithPrefix())).append(", ");
ObjectProperty opLangNeut = opDaoLangNeut.getObjectPropertyByURI(prop.getURI()); ObjectProperty opLangNeut = opDaoLangNeut.getObjectPropertyByURI(prop.getURI());
if(opLangNeut == null) { if(opLangNeut == null) {
opLangNeut = prop; opLangNeut = prop;
} }
String domainStr = getVClassNameFromURI(opLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut); String domainStr = getVClassNameFromURI(opLangNeut.getDomainVClassURI(), vcDao, vcDaoLangNeut);
json += "\"domainVClass\": " + JacksonUtils.quote(domainStr) + ", " ; json.append("\"domainVClass\": ").append(JacksonUtils.quote(domainStr)).append(", ");
String rangeStr = getVClassNameFromURI(opLangNeut.getRangeVClassURI(), vcDao, vcDaoLangNeut); String rangeStr = getVClassNameFromURI(opLangNeut.getRangeVClassURI(), vcDao, vcDaoLangNeut);
json += "\"rangeVClass\": " + JacksonUtils.quote(rangeStr) + ", " ; json.append("\"rangeVClass\": ").append(JacksonUtils.quote(rangeStr)).append(", ");
if (prop.getGroupURI() != null) { if (prop.getGroupURI() != null) {
PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI()); PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
json += "\"group\": " + JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName()) + " } } " ; json.append("\"group\": ").append(JacksonUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName())).append(" } } ");
} else { } else {
json += "\"group\": \"unspecified\" } }" ; json.append("\"group\": \"unspecified\" } }");
} }
counter += 1; counter += 1;
} }
} }
body.put("jsonTree",json); body.put("jsonTree", json.toString());
} }
} catch (Throwable t) { } catch (Throwable t) {

View file

@ -76,7 +76,7 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
} }
} }
String json = new String(); StringBuilder json = new StringBuilder();
int counter = 0; int counter = 0;
String ontologyURI = vreq.getParameter("ontologyUri"); String ontologyURI = vreq.getParameter("ontologyUri");
@ -86,21 +86,21 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
Iterator<VClass> classesIt = classes.iterator(); Iterator<VClass> classesIt = classes.iterator();
while (classesIt.hasNext()) { while (classesIt.hasNext()) {
if ( counter > 0 ) { if ( counter > 0 ) {
json += ", "; json.append(", ");
} }
VClass cls = (VClass) classesIt.next(); VClass cls = (VClass) classesIt.next();
if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) { if ( (ontologyURI==null) || ( (ontologyURI != null) && (cls.getNamespace()!=null) && (ontologyURI.equals(cls.getNamespace())) ) ) {
if (cls.getName() != null) if (cls.getName() != null)
try { try {
json += "{ \"name\": " + JacksonUtils.quote("<a href='./vclassEdit?uri="+URLEncoder.encode(cls.getURI(),"UTF-8")+"'>"+cls.getPickListName()+"</a>") + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote("<a href='./vclassEdit?uri=" + URLEncoder.encode(cls.getURI(), "UTF-8") + "'>" + cls.getPickListName() + "</a>")).append(", ");
} catch (Exception e) { } catch (Exception e) {
json += "{ \"name\": " + JacksonUtils.quote(cls.getPickListName()) + ", "; json.append("{ \"name\": ").append(JacksonUtils.quote(cls.getPickListName())).append(", ");
} }
else else
json += "{ \"name\": \"\""; json.append("{ \"name\": \"\"");
String shortDef = (cls.getShortDef() == null) ? "" : cls.getShortDef(); String shortDef = (cls.getShortDef() == null) ? "" : cls.getShortDef();
json += "\"data\": { \"shortDef\": " + JacksonUtils.quote(shortDef) + ", "; json.append("\"data\": { \"shortDef\": ").append(JacksonUtils.quote(shortDef)).append(", ");
// get group name // get group name
WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory(); WebappDaoFactory wadf = vreq.getUnfilteredWebappDaoFactory();
@ -115,7 +115,7 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
} }
} }
json += "\"classGroup\": " + JacksonUtils.quote(groupName) + ", "; json.append("\"classGroup\": ").append(JacksonUtils.quote(groupName)).append(", ");
// get ontology name // get ontology name
OntologyDao ontDao = wadf.getOntologyDao(); OntologyDao ontDao = wadf.getOntologyDao();
@ -124,13 +124,13 @@ public class ListVClassWebappsController extends FreemarkerHttpServlet {
if (ont != null && ont.getName() != null) { if (ont != null && ont.getName() != null) {
ontName = ont.getName(); ontName = ont.getName();
} }
json += "\"ontology\": " + JacksonUtils.quote(ontName) + "} }"; json.append("\"ontology\": ").append(JacksonUtils.quote(ontName)).append("} }");
counter++; counter++;
} }
} }
body.put("jsonTree",json); body.put("jsonTree", json.toString());
} }
return new TemplateResponseValues(TEMPLATE_NAME, body); return new TemplateResponseValues(TEMPLATE_NAME, body);

View file

@ -76,7 +76,7 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
} else { } else {
vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao(); vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
} }
String json = new String(); StringBuilder json = new StringBuilder();
String ontologyUri = vreq.getParameter("ontologyUri"); String ontologyUri = vreq.getParameter("ontologyUri");
String startClassUri = vreq.getParameter("vclassUri"); String startClassUri = vreq.getParameter("vclassUri");
@ -104,22 +104,22 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
if (!rootIt.hasNext()) { if (!rootIt.hasNext()) {
VClass vcw = new VClass(); VClass vcw = new VClass();
vcw.setName("<strong>No classes found.</strong>"); vcw.setName("<strong>No classes found.</strong>");
json += addVClassDataToResultsList(vreq.getUnfilteredWebappDaoFactory(), vcw,0,ontologyUri,counter); json.append(addVClassDataToResultsList(vreq.getUnfilteredWebappDaoFactory(), vcw, 0, ontologyUri, counter));
} else { } else {
while (rootIt.hasNext()) { while (rootIt.hasNext()) {
VClass root = (VClass) rootIt.next(); VClass root = (VClass) rootIt.next();
if (root != null) { if (root != null) {
json += addChildren(vreq.getUnfilteredWebappDaoFactory(), json.append(addChildren(vreq.getUnfilteredWebappDaoFactory(),
root, 0, ontologyUri, counter, vreq); root, 0, ontologyUri, counter, vreq));
counter += 1; counter += 1;
} }
} }
int length = json.length(); int length = json.length();
if ( length > 0 ) { if ( length > 0 ) {
json += " }"; json.append(" }");
} }
} }
body.put("jsonTree",json); body.put("jsonTree", json.toString());
return new TemplateResponseValues(TEMPLATE_NAME, body); return new TemplateResponseValues(TEMPLATE_NAME, body);
} }
@ -129,8 +129,8 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
String rowElts = addVClassDataToResultsList(wadf, parent, position, ontologyUri, counter); String rowElts = addVClassDataToResultsList(wadf, parent, position, ontologyUri, counter);
int childShift = (rowElts.length() > 0) ? 1 : 0; // if addVClassDataToResultsList filtered out the result, don't shift the children over int childShift = (rowElts.length() > 0) ? 1 : 0; // if addVClassDataToResultsList filtered out the result, don't shift the children over
int length = rowElts.length(); int length = rowElts.length();
String leaves = ""; StringBuilder leaves = new StringBuilder();
leaves += rowElts; leaves.append(rowElts);
List<String> childURIstrs = vcDao.getSubClassURIs(parent.getURI()); List<String> childURIstrs = vcDao.getSubClassURIs(parent.getURI());
if ((childURIstrs.size()>0) && position<MAXDEPTH) { if ((childURIstrs.size()>0) && position<MAXDEPTH) {
List<VClass> childClasses = new ArrayList<VClass>(); List<VClass> childClasses = new ArrayList<VClass>();
@ -148,22 +148,24 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
Iterator<VClass> childClassIt = childClasses.iterator(); Iterator<VClass> childClassIt = childClasses.iterator();
while (childClassIt.hasNext()) { while (childClassIt.hasNext()) {
VClass child = (VClass) childClassIt.next(); VClass child = (VClass) childClassIt.next();
leaves += addChildren(wadf, child, position + childShift, ontologyUri, counter, vreq); leaves.append(addChildren(wadf, child, position + childShift, ontologyUri, counter, vreq));
if (!childClassIt.hasNext()) { if (!childClassIt.hasNext()) {
if ( ontologyUri == null ) { if ( ontologyUri == null ) {
leaves += " }] "; leaves.append(" }] ");
} }
else if ( ontologyUri != null && length > 0 ) { else if ( ontologyUri != null && length > 0 ) {
// need this for when we show the classes associated with an ontology // need this for when we show the classes associated with an ontology
String ending = leaves.substring(leaves.length() - 2, leaves.length()); String ending = leaves.substring(leaves.length() - 2, leaves.length());
if ( ending.equals("] ") ) { switch (ending) {
leaves += "}]"; case "] ":
} leaves.append("}]");
else if ( ending.equals(" [") ){ break;
leaves += "] "; case " [":
} leaves.append("] ");
else { break;
leaves += "}]"; default:
leaves.append("}]");
break;
} }
} }
} }
@ -171,13 +173,13 @@ public class ShowClassHierarchyController extends FreemarkerHttpServlet {
} }
else { else {
if ( ontologyUri == null ) { if ( ontologyUri == null ) {
leaves += "] "; leaves.append("] ");
} }
else if ( ontologyUri != null && length > 0 ) { else if ( ontologyUri != null && length > 0 ) {
leaves += "] "; leaves.append("] ");
} }
} }
return leaves; return leaves.toString();
} }
private String addVClassDataToResultsList(WebappDaoFactory wadf, VClass vcw, int position, String ontologyUri, int counter) { private String addVClassDataToResultsList(WebappDaoFactory wadf, VClass vcw, int position, String ontologyUri, int counter) {

View file

@ -84,7 +84,7 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao(); pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
dDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getDatatypeDao(); dDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getDatatypeDao();
String json = new String(); StringBuilder json = new StringBuilder();
String ontologyUri = vreq.getParameter("ontologyUri"); String ontologyUri = vreq.getParameter("ontologyUri");
String startPropertyUri = vreq.getParameter("propertyUri"); String startPropertyUri = vreq.getParameter("propertyUri");
@ -111,23 +111,23 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
String notFoundMessage = "<strong>No data properties found.</strong>"; String notFoundMessage = "<strong>No data properties found.</strong>";
dp.setName(notFoundMessage); dp.setName(notFoundMessage);
dp.setName(notFoundMessage); dp.setName(notFoundMessage);
json += addDataPropertyDataToResultsList(dp, 0, ontologyUri, counter); json.append(addDataPropertyDataToResultsList(dp, 0, ontologyUri, counter));
} else { } else {
while (rootIt.hasNext()) { while (rootIt.hasNext()) {
DataProperty root = rootIt.next(); DataProperty root = rootIt.next();
if ( (ontologyUri==null) || ( (ontologyUri!=null) && (root.getNamespace()!=null) && (ontologyUri.equals(root.getNamespace())) ) ) { if ( (ontologyUri==null) || ( (ontologyUri!=null) && (root.getNamespace()!=null) && (ontologyUri.equals(root.getNamespace())) ) ) {
json += addChildren(root, 0, ontologyUri, counter, vreq); json.append(addChildren(root, 0, ontologyUri, counter, vreq));
counter += 1; counter += 1;
} }
} }
int length = json.length(); int length = json.length();
if ( length > 0 ) { if ( length > 0 ) {
json += " }"; json.append(" }");
} }
} }
} }
body.put("jsonTree",json); body.put("jsonTree", json.toString());
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
@ -142,8 +142,8 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
} }
String details = addDataPropertyDataToResultsList(parent, position, ontologyUri, counter); String details = addDataPropertyDataToResultsList(parent, position, ontologyUri, counter);
int length = details.length(); int length = details.length();
String leaves = ""; StringBuilder leaves = new StringBuilder();
leaves += details; leaves.append(details);
List<String> childURIstrs = dpDao.getSubPropertyURIs(parent.getURI()); List<String> childURIstrs = dpDao.getSubPropertyURIs(parent.getURI());
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) { if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
List<DataProperty> childProps = new ArrayList<DataProperty>(); List<DataProperty> childProps = new ArrayList<DataProperty>();
@ -157,22 +157,24 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
Iterator<DataProperty> childPropIt = childProps.iterator(); Iterator<DataProperty> childPropIt = childProps.iterator();
while (childPropIt.hasNext()) { while (childPropIt.hasNext()) {
DataProperty child = childPropIt.next(); DataProperty child = childPropIt.next();
leaves += addChildren(child, position+1, ontologyUri, counter, vreq); leaves.append(addChildren(child, position + 1, ontologyUri, counter, vreq));
if (!childPropIt.hasNext()) { if (!childPropIt.hasNext()) {
if ( ontologyUri == null ) { if ( ontologyUri == null ) {
leaves += " }] "; leaves.append(" }] ");
} }
else if ( ontologyUri != null && length > 0 ) { else if ( ontologyUri != null && length > 0 ) {
// need this for when we show the classes associated with an ontology // need this for when we show the classes associated with an ontology
String ending = leaves.substring(leaves.length() - 2, leaves.length()); String ending = leaves.substring(leaves.length() - 2, leaves.length());
if ( ending.equals("] ") ) { switch (ending) {
leaves += "}]"; case "] ":
} leaves.append("}]");
else if ( ending.equals(" [") ){ break;
leaves += "] "; case " [":
} leaves.append("] ");
else { break;
leaves += "}]"; default:
leaves.append("}]");
break;
} }
} }
} }
@ -180,13 +182,13 @@ public class ShowDataPropertyHierarchyController extends FreemarkerHttpServlet {
} }
else { else {
if ( ontologyUri == null ) { if ( ontologyUri == null ) {
leaves += "] "; leaves.append("] ");
} }
else if ( ontologyUri != null && length > 0 ) { else if ( ontologyUri != null && length > 0 ) {
leaves += "] "; leaves.append("] ");
} }
} }
return leaves; return leaves.toString();
} }
private String addDataPropertyDataToResultsList(DataProperty dp, int position, String ontologyUri, int counter) { private String addDataPropertyDataToResultsList(DataProperty dp, int position, String ontologyUri, int counter) {

View file

@ -84,7 +84,7 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
vcDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao(); vcDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao(); pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
String json = new String(); StringBuilder json = new StringBuilder();
String ontologyUri = vreq.getParameter("ontologyUri"); String ontologyUri = vreq.getParameter("ontologyUri");
String startPropertyUri = vreq.getParameter("propertyUri"); String startPropertyUri = vreq.getParameter("propertyUri");
@ -115,7 +115,7 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
op.setURI(ontologyUri+"fake"); op.setURI(ontologyUri+"fake");
String notFoundMessage = "<strong>No object properties found.</strong>"; String notFoundMessage = "<strong>No object properties found.</strong>";
op.setDomainPublic(notFoundMessage); op.setDomainPublic(notFoundMessage);
json += addObjectPropertyDataToResultsList(op, 0, ontologyUri, counter); json.append(addObjectPropertyDataToResultsList(op, 0, ontologyUri, counter));
} else { } else {
while (rootIt.hasNext()) { while (rootIt.hasNext()) {
ObjectProperty root = rootIt.next(); ObjectProperty root = rootIt.next();
@ -123,18 +123,18 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
( (ontologyUri != null) ( (ontologyUri != null)
&& (root.getNamespace() != null) && (root.getNamespace() != null)
&& (ontologyUri.equals(root.getNamespace())) ) ) { && (ontologyUri.equals(root.getNamespace())) ) ) {
json += addChildren(root, 0, ontologyUri, counter); json.append(addChildren(root, 0, ontologyUri, counter));
counter += 1; counter += 1;
} }
} }
int length = json.length(); int length = json.length();
if ( length > 0 ) { if ( length > 0 ) {
json += " }"; json.append(" }");
} }
} }
} }
body.put("jsonTree",json); body.put("jsonTree", json.toString());
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
@ -146,8 +146,8 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
private String addChildren(ObjectProperty parent, int position, String ontologyUri, int counter) { private String addChildren(ObjectProperty parent, int position, String ontologyUri, int counter) {
String details = addObjectPropertyDataToResultsList(parent, position, ontologyUri, counter); String details = addObjectPropertyDataToResultsList(parent, position, ontologyUri, counter);
int length = details.length(); int length = details.length();
String leaves = ""; StringBuilder leaves = new StringBuilder();
leaves += details; leaves.append(details);
List<String> childURIstrs = opDao.getSubPropertyURIs(parent.getURI()); List<String> childURIstrs = opDao.getSubPropertyURIs(parent.getURI());
if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) { if ( (childURIstrs.size() > 0) && (position < MAXDEPTH) ) {
List<ObjectProperty> childProps = new ArrayList<ObjectProperty>(); List<ObjectProperty> childProps = new ArrayList<ObjectProperty>();
@ -161,22 +161,24 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
Iterator<ObjectProperty> childPropIt = childProps.iterator(); Iterator<ObjectProperty> childPropIt = childProps.iterator();
while (childPropIt.hasNext()) { while (childPropIt.hasNext()) {
ObjectProperty child = childPropIt.next(); ObjectProperty child = childPropIt.next();
leaves += addChildren(child, position+1, ontologyUri, counter); leaves.append(addChildren(child, position + 1, ontologyUri, counter));
if (!childPropIt.hasNext()) { if (!childPropIt.hasNext()) {
if ( ontologyUri == null ) { if ( ontologyUri == null ) {
leaves += " }] "; leaves.append(" }] ");
} }
else if ( ontologyUri != null && length > 0 ) { else if ( ontologyUri != null && length > 0 ) {
// need this for when we show the classes associated with an ontology // need this for when we show the classes associated with an ontology
String ending = leaves.substring(leaves.length() - 2, leaves.length()); String ending = leaves.substring(leaves.length() - 2, leaves.length());
if ( ending.equals("] ") ) { switch (ending) {
leaves += "}]"; case "] ":
} leaves.append("}]");
else if ( ending.equals(" [") ){ break;
leaves += "] "; case " [":
} leaves.append("] ");
else { break;
leaves += "}]"; default:
leaves.append("}]");
break;
} }
} }
} }
@ -184,13 +186,13 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
} }
else { else {
if ( ontologyUri == null ) { if ( ontologyUri == null ) {
leaves += "] "; leaves.append("] ");
} }
else if ( ontologyUri != null && length > 0 ) { else if ( ontologyUri != null && length > 0 ) {
leaves += "] "; leaves.append("] ");
} }
} }
return leaves; return leaves.toString();
} }
private String addObjectPropertyDataToResultsList(ObjectProperty op, int position, String ontologyUri, int counter) { private String addObjectPropertyDataToResultsList(ObjectProperty op, int position, String ontologyUri, int counter) {

View file

@ -7,7 +7,6 @@ import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.freemarker; package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -13,10 +12,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; 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.controller.freemarker.responsevalues.TemplateResponseValues;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* Freemarker controller and template sandbox. * Freemarker controller and template sandbox.

View file

@ -208,6 +208,8 @@ public class UrlBuilder {
} }
private static String addParams(String url, ParamMap params, String glue) { private static String addParams(String url, ParamMap params, String glue) {
if (params.size() > 0) {
StringBuilder sb = new StringBuilder(url);
for (String key: params.keySet()) { for (String key: params.keySet()) {
String value = params.get(key); String value = params.get(key);
// rjy7 Some users might require nulls to be converted to empty // rjy7 Some users might require nulls to be converted to empty
@ -217,9 +219,12 @@ public class UrlBuilder {
// to remove null values or convert to empty strings, whichever // to remove null values or convert to empty strings, whichever
// is desired in the particular instance. // is desired in the particular instance.
value = (value == null) ? "" : urlEncode(value); value = (value == null) ? "" : urlEncode(value);
url += glue + key + "=" + value; sb.append(glue).append(key).append("=").append(value);
glue = "&"; glue = "&";
} }
url = sb.toString();
}
return url; return url;
} }

View file

@ -23,19 +23,15 @@ import org.apache.commons.logging.LogFactory;
import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet; import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Literal;
import org.apache.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; 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.FreemarkerHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues; 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.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale; import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DataPropertyStatementTemplateModel;
/*Servlet to view all labels in various languages for individual*/ /*Servlet to view all labels in various languages for individual*/

View file

@ -19,11 +19,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import edu.cornell.mannlib.vitro.webapp.utils.json.JacksonUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;

View file

@ -91,7 +91,7 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
ArrayList<DataProperty> vcProps = (ArrayList<DataProperty>)classPropertiesMap.get(vc); ArrayList<DataProperty> vcProps = (ArrayList<DataProperty>)classPropertiesMap.get(vc);
for (DataProperty prop: vcProps) { for (DataProperty prop: vcProps) {
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? null : prop.getName() : prop.getPublicName(); String nameStr = prop.getPublicName()==null ? prop.getName() : prop.getPublicName();
//System.out.println("--- uri: " + prop.getURI()); //System.out.println("--- uri: " + prop.getURI());
//System.out.println("--- name: " + nameStr); //System.out.println("--- name: " + nameStr);
// top level // top level
@ -152,7 +152,7 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
VClass vc = (VClass) iter.next(); VClass vc = (VClass) iter.next();
ArrayList<DataProperty> vcProps = (ArrayList<DataProperty>)lvl2ClassPropertiesMap.get(vc); ArrayList<DataProperty> vcProps = (ArrayList<DataProperty>)lvl2ClassPropertiesMap.get(vc);
for (DataProperty prop: vcProps) { for (DataProperty prop: vcProps) {
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? null : prop.getName() : prop.getPublicName(); String nameStr = prop.getPublicName()==null ? prop.getName() : prop.getPublicName();
// top level // top level
ObjectNode propertiesItemJson = JsonNodeFactory.instance.objectNode(); ObjectNode propertiesItemJson = JsonNodeFactory.instance.objectNode();
@ -222,7 +222,7 @@ public class GrefinePropertyListServlet extends VitroHttpServlet {
Collections.sort(props); Collections.sort(props);
for (DataProperty prop: props) { for (DataProperty prop: props) {
String nameStr = prop.getPublicName()==null ? prop.getName()==null ? null : prop.getName() : prop.getPublicName(); String nameStr = prop.getPublicName()==null ? prop.getName() : prop.getPublicName();
if (nameStr != null) { if (nameStr != null) {
if (prop.getDomainClassURI() != null) { if (prop.getDomainClassURI() != null) {
VClass vc = vcDao.getVClassByURI(prop.getDomainClassURI()); VClass vc = vcDao.getVClassByURI(prop.getDomainClassURI());

View file

@ -198,10 +198,10 @@ public class JSONReconcileServlet extends VitroHttpServlet {
json.put("schemaSpace", defaultNamespace); json.put("schemaSpace", defaultNamespace);
} }
ObjectNode viewJson = JsonNodeFactory.instance.objectNode(); ObjectNode viewJson = JsonNodeFactory.instance.objectNode();
StringBuffer urlBuf = new StringBuffer(); StringBuilder urlBuf = new StringBuilder();
urlBuf.append("http://" + serverName); urlBuf.append("http://").append(serverName);
if (serverPort == 8080) { if (serverPort == 8080) {
urlBuf.append(":" + serverPort); urlBuf.append(":").append(serverPort);
} }
if (req.getContextPath() != null) { if (req.getContextPath() != null) {
urlBuf.append(req.getContextPath()); urlBuf.append(req.getContextPath());

View file

@ -265,18 +265,18 @@ class IndividualResponseBuilder {
- Much simpler is to just create an anchor element. This has the added advantage that the - Much simpler is to just create an anchor element. This has the added advantage that the
browser doesn't ask to resend the form data when reloading the page. browser doesn't ask to resend the form data when reloading the page.
*/ */
String url = vreq.getRequestURI() + "?verbose=" + !verboseValue; StringBuilder url = new StringBuilder(vreq.getRequestURI() + "?verbose=" + !verboseValue);
// Append request query string, except for current verbose value, to url // Append request query string, except for current verbose value, to url
String queryString = vreq.getQueryString(); String queryString = vreq.getQueryString();
if (queryString != null) { if (queryString != null) {
String[] params = queryString.split("&"); String[] params = queryString.split("&");
for (String param : params) { for (String param : params) {
if (! param.startsWith("verbose=")) { if (! param.startsWith("verbose=")) {
url += "&" + param; url.append("&").append(param);
} }
} }
} }
map.put("url", url); map.put("url", url.toString());
} else { } else {
vreq.getSession().setAttribute("verbosePropertyDisplay", false); vreq.getSession().setAttribute("verbosePropertyDisplay", false);
} }

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.individuallist;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;

View file

@ -8,7 +8,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;

View file

@ -163,7 +163,7 @@ public class JenaAdminActions extends BaseEditController {
} }
private String testWriteXML() { private String testWriteXML() {
StringBuffer output = new StringBuffer(); StringBuilder output = new StringBuilder();
output.append("<html><head><title>Test Write XML</title></head><body><pre>\n"); output.append("<html><head><title>Test Write XML</title></head><body><pre>\n");
OntModel model = ModelAccess.on(getServletContext()).getOntModel(); OntModel model = ModelAccess.on(getServletContext()).getOntModel();
Model tmp = ModelFactory.createDefaultModel(); Model tmp = ModelFactory.createDefaultModel();
@ -177,10 +177,10 @@ public class JenaAdminActions extends BaseEditController {
valid = false; valid = false;
output.append("-----\n"); output.append("-----\n");
output.append("Unable to write statement as RDF/XML:\n"); output.append("Unable to write statement as RDF/XML:\n");
output.append("Subject : \n"+stmt.getSubject().getURI()); output.append("Subject : \n").append(stmt.getSubject().getURI());
output.append("Subject : \n"+stmt.getPredicate().getURI()); output.append("Subject : \n").append(stmt.getPredicate().getURI());
String objectStr = (stmt.getObject().isLiteral()) ? ((Literal)stmt.getObject()).getLexicalForm() : ((Resource)stmt.getObject()).getURI(); String objectStr = (stmt.getObject().isLiteral()) ? ((Literal)stmt.getObject()).getLexicalForm() : ((Resource)stmt.getObject()).getURI();
output.append("Subject : \n"+objectStr); output.append("Subject : \n").append(objectStr);
output.append("Exception: \n"); output.append("Exception: \n");
e.printStackTrace(); e.printStackTrace();
} }
@ -250,16 +250,20 @@ public class JenaAdminActions extends BaseEditController {
VitroRequest request = new VitroRequest(req); VitroRequest request = new VitroRequest(req);
String actionStr = request.getParameter("action"); String actionStr = request.getParameter("action");
if (actionStr.equals("printRestrictions")) { switch (actionStr) {
case "printRestrictions":
printRestrictions(); printRestrictions();
} else if (actionStr.equals("outputTbox")) { break;
case "outputTbox":
outputTbox(response); outputTbox(response);
} else if (actionStr.equals("testWriteXML")) { break;
case "testWriteXML":
try { try {
response.getWriter().write(testWriteXML()); response.getWriter().write(testWriteXML());
} catch ( IOException ioe ) { } catch (IOException ioe) {
throw new RuntimeException( ioe ); throw new RuntimeException(ioe);
} }
break;
} }
if (actionStr.equals("checkURIs")) { if (actionStr.equals("checkURIs")) {

View file

@ -139,7 +139,6 @@ public class JenaCsv2RdfController extends JenaIngestController {
log.error(e1); log.error(e1);
throw new ServletException(e1); throw new ServletException(e1);
} }
return;
} }
public Model doExecuteCsv2Rdf(VitroRequest vreq, FileItem fileStream, String filePath) throws Exception { public Model doExecuteCsv2Rdf(VitroRequest vreq, FileItem fileStream, String filePath) throws Exception {

View file

@ -106,7 +106,7 @@ public class JenaExportController extends BaseEditController {
String formatParam = vreq.getParameter("format"); String formatParam = vreq.getParameter("format");
String subgraphParam = vreq.getParameter("subgraph"); String subgraphParam = vreq.getParameter("subgraph");
String assertedOrInferredParam = vreq.getParameter("assertedOrInferred"); String assertedOrInferredParam = vreq.getParameter("assertedOrInferred");
String ontologyURI = vreq.getParameter("ontologyURI"); StringBuilder ontologyURI = new StringBuilder(vreq.getParameter("ontologyURI"));
Model model = null; Model model = null;
OntModel ontModel = ModelFactory.createOntologyModel(); OntModel ontModel = ModelFactory.createOntologyModel();
@ -114,12 +114,13 @@ public class JenaExportController extends BaseEditController {
if(!subgraphParam.equalsIgnoreCase("tbox") if(!subgraphParam.equalsIgnoreCase("tbox")
&& !subgraphParam.equalsIgnoreCase("abox") && !subgraphParam.equalsIgnoreCase("abox")
&& !subgraphParam.equalsIgnoreCase("full")){ && !subgraphParam.equalsIgnoreCase("full")){
ontologyURI = subgraphParam; ontologyURI = new StringBuilder(subgraphParam);
subgraphParam = "tbox"; subgraphParam = "tbox";
char[] uri = ontologyURI.toCharArray(); char[] uri = ontologyURI.toString().toCharArray();
ontologyURI=""; ontologyURI = new StringBuilder();
for(int i =0; i < uri.length-1;i++) for(int i =0; i < uri.length-1;i++) {
ontologyURI = ontologyURI + uri[i]; ontologyURI.append(uri[i]);
}
} }
if( "abox".equals(subgraphParam)){ if( "abox".equals(subgraphParam)){
@ -141,7 +142,7 @@ public class JenaExportController extends BaseEditController {
// only those statements that are in the inferred graph // only those statements that are in the inferred graph
Model tempModel = xutil.extractTBox( Model tempModel = xutil.extractTBox(
ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION), ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION),
ontologyURI); ontologyURI.toString());
Model inferenceModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_INFERENCES); Model inferenceModel = ModelAccess.on(getServletContext()).getOntModel(TBOX_INFERENCES);
inferenceModel.enterCriticalSection(Lock.READ); inferenceModel.enterCriticalSection(Lock.READ);
try { try {
@ -152,17 +153,17 @@ public class JenaExportController extends BaseEditController {
} else if ("full".equals(assertedOrInferredParam)) { } else if ("full".equals(assertedOrInferredParam)) {
model = xutil.extractTBox( model = xutil.extractTBox(
ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION), ModelAccess.on(getServletContext()).getOntModel(TBOX_UNION),
ontologyURI); ontologyURI.toString());
} else { } else {
model = xutil.extractTBox( model = xutil.extractTBox(
ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS), ontologyURI); ModelAccess.on(getServletContext()).getOntModel(TBOX_ASSERTIONS), ontologyURI.toString());
} }
} }
else if("full".equals(subgraphParam)){ else if("full".equals(subgraphParam)){
if("inferred".equals(assertedOrInferredParam)){ if("inferred".equals(assertedOrInferredParam)){
ontModel = xutil.extractTBox( ontModel = xutil.extractTBox(
dataset, ontologyURI, ABOX_INFERENCES); dataset, ontologyURI.toString(), ABOX_INFERENCES);
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(ABOX_INFERENCES)); ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(ABOX_INFERENCES));
ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(TBOX_INFERENCES)); ontModel.addSubModel(ModelAccess.on(getServletContext()).getOntModel(TBOX_INFERENCES));
} }
@ -217,20 +218,28 @@ public class JenaExportController extends BaseEditController {
if ( formatParam == null ) { if ( formatParam == null ) {
formatParam = "RDF/XML-ABBREV"; // default formatParam = "RDF/XML-ABBREV"; // default
} }
String mime = formatToMimetype.get( formatParam ); String mime = formatToMimetype.get( formatParam );
if ( mime == null ) { if ( mime == null ) {
throw new RuntimeException( "Unsupported RDF format " + formatParam); throw new RuntimeException( "Unsupported RDF format " + formatParam);
} }
response.setContentType( mime ); response.setContentType( mime );
if(mime.equals("application/rdf+xml"))
switch (mime) {
case "application/rdf+xml":
response.setHeader("content-disposition", "attachment; filename=" + "export.rdf"); response.setHeader("content-disposition", "attachment; filename=" + "export.rdf");
else if(mime.equals("text/n3")) break;
case "text/n3":
response.setHeader("content-disposition", "attachment; filename=" + "export.n3"); response.setHeader("content-disposition", "attachment; filename=" + "export.n3");
else if(mime.equals("text/plain")) break;
case "text/plain":
response.setHeader("content-disposition", "attachment; filename=" + "export.txt"); response.setHeader("content-disposition", "attachment; filename=" + "export.txt");
else if(mime.equals("application/x-turtle")) break;
case "application/x-turtle":
response.setHeader("content-disposition", "attachment; filename=" + "export.ttl"); response.setHeader("content-disposition", "attachment; filename=" + "export.ttl");
break;
}
} }
private void outputSparqlConstruct(String queryStr, String formatParam, private void outputSparqlConstruct(String queryStr, String formatParam,
@ -248,10 +257,8 @@ public class JenaExportController extends BaseEditController {
IOUtils.copy(in, out); IOUtils.copy(in, out);
out.flush(); out.flush();
out.close(); out.close();
} catch (RDFServiceException e) { } catch (RDFServiceException | IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} finally { } finally {
rdfService.close(); rdfService.close();
} }

View file

@ -303,11 +303,11 @@ public class JenaIngestController extends BaseEditController {
} catch (org.apache.jena.shared.CannotEncodeCharacterException cece) { } catch (org.apache.jena.shared.CannotEncodeCharacterException cece) {
// there's got to be a better way to do this // there's got to be a better way to do this
byte[] badCharBytes = String.valueOf(cece.getBadChar()).getBytes(); byte[] badCharBytes = String.valueOf(cece.getBadChar()).getBytes();
String errorMsg = "Cannot encode character with byte values: (decimal) "; StringBuilder errorMsg = new StringBuilder("Cannot encode character with byte values: (decimal) ");
for (int i=0; i<badCharBytes.length; i++) { for (int i=0; i<badCharBytes.length; i++) {
errorMsg += badCharBytes[i]; errorMsg.append(badCharBytes[i]);
} }
throw new RuntimeException(errorMsg, cece); throw new RuntimeException(errorMsg.toString(), cece);
} catch (Exception e) { } catch (Exception e) {
log.error(e, e); log.error(e, e);
} finally { } finally {

View file

@ -454,7 +454,6 @@ public class RDFUploadController extends JenaIngestController {
log.error(e1); log.error(e1);
throw new ServletException(e1); throw new ServletException(e1);
} }
return;
} }
private OntModel getABoxModel(ServletContext ctx) { private OntModel getABoxModel(ServletContext ctx) {

View file

@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;

View file

@ -18,7 +18,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService; 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.ShortViewService.ShortViewContext;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup; import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
/** /**
* Does a Solr search for individuals, and uses the short view to render each of * Does a Solr search for individuals, and uses the short view to render each of

View file

@ -18,7 +18,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService; 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.ShortViewService.ShortViewContext;
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup; import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
/** /**
* Does a search for individuals, and uses the short view to render each of * Does a search for individuals, and uses the short view to render each of

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.json; package edu.cornell.mannlib.vitro.webapp.controller.json;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.controller.json; package edu.cornell.mannlib.vitro.webapp.controller.json;
import java.util.ArrayList;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;

View file

@ -8,8 +8,6 @@ import java.io.Writer;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;

View file

@ -10,7 +10,6 @@ import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.dao.jena.IndividualDaoJena;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.NewURIMaker; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.NewURIMaker;
public class NewURIMakerVitro implements NewURIMaker { public class NewURIMakerVitro implements NewURIMaker {

View file

@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.List; import java.util.List;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
public interface PropertyGroupDao { public interface PropertyGroupDao {

View file

@ -3,9 +3,7 @@
package edu.cornell.mannlib.vitro.webapp.dao; package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstanceIface; import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstanceIface;

View file

@ -1,12 +1,9 @@
/* $This file is distributed under the terms of the license in LICENSE$ */ /* $This file is distributed under the terms of the license in LICENSE$ */
package edu.cornell.mannlib.vitro.webapp.dao.filtering; package edu.cornell.mannlib.vitro.webapp.dao.filtering;
import java.util.Date;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
public class DataPropertyStatementFiltering implements DataPropertyStatement { public class DataPropertyStatementFiltering implements DataPropertyStatement {

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.dao.filtering; package edu.cornell.mannlib.vitro.webapp.dao.filtering;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import net.sf.jga.algorithms.Filter; import net.sf.jga.algorithms.Filter;
@ -67,16 +66,13 @@ public class FilteringPropertyInstanceDao implements PropertyInstanceDao {
//Filter based on subject, property and object. This could be changed //Filter based on subject, property and object. This could be changed
//to filter on the subject's and object's class. //to filter on the subject's and object's class.
Individual sub = individualDao.getIndividualByURI(inst.getSubjectEntURI()); Individual sub = individualDao.getIndividualByURI(inst.getSubjectEntURI());
if( filters.getIndividualFilter().fn(sub) == false ) if(!filters.getIndividualFilter().fn(sub))
return false; return false;
Individual obj = individualDao.getIndividualByURI(inst.getObjectEntURI()); Individual obj = individualDao.getIndividualByURI(inst.getObjectEntURI());
if( filters.getIndividualFilter().fn(obj) == false) if(!filters.getIndividualFilter().fn(obj))
return false; return false;
ObjectProperty prop = objectPropDao.getObjectPropertyByURI(inst.getPropertyURI()); ObjectProperty prop = objectPropDao.getObjectPropertyByURI(inst.getPropertyURI());
if( filters.getObjectPropertyFilter().fn(prop) == false) return filters.getObjectPropertyFilter().fn(prop);
return false;
else
return true;
} }
}; };
} }

View file

@ -155,8 +155,10 @@ public class IndividualFiltering implements Individual {
// predicate + range class combination is allowed even if the predicate is // predicate + range class combination is allowed even if the predicate is
// hidden on its own. // hidden on its own.
// Will revisit filtering at this level if it turns out to be truly necessary. return _innerIndividual.getPopulatedObjectPropertyList();
// Will revisit filtering at this level if it turns out to be truly necessary.
/*
List<ObjectProperty> outOProps = new ArrayList<ObjectProperty>(); List<ObjectProperty> outOProps = new ArrayList<ObjectProperty>();
List<ObjectProperty> oProps = _innerIndividual.getPopulatedObjectPropertyList(); List<ObjectProperty> oProps = _innerIndividual.getPopulatedObjectPropertyList();
for (ObjectProperty op: oProps) { for (ObjectProperty op: oProps) {
@ -166,6 +168,7 @@ public class IndividualFiltering implements Individual {
} }
} }
return outOProps; return outOProps;
*/
} }
/* ********************* methods that need delegated filtering *************** */ /* ********************* methods that need delegated filtering *************** */

View file

@ -1,7 +1,6 @@
/* $This file is distributed under the terms of the license in LICENSE$ */ /* $This file is distributed under the terms of the license in LICENSE$ */
package edu.cornell.mannlib.vitro.webapp.dao.filtering; package edu.cornell.mannlib.vitro.webapp.dao.filtering;
import java.util.Date;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;

View file

@ -2,17 +2,13 @@
package edu.cornell.mannlib.vitro.webapp.dao.filtering; package edu.cornell.mannlib.vitro.webapp.dao.filtering;
import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import net.sf.jga.algorithms.Filter;
import org.apache.jena.ontology.DatatypeProperty; import org.apache.jena.ontology.DatatypeProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property; import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
@ -70,7 +66,6 @@ public class PropertyGroupDaoFiltering implements PropertyGroupDao {
} }
grp.setPropertyList(filteredProps); //side effect grp.setPropertyList(filteredProps); //side effect
return ;
} }
public List<PropertyGroup> getPublicGroups(boolean withProperties) { public List<PropertyGroup> getPublicGroups(boolean withProperties) {

View file

@ -223,7 +223,6 @@ public class VClassDaoFiltering extends BaseFiltering implements VClassDao{
if( out != null ) if( out != null )
vclass.setEntityCount(out.size()); vclass.setEntityCount(out.size());
System.out.println(vclass.getURI() + " count: " + vclass.getEntityCount()); System.out.println(vclass.getURI() + " count: " + vclass.getEntityCount());
return;
} }
private List<VClass> correctVClassCounts(List<VClass> vclasses){ private List<VClass> correctVClassCounts(List<VClass> vclasses){

View file

@ -4,12 +4,10 @@ package edu.cornell.mannlib.vitro.webapp.dao.filtering.filters;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import net.sf.jga.fn.UnaryFunctor; import net.sf.jga.fn.UnaryFunctor;

View file

@ -12,7 +12,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User;
/** /**
* A object to hold all the filters commonly used by the vitro webapp. * A object to hold all the filters commonly used by the vitro webapp.

View file

@ -104,7 +104,7 @@ public class DisplayModelDaoJena implements DisplayModelDao {
if( text == null ){ if( text == null ){
//text of file is not yet in model //text of file is not yet in model
File oldMenuFile = new File(context.getRealPath(MENU_N3_FILE)); File oldMenuFile = new File(context.getRealPath(MENU_N3_FILE));
StringBuffer str = new StringBuffer(2000); StringBuilder str = new StringBuilder(2000);
BufferedReader reader = new BufferedReader(new FileReader(oldMenuFile)); BufferedReader reader = new BufferedReader(new FileReader(oldMenuFile));
char[] buf = new char[1024]; char[] buf = new char[1024];
int numRead=0; int numRead=0;

View file

@ -219,12 +219,12 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
ontModel.enterCriticalSection(Lock.WRITE); ontModel.enterCriticalSection(Lock.WRITE);
try { try {
entURI = new String(preferredURI); entURI = preferredURI;
org.apache.jena.ontology.Individual test = ontModel.getIndividual(entURI); org.apache.jena.ontology.Individual test = ontModel.getIndividual(entURI);
int count = 0; int count = 0;
while (test != null) { while (test != null) {
++count; ++count;
entURI = new String(preferredURI) + count; entURI = preferredURI + count;
test = ontModel.getIndividual(entURI); test = ontModel.getIndividual(entURI);
} }
@ -677,7 +677,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
int attempts = 0; int attempts = 0;
while( uriIsGood == false && attempts < 30 ){ while(!uriIsGood && attempts < 30 ){
log.debug("While loop: Uri is good false, attempt=" + attempts); log.debug("While loop: Uri is good false, attempt=" + attempts);
String localName = "n" + random.nextInt( Math.min(Integer.MAX_VALUE,(int)Math.pow(2,attempts + 13)) ); String localName = "n" + random.nextInt( Math.min(Integer.MAX_VALUE,(int)Math.pow(2,attempts + 13)) );
uri = namespace + localName; uri = namespace + localName;

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena; package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -28,7 +27,6 @@ import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet; import org.apache.jena.query.ResultSet;
import org.apache.jena.query.ResultSetFactory;
import org.apache.jena.rdf.model.AnonId; import org.apache.jena.rdf.model.AnonId;
import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Property;

Some files were not shown because too many files have changed in this diff Show more