mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-4455 Changed RemoteFileItem to cache FileID
This commit is contained in:
parent
26d3a2bc79
commit
b8cc7abea1
3 changed files with 56 additions and 118 deletions
|
@ -48,6 +48,7 @@ public class RepositoryItem implements java.io.Serializable {
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param folderPath path of folder containing item.
|
* @param folderPath path of folder containing item.
|
||||||
* @param itemName name of item
|
* @param itemName name of item
|
||||||
|
* @param fileID unique file ID
|
||||||
* @param itemType type of item (FILE or DATABASE)
|
* @param itemType type of item (FILE or DATABASE)
|
||||||
* @param contentType content type associated with item
|
* @param contentType content type associated with item
|
||||||
* @param version repository item version or -1 if versioning not supported
|
* @param version repository item version or -1 if versioning not supported
|
||||||
|
@ -66,8 +67,8 @@ public class RepositoryItem implements java.io.Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialization method
|
* Serialization method
|
||||||
* @param out
|
* @param out serialization output stream
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
|
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
|
||||||
out.writeLong(serialVersionUID);
|
out.writeLong(serialVersionUID);
|
||||||
|
@ -82,9 +83,9 @@ public class RepositoryItem implements java.io.Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deserialization method
|
* Deserialization method
|
||||||
* @param in
|
* @param in deserialization input stream
|
||||||
* @throws IOException
|
* @throws IOException if IO error occurs
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException if unrecognized serialVersionUID detected
|
||||||
*/
|
*/
|
||||||
private void readObject(java.io.ObjectInputStream in) throws IOException,
|
private void readObject(java.io.ObjectInputStream in) throws IOException,
|
||||||
ClassNotFoundException {
|
ClassNotFoundException {
|
||||||
|
|
|
@ -57,13 +57,13 @@ public class RemoteDatabaseItem extends RemoteFolderItem implements DatabaseItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManagedBufferFileAdapter open(int version, int minChangeDataVer) throws IOException {
|
public ManagedBufferFileAdapter open(int fileVersion, int minChangeDataVer) throws IOException {
|
||||||
return repository.openDatabase(parentPath, itemName, version, minChangeDataVer);
|
return repository.openDatabase(parentPath, itemName, fileVersion, minChangeDataVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManagedBufferFileAdapter open(int version) throws IOException {
|
public ManagedBufferFileAdapter open(int fileVersion) throws IOException {
|
||||||
return repository.openDatabase(parentPath, itemName, version, -1);
|
return repository.openDatabase(parentPath, itemName, fileVersion, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,9 +82,6 @@ public class RemoteDatabaseItem extends RemoteFolderItem implements DatabaseItem
|
||||||
repository.updateCheckoutVersion(parentPath, itemName, checkoutId, checkoutVersion);
|
repository.updateCheckoutVersion(parentPath, itemName, checkoutId, checkoutVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ghidra.framework.store.FolderItem#hasCheckouts()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCheckouts() throws IOException {
|
public boolean hasCheckouts() throws IOException {
|
||||||
return repository.hasCheckouts(parentPath, itemName);
|
return repository.hasCheckouts(parentPath, itemName);
|
||||||
|
@ -96,10 +93,10 @@ public class RemoteDatabaseItem extends RemoteFolderItem implements DatabaseItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void output(File outputFile, int version, TaskMonitor monitor)
|
public void output(File outputFile, int fileVersion, TaskMonitor monitor)
|
||||||
throws IOException, CancelledException {
|
throws IOException, CancelledException {
|
||||||
|
|
||||||
BufferFile bf = repository.openDatabase(parentPath, itemName, version, -1);
|
BufferFile bf = repository.openDatabase(parentPath, itemName, fileVersion, -1);
|
||||||
try {
|
try {
|
||||||
File tmpFile = File.createTempFile("ghidra", LocalBufferFile.TEMP_FILE_EXT);
|
File tmpFile = File.createTempFile("ghidra", LocalBufferFile.TEMP_FILE_EXT);
|
||||||
tmpFile.delete();
|
tmpFile.delete();
|
||||||
|
@ -108,18 +105,10 @@ public class RemoteDatabaseItem extends RemoteFolderItem implements DatabaseItem
|
||||||
LocalBufferFile.copyFile(bf, tmpBf, null, monitor);
|
LocalBufferFile.copyFile(bf, tmpBf, null, monitor);
|
||||||
tmpBf.close();
|
tmpBf.close();
|
||||||
|
|
||||||
InputStream itemIn = new FileInputStream(tmpFile);
|
try (InputStream itemIn = new FileInputStream(tmpFile)) {
|
||||||
try {
|
|
||||||
ItemSerializer.outputItem(getName(), getContentType(), DATABASE_FILE_TYPE,
|
ItemSerializer.outputItem(getName(), getContentType(), DATABASE_FILE_TYPE,
|
||||||
tmpFile.length(), itemIn, outputFile, monitor);
|
tmpFile.length(), itemIn, outputFile, monitor);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
itemIn.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tmpBf.close();
|
tmpBf.close();
|
||||||
|
|
|
@ -27,9 +27,11 @@ import ghidra.framework.store.*;
|
||||||
*/
|
*/
|
||||||
public abstract class RemoteFolderItem implements FolderItem {
|
public abstract class RemoteFolderItem implements FolderItem {
|
||||||
|
|
||||||
protected String parentPath;
|
protected final String parentPath;
|
||||||
protected String itemName;
|
protected final String itemName;
|
||||||
protected String contentType;
|
protected final String contentType;
|
||||||
|
protected final String fileID;
|
||||||
|
|
||||||
protected int version;
|
protected int version;
|
||||||
protected long versionTime;
|
protected long versionTime;
|
||||||
|
|
||||||
|
@ -45,26 +47,26 @@ public abstract class RemoteFolderItem implements FolderItem {
|
||||||
parentPath = item.getParentPath();
|
parentPath = item.getParentPath();
|
||||||
itemName = item.getName();
|
itemName = item.getName();
|
||||||
contentType = item.getContentType();
|
contentType = item.getContentType();
|
||||||
|
fileID = item.getFileID();
|
||||||
|
|
||||||
version = item.getVersion();
|
version = item.getVersion();
|
||||||
versionTime = item.getVersionTime();
|
versionTime = item.getVersionTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the item type as defined by RepositoryItem.
|
* Returns the item type as defined by RepositoryItem which corresponds to specific
|
||||||
|
* implementation of this class.
|
||||||
|
* @return item type (Only {@link RepositoryItem#DATABASE} is supported).
|
||||||
* @see ghidra.framework.remote.RepositoryItem
|
* @see ghidra.framework.remote.RepositoryItem
|
||||||
*/
|
*/
|
||||||
abstract int getItemType();
|
abstract int getItemType();
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getName()
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return itemName;
|
return itemName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#refresh()
|
|
||||||
*/
|
|
||||||
public RemoteFolderItem refresh() throws IOException {
|
public RemoteFolderItem refresh() throws IOException {
|
||||||
RepositoryItem item = repository.getItem(parentPath, itemName);
|
RepositoryItem item = repository.getItem(parentPath, itemName);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
@ -75,42 +77,27 @@ public abstract class RemoteFolderItem implements FolderItem {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @throws IOException
|
public String getFileID() {
|
||||||
* @see ghidra.framework.store.FolderItem#getFileID()
|
return fileID;
|
||||||
*/
|
|
||||||
public String getFileID() throws IOException {
|
|
||||||
RepositoryItem item = repository.getItem(parentPath, itemName);
|
|
||||||
if (item != null) {
|
|
||||||
return item.getFileID();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#resetFileID()
|
|
||||||
*/
|
|
||||||
public String resetFileID() {
|
public String resetFileID() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getContentType()
|
|
||||||
*/
|
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return contentType;
|
return contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getParentPath()
|
|
||||||
*/
|
|
||||||
public String getParentPath() {
|
public String getParentPath() {
|
||||||
return parentPath;
|
return parentPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getPathName()
|
|
||||||
*/
|
|
||||||
public String getPathName() {
|
public String getPathName() {
|
||||||
String path = parentPath;
|
String path = parentPath;
|
||||||
if (path.length() != 1) {
|
if (path.length() != 1) {
|
||||||
|
@ -119,149 +106,110 @@ public abstract class RemoteFolderItem implements FolderItem {
|
||||||
return path + itemName;
|
return path + itemName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#isReadOnly()
|
|
||||||
*/
|
|
||||||
public boolean isReadOnly() {
|
public boolean isReadOnly() {
|
||||||
throw new UnsupportedOperationException("isReadOnly is not applicable to versioned item");
|
throw new UnsupportedOperationException("isReadOnly is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#setReadOnly(boolean)
|
|
||||||
*/
|
|
||||||
public void setReadOnly(boolean state) {
|
public void setReadOnly(boolean state) {
|
||||||
throw new UnsupportedOperationException("setReadOnly is not applicable to versioned item");
|
throw new UnsupportedOperationException("setReadOnly is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
public int getContentTypeVersion() {
|
public int getContentTypeVersion() {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"getContentTypeVersion is not applicable to versioned item");
|
"getContentTypeVersion is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#setContentTypeVersion(int)
|
|
||||||
*/
|
|
||||||
public void setContentTypeVersion(int version) throws IOException {
|
public void setContentTypeVersion(int version) throws IOException {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"setContentTypeVersion is not applicable to versioned item");
|
"setContentTypeVersion is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#lastModified()
|
|
||||||
*/
|
|
||||||
public long lastModified() {
|
public long lastModified() {
|
||||||
return versionTime;
|
return versionTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getCurrentVersion()
|
|
||||||
*/
|
|
||||||
public int getCurrentVersion() {
|
public int getCurrentVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#isVersioned()
|
|
||||||
*/
|
|
||||||
public boolean isVersioned() {
|
public boolean isVersioned() {
|
||||||
return (version != -1);
|
return (version != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getVersions()
|
|
||||||
*/
|
|
||||||
public Version[] getVersions() throws IOException {
|
public Version[] getVersions() throws IOException {
|
||||||
return repository.getVersions(parentPath, itemName);
|
return repository.getVersions(parentPath, itemName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#delete(int, java.lang.String)
|
|
||||||
*/
|
|
||||||
public void delete(int ver, String user) throws IOException {
|
public void delete(int ver, String user) throws IOException {
|
||||||
repository.deleteItem(parentPath, itemName, ver);
|
repository.deleteItem(parentPath, itemName, ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#isPrivate()
|
|
||||||
*/
|
|
||||||
public boolean isCheckedOut() {
|
public boolean isCheckedOut() {
|
||||||
throw new UnsupportedOperationException("isCheckedOut is not applicable to versioned item");
|
throw new UnsupportedOperationException("isCheckedOut is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#isCheckedOutExclusive()
|
|
||||||
*/
|
|
||||||
public boolean isCheckedOutExclusive() {
|
public boolean isCheckedOutExclusive() {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"isCheckedOutExclusive is not applicable to versioned item");
|
"isCheckedOutExclusive is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#checkout(boolean, java.lang.String, java.lang.String)
|
|
||||||
*/
|
|
||||||
public ItemCheckoutStatus checkout(CheckoutType checkoutType, String user, String projectPath)
|
public ItemCheckoutStatus checkout(CheckoutType checkoutType, String user, String projectPath)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return repository.checkout(parentPath, itemName, checkoutType, projectPath);
|
return repository.checkout(parentPath, itemName, checkoutType, projectPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#terminateCheckout(long, boolean)
|
|
||||||
*/
|
|
||||||
public void terminateCheckout(long checkoutId, boolean notify) throws IOException {
|
public void terminateCheckout(long checkoutId, boolean notify) throws IOException {
|
||||||
repository.terminateCheckout(parentPath, itemName, checkoutId, notify);
|
repository.terminateCheckout(parentPath, itemName, checkoutId, notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getCheckout(long)
|
|
||||||
*/
|
|
||||||
public ItemCheckoutStatus getCheckout(long checkoutId) throws IOException {
|
public ItemCheckoutStatus getCheckout(long checkoutId) throws IOException {
|
||||||
return repository.getCheckout(parentPath, itemName, checkoutId);
|
return repository.getCheckout(parentPath, itemName, checkoutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getCheckouts()
|
|
||||||
*/
|
|
||||||
public ItemCheckoutStatus[] getCheckouts() throws IOException {
|
public ItemCheckoutStatus[] getCheckouts() throws IOException {
|
||||||
return repository.getCheckouts(parentPath, itemName);
|
return repository.getCheckouts(parentPath, itemName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#clearCheckout()
|
|
||||||
*/
|
|
||||||
public void clearCheckout() throws IOException {
|
public void clearCheckout() throws IOException {
|
||||||
throw new UnsupportedOperationException("clearCheckout is not applicable to versioned item");
|
throw new UnsupportedOperationException(
|
||||||
|
"clearCheckout is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getCheckoutId()
|
|
||||||
*/
|
|
||||||
public long getCheckoutId() throws IOException {
|
public long getCheckoutId() throws IOException {
|
||||||
throw new UnsupportedOperationException("getCheckoutId is not applicable to versioned item");
|
throw new UnsupportedOperationException(
|
||||||
|
"getCheckoutId is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getCheckoutVersion()
|
|
||||||
*/
|
|
||||||
public int getCheckoutVersion() throws IOException {
|
public int getCheckoutVersion() throws IOException {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"getCheckoutVersion is not applicable to versioned item");
|
"getCheckoutVersion is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#getLocalCheckoutVersion()
|
|
||||||
*/
|
|
||||||
public int getLocalCheckoutVersion() {
|
public int getLocalCheckoutVersion() {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"getLocalCheckoutVersion is not applicable to versioned item");
|
"getLocalCheckoutVersion is not applicable to versioned item");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see ghidra.framework.store.FolderItem#setCheckout(long, boolean, int, int)
|
|
||||||
*/
|
|
||||||
public void setCheckout(long checkoutId, boolean exclusive, int checkoutVersion,
|
public void setCheckout(long checkoutId, boolean exclusive, int checkoutVersion,
|
||||||
int localVersion) throws IOException {
|
int localVersion) throws IOException {
|
||||||
throw new UnsupportedOperationException("setCheckout is not applicable to versioned item");
|
throw new UnsupportedOperationException("setCheckout is not applicable to versioned item");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue