Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Generalize fedora 3 node organization through a new java interface.
- Loading branch information
Michael Durbin
authored and
Andrew Woods
committed
Oct 10, 2013
1 parent
2d51af6
commit 45af9e8
Showing
10 changed files
with
375 additions
and
78 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
50 changes: 50 additions & 0 deletions
50
...-federation-connector/src/main/java/org/fcrepo/connector/fedora3/RepositoryOrganizer.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,50 @@ | ||
/** | ||
* 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.connector.fedora3; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* An interface that defines methods to expose an arbitrary organization of | ||
* objects (from a fedora 3 repository) in a federation. | ||
* | ||
* @author Michael Durbin | ||
*/ | ||
public interface RepositoryOrganizer { | ||
|
||
/** | ||
* Gets the id values of all children nodes for the node with the given id. | ||
* @throws IllegalArgumentException if the id is not an organizational node | ||
*/ | ||
public List<String> getChildrenForId(String id); | ||
|
||
/** | ||
* Gets the id of the parent of the node with the given id. | ||
* @throws IllegalArgumentException if the id has never been returned by a | ||
* call to getChildrenForId. | ||
*/ | ||
public String getParentForId(String id); | ||
|
||
/** | ||
* Determine whether a given node (identified by id) is an organizational | ||
* node fabricated by this RepositoryOrganizer implementation. | ||
* @throws IllegalArgumentException if the id has never been returned by a | ||
* call to getChildrenForId. | ||
*/ | ||
public boolean isOrganizationalNode(String id); | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
...nnector/src/main/java/org/fcrepo/connector/fedora3/organizers/FlatTruncatedOrganizer.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,73 @@ | ||
/** | ||
* 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.connector.fedora3.organizers; | ||
|
||
import org.fcrepo.connector.fedora3.Fedora3DataInterface; | ||
import org.fcrepo.connector.fedora3.ID; | ||
import org.fcrepo.connector.fedora3.RepositoryOrganizer; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* This is a dummy implementation that does exactly what the hard-coded | ||
* organization from previous versions of Fedora3FederationConnector did. | ||
* It's useful only a step on the way towards a more useful implementation. | ||
* | ||
* @author Michael Durbin | ||
*/ | ||
public class FlatTruncatedOrganizer implements RepositoryOrganizer { | ||
|
||
private Fedora3DataInterface f3; | ||
|
||
/** | ||
* A constructor that accepts the Fedora3DataInterface whose fedora objects | ||
* will be organized by this instance. | ||
*/ | ||
public FlatTruncatedOrganizer(Fedora3DataInterface fedora3Data) { | ||
f3 = fedora3Data; | ||
} | ||
|
||
/** | ||
* Returns the first 10 objects in the repository when invoked for the | ||
* root ID; otherwise throws an IllegalArgumentException. | ||
*/ | ||
public List<String> getChildrenForId(String id) { | ||
if (id.equals(ID.ROOT_ID.getId())) { | ||
return f3.getObjectPids(0, 10); | ||
} else { | ||
throw new IllegalArgumentException(); | ||
} | ||
} | ||
|
||
/** | ||
* Returns null if the id isn't the root ID, and otherwise the root id. | ||
*/ | ||
public String getParentForId(String id) { | ||
if (ID.ROOT_ID.getId().equals(id)) { | ||
return null; | ||
} else { | ||
return ID.ROOT_ID.getId(); | ||
} | ||
} | ||
|
||
/** | ||
* Returns true for the root id, false otherwise. | ||
*/ | ||
public boolean isOrganizationalNode(String id) { | ||
return ID.ROOT_ID.getId().equals(id); | ||
} | ||
} |
Oops, something went wrong.