Package ghidra.framework.store.local
Class LocalFolderItem
- java.lang.Object
-
- ghidra.framework.store.local.LocalFolderItem
-
- All Implemented Interfaces:
FolderItem
- Direct Known Subclasses:
LocalDatabaseItem
,LocalDataFile
,UnknownFolderItem
public abstract class LocalFolderItem extends java.lang.Object implements FolderItem
LocalFolderItem
provides an abstract implementation of a folder item which resides on a local file-system. An item is defined by a property file and generally has a hidden data directory which contains the actual data file(s).An item may be either private or shared (i.e., versioned) as defined by the associated file-system. A shared item utilizes a CheckoutManager and HistoryManager for tracking version control data related to this item.
-
-
Field Summary
-
Fields inherited from interface ghidra.framework.store.FolderItem
DATABASE_FILE_TYPE, DATAFILE_FILE_TYPE, DEFAULT_CHECKOUT_ID, LATEST_VERSION, UNKNOWN_FILE_TYPE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ItemCheckoutStatus
checkout(CheckoutType checkoutType, java.lang.String user, java.lang.String projectPath)
Checkout this folder item.void
clearCheckout()
Clears the checkout data associated with this non-shared file.void
delete(int version, java.lang.String user)
Deletes the item or a specific version.boolean
equals(java.lang.Object obj)
ItemCheckoutStatus
getCheckout(long checkoutId)
Get the checkout status which corresponds to the specified checkout ID.long
getCheckoutId()
Returns the checkoutId for this file.ItemCheckoutStatus[]
getCheckouts()
Get all current checkouts for this item.int
getCheckoutVersion()
Returns the item version which was checked-out.java.lang.String
getContentType()
Return The content type name for this item.int
getContentTypeVersion()
Returns the version of content type.java.lang.String
getFileID()
Return the file ID if one has been established or nullint
getLocalCheckoutVersion()
Returns the local item version at the time the checkout was completed.java.lang.String
getName()
Return The display name for this item.java.lang.String
getParentPath()
Returns the path of the parent folder.java.lang.String
getPathName()
Return The concatenation of the pathname and the basename which can be used to uniquely identify a folder item.Version[]
getVersions()
Returns list of all available versions or null if item is not versioned.boolean
hasCheckouts()
Returns true if this item is versioned and has one or more checkouts.boolean
isCheckedOut()
Returns true if this item is a checked-out copy from a versioned file system.boolean
isCheckedOutExclusive()
Returns true if this item is a checked-out copy with exclusive access from a versioned file system.boolean
isCheckinActive()
Returns true if this item is versioned and has a checkin in-progress.boolean
isReadOnly()
Returns true if item can be overwritten/deleted.boolean
isVersioned()
Return true if this is a versioned item, else falselong
lastModified()
Return The time that this item was last modified.LocalFolderItem
refresh()
Returns this instance after refresh or null if item no longer existsjava.lang.String
resetFileID()
Assign a new file-ID to this local non-versioned file.void
setCheckout(long checkoutId, boolean exclusive, int checkoutVersion, int localVersion)
Set the checkout data associated with this non-shared file.void
setContentTypeVersion(int version)
Sets the version for the content type.void
setReadOnly(boolean state)
Set the state of the read-only indicator for this non-shared item.void
terminateCheckout(long checkoutId, boolean notify)
Terminates a checkout.abstract void
updateCheckout(FolderItem versionedFolderItem, boolean updateItem, TaskMonitor monitor)
Update this non-versioned item with the latest version of the specified versioned item.abstract void
updateCheckout(FolderItem item, int checkoutVersion)
Update this non-versioned item with the contents of the specified item which must be within the same non-versioned fileSystem.void
updateCheckoutVersion(long checkoutId, int checkoutVersion, java.lang.String user)
Update the checkout version associated with this versioned item.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ghidra.framework.store.FolderItem
canRecover, getCurrentVersion, length, output
-
-
-
-
Method Detail
-
refresh
public LocalFolderItem refresh() throws java.io.IOException
Description copied from interface:FolderItem
Returns this instance after refresh or null if item no longer exists- Specified by:
refresh
in interfaceFolderItem
- Throws:
java.io.IOException
-
delete
public void delete(int version, java.lang.String user) throws java.io.IOException
Description copied from interface:FolderItem
Deletes the item or a specific version. If a specific version is specified, it must either be the oldest or latest (i.e., current).- Specified by:
delete
in interfaceFolderItem
- Parameters:
version
- specific version to be deleted, or -1 to remove all versions.user
- user name- Throws:
java.io.IOException
- if an IO error occurs, including the inability to delete a version because this item is checked-out, the user does not have permission, or the specified version is not the oldest or latest.- See Also:
FolderItem.delete(int, java.lang.String)
-
getContentType
public java.lang.String getContentType()
Description copied from interface:FolderItem
Return The content type name for this item.- Specified by:
getContentType
in interfaceFolderItem
- See Also:
FolderItem.getContentType()
-
getFileID
public java.lang.String getFileID()
Description copied from interface:FolderItem
Return the file ID if one has been established or null- Specified by:
getFileID
in interfaceFolderItem
- See Also:
FolderItem.getFileID()
-
resetFileID
public java.lang.String resetFileID() throws java.io.IOException
Description copied from interface:FolderItem
Assign a new file-ID to this local non-versioned file. NOTE: This method is only valid for a local non-versioned file-system.- Specified by:
resetFileID
in interfaceFolderItem
- Returns:
- new file-ID
- Throws:
java.io.IOException
- thrown if IO or access error occurs- See Also:
FolderItem.resetFileID()
-
getName
public java.lang.String getName()
Description copied from interface:FolderItem
Return The display name for this item.- Specified by:
getName
in interfaceFolderItem
- See Also:
FolderItem.getName()
-
getParentPath
public java.lang.String getParentPath()
Description copied from interface:FolderItem
Returns the path of the parent folder.- Specified by:
getParentPath
in interfaceFolderItem
- See Also:
FolderItem.getParentPath()
-
getPathName
public java.lang.String getPathName()
Description copied from interface:FolderItem
Return The concatenation of the pathname and the basename which can be used to uniquely identify a folder item.- Specified by:
getPathName
in interfaceFolderItem
- See Also:
FolderItem.getPathName()
-
isCheckedOut
public boolean isCheckedOut()
Description copied from interface:FolderItem
Returns true if this item is a checked-out copy from a versioned file system.- Specified by:
isCheckedOut
in interfaceFolderItem
- See Also:
FolderItem.isCheckedOut()
-
isCheckedOutExclusive
public boolean isCheckedOutExclusive()
Description copied from interface:FolderItem
Returns true if this item is a checked-out copy with exclusive access from a versioned file system.- Specified by:
isCheckedOutExclusive
in interfaceFolderItem
-
isVersioned
public boolean isVersioned() throws java.io.IOException
Description copied from interface:FolderItem
Return true if this is a versioned item, else false- Specified by:
isVersioned
in interfaceFolderItem
- Throws:
java.io.IOException
- thrown if an IO error occurs.- See Also:
FolderItem.isVersioned()
-
getVersions
public Version[] getVersions() throws java.io.IOException
Description copied from interface:FolderItem
Returns list of all available versions or null if item is not versioned.- Specified by:
getVersions
in interfaceFolderItem
- Throws:
java.io.IOException
- thrown if an IO error occurs.- See Also:
FolderItem.getVersions()
-
lastModified
public long lastModified()
Description copied from interface:FolderItem
Return The time that this item was last modified.- Specified by:
lastModified
in interfaceFolderItem
- See Also:
FolderItem.lastModified()
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:FolderItem
Returns true if item can be overwritten/deleted.- Specified by:
isReadOnly
in interfaceFolderItem
- See Also:
FolderItem.isReadOnly()
-
setReadOnly
public void setReadOnly(boolean state) throws java.io.IOException
Description copied from interface:FolderItem
Set the state of the read-only indicator for this non-shared item.- Specified by:
setReadOnly
in interfaceFolderItem
- Parameters:
state
- read-only state- Throws:
java.io.IOException
- if an IO error occurs or item is stored on a shared file-system- See Also:
FolderItem.setReadOnly(boolean)
-
getContentTypeVersion
public int getContentTypeVersion()
Description copied from interface:FolderItem
Returns the version of content type. Note this is the version of the structure/storage for the content type, Not the users version of their data.- Specified by:
getContentTypeVersion
in interfaceFolderItem
-
setContentTypeVersion
public void setContentTypeVersion(int version) throws java.io.IOException
Description copied from interface:FolderItem
Sets the version for the content type. This will change whenever the domain objects are upgraded.- Specified by:
setContentTypeVersion
in interfaceFolderItem
- Parameters:
version
- the new version for the content type.- Throws:
java.io.IOException
- if an IO error occurs or item is stored on a shared file-system
-
checkout
public ItemCheckoutStatus checkout(CheckoutType checkoutType, java.lang.String user, java.lang.String projectPath) throws java.io.IOException
Description copied from interface:FolderItem
Checkout this folder item.- Specified by:
checkout
in interfaceFolderItem
- Parameters:
checkoutType
- type of checkoutuser
- user requesting checkoutprojectPath
- path of project where checkout was made- Returns:
- checkout status or null if exclusive checkout request failed
- Throws:
java.io.IOException
- if an IO error occurs or this item is not versioned
-
terminateCheckout
public void terminateCheckout(long checkoutId, boolean notify) throws java.io.IOException
Description copied from interface:FolderItem
Terminates a checkout. The checkout ID becomes invalid, therefore the associated checkout copy should either be removed or converted to a private file.- Specified by:
terminateCheckout
in interfaceFolderItem
- Parameters:
checkoutId
- checkout IDnotify
- if true item change notification will be sent- Throws:
java.io.IOException
- if an IO error occurs or this item is not versioned
-
getCheckout
public ItemCheckoutStatus getCheckout(long checkoutId) throws java.io.IOException
Description copied from interface:FolderItem
Get the checkout status which corresponds to the specified checkout ID.- Specified by:
getCheckout
in interfaceFolderItem
- Parameters:
checkoutId
- checkout ID- Returns:
- checkout status or null if checkout ID not found.
- Throws:
java.io.IOException
- if an IO error occurs or this item is not versioned
-
getCheckouts
public ItemCheckoutStatus[] getCheckouts() throws java.io.IOException
Description copied from interface:FolderItem
Get all current checkouts for this item.- Specified by:
getCheckouts
in interfaceFolderItem
- Returns:
- array of checkouts
- Throws:
java.io.IOException
- if an IO error occurs or this item is not versioned
-
getCheckoutId
public long getCheckoutId()
Description copied from interface:FolderItem
Returns the checkoutId for this file. A value of -1 indicates a private item. NOTE: This method is only valid for a local non-versioned file-system.- Specified by:
getCheckoutId
in interfaceFolderItem
-
getCheckoutVersion
public int getCheckoutVersion() throws java.io.IOException
Description copied from interface:FolderItem
Returns the item version which was checked-out. A value of -1 indicates a private item. NOTE: This method is only valid for a local non-versioned file-system.- Specified by:
getCheckoutVersion
in interfaceFolderItem
- Throws:
java.io.IOException
-
getLocalCheckoutVersion
public int getLocalCheckoutVersion()
Description copied from interface:FolderItem
Returns the local item version at the time the checkout was completed. A value of -1 indicates a private item. NOTE: This method is only valid for a local non-versioned file-system.- Specified by:
getLocalCheckoutVersion
in interfaceFolderItem
-
setCheckout
public void setCheckout(long checkoutId, boolean exclusive, int checkoutVersion, int localVersion) throws java.io.IOException
Description copied from interface:FolderItem
Set the checkout data associated with this non-shared file. NOTE: This method is only valid for a local non-versioned file-system.- Specified by:
setCheckout
in interfaceFolderItem
- Parameters:
checkoutId
- checkout ID (provided by ItemCheckoutStatus).exclusive
- true if checkout is exclusivecheckoutVersion
- the item version which was checked-out (provided by ItemCheckoutStatus).localVersion
- the local item version at the time the checkout was completed.- Throws:
java.io.IOException
- if an IO error occurs or item is stored on a shared file-system
-
clearCheckout
public void clearCheckout() throws java.io.IOException
Description copied from interface:FolderItem
Clears the checkout data associated with this non-shared file. NOTE: This method is only valid for a local non-versioned file-system.- Specified by:
clearCheckout
in interfaceFolderItem
- Throws:
java.io.IOException
-
hasCheckouts
public boolean hasCheckouts()
Description copied from interface:FolderItem
Returns true if this item is versioned and has one or more checkouts.- Specified by:
hasCheckouts
in interfaceFolderItem
-
isCheckinActive
public boolean isCheckinActive()
Description copied from interface:FolderItem
Returns true if this item is versioned and has a checkin in-progress.- Specified by:
isCheckinActive
in interfaceFolderItem
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
updateCheckout
public abstract void updateCheckout(FolderItem versionedFolderItem, boolean updateItem, TaskMonitor monitor) throws java.io.IOException, CancelledException
Update this non-versioned item with the latest version of the specified versioned item.- Parameters:
versionedFolderItem
- versioned item which corresponds to this non-versioned item.updateItem
- if true this items content is updated using the versionedFolderItemmonitor
- progress monitor for update- Throws:
java.io.IOException
- if this file is not a checked-out non-versioned file or an IO error occurs.CancelledException
- if monitor cancels operation
-
updateCheckout
public abstract void updateCheckout(FolderItem item, int checkoutVersion) throws java.io.IOException
Update this non-versioned item with the contents of the specified item which must be within the same non-versioned fileSystem. If successful, the specified item will be removed after its content has been moved into this item.- Parameters:
item
-checkoutVersion
-- Throws:
java.io.IOException
- if this file is not a checked-out non-versioned file or an IO error occurs.
-
updateCheckoutVersion
public void updateCheckoutVersion(long checkoutId, int checkoutVersion, java.lang.String user) throws java.io.IOException
Description copied from interface:FolderItem
Update the checkout version associated with this versioned item.- Specified by:
updateCheckoutVersion
in interfaceFolderItem
- Parameters:
checkoutId
- id corresponding to an existing checkout- Throws:
java.io.IOException
- if an IO error occurs.
-
-