protected void load() throws Exception { if (id == null) { return; } File file = getIdAsFile(id, data_suffix); if (file == null || !file.exists()) { throw new Exception("unexpected condition:not exist:id=" + id); } if (file.length() == 0) { return; // need setRNSDirProps(not null) } ObjectInputStream ois = null; RNSDirectoryProperties newRnsProps = new RNSDirectoryProperties(); try { ois = new ObjectInputStream(new FileInputStream(file)); /* 1 */ newRnsProps.setCreateTime((Calendar) ois.readObject()); /* 2 */ newRnsProps.setAccessTime((Calendar) ois.readObject()); /* 3 */ newRnsProps.setModificationTime((Calendar) ois.readObject()); /* 4 */ int size = ois.readInt(); /* create new list */ Map<String, RNSEntryData> newlist = Collections.synchronizedMap(new HashMap<String, RNSEntryData>()); for (int i = 0; i < size; i++) { /* 5 */ String keyname = ois.readUTF(); RNSEntryData ent = new RNSEntryData(); /* 6 */ ent.setDirectory(ois.readBoolean()); /* 7 */ ent.setLocalID(ois.readUTF()); if ("".equals(ent.getLocalID())) { ent.setLocalID(null); } /* 8 */ String eprStr = ois.readUTF(); if (eprStr != null && eprStr.length() != 0) { ent.setEpr(RNSUtil.toEPR(eprStr)); } /* 9 */ int metalen = ois.readInt(); if (metalen > 0) { MessageElement[] me = new MessageElement[metalen]; for (int n = 0; n < metalen; n++) { /* 10 */ String xml = ois.readUTF(); me[n] = RNSUtil.toMessageElement(xml); } ent.setAny(me); } newlist.put(keyname, ent); } ACLEntryType[] newaclents; /* ACL */ int acllen; try { acllen = ois.readInt(); /* 11 */ } catch (EOFException eof) { acllen = 0; } if (acllen > 0) { newaclents = new ACLEntryType[acllen]; for (int n = 0; n < acllen; n++) { /* 12 */ newaclents[n] = new ACLEntryType(); newaclents[n].setType(ois.readShort()); String aclname = ois.readUTF(); if (aclname.equals(DUMMY)) { aclname = null; } newaclents[n].setName(aclname); newaclents[n].setPerm(ois.readShort()); } } else { newaclents = null; } rnsProps = newRnsProps; list = newlist; aclents = newaclents; logger.debug("load id=" + id); } catch (IOException e) { throw new Exception("Failed to load resource: id=" + id, e); } finally { if (ois != null) { try { ois.close(); } catch (Exception e2) { logger.warn("cannot close: resource id=" + id + ": " + e2.getMessage()); } } } }