Skip to content

Commit

Permalink
Supressed links to modify nodes on the frozen node HTML view.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Durbin authored and Andrew Woods committed Nov 26, 2013
1 parent 1df8cea commit 42f3f2d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
31 changes: 22 additions & 9 deletions fcrepo-http-api/src/main/resources/views/common-node-actions.vsl
@@ -1,19 +1,30 @@
#set ($content = $helpers.getObjectsAsString($rdf, $topic, $rdfLexicon.HAS_CONTENT, false))
#set ($readonly = $helpers.isFrozenNode($rdf, $topic))

#if ($readonly == true)
<div class="alert alert-warning">
<span class="glyphicon glyphicon-warning-sign"></span>
This is a <strong>historic version</strong> and cannot be modified.
</div>
#end

#if ($content != "")
<a href="$content" class="btn btn-success btn-lg"><span class="glyphicon glyphicon-download"></span> Download Content</a>


#if ($readonly == false)
<h3>Update Content</h3>
<form action="javascript:updateFile()">
<div class="form-group">
<label for="update_file" class="control-label">File</label>
<input type="file" id="update_file"/>
</div>
<input type="submit" class="btn btn-primary" value="Update">
</form>
<form action="javascript:updateFile()">
<div class="form-group">
<label for="update_file" class="control-label">File</label>
<input type="file" id="update_file"/>
</div>
<input type="submit" class="btn btn-primary" value="Update">
</form>
#end
<hr />
#end

#if ($readonly == false)
<form id="action_create" name="action_create" method="POST" enctype="multipart/form-data">
<h3>Create New Node</h3>
<div class="form-group">
Expand Down Expand Up @@ -67,7 +78,7 @@ WHERE { }
<button name="delete-button" type="submit" class="btn btn-danger">Delete</button>
<hr />
</form>

#end

#set ($serializations = $rdf.find($nodeany, $topic, $helpers.asNode($rdfLexicon.HAS_SERIALIZATION), $nodeany))

Expand All @@ -90,6 +101,7 @@ WHERE { }
#end


#if ($readonly == false)
#set ($serializations = $rdf.find($nodeany, $topic, $helpers.asNode($rdfLexicon.HAS_SERIALIZATION), $nodeany))

#if($serializations.hasNext())
Expand Down Expand Up @@ -138,3 +150,4 @@ WHERE { }
<button type="submit" class="btn btn-primary">Start Transaction</button>
</form>
#end
#end
Expand Up @@ -30,6 +30,7 @@
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
import org.fcrepo.http.commons.api.rdf.QuadOrdering;
import org.fcrepo.kernel.RdfLexicon;
import org.slf4j.Logger;

import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -110,6 +111,18 @@ public String getObjectTitle(final DatasetGraph dataset,

}

/**
* Determines whether the subject is of type nt:frozenNode.
*/
public boolean isFrozenNode(final DatasetGraph dataset,
final Node subject) {
final Iterator<Quad> objects
= getObjects(dataset, subject, RdfLexicon.HAS_PRIMARY_TYPE);
return objects.hasNext()
&& objects.next().getObject()
.getLiteralValue().toString().equals("nt:frozenNode");
}

/**
* Get the string version of the object that matches the given subject and
* predicate
Expand Down
Expand Up @@ -28,7 +28,9 @@
import static org.fcrepo.kernel.RdfLexicon.CREATED_BY;
import static org.fcrepo.kernel.RdfLexicon.DC_TITLE;
import static org.fcrepo.http.commons.test.util.TestHelpers.getUriInfoImpl;
import static org.fcrepo.kernel.RdfLexicon.HAS_PRIMARY_TYPE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.Iterator;
Expand Down Expand Up @@ -85,6 +87,22 @@ public void shouldRefuseToConvertAForeignUriToNodeBreadcrumbs() {
assertTrue(nodeBreadcrumbs.isEmpty());
}

@Test
public void testIsFrozenNode() {
final DatasetGraph mem = createMem();
mem.add(createAnon(), createURI("a/b/c"), HAS_PRIMARY_TYPE.asNode(),
createLiteral("nt:frozenNode"));
assertTrue("Node is a frozen node.", testObj.isFrozenNode(mem, createURI("a/b/c")));
}

@Test
public void testIsNotFrozenNode() {
final DatasetGraph mem = createMem();
mem.add(createAnon(), createURI("a/b/c"), HAS_PRIMARY_TYPE.asNode(),
createLiteral("nt:file"));
assertFalse("Node is not a frozen node.", testObj.isFrozenNode(mem, createURI("a/b/c")));
}

@Test
public void shouldTryToExtractDublinCoreTitleFromNode() {
final DatasetGraph mem = createMem();
Expand Down

0 comments on commit 42f3f2d

Please sign in to comment.