-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #17: Added ICloudFile interface. MetadataManagers have to return
ICloudFiles for different methods.
- Loading branch information
Florian Bausch
committed
Jul 28, 2012
1 parent
ef7ebf3
commit cdf8e13
Showing
7 changed files
with
214 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
interfaces/src/de/dhbw_mannheim/cloudraid/metadatamgr/ICloudFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package de.dhbw_mannheim.cloudraid.metadatamgr; | ||
|
||
/** | ||
* An interface for the representation of a file stored by CloudRAID. | ||
* | ||
* @author Florian Bausch | ||
* | ||
*/ | ||
public interface ICloudFile { | ||
|
||
/** | ||
* Returns the file ID. | ||
* | ||
* @return The file ID. | ||
*/ | ||
public int getFileId(); | ||
|
||
/** | ||
* Returns the hashed file name. | ||
* | ||
* @return The hashed file name. | ||
*/ | ||
public String getHash(); | ||
|
||
/** | ||
* Returns the date (milliseconds since 01/01/1970) of the last modification | ||
* of a file. | ||
* | ||
* @return The last modification date. | ||
*/ | ||
public long getLastMod(); | ||
|
||
/** | ||
* Returns the file name. | ||
* | ||
* @return The file name. | ||
*/ | ||
public String getName(); | ||
|
||
/** | ||
* Returns the file's status. | ||
* | ||
* @return The status. | ||
*/ | ||
public String getStatus(); | ||
|
||
/** | ||
* Returns the user ID the file belongs to. | ||
* | ||
* @return The user ID. | ||
*/ | ||
public int getUserId(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
metadatamgr/src/de/dhbw_mannheim/cloudraid/metadatamgr/impl/HSQLCloudFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package de.dhbw_mannheim.cloudraid.metadatamgr.impl; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.Collection; | ||
import java.util.Vector; | ||
|
||
import de.dhbw_mannheim.cloudraid.metadatamgr.ICloudFile; | ||
|
||
/** | ||
* An implementation of {@link ICloudFile} that can read data from the | ||
* {@link HSQLMetadataManager} database. | ||
* | ||
* @author Florian Bausch | ||
* | ||
*/ | ||
public class HSQLCloudFile implements ICloudFile { | ||
|
||
/** | ||
* Creates from a {@link ResultSet} a Collection of {@link ICloudFile}s. The | ||
* cursor must be set before the first row. | ||
* | ||
* @param rs | ||
* A SQL {@link ResultSet}. | ||
* @return The Collection. | ||
* @throws SQLException | ||
*/ | ||
protected static Collection<ICloudFile> createFileList(ResultSet rs) | ||
throws SQLException { | ||
Vector<ICloudFile> ret = new Vector<ICloudFile>(); | ||
while (rs.next()) { | ||
ret.add(new HSQLCloudFile(rs)); | ||
} | ||
return ret; | ||
} | ||
|
||
private String path; | ||
private String hash; | ||
private int userid; | ||
private String status; | ||
private long lastMod; | ||
private int fileid; | ||
|
||
/** | ||
* Creates a {@link ICloudFile} from a {@link ResultSet}. The cursor must be | ||
* set on a row. | ||
* | ||
* @param rs | ||
* The {@link ResultSet}. | ||
* @throws SQLException | ||
*/ | ||
protected HSQLCloudFile(ResultSet rs) throws SQLException { | ||
this.path = rs.getString("path_name"); | ||
this.hash = rs.getString("hash_name"); | ||
this.userid = rs.getInt("user_id"); | ||
this.status = rs.getString("status"); | ||
this.lastMod = rs.getTimestamp("last_mod").getTime(); | ||
this.fileid = rs.getInt("id"); | ||
} | ||
|
||
@Override | ||
public int getFileId() { | ||
return this.fileid; | ||
} | ||
|
||
@Override | ||
public String getHash() { | ||
return this.hash; | ||
} | ||
|
||
@Override | ||
public long getLastMod() { | ||
return this.lastMod; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.path; | ||
} | ||
|
||
@Override | ||
public String getStatus() { | ||
return this.status; | ||
} | ||
|
||
@Override | ||
public int getUserId() { | ||
return this.userid; | ||
} | ||
|
||
} |
Oops, something went wrong.