|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fcrepo.server.storage.translation.DOTranslationUtility
public abstract class DOTranslationUtility
Utility methods for usage by digital object serializers and deserializers. This class provides methods for detecting various forms of relative repository URLs, which are URLs that point to the hostname and port of the local repository. Methods will detect these kinds of URLS in datastream location fields and in special cases of inline XML. Methods are available to convert these URLS back and forth from relative URL syntax, to Fedora's internal local URL syntax, and to absolute URL sytnax. This utility class defines different "translation contexts" and the format of these relative URLs will be set appropriately to the context. Currently defined translation contexts are: 0=Deserialize XML into java object appropriate for in-memory usage 1=Serialize java object to XML appropriate for "public" export (absolute URLs) 2=Serialize java object to XML appropriate for move/migrate to another repository 3=Serialize java object to XML appropriate for internal storage
The public "normalize*" methods in this class should be called to make the right decisions about what conversions should occur for what contexts. Other utility methods set default values for datastreams and disseminators.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.fcrepo.common.Constants |
|---|
Constants.FedoraHome |
| Field Summary | |
|---|---|
static int |
AS_IS
Deserialize or Serialize as is. |
static int |
DESERIALIZE_INSTANCE
DESERIALIZE_INSTANCE: Deserialize XML into a java object appropriate for in-memory usage. |
static Pattern |
s_getItemPattern
|
static int |
SERIALIZE_EXPORT_ARCHIVE
SERIALIZE_EXPORT_ARCHIVE: Serialize digital object to XML in a manner appropriate for creating a stand alone archive of objects from a repository that will NOT be available after objects have been exported. |
static int |
SERIALIZE_EXPORT_MIGRATE
SERIALIZE_EXPORT_MIGRATE: Serialize digital object to XML in a manner appropriate for migrating or moving objects from one repository to another. |
static int |
SERIALIZE_EXPORT_PUBLIC
SERIALIZE_EXPORT_PUBLIC: Serialize digital object to XML appropriate for "public" external use. |
static int |
SERIALIZE_STORAGE_INTERNAL
SERIALIZE_STORAGE_INTERNAL: Serialize java object to XML appropriate for persistent storage in the repository, ensuring that any URLs that are relative to the local repository are stored with the Fedora local URL syntax. |
| Constructor Summary | |
|---|---|
DOTranslationUtility()
|
|
| Method Summary | |
|---|---|
protected static void |
appendAuditTrail(DigitalObject obj,
PrintWriter writer)
|
protected static void |
appendXMLStream(InputStream in,
PrintWriter writer,
String encoding)
Appends XML to a PrintWriter. |
protected static List<AuditRecord> |
getAuditRecords(InputStream auditTrail)
Parse an audit:auditTrail and return a list of AuditRecords. |
protected static List<AuditRecord> |
getAuditRecords(Reader auditTrail)
|
protected static List<AuditRecord> |
getAuditRecords(XMLEventReader reader)
|
protected static String |
getAuditTrail(DigitalObject obj)
|
static String |
getStateAttribute(DigitalObject obj)
Reads the state attribute from a DigitalObject. |
static RDFName |
getTypeAttribute(DigitalObject obj)
|
static String |
makeAbsoluteURLs(String input)
Make URLs that are relative to the local Fedora repository ABSOLUTE URLs. |
static String |
makeFedoraLocalURLs(String input)
Detect all forms of URLs that point to the local Fedora repository and make sure they are encoded in the special Fedora local URL syntax (http://local.fedora.server/..."). |
static void |
normalizeDatastreams(DigitalObject obj,
int transContext,
String characterEncoding)
|
static Datastream |
normalizeDSLocationURLs(String PID,
Datastream origDS,
int transContext)
|
static String |
normalizeInlineXML(String xml,
int transContext)
Utility method to normalize a chunk of inline XML depending on the translation context. |
protected static String |
oneString(String[] idList)
|
static String |
readStateAttribute(String rawValue)
Parse and read the object state value from raw text. |
static Datastream |
setDatastreamDefaults(Datastream ds)
Check for null values in attributes and set them to empty string so 'null' does not appear in XML attribute values. |
static Disseminator |
setDisseminatorDefaults(Disseminator diss)
Deprecated. |
protected static void |
validateAudit(AuditRecord audit)
The audit record is created by the system, so programmatic validation here is o.k. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DESERIALIZE_INSTANCE
public static final int SERIALIZE_EXPORT_PUBLIC
public static final int SERIALIZE_EXPORT_MIGRATE
public static final int SERIALIZE_STORAGE_INTERNAL
public static final int SERIALIZE_EXPORT_ARCHIVE
public static final int AS_IS
public static Pattern s_getItemPattern
| Constructor Detail |
|---|
public DOTranslationUtility()
| Method Detail |
|---|
public static String makeAbsoluteURLs(String input)
m_xmlContent -
public static String makeFedoraLocalURLs(String input)
input -
public static Datastream normalizeDSLocationURLs(String PID,
Datastream origDS,
int transContext)
public static String normalizeInlineXML(String xml,
int transContext)
xml - a chunk of XML that's contents of an inline XML datastreamtransContext - Integer value indicating the serialization or deserialization
context. Valid values are defined as constants in
org.fcrepo.server.storage.translation.DOTranslationUtility:
0=DOTranslationUtility.DESERIALIZE_INSTANCE
1=DOTranslationUtility.SERIALIZE_EXPORT_PUBLIC
2=DOTranslationUtility.SERIALIZE_EXPORT_MIGRATE
3=DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL
4=DOTranslationUtility.SERIALIZE_EXPORT_ARCHIVE
public static Datastream setDatastreamDefaults(Datastream ds)
throws ObjectIntegrityException
ds - The Datastream object to work on.
ObjectIntegrityException
protected static void appendXMLStream(InputStream in,
PrintWriter writer,
String encoding)
throws ObjectIntegrityException,
UnsupportedEncodingException,
StreamIOException
in - InputStreaming containing serialized XML.writer - PrintWriter to write XML content to.encoding - Character set encoding.
ObjectIntegrityException
UnsupportedEncodingException
StreamIOException
public static void normalizeDatastreams(DigitalObject obj,
int transContext,
String characterEncoding)
throws UnsupportedEncodingException
UnsupportedEncodingException
@Deprecated
public static Disseminator setDisseminatorDefaults(Disseminator diss)
throws ObjectIntegrityException
ObjectIntegrityExceptionprotected static String oneString(String[] idList)
public static String getStateAttribute(DigitalObject obj)
throws ObjectIntegrityException
Null or empty strings are interpteted as "Active".
obj - Object that potentially contains object state data.
ObjectIntegrityException - thrown when the state cannot be parsed.
public static String readStateAttribute(String rawValue)
throws ParseException
Reads a text representation of object state, and returns a "state code" abbreviation corresponding to that state. Null or empty values are interpreted as "Active".
XXX: It might clearer to nix state codes altogether and just use the full value
rawValue - Raw string to parse. May be null
ParseException - thrown when state value cannot be determined
public static RDFName getTypeAttribute(DigitalObject obj)
throws ObjectIntegrityException
ObjectIntegrityException
protected static void validateAudit(AuditRecord audit)
throws ObjectIntegrityException
audit -
ObjectIntegrityException
protected static String getAuditTrail(DigitalObject obj)
throws ObjectIntegrityException
ObjectIntegrityException
protected static void appendAuditTrail(DigitalObject obj,
PrintWriter writer)
throws ObjectIntegrityException
ObjectIntegrityException
protected static List<AuditRecord> getAuditRecords(XMLEventReader reader)
throws XMLStreamException
XMLStreamException
protected static List<AuditRecord> getAuditRecords(InputStream auditTrail)
throws XMLStreamException
auditTrail -
XMLStreamException
protected static List<AuditRecord> getAuditRecords(Reader auditTrail)
throws XMLStreamException
XMLStreamException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||