public class TextGridObject extends AbstractResource implements ITextGridPermission, ITextGridModelConstants
IFile
, call it file
TextGridObject tgo = file.getAdapter(TextGridObject.class);
URI
representing a TextGridObject:
TextGridObject
tgo = TextGridObject.getInstance(uri, true);
(or false
to always avoid network operations)
OMElement
containing existing metadata:
TextGridObject
tgo = TextGridObject.getInstance(element, false);
(or true
as last argument if element
definitely
contains the complete metadata)
You cannot call a constructor directly. The create methods make sure
that every object in the TextGridRep is represented by only one
TextGridObject
.
TextGridObjects may be incomplete, i.e. they may contain less
metadata than the object has, if this avoids network access. It will always
have an URI, however. Check for completeness using
isComplete()
, retrieve potentially incomplete objects via
getInstance(OMElement, boolean)
or
getInstance(URI, boolean)
with the second argument set to
false
.
To read or write the actual contents of an object, you should convert the
TextGridObject to an IFile
:
IFile file = (IFile) textGridObject.getAdapter(IFile.class);
You can then call IFile's IFile.getContents()
and
IFile.setContents(InputStream, int, IProgressMonitor)
methods.
Modifier and Type | Class and Description |
---|---|
protected static class |
TextGridObject.DeepCopyException
Runtime exception that is thrown when creating a deep copy of a metadata
record fails.
|
static interface |
TextGridObject.ITextGridObjectListener
A listener that is called when something happens with an object.
|
Modifier and Type | Field and Description |
---|---|
static QName |
CLIENT_NAME
Deprecated.
|
static String |
CUSTOM_NAMESPACE |
static QName |
METADATA_ROOT_NAME
This
QName is passed into the stub's getOMElement method for
tgObjectMetadata as parent qname since this may not be null (or it would
result in an NullPointerException ). |
static String |
MOVE_TGOBJECT |
static String |
NO_TITLE |
static String |
TEXTGRID_DATERANGE_NAMESPACE
Deprecated.
|
static String |
TEXTGRID_METADATA_NAMESPACE |
CREATE, DELEGATE, DELETE, PUBLISH, READ, RESET, UNKNOWN, UPDATE
AUTHORITY_EFS, SCHEMA, SCHEMA_EFS, SCHEMA_HANDLE, SCHEMA_NEWFILE
Modifier | Constructor and Description |
---|---|
protected |
TextGridObject(info.textgrid.namespaces.metadata.core._2010.ObjectType metadata)
Creates a new TextGridObject instance from an existing XML representation
of a metadata object.
|
protected |
TextGridObject(String project,
String format)
Creates a new TextGridObject instance representing a new TextGridRep
object.
|
protected |
TextGridObject(URI uri,
boolean readMetadata)
Creates a new TextGridObject from the URI of an existing object, reading
the metadata via TGcrud.
|
Modifier and Type | Method and Description |
---|---|
static void |
addDefaultMetaDataXML(TextGridObject object,
String title)
Add a new metadata xml to the object
|
static void |
addLatestRegistryItem(URI latest,
URI uri)
Adds an item to the latest URI registry.
|
static void |
addListener(TextGridObject.ITextGridObjectListener listener)
Adds a listener for object change events.
|
void |
cancelNewRevision() |
void |
cancelNewVersion() |
void |
clearAdaptor()
If an adaptor is associated, clears it.
|
void |
clearPreviousVersion()
Deprecated.
|
static URI |
computeEFSURI(URI textGridURI)
Convert the passed in TextGrid URI into an hierarchical URI for EFS
internal use.
|
static URI |
computeTextGridURI(URI efsURI)
retrieve the TextGrid URI from the passed in EFS URI.
|
protected static void |
createRecursively(IContainer folder) |
static info.textgrid.namespaces.metadata.core._2010.ObjectType |
deepCopy(info.textgrid.namespaces.metadata.core._2010.ObjectType in)
Creates a deep copy of the given ObjectType.
|
void |
delete(IProgressMonitor monitor)
Deletes this object (and the corresponding resource, if applicable)
|
void |
deleteSchema()
Removes the schema association from this element, if it has one.
|
static void |
fetchURIs(Iterable<TextGridObject> newObjects,
IProgressMonitor monitor)
Fetches new URIs for all objects passed in that don't already have URIs.
|
URI |
getAdaptor()
Returns the adaptor associated with this object or
null if
none has been associated |
List<String> |
getAuthors()
Returns a list of authors of this object for display purposes.
|
TGContentType |
getContentType()
Deprecated.
use
getContentType(boolean) instead. |
TGContentType |
getContentType(boolean exact)
Returns the content type of this object.
|
String |
getContentTypeID() |
Calendar |
getCreated()
Returns the create date from the object's administrative metadata.
|
String |
getCrudWarning()
Returns the object's CRUD-Warning from the metadata.
|
String |
getDataContributor()
Returns the object's owner from the metadata.
|
URI |
getEFSURI() |
byte[] |
getInitialContent()
Returns the initial content of new files, if available, or null.
|
static TextGridObject |
getInstance(info.textgrid.namespaces.metadata.core._2010.ObjectType metadata,
boolean complete,
boolean setMetadata)
Returns the TextGridObject instance representing the existing TextGridRep
object represented by the given metadata.
|
static TextGridObject |
getInstance(org.apache.axiom.om.OMElement element,
boolean isComplete)
Deprecated.
|
static TextGridObject |
getInstance(URI uri,
boolean readMetadata)
Returns the TextGridObject representing the TextGridRep object identified
by the given URI.
|
protected static TextGridObject |
getInstanceByHandle(URI handle,
boolean readMetadata)
Returns a published TextGrid object by the given handle.
|
static TextGridObject |
getInstanceOffline(URI uri)
Retrieves the TextGridObject for the given URI without any grid access.
|
Calendar |
getLastModified()
Returns the last modified date from the object's administrative metadata.
|
String |
getLatestURI()
Returns the latest URI identifying this object as string.
|
info.textgrid.namespaces.metadata.core._2010.ObjectType |
getMetadata()
Creates a deep copy of the TextGridObject's metadata and give is back as
function value.
|
info.textgrid.namespaces.metadata.core._2010.ObjectType |
getMetadataForReading()
Returns a reference to the TextGridObject's metadata.
|
org.apache.axiom.om.OMElement |
getMetadataXML()
Deprecated.
|
String |
getNameCandidate()
Returns the name under which the file is represented in the local file
system, without potential numerical suffix.
|
static TextGridObject |
getNewObjectInstance(String project,
String format)
Deprecated.
use
getNewObjectInstance(TextGridProject, TGContentType)
instead to ensure that the values for project and object are
valid |
static TextGridObject |
getNewObjectInstance(TextGridProject project,
TGContentType contentType)
Creates and registers a new TextGridObject instance representing a new
TextGridRep object.
|
static TextGridObject |
getNewObjectInstance(TextGridProject project,
TGContentType contentType,
String title)
Builds a new TextGrid object with metadata that has been initialized to
the given metadata values.
|
int |
getPermissions()
Return the user's permissions on the current resource.
|
TextGridObject |
getPreparedNewRevision() |
TextGridObject |
getPreparedNewVersion() |
URI |
getPreparedURI() |
TextGridObject |
getPreviousVersion()
Deprecated.
|
String |
getProject()
Returns the object's project from the metadata.
|
TextGridProject |
getProjectInstance() |
String |
getRevisionNumber()
Returns the revision number of this object as string.
|
String |
getRevisionURI() |
URI |
getSchemaURI()
Returns the URI of this object's URI relation or null if none present.
|
long |
getSize()
Extract the object's size (in bytes) from the metadata.
|
String |
getTitle()
Returns the object's first title field.
|
URI |
getURI()
Returns the URI identifying this object.
|
String |
getURIBasedName()
Creates a local file name based on the object's URI.
|
boolean |
hasEmptyTitle() |
void |
internalSetMetadata(info.textgrid.namespaces.metadata.core._2010.ObjectType metadata,
boolean markDirty)
Internal method that sets the XML fragment that is the basis for this
element.
|
protected void |
invalidateCache()
Invalidate this object's data cache, this MUST be called every time the
backing XML data is modified.
|
boolean |
isAccessible()
This flag determines whether this object is generally considered
accessible, i.e.
|
boolean |
isComplete()
Returns whether the TextGridObject contains a copy of the metadata that
is considered complete, i.e.
|
boolean |
isDeleted()
If true, this object has been deleted.
|
boolean |
isMetadataDirty()
True if this object's metadata has been
modified but not
yet made persistent.
|
boolean |
isNew()
Returns true when this object has not yet been created in the
TextGridRep.
|
boolean |
isPublic()
Checks if the object is public.
|
boolean |
isSubmittable()
Returns whether the user has supplied enough metadata for this object to
be submitted to the repository.
|
boolean |
isToOpenAsReadOnly()
Gives the "open as read only" flag.
|
void |
joinWorkspaceJobs(IProgressMonitor monitor)
Wait for all workspace jobs that have been created for this object.
|
void |
loadMetadata(InputStream source)
Loads this object's metadata from an external source.
|
protected static IPath |
makeLocalPath(IPath path) |
void |
makeMetadataPersistent()
Deprecated.
this is a long-running operation, use
makeMetadataPersistent(IProgressMonitor) instead. |
void |
makeMetadataPersistent(IProgressMonitor monitor)
Pushes the TextGridObject's metadata to the Grid.
|
void |
move(info.textgrid.namespaces.metadata.core._2010.ObjectType newMetadata)
This method is used in two cases: (1) when a new object is created with
TGcrud, (2) when a new version of an object is created.
|
static void |
notifyListeners(TextGridObject.ITextGridObjectListener.Event event,
TextGridObject textGridObject)
THIS IS NOT API, it may only be called from the model or
EFS implementation.
|
void |
notifyMetadataEditor()
Notify the metadata editor, that the metadata of this object has been
changed
|
TextGridObject |
prepareNewRevision(IProgressMonitor monitor)
Prepares a new revision of the object.
|
TextGridObject |
prepareNewVersion(IProgressMonitor monitor)
Prepares a new version of the object.
|
void |
refreshWorkspaceIfNeccessary()
Eclipse's resource framework caches some information about the
IFile s it contains, even if these are links (like our
TextGridObject counterparts). |
protected void |
register()
Registers this object with the object registry.
|
void |
reloadMetadata(boolean force)
Reloads or completes the object's metadata.
|
static void |
removeLatestRegistryItem(URI latest)
Removes an item to the latest URI registry.
|
static void |
removeListener(TextGridObject.ITextGridObjectListener listener)
Removes a listener for object change events.
|
protected void |
resetPermissionCache() |
String |
serialize()
Serializes the object's metadata to an XML string.
|
protected void |
setAccessible(boolean accessible) |
void |
setAdaptor(URI uri)
Sets the hasAdaptor relation to this object to uri.
|
void |
setCollectionMetadata(info.textgrid.namespaces.metadata.agent._2010.PersonType collector,
String abstract_var,
String collectionDescription,
info.textgrid.namespaces.metadata.core._2010.AuthorityType spartial,
info.textgrid.namespaces.metadata.core._2010.AuthorityType temporal,
info.textgrid.namespaces.metadata.core._2010.AuthorityType subject)
Prepares the metadata set of the TextGrid object for a collection.
|
protected void |
setComplete(boolean complete) |
void |
setContentType(TGContentType contentType)
Sets this object's format / content type metadatum to the argument.
|
void |
setEditionMetadata(String isEditionOf,
info.textgrid.namespaces.metadata.agent._2010.AgentType agent,
info.textgrid.namespaces.metadata.core._2010.SourceType source,
info.textgrid.namespaces.metadata.script._2010.FormOfNotationType formOfNotation,
info.textgrid.namespaces.metadata.core._2010.EditionType.License license)
Prepares the metadata set of the TextGrid object for an edition.
|
void |
setIdnoTypeEmpty(boolean empty) |
void |
setInitialContent(byte[] initialContents)
Sets the initial content of a new TextGridObject.
|
void |
setInitialContent(InputStream contentStream,
IProgressMonitor monitor)
Read the initial contents for a TextGridObject from a stream.
|
void |
setItemMetadata(info.textgrid.namespaces.metadata.agent._2010.PersonType rightsHolder)
Prepares the metadata set of the TextGrid object for an item.
|
void |
setMetadata(info.textgrid.namespaces.metadata.core._2010.ObjectType metadata)
Sets this object's metadata.
|
void |
setMetadataDirty(boolean dirty)
DO NOT CALL THIS AT HOME.
|
void |
setMetadataXML(org.apache.axiom.om.OMElement metadataXML)
Deprecated.
use
setMetadata(ObjectType) directly |
void |
setOpenAsReadOnly(boolean value)
Set the "open as read only" flag.
|
void |
setPreviousVersion(URI uri)
Deprecated.
|
void |
setProject(TextGridProject target)
Change the project.
|
void |
setRevisionURI(String revisionURI) |
void |
setSchema(URI uri)
Sets the hasSchema relation of this object to uri,
i.e.
|
protected void |
setSubmittable(boolean submittable) |
void |
setTitle(String value)
Directly sets this object's (first) title field.
|
void |
setTitleEmpty(boolean empty) |
void |
setWorkMetadata(info.textgrid.namespaces.metadata.agent._2010.AgentType agent)
Prepares the metadata set of the TextGrid object for a work.
|
File |
toLocalFile(IProgressMonitor monitor,
boolean reload)
Creates a local (read-only) copy of the document.
|
String |
toString()
Returns a string representation of this object.
|
assertPermission, getNumericPermission, hasPermissions, retrievePermissions
getAdapter
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
assertPermission, hasPermissions
public static final String MOVE_TGOBJECT
public static final String TEXTGRID_METADATA_NAMESPACE
@Deprecated public static final QName CLIENT_NAME
@Deprecated public static final String TEXTGRID_DATERANGE_NAMESPACE
public static String CUSTOM_NAMESPACE
public static final QName METADATA_ROOT_NAME
QName
is passed into the stub's getOMElement method for
tgObjectMetadata as parent qname since this may not be null (or it would
result in an NullPointerException
). It is used to create the
tgObjectMetadata element, because the response types' getTgObjectMetadata
seem to return only the contents of the tgObjectMetadata
element, not the actual element.
Is it possible to retrieve the actual root element?public static final String NO_TITLE
protected TextGridObject(URI uri, boolean readMetadata) throws CrudServiceException
#getInstance(URI)
.uri
- the object's URIreadMetadata
- if true, ask CRUD politely for the complete metadata (this may
be a long-running operation), otherwise, set
isComplete()
to false
.CrudServiceException
- when a call to the service fails.protected TextGridObject(info.textgrid.namespaces.metadata.core._2010.ObjectType metadata) throws CoreException
#getInstance(OMElement)
.
This is a long-running operation with network access.
metadata
- CoreException
- when something goes wrongprotected TextGridObject(String project, String format)
getNewObjectInstance(String, String)
instead.project
- The ID of the project the object lives in.format
- The object's content type.getNewObjectInstance(String, String)
public String toString()
The result of this method is not intended for end users, it should be used in logging and debugging contexts. The following alternative methods also return some kind of string representation of this object:
getURI()
returns the object's uri.serialize()
returns a serialized XML representation of the
object's full metadata.getNameCandidate()
returns a candidate for representing this
object to the user when a name is required.
toString
in class Object
Object.toString()
public void setTitleEmpty(boolean empty)
public void setIdnoTypeEmpty(boolean empty)
public boolean isDeleted()
public boolean isMetadataDirty()
public void setMetadataDirty(boolean dirty)
protected void invalidateCache()
Instances of this class store the TextGrid object's metadata in an XML
representation, like it is read and written from and to the repository.
Frequently accessed fields may be accessed by getter methods like
getProject()
, getTitle()
, getURI()
etc. These
getters walk through (and potentially parse) the XML data the first time
they are called. For further calls the results are cached.
invalidateCache
is automatically called by
#internalSetMetadataXML(OMElement, boolean)
and
#move(OMElement)
.
public boolean isNew()
public void setMetadata(info.textgrid.namespaces.metadata.core._2010.ObjectType metadata)
This method does not make anything persistent, i.e. nothing is written to the repository until one of the following events occur:
makeMetadataPersistent()
The metadata modified using this method is marked as dirty until someone saves it.
TextGridObject
's behaviour is undefined.
getMetadata()
setMetadata(ObjectType)
to set the
TextGridObject
to the modified metadata objectmakeMetadataPersistent()
to write the
metadata to the grid.getMetadata()
may be and setMetadata(ObjectType)
is a long running operation, thus you should perform these steps in a
background job. You should also perform steps 1–3 immediately after one
another in the background job to avoid corrupting other clients' changes.
Clients that use this method to modify metadata MUST ensure that:
administrative/middleware
is left unchanged,
metadata
- root element containing the new metadata. This must be in the
TEXTGRID_METADATA_NAMESPACE
and may not be null.
Clients MUST give up on this object after calling this
method.IllegalArgumentException
- if the given metadata element is not in the correct namespace
(i.e. TEXTGRID_METADATA_NAMESPACE
) or some other
condition required above has been detected as not been metpublic void setMetadataXML(org.apache.axiom.om.OMElement metadataXML)
setMetadata(ObjectType)
directlyObjectType
and then call setMetadata(ObjectType)
metadataXML
- an XML fragment starting at <tgm:object>public void internalSetMetadata(info.textgrid.namespaces.metadata.core._2010.ObjectType metadata, boolean markDirty)
setMetadataXML(OMElement)
.element
- root element containing the new metadata. This must be in the
TEXTGRID_METADATA_NAMESPACE
and may not be null.markDirty
- the new value of the object's isMetadataDirty()
flag.
Only internal methods may set this to false
, and
only if the metadata in element is coming directly
from the TextGridRep (ie TG-search or TG-crud). In all other
events, setMetadataXML(OMElement)
must be called
(which sets the flag to true
).IllegalArgumentException
- if the given metadata element is not in the correct namespace
(i.e. TEXTGRID_METADATA_NAMESPACE
) or some other
condition required above has been detected as not been metpublic void refreshWorkspaceIfNeccessary()
IFile
s it contains, even if these are links (like our
TextGridObject counterparts). If the remote copy has changed, but the
local cache hasn't, our users are likely to get a
Resource out of Sync error message (TG-301).
This method tries to check first if a refresh is neccessary and if true,
tries to perform a refresh of the local file's information.
Note that this method may silently fail (well, almost silently: It logs
an error to eclipse's error log) if a refresh is forbidden by the current
scheduling rules.
Also note that refreshing may happen deferredly in a separate workspace
job.public void makeMetadataPersistent(IProgressMonitor monitor) throws CoreException
This is a long-running operation with network access. Clients should not call this from the UI thread.
CoreException
@Deprecated public void makeMetadataPersistent() throws CoreException
makeMetadataPersistent(IProgressMonitor)
instead.CoreException
public info.textgrid.namespaces.metadata.core._2010.ObjectType getMetadata() throws CrudServiceException
getMetadataForReading()
should be used.CrudServiceException
public info.textgrid.namespaces.metadata.core._2010.ObjectType getMetadataForReading() throws CrudServiceException
getMetadata()
should be used.CrudServiceException
@Deprecated public org.apache.axiom.om.OMElement getMetadataXML() throws CrudServiceException
CrudServiceException
public static info.textgrid.namespaces.metadata.core._2010.ObjectType deepCopy(info.textgrid.namespaces.metadata.core._2010.ObjectType in)
in
- public void loadMetadata(InputStream source) throws CoreException
This method does not replace all metadata. Generally, it cannot be used to change the project or the URI (it is not possible to change these values), and the middleware generated fields (if present) will not be modified, as well.
source
- the stream to load the metadata fromCoreException
public boolean isComplete()
isSubmittable()
.reloadMetadata(boolean)
,
isSubmittable()
protected void setComplete(boolean complete)
public boolean isAccessible()
The value defaults to true
and might be set to
false
when a read operation on the object fails with an
authentication or object not found fault.
Clients may use this to avoid repeated authentication errors on the same object, cf., e.g., TG-897.
false
if a previous attempt to load this object's
metadata during this session has failed, true
otherwise.protected void setAccessible(boolean accessible)
public boolean isSubmittable()
isComplete()
protected void setSubmittable(boolean submittable)
isSubmittable()
public void reloadMetadata(boolean force) throws CrudServiceException
Clients should call this whenever they need a consistent and {linkplain
complete
set of metadata, e.g. before editing.
This is a long-running operation with network access. Clients should not call this from the UI thread.
force
- If false, call TGcrud only if the object does not consider the
metadata to be complete. If true,
TGcrud is called in any case.CrudServiceException
- If the call to crud fails.@Deprecated public static TextGridObject getInstance(org.apache.axiom.om.OMElement element, boolean isComplete) throws CoreException
CoreException
public static TextGridObject getInstance(info.textgrid.namespaces.metadata.core._2010.ObjectType metadata, boolean complete, boolean setMetadata) throws CoreException
In every TextGridLab instance, there is at most one instance of TextGridObject for every TextGridRep object (identified by a unique URI without fragment identifier).
This method does never call TGcrud, i.e. no direct net interaction. As
well, it currently does not update the metadata of TextGridObjects
already existing in the registry, if you want this, call
#internalSetMetadataXML(OMElement, boolean)
on the result.
metadata
- the object's metadata as stored in the repository.
Clients must not modify this object (or anything
referenced from therein) after they have passed it to
this factory method.complete
- clients may only set this to true if they consider the
metadata passed in the metadata
argument as
complete (i.e. TextGridRep does not have 'more' metadata for
the object) and if the said metadata conforms to TextGrid's
metadata schema. Otherwise, clients should set complete to
false.setMetadata
- used to force a replacing of existent metadata with the
delivered ObjectType. Should only be used if it is sure, that
the delivered metadata is newer than the cached one (e.g.
search result)CoreException
- if no URI
has been found or the URI is invalid. This
exception will have a cause
field.
FIXME create specialized exceptionisComplete()
,
#internalSetMetadataXML(OMElement, boolean)
,
reloadMetadata(boolean)
public static TextGridObject getInstance(URI uri, boolean readMetadata) throws CrudServiceException
uri
- the object's URI (from the textgrid
scheme for
TextGridRep objects or from the
textgrid-temporary
scheme for objects yet to be
created). May not be null
.readMetadata
- if true, ask TGcrud politely for the complete metadata (this
may be a long-running operation), otherwise, set
isComplete()
to false
.CrudServiceException
- on errors reading metadata, but only if
readMetadata is true.AssertionFailedException
- if the URI is invalidgetInstance(OMElement, boolean)
,
getInstanceOffline(URI)
,
reloadMetadata(boolean)
protected static TextGridObject getInstanceByHandle(URI handle, boolean readMetadata) throws FileNotFoundException, CoreException
handle
- an URI containing the handle URL of the objectreadMetadata
- if true, read the metadata if we don't know the object yetFileNotFoundException
- if the object has not been found in the repository.CoreException
- if something else goes wrong.public static TextGridObject getInstanceOffline(URI uri)
getInstance(uri, false)
, but it doesn't declare any exceptions.uri
- The TextGridObject's URIAssertionFailedException
- if the URI is not a
valid TextGrid URI.@Deprecated public static TextGridObject getNewObjectInstance(String project, String format)
getNewObjectInstance(TextGridProject, TGContentType)
instead to ensure that the values for project and object are
validgetNewObjectInstance(TextGridProject, TGContentType)
instead.
A call to this method does not yet write something to the grid. it just
represents this object. You will have to set at least the mandatory
metadata fields before storing this object to TextGridRep.
If you need to create contents for this object, please use code like
<code> TextGridObject object = TextGridObject.getNewObjectInstance(project, "text/plain"); IFile file = object.getAdapter(IFile.class); </code>You may now pass this
IFile
to IEditorPart
s etc. Calling
one of the file's setContents
methods saves contents
and metadata to the repository, but fails if you have not
provided the mandatory metadata fields.project
- The id of the project the object lives in.format
- The object's content type.public static TextGridObject getNewObjectInstance(TextGridProject project, TGContentType contentType)
<code> TextGridObject object = TextGridObject.getNewObjectInstance(project, "text/plain"); IFile file = object.getAdapter(IFile.class); </code>You may now pass this
IFile
to IEditorPart
s etc. Calling
one of the file's setContents
methods saves contents
and metadata to the repository, but fails if you have not
provided the mandatory metadata fields.project
- The project the object lives in.format
- The object's content type.public static void addDefaultMetaDataXML(TextGridObject object, String title)
object
- title
- public static TextGridObject getNewObjectInstance(TextGridProject project, TGContentType contentType, String title)
project
- Target project. Must not be null
.contentType
- Target content type. Must not be null
.title
- Title. Must not be null
public Calendar getLastModified() throws CoreException
CoreException
- on an internal error or invalid metadata.public Calendar getCreated() throws CoreException
CoreException
- on an internal error or invalid metadata.public long getSize() throws CoreException
CoreException
public String serialize() throws DataBindingException
DataBindingException
- if something goes wrong while serializing (which shouldn't).public String getProject() throws CoreException
CoreException
public String getDataContributor() throws CoreException
CoreException
public String getCrudWarning() throws CoreException
CoreException
- FIXME there can be several warnings. We just join them here,
but that's probably not optimal.public TextGridProject getProjectInstance() throws CoreException
CoreException
- // FIXME subject to refactoring (Exceptions, Name!?)public String getContentTypeID() throws CoreException
CoreException
public String getNameCandidate() throws CoreException
CoreException
- if one of the underlying getters failspublic String getURIBasedName() throws CoreException
CoreException
- if determining the content type failed.public String getTitle() throws CoreException
NO_TITLE
when no title present -- throwing core
exceptions causes too much trouble currently.CoreException
- FIXME e.g. if the field does not existpublic boolean hasEmptyTitle() throws CoreException
CoreException
public void setTitle(String value)
value
- the new title.public List<String> getAuthors() throws CoreException
CoreException
- with an embedded JaxenException
if extracting the
authors failedpublic URI getURI()
public String getLatestURI()
public String getRevisionNumber()
public URI getEFSURI()
public URI getPreparedURI()
public static void fetchURIs(Iterable<TextGridObject> newObjects, IProgressMonitor monitor) throws CoreException
newObjects
- the new objects for which to fetch URIs.monitor
- progress reportingCoreException
- if something goes wrong (typically CRUD access problems)getPreparedURI()
public void move(info.textgrid.namespaces.metadata.core._2010.ObjectType newMetadata) throws CoreException
newMetadata
- CoreException
public static URI computeEFSURI(URI textGridURI)
computeTextGridURI(computeEFSURI(uri)).equals(uri) == true
for all valid URIs uri.
textGridURI
- public static URI computeTextGridURI(URI efsURI)
efsURI
- public void joinWorkspaceJobs(IProgressMonitor monitor) throws OperationCanceledException, InterruptedException
monitor
- Progress monitor for reporting progress on how the wait is
progressing, or null if no progress monitoring is required.OperationCanceledException
- if the progress monitor is canceled while waitingInterruptedException
- if this thread is interrupted while waitingIJobManager.join(Object, IProgressMonitor)
public void delete(IProgressMonitor monitor) throws CoreException
monitor
- the progress monitor to use for reporting progress to the
user. It is the caller's responsibility to call done() on the
given monitor. Accepts null, indicating that no progress
should be reported and that the operation cannot be cancelled.CoreException
- if something goes wrongpublic static void addListener(TextGridObject.ITextGridObjectListener listener)
listener
- public static void removeListener(TextGridObject.ITextGridObjectListener listener)
listener
- public static void notifyListeners(TextGridObject.ITextGridObjectListener.Event event, TextGridObject textGridObject)
event
- textGridObject
- public TGContentType getContentType(boolean exact) throws CoreException
exact
- if true, return only content types exactly matching the
content type string. Otherwise, if the Lab has not registered
a content type with the object's content type ID, tries to
match a content type object.CoreException
- When reading the object's metadata fails.@Deprecated public TGContentType getContentType() throws CoreException
getContentType(boolean)
instead.CoreException
public void setInitialContent(byte[] initialContents) throws IllegalStateException
The initial contents feature is intended for situations where you want a new TextGridObject to have some content available, but do not want to save the object to the Grid. If you'd use the regular way of setting content, i.e.
IFile file = (IFile) textGridObject.getAdapter(IFile.<b>class</b>); <b>if</b> (file != <b>null</b>) file.setContent(inputStream);
you would cause an attempt to save the file to the grid (which will fail if, e.g., the metadata isn't valid yet). OTOH, you might want to pass some content to arbtrary editors, anyway.
The contents of this file will be returned by code like
IFile file = (IFile) textGridObject.getAdapter(IFile.<b>class</b>); <b>if</b> (file != <b>null</b>) outputStream = file.getContent();
so it will be available in editors etc.
initialContents
- The initial contents.IllegalStateException
- When someone tries to set intial contents of a non-
new object.public void setInitialContent(InputStream contentStream, IProgressMonitor monitor) throws IOException
contentStream
- The stream holding the initial contents.monitor
- the progress monitor to use for reporting progress to the
user. It is the caller's responsibility to call done() on the
given monitor. Accepts null, indicating that no progress
should be reported and that the operation cannot be cancelled.IOException
- on errors while reading from the contentStreamIllegalStateException
- When someone tries to set intial contents of a non-
new object.setInitialContent(byte[])
public byte[] getInitialContent()
public void setSchema(URI uri)
public void setAdaptor(URI uri)
uri
- the URI to the Adaptor of this object.@Deprecated public void setPreviousVersion(URI uri)
uri
- the URI of the object of which this object is a version.@Deprecated public void clearPreviousVersion()
@Deprecated public TextGridObject getPreviousVersion()
null
.
This method doesn't access the repository, if the respective metadatum
isn't there, it returns null
. Call
reloadMetadata(boolean)
first if you really need to be sure.public URI getAdaptor() throws CrudServiceException
null
if
none has been associatedCrudServiceException
public void clearAdaptor() throws CrudServiceException
CrudServiceException
- if reading the object's metadata failspublic URI getSchemaURI() throws CrudServiceException
CrudServiceException
public void deleteSchema()
public File toLocalFile(IProgressMonitor monitor, boolean reload) throws CoreException
monitor
- the progress monitor to use for reporting progress to the
user. It is the caller's responsibility to call done() on the
given monitor. Accepts null, indicating that no progress
should be reported and that the operation cannot be cancelled.reload
- FIXME currently not honoured CoreException
- when some access function failsprotected static void createRecursively(IContainer folder) throws CoreException
CoreException
public int getPermissions() throws CoreException
ITextGridPermission
getPermissions
in interface ITextGridPermission
CoreException
- with further details when something goes wrong determining
the permissions. FIXME: This is subject to TG-23 refactoring.protected void resetPermissionCache()
public boolean isPublic() throws CoreException
CoreException
public void setContentType(TGContentType contentType)
contentType
- the new content type. May not be null.public void setProject(TextGridProject target) throws IllegalStateException
target
- the target projectIllegalStateException
- if the object has already been written to the repositoryprotected void register()
public TextGridObject prepareNewVersion(IProgressMonitor monitor)
If you would like to save an object as a new version (i.e. "Save as"), you need to perform a two-step process:
prepareNewVersion(IProgressMonitor)
creates a
new TextGridObject that represents the new version
and puts this object in new-version-mode. When saving this object's
associated file's contents the next time, the save operation will go to
the new version instead and this object will be reset.
While there is a prepared new version for this object, the new version
can be requested by getPreparedNewVersion()
. To cancel the
creation process, call cancelNewVersion()
.
monitor
- TODOpublic void cancelNewVersion()
public TextGridObject getPreparedNewVersion()
public TextGridObject prepareNewRevision(IProgressMonitor monitor)
If you would like to save an object as a new revision (i.e. "Save as new revision"), you need to perform a two-step process:
prepareNewRevision(IProgressMonitor)
creates a
new TextGridObject that represents the new revision
and puts this object in new-revision-mode. When saving this object's
associated file's contents the next time, the save operation will go to
the new revision instead and this object will be reset.
While there is a prepared new revision for this object, the new revision
can be requested by getPreparedNewRevision()
. To cancel the
creation process, call cancelNewRevision()
.
monitor
- TODOpublic void cancelNewRevision()
public TextGridObject getPreparedNewRevision()
public void setRevisionURI(String revisionURI)
public String getRevisionURI()
public void setEditionMetadata(String isEditionOf, info.textgrid.namespaces.metadata.agent._2010.AgentType agent, info.textgrid.namespaces.metadata.core._2010.SourceType source, info.textgrid.namespaces.metadata.script._2010.FormOfNotationType formOfNotation, info.textgrid.namespaces.metadata.core._2010.EditionType.License license)
isEditonOf
- agent
- should not be nullsource
- formOfNotiation
- license
- should not be nullpublic void setCollectionMetadata(info.textgrid.namespaces.metadata.agent._2010.PersonType collector, String abstract_var, String collectionDescription, info.textgrid.namespaces.metadata.core._2010.AuthorityType spartial, info.textgrid.namespaces.metadata.core._2010.AuthorityType temporal, info.textgrid.namespaces.metadata.core._2010.AuthorityType subject)
collector
- should not be nullabstract_var
- collectionDescription
- spartial
- temporal
- subject
- public void setItemMetadata(info.textgrid.namespaces.metadata.agent._2010.PersonType rightsHolder)
rightsHolder
- should not be nullpublic void setWorkMetadata(info.textgrid.namespaces.metadata.agent._2010.AgentType agent)
agent
- should not be nullpublic static void addLatestRegistryItem(URI latest, URI uri)
latest
- the latest uriuri
- the concret uripublic static void removeLatestRegistryItem(URI latest)
latest
- the latest uripublic void notifyMetadataEditor()
public void setOpenAsReadOnly(boolean value)
value
- public boolean isToOpenAsReadOnly()