Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workspace rdf to fcr:workspace responses
- Loading branch information
Andrew Woods
committed
Aug 8, 2013
1 parent
07a6d23
commit 6364d47
Showing
9 changed files
with
216 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
fcrepo-http-api/src/main/resources/views/jcr-workspaces.vsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#* @vtlvariable name="rdf" type="com.hp.hpl.jena.sparql.core.DatasetGraph" *# | ||
#* @vtlvariable name="subjects" type="com.hp.hpl.jena.rdf.model.ResIterator" *# | ||
#* @vtlvariable name="nodeany" type="com.hp.hpl.jena.graph.Node" *# | ||
#* @vtlvariable name="topic" type="com.hp.hpl.jena.graph.Node" *# | ||
<!DOCTYPE html> | ||
#parse("views/common.vsl") | ||
<html> | ||
<head> | ||
<title>registered workspaces</title> | ||
#parse("views/common-head.vsl") | ||
</head> | ||
<body> | ||
<div id="main" class="container" resource="$uriInfo.baseUriBuilder.build()fcr:workspaces"> | ||
#parse("views/common-header.vsl") | ||
|
||
<div class="row"> | ||
<div class="span9"> | ||
<h1>Workspaces</h1> | ||
|
||
## output other nodes | ||
#foreach($subject in $subjects) | ||
<div class="well" resource="$subject.getURI()"> | ||
<h3>$subject.getURI()</h3> | ||
#triples($subject.asNode()) | ||
</div> | ||
#end | ||
</div> | ||
|
||
</div> | ||
</body> | ||
</html> |
94 changes: 94 additions & 0 deletions
94
fcrepo-http-api/src/test/java/org/fcrepo/api/repository/FedoraRepositoryWorkspacesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
* Copyright 2013 DuraSpace, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.fcrepo.api.repository; | ||
|
||
import com.hp.hpl.jena.query.Dataset; | ||
import com.hp.hpl.jena.rdf.model.Resource; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.modeshape.jcr.api.NamespaceRegistry; | ||
|
||
import javax.jcr.Session; | ||
import javax.jcr.Workspace; | ||
import javax.ws.rs.core.UriBuilder; | ||
import javax.ws.rs.core.UriInfo; | ||
import java.net.URI; | ||
|
||
import static org.fcrepo.test.util.TestHelpers.setField; | ||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.MockitoAnnotations.initMocks; | ||
|
||
/** | ||
* @author Andrew Woods | ||
* Date: 8/7/13 | ||
*/ | ||
public class FedoraRepositoryWorkspacesTest { | ||
|
||
private FedoraRepositoryWorkspaces workspaces; | ||
|
||
@Mock | ||
private Workspace mockWorkspace; | ||
|
||
@Mock | ||
private NamespaceRegistry mockNamespaceRegistry; | ||
|
||
@Mock | ||
private UriInfo mockUriInfo; | ||
|
||
@Mock | ||
private UriBuilder mockUriBuilder; | ||
|
||
@Mock | ||
private Session mockSession; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
initMocks(this); | ||
workspaces = new FedoraRepositoryWorkspaces(); | ||
setField(workspaces, "session", mockSession); | ||
setField(workspaces, "uriInfo", mockUriInfo); | ||
} | ||
|
||
@Test | ||
public void testGetWorkspaces() throws Exception { | ||
when(mockSession.getWorkspace()).thenReturn(mockWorkspace); | ||
when(mockWorkspace.getAccessibleWorkspaceNames()).thenReturn(new String[]{"xxx"}); | ||
|
||
when(mockWorkspace.getNamespaceRegistry()).thenReturn( | ||
mockNamespaceRegistry); | ||
when(mockNamespaceRegistry.getPrefixes()).thenReturn(new String[]{"yyy"}); | ||
|
||
when(mockUriInfo.getBaseUriBuilder()).thenReturn(mockUriBuilder); | ||
when(mockUriBuilder.path(any(String.class))).thenReturn(mockUriBuilder); | ||
|
||
URI uri = new URI("http://base/workspaces"); | ||
when(mockUriBuilder.build()).thenReturn(uri); | ||
|
||
// Do the test. | ||
Dataset dataset = workspaces.getWorkspaces(); | ||
|
||
Resource resource = dataset.getDefaultModel() | ||
.getResource(uri.toString()); | ||
String resourceName = resource.toString(); | ||
|
||
org.junit.Assert.assertNotNull(resourceName); | ||
org.junit.Assert.assertEquals(uri.toString(), resourceName); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters