*
* @throws Exception if an error occurs
*/
public synchronized void loadContents() throws Exception {
// read item states
FileSystemResource fsRes = new FileSystemResource(wspFS, STATE_FILE_PATH);
if (!fsRes.exists()) {
return;
}
BufferedInputStream bis = new BufferedInputStream(fsRes.getInputStream());
DataInputStream in = new DataInputStream(bis);
try {
int n = in.readInt(); // number of entries
while (n-- > 0) {
byte type = in.readByte(); // entry type
ItemId id;
if (type == NODE_ENTRY) {
// entry type: node
String s = in.readUTF(); // id
id = NodeId.valueOf(s);
} else {
// entry type: property
String s = in.readUTF(); // id
id = PropertyId.valueOf(s);
}
int length = in.readInt(); // data length
byte[] data = new byte[length];
in.readFully(data); // data
// store in map
stateStore.put(id, data);
}
} finally {
in.close();
}
// read references
fsRes = new FileSystemResource(wspFS, REFS_FILE_PATH);
bis = new BufferedInputStream(fsRes.getInputStream());
in = new DataInputStream(bis);
try {
int n = in.readInt(); // number of entries
while (n-- > 0) {