Skip to content
Snippets Groups Projects
Unverified Commit 729fbdf9 authored by Richard Cordovano's avatar Richard Cordovano Committed by GitHub
Browse files

Merge pull request #2269 from rcordovano/7415-reformat-AbstractFile.java

7415 reformat AbstractFile.java
parents 11b904c1 8375e636
No related branches found
No related tags found
No related merge requests found
...@@ -99,9 +99,10 @@ public abstract class AbstractFile extends AbstractContent { ...@@ -99,9 +99,10 @@ public abstract class AbstractFile extends AbstractContent {
private boolean loadedAttributesCacheFromDb = false; private boolean loadedAttributesCacheFromDb = false;
private final String ownerUid; // string owner uid, for example a Windows SID. private final String ownerUid; // string owner uid, for example a Windows SID.
// different from the numeric uid which is more commonly found // different from the numeric uid which is more commonly found
// on Unix based file systems. // on Unix based file systems.
private final Long osAccountObjId; // obj id of the owner's OS account, may be null private final Long osAccountObjId; // obj id of the owner's OS account, may be null
/** /**
* Initializes common fields used by AbstactFile implementations (objects in * Initializes common fields used by AbstactFile implementations (objects in
* tsk_files table) * tsk_files table)
...@@ -522,12 +523,14 @@ public void setSha256Hash(String sha256Hash) { ...@@ -522,12 +523,14 @@ public void setSha256Hash(String sha256Hash) {
*/ */
public String getSha256Hash() { public String getSha256Hash() {
return this.sha256Hash; return this.sha256Hash;
} }
/** /**
* Gets the attributes of this File * Gets the attributes of this File
*
* @return * @return
* @throws TskCoreException *
* @throws TskCoreException
*/ */
public List<Attribute> getAttributes() throws TskCoreException { public List<Attribute> getAttributes() throws TskCoreException {
synchronized (this) { synchronized (this) {
...@@ -542,17 +545,17 @@ public List<Attribute> getAttributes() throws TskCoreException { ...@@ -542,17 +545,17 @@ public List<Attribute> getAttributes() throws TskCoreException {
} }
/** /**
* Adds a collection of attributes to this file in a single operation * Adds a collection of attributes to this file in a single operation within
* within a transaction supplied by the caller. * a transaction supplied by the caller.
* *
* @param attributes The collection of attributes. * @param attributes The collection of attributes.
* @param caseDbTransaction The transaction in the scope of which the * @param caseDbTransaction The transaction in the scope of which the
* operation is to be performed, managed by the * operation is to be performed, managed by the
* caller. if Null is passed in a local transaction * caller. if Null is passed in a local transaction
* will be created and used. * will be created and used.
* *
* @throws TskCoreException If an error occurs and the attributes * @throws TskCoreException If an error occurs and the attributes were not
* were not added to the artifact. * added to the artifact.
*/ */
public void addAttributes(Collection<Attribute> attributes, final SleuthkitCase.CaseDbTransaction caseDbTransaction) throws TskCoreException { public void addAttributes(Collection<Attribute> attributes, final SleuthkitCase.CaseDbTransaction caseDbTransaction) throws TskCoreException {
...@@ -560,17 +563,17 @@ public void addAttributes(Collection<Attribute> attributes, final SleuthkitCase. ...@@ -560,17 +563,17 @@ public void addAttributes(Collection<Attribute> attributes, final SleuthkitCase.
throw new TskCoreException("Illegal Argument passed to addAttributes: null or empty attributes passed to addAttributes"); throw new TskCoreException("Illegal Argument passed to addAttributes: null or empty attributes passed to addAttributes");
} }
boolean isLocalTransaction = Objects.isNull(caseDbTransaction); boolean isLocalTransaction = Objects.isNull(caseDbTransaction);
SleuthkitCase.CaseDbTransaction localTransaction = isLocalTransaction ? getSleuthkitCase().beginTransaction() : null; SleuthkitCase.CaseDbTransaction localTransaction = isLocalTransaction ? getSleuthkitCase().beginTransaction() : null;
SleuthkitCase.CaseDbConnection connection = isLocalTransaction ? localTransaction.getConnection() : caseDbTransaction.getConnection(); SleuthkitCase.CaseDbConnection connection = isLocalTransaction ? localTransaction.getConnection() : caseDbTransaction.getConnection();
try { try {
for (final Attribute attribute : attributes) { for (final Attribute attribute : attributes) {
attribute.setAttributeParentId(getId()); attribute.setAttributeParentId(getId());
attribute.setCaseDatabase(getSleuthkitCase()); attribute.setCaseDatabase(getSleuthkitCase());
getSleuthkitCase().addFileAttribute(attribute, connection); getSleuthkitCase().addFileAttribute(attribute, connection);
} }
if(isLocalTransaction) { if (isLocalTransaction) {
localTransaction.commit(); localTransaction.commit();
localTransaction = null; localTransaction = null;
} }
...@@ -591,7 +594,7 @@ public void addAttributes(Collection<Attribute> attributes, final SleuthkitCase. ...@@ -591,7 +594,7 @@ public void addAttributes(Collection<Attribute> attributes, final SleuthkitCase.
throw new TskCoreException("Error adding file attributes", ex); throw new TskCoreException("Error adding file attributes", ex);
} }
} }
/** /**
* Sets the known state for this file. Passed in value will be ignored if it * Sets the known state for this file. Passed in value will be ignored if it
* is "less" than the current state. A NOTABLE file cannot be downgraded to * is "less" than the current state. A NOTABLE file cannot be downgraded to
...@@ -729,7 +732,7 @@ public long convertToImgOffset(long fileOffset) throws TskCoreException { ...@@ -729,7 +732,7 @@ public long convertToImgOffset(long fileOffset) throws TskCoreException {
/** /**
* Converts a file offset and length into a series of TskFileRange objects * Converts a file offset and length into a series of TskFileRange objects
* whose offsets are relative to the image. This method will only work on * whose offsets are relative to the image. This method will only work on
* files with layout ranges. * files with layout ranges.
* *
* @param fileOffset The byte offset in this file to map. * @param fileOffset The byte offset in this file to map.
...@@ -777,7 +780,7 @@ public List<TskFileRange> convertToImgRanges(long fileOffset, long length) throw ...@@ -777,7 +780,7 @@ public List<TskFileRange> convertToImgRanges(long fileOffset, long length) throw
// how much this current range exceeds the length requested (or 0 if within the length requested) // how much this current range exceeds the length requested (or 0 if within the length requested)
long rangeOvershoot = Math.max(0, curRangeEnd - requestedEnd); long rangeOvershoot = Math.max(0, curRangeEnd - requestedEnd);
long newRangeLen = curRangeLen - rangeOffset - rangeOvershoot; long newRangeLen = curRangeLen - rangeOffset - rangeOvershoot;
toRet.add(new TskFileRange(newRangeStart, newRangeLen, toRet.size())); toRet.add(new TskFileRange(newRangeStart, newRangeLen, toRet.size()));
} }
...@@ -932,13 +935,13 @@ public String getDirFlagAsString() { ...@@ -932,13 +935,13 @@ public String getDirFlagAsString() {
/** /**
* Set the directory name flag. * Set the directory name flag.
* *
* @param flag Flag to set to. * @param flag Flag to set to.
*/ */
void setDirFlag(TSK_FS_NAME_FLAG_ENUM flag) { void setDirFlag(TSK_FS_NAME_FLAG_ENUM flag) {
dirFlag = flag; dirFlag = flag;
} }
/** /**
* @return a string representation of the meta flags * @return a string representation of the meta flags
*/ */
...@@ -962,33 +965,32 @@ public boolean isMetaFlagSet(TSK_FS_META_FLAG_ENUM metaFlag) { ...@@ -962,33 +965,32 @@ public boolean isMetaFlagSet(TSK_FS_META_FLAG_ENUM metaFlag) {
} }
/** /**
* Set the specified meta flag. * Set the specified meta flag.
* *
* @param metaFlag Meta flag to set * @param metaFlag Meta flag to set
*/ */
void setMetaFlag(TSK_FS_META_FLAG_ENUM metaFlag) { void setMetaFlag(TSK_FS_META_FLAG_ENUM metaFlag) {
metaFlags.add(metaFlag); metaFlags.add(metaFlag);
} }
/** /**
* Remove the specified meta flag. * Remove the specified meta flag.
* *
* @param metaFlag Meta flag to remove. * @param metaFlag Meta flag to remove.
*/ */
void removeMetaFlag(TSK_FS_META_FLAG_ENUM metaFlag) { void removeMetaFlag(TSK_FS_META_FLAG_ENUM metaFlag) {
metaFlags.remove(metaFlag); metaFlags.remove(metaFlag);
} }
/** /**
* Get meta flags as an integer. * Get meta flags as an integer.
* *
* @return Integer representation of the meta flags. * @return Integer representation of the meta flags.
*/ */
short getMetaFlagsAsInt() { short getMetaFlagsAsInt() {
return TSK_FS_META_FLAG_ENUM.toInt(metaFlags); return TSK_FS_META_FLAG_ENUM.toInt(metaFlags);
} }
@Override @Override
public final int read(byte[] buf, long offset, long len) throws TskCoreException { public final int read(byte[] buf, long offset, long len) throws TskCoreException {
//template method //template method
...@@ -1365,26 +1367,25 @@ public void save() throws TskCoreException { ...@@ -1365,26 +1367,25 @@ public void save() throws TskCoreException {
/** /**
* Get the owner uid. * Get the owner uid.
* *
* Note this is a string uid, typically a Windows SID. * Note this is a string uid, typically a Windows SID. This is different
* This is different from the numeric uid commonly found * from the numeric uid commonly found on Unix based file systems.
* on Unix based file systems. *
*
* @return Optional with owner uid. * @return Optional with owner uid.
*/ */
public Optional<String> getOwnerUid() { public Optional<String> getOwnerUid() {
return Optional.ofNullable(ownerUid); return Optional.ofNullable(ownerUid);
} }
/** /**
* Get the Object Id of the owner account. * Get the Object Id of the owner account.
* *
* @return Optional with Object Id of the OsAccount, or Optional.empty. * @return Optional with Object Id of the OsAccount, or Optional.empty.
*/ */
public Optional<Long> getOsAccountObjectId() { public Optional<Long> getOsAccountObjectId() {
return Optional.ofNullable(osAccountObjId); return Optional.ofNullable(osAccountObjId);
} }
/** /**
* Gets the owner account for the file. * Gets the owner account for the file.
* *
...@@ -1393,14 +1394,14 @@ public Optional<Long> getOsAccountObjectId() { ...@@ -1393,14 +1394,14 @@ public Optional<Long> getOsAccountObjectId() {
* @throws TskCoreException If there is an error getting the account. * @throws TskCoreException If there is an error getting the account.
*/ */
public Optional<OsAccount> getOsAccount() throws TskCoreException { public Optional<OsAccount> getOsAccount() throws TskCoreException {
if (osAccountObjId == null) { if (osAccountObjId == null) {
return Optional.empty(); return Optional.empty();
} }
return Optional.of(getSleuthkitCase().getOsAccountManager().getOsAccount(this.osAccountObjId)); return Optional.of(getSleuthkitCase().getOsAccountManager().getOsAccount(this.osAccountObjId));
} }
@Override @Override
public BlackboardArtifact newArtifact(int artifactTypeID) throws TskCoreException { public BlackboardArtifact newArtifact(int artifactTypeID) throws TskCoreException {
// don't let them make more than 1 GEN_INFO // don't let them make more than 1 GEN_INFO
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment