model.enterCriticalSection(ModelLock.WRITE);
try {
comment = relation.getProperty(KNOBOT.target).getResource();
if (!comment.hasProperty(DC.date)) {
Literal currentDate = importing.createTypedLiteral(
new W3CDateFormat().format(new Date()),
XSDDatatype.XSDdateTime);
comment.addProperty(DC.date, currentDate);
}
Statement makerStmt = comment.getProperty(FOAF.maker);
if (makerStmt != null) {
Resource maker = makerStmt.getResource();
Statement mboxStmt = maker.getProperty(FOAF.mbox);
if (mboxStmt != null) {
Resource mbox = mboxStmt.getResource();
Resource user = VirtuserHandler.getSubject();
;
ResIterator existingAgents = model
.listSubjectsWithProperty(FOAF.mbox, mbox);
if (existingAgents.hasNext()) {
Resource agent = existingAgents.nextResource();
if (agent.hasProperty(AUTHORIZATION.pass_sha1sum)
&& !agent.equals(user)) {
throw new AccessControlException(
"Posting comment with exiting users mailbox");
}
// remove statements othe than mbox:
Collection removingStmt = new ArrayList();
StmtIterator makerProperties = maker.listProperties();
while (makerProperties.hasNext()) {
Statement current = (Statement) makerProperties
.nextStatement();
if (current.getPredicate().equals(FOAF.mbox)
&& current.getObject().equals(mbox)) {
continue;
}
if (current.getPredicate().equals(FOAF.name)) {
RDFNode currentNameObject = current.getObject();
if (!agent.hasProperty(FOAF.name,
currentNameObject)) {
comment.addProperty(DC.creator,
currentNameObject);
}
}
removingStmt.add(current);
}
makerProperties.close();
for (Iterator iter = removingStmt.iterator(); iter
.hasNext();) {
Statement current = (Statement) iter.next();
current.remove();
}
}
if (existingAgents.hasNext()) {
log.warn("duplicate agent with " + mbox);
}
existingAgents.close();
}
}
relation.addProperty(KNOBOT.strength, model.createTypedLiteral(1f));
relation.addProperty(KNOBOT.childStrength, model.createTypedLiteral(0.5f));
Literal effectiveDateLiteral = model.createTypedLiteral(
new W3CDateFormat().format(new Date()),
XSDDatatype.XSDdateTime);
relation.addProperty(KNOBOT.effectiveDate, effectiveDateLiteral);
relation.addProperty(KNOBOT.strengthReduction, model.createTypedLiteral(DefaultValuesHandler
.getDefaultStrengthReduction(model)));
Statement titleStatement = comment.getProperty(RSS.title);