Merge revisions 4706 4715 4724 4726 4731 4733 4734 4735 4739 to the trunk. For bjl23 and bdc34. Also web.xml from 4719, but not EntityController.java, which causes SVN to barf.

This commit is contained in:
jeb228 2010-04-13 19:51:58 +00:00
parent 10bf357d5e
commit b88ed19ed0
6 changed files with 292 additions and 193 deletions

View file

@ -1044,6 +1044,10 @@
<servlet-name>entity</servlet-name>
<url-pattern>/individual/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>entity</servlet-name>
<url-pattern>/display/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>updateEntityFlags</servlet-name>
<url-pattern>/updateEntityFlags</url-pattern>

View file

@ -22,21 +22,24 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
public class ContactMailServlet extends VitroHttpServlet {
private static final Logger LOG = Logger.getLogger(ContactMailServlet.class);
public static HttpServletRequest request;
public static HttpServletRequest response;
private final static String CONFIRM_PAGE = "/thankyou.jsp";
private final static String ERR_PAGE = "/contact_err.jsp";
private final static String SPAM_MESSAGE = "Your message was flagged as spam.";
private final static String EMAIL_BACKUP_FILE_PATH = "/WEB-INF/LatestMessage.html";
private final static String WEB_USERNAME_PARAM = "webusername";
private final static String WEB_USEREMAIL_PARAM = "webuseremail";
private final static String COMMENTS_PARAM = "s34gfd88p9x1";
private static String smtpHost = null;
private static final Log log = LogFactory.getLog(ContactMailServlet.class.getName());
public void init(ServletConfig servletConfig) throws javax.servlet.ServletException {
super.init(servletConfig);
@ -62,39 +65,57 @@ public class ContactMailServlet extends VitroHttpServlet {
public void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
VitroRequest vreq = new VitroRequest(request);
Portal portal = vreq.getPortal();
String confirmpage = "/thankyou.jsp";
String errpage = "/contact_err.jsp";
String status = null; // holds the error status
String statusMsg = null; // holds the error status
if (smtpHost==null || smtpHost.equals("")){
status = "This application has not yet been configured to send mail " +
statusMsg = "This application has not yet been configured to send mail " +
"-- smtp host has not been identified in the Configuration Properties file.";
response.sendRedirect( "test?bodyJsp=" + errpage + "&ERR=" + status + "&home=" + portal.getPortalId() );
redirectToError(response, statusMsg, portal);
return;
}
String SPAM_MESSAGE = "Your message was flagged as spam.";
String webusername = vreq.getParameter(WEB_USERNAME_PARAM);
String webuseremail = vreq.getParameter(WEB_USEREMAIL_PARAM);
String comments = vreq.getParameter(COMMENTS_PARAM);
boolean probablySpam = false;
String spamReason = "";
String validationMessage = validateInput(webusername, webuseremail,
comments);
if (validationMessage != null) {
redirectToError(response, validationMessage, portal);
return;
}
webusername = webusername.trim();
webuseremail = webuseremail.trim();
comments = comments.trim();
String originalReferer = (String) request.getSession().getAttribute("commentsFormReferer");
request.getSession().removeAttribute("commentsFormReferer");
if (originalReferer == null) {
originalReferer = "none";
// (the following does not support cookie-less browsing:)
// probablySpam = true;
// status = SPAM_MESSAGE;
String spamReason = null;
String originalReferer = (String) request.getSession()
.getAttribute("commentsFormReferer");
if (originalReferer != null) {
request.getSession().removeAttribute("commentsFormReferer");
/* does not support legitimate clients that don't send the Referer header
String referer = request.getHeader("Referer");
if (referer == null ||
(referer.indexOf("comments") <0
&& referer.indexOf("correction") <0) ) {
spamReason = "The form was not submitted from the " +
"Contact Us or Corrections page.";
statusMsg = SPAM_MESSAGE;
}
*/
} else {
String referer = request.getHeader("Referer");
if (referer.indexOf("comments")<0 && referer.indexOf("correction")<0) {
probablySpam=true;
status = SPAM_MESSAGE ;
spamReason = "The form was not submitted from the Contact Us or Corrections page.";
}
originalReferer = "none";
}
if (spamReason == null) {
spamReason = checkForSpam(comments);
if (spamReason != null) {
statusMsg = SPAM_MESSAGE;
}
}
String formType = vreq.getParameter("DeliveryType");
@ -104,19 +125,19 @@ public class ContactMailServlet extends VitroHttpServlet {
if ("comment".equals(formType)) {
if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) {
log.error("No contact mail address defined in current portal "+portal.getPortalId());
LOG.error("No contact mail address defined in current portal "+portal.getPortalId());
throw new Error(
"To establish the Contact Us mail capability the system administrators must "
+ "specify an email address in the current portal.");
} else {
deliverToArray = portal.getContactMail().split(",");
}
deliveryfrom = "Message from the "+portal.getAppName()+" Contact Form (ARMANN-nospam)";
deliveryfrom = "Message from the "+portal.getAppName()+" Contact Form";
} else if ("correction".equals(formType)) {
if (portal.getCorrectionMail() == null || portal.getCorrectionMail().trim().length()==0) {
log.error("Expecting one or more correction email addresses to be specified in current portal "+portal.getPortalId()+"; will attempt to use contact mail address");
LOG.error("Expecting one or more correction email addresses to be specified in current portal "+portal.getPortalId()+"; will attempt to use contact mail address");
if (portal.getContactMail() == null || portal.getContactMail().trim().length()==0) {
log.error("No contact mail address or correction mail address defined in current portal "+portal.getPortalId());
LOG.error("No contact mail address or correction mail address defined in current portal "+portal.getPortalId());
} else {
deliverToArray = portal.getContactMail().split(",");
}
@ -126,78 +147,104 @@ public class ContactMailServlet extends VitroHttpServlet {
deliveryfrom = "Message from the "+portal.getAppName()+" Correction Form (ARMANN-nospam)";
} else {
deliverToArray = portal.getContactMail().split(",");
status = SPAM_MESSAGE ;
statusMsg = SPAM_MESSAGE ;
spamReason = "The form specifies no delivery type.";
}
recipientCount=(deliverToArray == null) ? 0 : deliverToArray.length;
if (recipientCount == 0) {
log.error("recipientCount is 0 when DeliveryType specified as \""+formType+"\"");
LOG.error("recipientCount is 0 when DeliveryType specified as \""+formType+"\"");
throw new Error(
"To establish the Contact Us mail capability the system administrators must "
+ "specify at least one email address in the current portal.");
}
// obtain passed in form data with a simple trim on the values
String webusername = vreq.getParameter("webusername");// Null.trim(); will give you an exception
String webuseremail = vreq.getParameter("webuseremail");//.trim();
String comments = vreq.getParameter("s34gfd88p9x1");
String msgText = composeEmail(webusername, webuseremail, comments,
deliveryfrom, originalReferer, request.getRemoteAddr());
if( webusername == null || "".equals(webusername) ){
probablySpam=true;
status = SPAM_MESSAGE;
spamReason = "A proper webusername field was not found in the form submitted.";
webusername="";
} else
webusername=webusername.trim();
// debugging
PrintWriter outFile = new PrintWriter
(new FileWriter(request.getSession().getServletContext()
.getRealPath(EMAIL_BACKUP_FILE_PATH),true)); //autoflush
writeBackupCopy(outFile, msgText, spamReason);
if( webuseremail == null || "".equals(webuseremail) ){
probablySpam=true;
status = SPAM_MESSAGE;
spamReason = "A proper webuser email field was not found in the form submitted.";
webuseremail="";
} else
webuseremail=webuseremail.trim();
// Set the smtp host
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpHost);
Session s = Session.getDefaultInstance(props,null); // was Session.getInstance(props,null);
//s.setDebug(true);
try {
if (comments==null || comments.equals("")) { // to avoid error messages in log due to null comments String
probablySpam=true;
status = SPAM_MESSAGE;
spamReason = "The proper comments field was not found in the form submitted.";
if (spamReason == null) {
sendMessage(s, webuseremail, deliverToArray, deliveryfrom,
recipientCount, msgText);
}
} catch (AddressException e) {
statusMsg = "Please supply a valid email address.";
outFile.println( statusMsg );
outFile.println( e.getMessage() );
} catch (SendFailedException e) {
statusMsg = "The system was unable to deliver your mail. Please try again later. [SEND FAILED]";
outFile.println( statusMsg );
outFile.println( e.getMessage() );
} catch (MessagingException e) {
statusMsg = "The system was unable to deliver your mail. Please try again later. [MESSAGING]";
outFile.println( statusMsg );
outFile.println( e.getMessage() );
e.printStackTrace();
}
outFile.flush();
outFile.close();
// Redirect to the appropriate confirmation page
if (statusMsg == null && spamReason == null) {
// message was sent successfully
redirectToConfirmation(response, statusMsg, portal);
} else {
comments=comments.trim();
// exception occurred
redirectToError( response, statusMsg, portal);
}
}
/* *************************** The following chunk code is for blocking specific types of spam messages. It should be removed from a more generalized codebase. */
public void doPost( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException
{
doGet( request, response );
}
/* if this blog markup is found, treat comment as blog spam */
if (!probablySpam
&& (comments.indexOf("[/url]") > -1
|| comments.indexOf("[/URL]") > -1
|| comments.indexOf("[url=") > -1
|| comments.indexOf("[URL=") > -1)) {
probablySpam = true;
status = SPAM_MESSAGE;
spamReason = "The message contained blog link markup.";
}
private void redirectToConfirmation(HttpServletResponse response,
String statusMsg, Portal portal) throws IOException {
response.sendRedirect( "test?bodyJsp=" + CONFIRM_PAGE + "&home=" +
portal.getPortalId() );
}
/* if message is absurdly short, treat as blog spam */
if (!probablySpam && comments.length()<15) {
probablySpam=true;
status = SPAM_MESSAGE;
spamReason="The message was too short.";
}
private void redirectToError(HttpServletResponse response, String statusMsg,
Portal portal) throws IOException {
response.sendRedirect( "test?bodyJsp=" + ERR_PAGE + "&ERR=" + statusMsg
+ "&home=" + portal.getPortalId() );
}
/* if contact form was requested directly, and message contains 'phentermine', treat as spam */
if (!probablySpam && originalReferer.equals("none") && (comments.indexOf("phentermine")>-1 || comments.indexOf("Phentermine")>-1)) {
probablySpam=true;
status = SPAM_MESSAGE;
spamReason = "The comments form was requested directly, and the message contains the word 'Phentermine.'";
}
/** Intended to mangle url so it can get through spam filtering
* http://host/dir/servlet?param=value -> host: dir/servlet?param=value */
public String stripProtocol( String in ){
if( in == null )
return "";
else
return in.replaceAll("http://", "host: " );
}
/* ************************** end spam filtering code */
private String composeEmail(String webusername, String webuseremail,
String comments, String deliveryfrom,
String originalReferer, String ipAddr) {
StringBuffer msgBuf = new StringBuffer();
// contains the intro copy for the body of the email message
String lineSeparator = System.getProperty("line.separator");
// \r\n on windows, \n on unix
StringBuffer msgBuf = new StringBuffer(); // contains the intro copy for the body of the email message
String lineSeparator = System.getProperty("line.separator"); // \r\n on windows, \n on unix
// from MyLibrary
msgBuf.setLength(0);
msgBuf.append("Content-Type: text/html; charset='us-ascii'" + lineSeparator);
@ -208,7 +255,8 @@ public class ContactMailServlet extends VitroHttpServlet {
msgBuf.append("</head>" + lineSeparator );
msgBuf.append("<body>" + lineSeparator );
msgBuf.append("<h4>" + deliveryfrom + "</h4>" + lineSeparator );
msgBuf.append("<h4>From: "+webusername +" (" + webuseremail + ")"+" at IP address "+request.getRemoteAddr()+"</h4>"+lineSeparator);
msgBuf.append("<h4>From: "+webusername +" (" + webuseremail + ")" +
" at IP address " + ipAddr + "</h4>"+lineSeparator);
if (!(originalReferer == null || originalReferer.equals("none"))){
//The spam filter that is being used by the listsrv is rejecting <a href="...
@ -227,17 +275,18 @@ public class ContactMailServlet extends VitroHttpServlet {
msgBuf.append("</body>" + lineSeparator );
msgBuf.append("</html>" + lineSeparator );
String msgText = msgBuf.toString();
// debugging
PrintWriter outFile = new PrintWriter (new FileWriter(request.getSession().getServletContext().getRealPath("/WEB-INF/LatestMessage.html"),true)); //autoflush
return msgBuf.toString();
Calendar cal = Calendar.getInstance();
}
private void writeBackupCopy(PrintWriter outFile, String msgText,
String spamReason) {
Calendar cal = Calendar.getInstance();
outFile.println("<hr/>");
outFile.println();
outFile.println("<p>"+cal.getTime()+"</p>");
outFile.println();
if (probablySpam) {
if (spamReason != null) {
outFile.println("<p>REJECTED - SPAM</p>");
outFile.println("<p>"+spamReason+"</p>");
outFile.println();
@ -247,86 +296,82 @@ public class ContactMailServlet extends VitroHttpServlet {
outFile.println();
outFile.flush();
// outFile.close();
}
// Set the smtp host
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpHost);
Session s = Session.getDefaultInstance(props,null); // was Session.getInstance(props,null);
//s.setDebug(true);
try {
// Construct the message
MimeMessage msg = new MimeMessage( s );
//System.out.println("trying to send message from servlet");
private void sendMessage(Session s, String webuseremail,
String[] deliverToArray, String deliveryfrom, int recipientCount,
String msgText)
throws AddressException, SendFailedException, MessagingException {
// Construct the message
MimeMessage msg = new MimeMessage( s );
//System.out.println("trying to send message from servlet");
// Set the from address
msg.setFrom( new InternetAddress( webuseremail ));
// Set the from address
msg.setFrom( new InternetAddress( webuseremail ));
// Set the recipient address
// Set the recipient address
if (recipientCount>0){
InternetAddress[] address=new InternetAddress[recipientCount];
for (int i=0; i<recipientCount; i++){
address[i] = new InternetAddress(deliverToArray[i]);
}
msg.setRecipients( Message.RecipientType.TO, address );
if (recipientCount>0){
InternetAddress[] address=new InternetAddress[recipientCount];
for (int i=0; i<recipientCount; i++){
address[i] = new InternetAddress(deliverToArray[i]);
}
// Set the subject and text
msg.setSubject( deliveryfrom );
// add the multipart to the message
msg.setContent(msgText,"text/html");
// set the Date: header
msg.setSentDate( new Date() );
//System.out.println("sending from servlet");
if (!probablySpam)
Transport.send( msg ); // try to send the message via smtp - catch error exceptions
} catch (AddressException e) {
status = "Please supply a valid email address.";
outFile.println( status );
outFile.println( e.getMessage() );
} catch (SendFailedException e) {
status = "The system was unable to deliver your mail. Please try again later. [SEND FAILED]";
outFile.println( status );
outFile.println( e.getMessage() );
} catch (MessagingException e) {
status = "The system was unable to deliver your mail. Please try again later. [MESSAGING]";
outFile.println( status );
outFile.println( e.getMessage() );
e.printStackTrace();
msg.setRecipients( Message.RecipientType.TO, address );
}
outFile.flush();
outFile.close();
// Set the subject and text
msg.setSubject( deliveryfrom );
// Redirect to the appropriate confirmation page
if (status == null && !probablySpam) {
// message was sent successfully
response.sendRedirect( "test?bodyJsp=" + confirmpage + "&home=" + portal.getPortalId() );
} else {
// exception occurred
response.sendRedirect( "test?bodyJsp=" + errpage + "&ERR=" + status + "&home=" + portal.getPortalId() );
}
// add the multipart to the message
msg.setContent(msgText,"text/html");
// set the Date: header
msg.setSentDate( new Date() );
Transport.send( msg ); // try to send the message via smtp - catch error exceptions
}
public void doPost( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException
{
doGet( request, response );
private String validateInput(String webusername, String webuseremail,
String comments) {
if( webusername == null || "".equals(webusername.trim()) ){
return "A proper webusername field was not found in the form submitted.";
}
if( webuseremail == null || "".equals(webuseremail.trim()) ){
return "A proper webuser email field was not found in the form submitted.";
}
if (comments==null || "".equals(comments.trim())) {
return "The proper comments field was not found in the form submitted.";
}
return null;
}
/** Intended to mangle url so it can get through spam filtering
* http://host/dir/servlet?param=value -> host: dir/servlet?param=value */
public String stripProtocol( String in ){
if( in == null )
return "";
else
return in.replaceAll("http://", "host: " );
/**
* @param request
* @return null if message not judged to be spam, otherwise a String
* containing the reason the message was flagged as spam.
*/
private String checkForSpam(String comments) {
/* if this blog markup is found, treat comment as blog spam */
if (
(comments.indexOf("[/url]") > -1
|| comments.indexOf("[/URL]") > -1
|| comments.indexOf("[url=") > -1
|| comments.indexOf("[URL=") > -1)) {
return "The message contained blog link markup.";
}
/* if message is absurdly short, treat as blog spam */
if (comments.length()<15) {
return "The message was too short.";
}
return null;
}
}

View file

@ -27,6 +27,7 @@ import org.openrdf.model.URI;
import org.openrdf.model.impl.URIImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper;
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory;
@ -37,12 +38,14 @@ public class URLRewritingHttpServletResponse implements HttpServletResponse {
private HttpServletResponse _response;
private HttpServletRequest _request;
private ServletContext _context;
private WebappDaoFactory wadf;
private int contextPathDepth;
private Pattern slashPattern = Pattern.compile("/");
public URLRewritingHttpServletResponse(HttpServletResponse response, HttpServletRequest request, ServletContext context) {
this._response = response;
this._context = context;
this.wadf = (WebappDaoFactory) context.getAttribute("webappDaoFactory");
this.contextPathDepth = slashPattern.split(request.getContextPath()).length-1;
}
@ -94,8 +97,11 @@ public class URLRewritingHttpServletResponse implements HttpServletResponse {
return _response.encodeURL(inUrl);
}
// rewrite home parameters as portal prefixes for URLs not relative to the current location
if (url.pathBeginsWithSlash && PortalPickerFilter.isPortalPickingActive) {
// rewrite home parameters as portal prefixes or remove
// if there is only one portal
if ( url.pathBeginsWithSlash &&
(PortalPickerFilter.isPortalPickingActive ||
wadf.getPortalDao().isSinglePortal()) ) {
PortalPickerFilter ppf = PortalPickerFilter.getPortalPickerFilter(this._context);
if ( (ppf != null) && (url.queryParams != null) ) {
Iterator<String[]> qpIt = url.queryParams.iterator();
@ -149,7 +155,16 @@ public class URLRewritingHttpServletResponse implements HttpServletResponse {
if ( (uri.getNamespace() != null) && (uri.getLocalName() != null) ) {
String prefix = nsMap.getPrefixForNamespace(uri.getNamespace());
String localName = uri.getLocalName();
if (prefix != null) {
if (wadf.getDefaultNamespace().
equals(uri.getNamespace())
&& prefix == null) {
// make a URI that matches the URI
// of the resource to support
// linked data request
url.pathParts.add(localName);
// remove the ugly uri parameter
indexToRemove = qpIndex;
} else if (prefix != null) {
// add the pretty path parts
url.pathParts.add(prefix);
url.pathParts.add(localName);

View file

@ -24,6 +24,7 @@ import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.ontology.update.AtomicOntologyChange.AtomicChangeType;
/**
@ -35,6 +36,7 @@ public class ABoxUpdater {
private OntModel oldTboxModel;
private OntModel newTboxModel;
private OntModel aboxModel;
private OntModel newTBoxAnnotationsModel;
private OntologyChangeLogger logger;
private OntologyChangeRecord record;
private OntClass OWL_THING = (ModelFactory
@ -57,12 +59,14 @@ public class ABoxUpdater {
public ABoxUpdater(OntModel oldTboxModel,
OntModel newTboxModel,
OntModel aboxModel,
OntModel newAnnotationsModel,
OntologyChangeLogger logger,
OntologyChangeRecord record) {
this.oldTboxModel = oldTboxModel;
this.newTboxModel = newTboxModel;
this.aboxModel = aboxModel;
this.newTBoxAnnotationsModel = newAnnotationsModel;
this.logger = logger;
this.record = record;
}
@ -129,30 +133,58 @@ public class ABoxUpdater {
Resource newClass = ResourceFactory.createResource(change.getDestinationURI());
// Change class references in the subjects of statements
// BJL 2010-04-09 : In future versions we need to keep track of
// the difference between true direct renamings and "use-insteads."
// For now, the best behavior is to remove any remaining statements
// where the old class is the subject, *unless* the statements
// is part of the new annotations file (see comment below) or the
// predicate is vitro:autolinkedToTab. In the latter case,
// the autolinking annotation should be rewritten using the
// new class name.
Property autoLinkedToTab = ResourceFactory.createProperty(VitroVocabulary.TAB_AUTOLINKEDTOTAB);
StmtIterator iter = aboxModel.listStatements(oldClass, (Property) null, (RDFNode) null);
int count = 0;
int renameCount = 0;
int removeCount = 0;
while (iter.hasNext()) {
count++;
Statement oldStatement = iter.next();
Statement newStatement = ResourceFactory.createStatement(newClass, oldStatement.getPredicate(), oldStatement.getObject());
retractions.add(oldStatement);
additions.add(newStatement);
if (newTBoxAnnotationsModel.contains(oldStatement)) {
continue;
// if this statement was loaded from the new annotations,
// don't attempt to remove it.
// This happens in cases where a class hasn't really
// been removed, but we just want to map any ABox
// data using it to use a different class instead.
}
if (autoLinkedToTab.equals(oldStatement.getPredicate())) {
renameCount++;
Statement newStatement = ResourceFactory.createStatement(newClass, oldStatement.getPredicate(), oldStatement.getObject());
additions.add(newStatement);
} else {
removeCount++;
retractions.add(oldStatement);
}
//logChange(oldStatement, false);
//logChange(newStatement,true);
}
//log summary of changes
if (count > 0) {
logger.log("Changed " + count + " subject reference" + ((count > 1) ? "s" : "") + " to the " + oldClass.getURI() + " class to be " + newClass.getURI());
if (renameCount > 0) {
logger.log("Changed " + renameCount + " subject reference" + ((renameCount > 1) ? "s" : "") + " to the " + oldClass.getURI() + " class to be " + newClass.getURI());
}
if (removeCount > 0) {
logger.log("Removed " + removeCount + " remaining subject reference" + ((removeCount > 1) ? "s" : "") + " to the " + oldClass.getURI() + " class");
}
// Change class references in the objects of statements
// Change class references in the objects of rdf:type statements
iter = aboxModel.listStatements((Resource) null, (Property) null, oldClass);
count = 0;
renameCount = 0;
while (iter.hasNext()) {
count++;
renameCount++;
Statement oldStatement = iter.next();
Statement newStatement = ResourceFactory.createStatement(oldStatement.getSubject(), oldStatement.getPredicate(), newClass);
retractions.add(oldStatement);
@ -163,8 +195,8 @@ public class ABoxUpdater {
}
//log summary of changes
if (count > 0) {
logger.log("Changed " + count + " object reference" + ((count > 1) ? "s" : "") + " to the " + oldClass.getURI() + " class to be " + newClass.getURI());
if (renameCount > 0) {
logger.log("Changed " + renameCount + " object reference" + ((renameCount > 1) ? "s" : "") + " to the " + oldClass.getURI() + " class to be " + newClass.getURI());
}
aboxModel.remove(retractions);

View file

@ -96,13 +96,11 @@ public class OntologyUpdater {
settings.getNewTBoxModel(),
settings.getOldTBoxModel());
//updateTBox(changes);
//preprocessChanges(changes);
//process the TBox before the ABox
updateTBoxAnnotations();
updateABox(changes);
updateTBoxAnnotations();
}
/**
@ -172,8 +170,12 @@ public class OntologyUpdater {
}
}
aboxModel.add(actualAdditions);
logger.log("Constructed " + actualAdditions.size() + " new " +
"statements using SPARQL CONSTRUCT queries.");
if (actualAdditions.size() > 0) {
logger.log("Constructed " + actualAdditions.size() + " new " +
"statement"
+ ((actualAdditions.size() > 1) ? "s" : "") +
" using SPARQL CONSTRUCT queries.");
}
record.recordAdditions(actualAdditions);
} finally {
aboxModel.leaveCriticalSection();
@ -198,7 +200,8 @@ public class OntologyUpdater {
OntModel newTBoxModel = settings.getNewTBoxModel();
OntModel ABoxModel = settings.getOntModelSelector().getABoxModel();
ABoxUpdater aboxUpdater = new ABoxUpdater(
oldTBoxModel, newTBoxModel, ABoxModel, logger, record);
oldTBoxModel, newTBoxModel, ABoxModel,
settings.getNewTBoxAnnotationsModel(), logger, record);
aboxUpdater.processPropertyChanges(changes.getAtomicPropertyChanges());
aboxUpdater.processClassChanges(changes.getAtomicClassChanges());
// run additional SPARQL CONSTRUCTS

View file

@ -54,9 +54,9 @@ public class UpdateKnowledgeBase implements ServletContextListener {
private final String ERROR_LOG_FILE = DATA_DIR + LOG_DIR +
"knowledgeBaseUpdate.error.log";
private final String REMOVED_DATA_FILE = DATA_DIR + CHANGED_DATA_DIR +
"removedData.rdf";
"removedData.n3";
private final String ADDED_DATA_FILE = DATA_DIR + CHANGED_DATA_DIR +
"addedData.rdf";
"addedData.n3";
private final String SPARQL_CONSTRUCTS_DIR = DATA_DIR + "sparqlConstructs/";
private final String MISC_REPLACEMENTS_FILE = DATA_DIR + "miscReplacements.rdf";
private final String OLD_TBOX_MODEL_DIR = DATA_DIR + "oldVersion/";