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