if (DefaultAttributes.acceptName(name)) { DefaultAttributes.Table table = DefaultAttributes.loadTable(jis, name); attributes.put(name, table); } else {
if (arr[0].equalsIgnoreCase("_nbattrs.")) { try { deleteFile(f + "/" + arr[0]); // NOI18N } catch (IOException ioe) { arr[0] = getFileName(); if ((getFileName().equals(arr[0]) || ATTR_NAME_EXT_XML.equals(arr[0]) || ATTR_NAME_EXT.equals(arr[0]))) { try { this.change.delete(f + "/" + arr[0]); copyVMSAttrFile(f); arr[i] = getFileName(); String safeNbAttrsCopy = getFileName() + "~"; //NOI18N getFileName().equals(arr[i]) || ATTR_NAME_EXT.equals(arr[i]) || ATTR_NAME_EXT_XML.equals(arr[i]) || safeNbAttrsCopy.equals(arr[i]) ) {
/** Load attributes from cache or * from disk. * @param name of folder to load data from */ private Table loadTable(String name) { //throws IOException { Reference r = (Reference) getCache().get(name); if (r != null) { Table m = (Table) r.get(); if (m != null) { return m; } } // have to load new table Table t = load(name); t.attach(name, this); getCache().put(name, new SoftReference(t)); return t; }
/** Loads the table. Does no initialization. */ private Table load(String name) { String[] acceptNames = { ((name.length() == 0) ? "" : (name + '/')) + getFileName(), // NOI18N ((name.length() == 0) ? "" : (name + '/')) + ATTR_NAME_EXT }; // NOI18N for (int i = 0; i < acceptNames.length; i++) { if (info.size(acceptNames[i]) > 0L) { try { InputStream fis = info.inputStream(acceptNames[i]); try { return loadTable(fis, acceptNames[i]); } finally { try { fis.close(); } catch (IOException e) { // ignore--who cares? } } } catch (FileNotFoundException ex) { ExternalUtil.exception(ex); } } } return new Table(); }
change.delete(f+"/"+arr[0]); // NOI18N } catch (IOException ioe) {} arr[0] = getFileName(); if ((getFileName().equals(arr[0]) || ATTR_NAME_EXT_XML.equals(arr[0]) || ATTR_NAME_EXT.equals(arr[0]))) { try { change.delete(f+"/"+arr[0]); // NOI18N if ( ! fp.exists() ) { cache = null; copyVMSAttrFile (f); arr[i] = getFileName(); String safeNbAttrsCopy = getFileName()+"~";//NOI18N if (getFileName().equals(arr[i]) || ATTR_NAME_EXT.equals (arr[i]) || ATTR_NAME_EXT_XML.equals (arr[i]) || safeNbAttrsCopy.equals (arr[i])) {
change.createData(f + "/" + getFileName()); is = info.inputStream(f + "/" + "_nbattrs."); os = info.outputStream(f + "/" + getFileName());
String fullName = ((name.length() == 0) ? "" : (name + '/')) + getFileName(); // NOI18N } else { if (map.size() == 0) { deleteFile(fullName); deleteFile(safeName); } catch (IOException ioe) { if (ioe.getCause() == null) { for (int counter = 0; ;counter++) { try { deleteFile(fullName); } catch (IOException iex2) {
@Override public Object readAttribute(String name, String attrName) { if (attrName.equals("java.io.File")) { // NOI18N return FileUtil.normalizeFile(lfs.getFile(name)); } return super.readAttribute(name, attrName); } }
/** Remove itself from the cache if finalized. */ @Override protected void finalize() { // System.out.println ("Finalizing table for: " + name); // NOI18N attrs.removeTable(name); }
/** Remove from cache */ synchronized void removeTable(String name) { getCache().remove(name); }
if (folderName.endsWith(ATTR_NAME_EXT)) { pbStream = new PushbackInputStream(is, 4); //is.available() isSerialized = isSerialized(pbStream);
public synchronized void renameAttributes(String oldName, String newName) { try { String[] arr = new String[2]; split(oldName, arr); Table t = loadTable(arr[0]); Map v = (Map) t.remove(arr[1]); // System.out.println ("ARg[0] = " + arr[0] + " arr[1] = " + arr[1] + " value: " + v); // NOI18N if (v == null) { // no attrs no change return; } split(newName, arr); // Remove transient attributes: Iterator it = v.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); if (FileUtil.transientAttributes.contains(pair.getKey())) { it.remove(); } } t.put(arr[1], v); // System.out.println ("xyz[0] = " + arr[0] + " xyz[1] = " + arr[1] + " value: " + v); // NOI18N saveTable(arr[0], t); } catch (IOException e) { ExternalUtil.exception(e); } }
public Object readAttribute(String name, String attrName) { Table t; String[] arr = new String[2]; split(name, arr); /** At the momement substitutes lack of API */ if (attrName.equals(READONLY_ATTRIBUTES)) { return info.readOnly(arr[0]) ? Boolean.TRUE : Boolean.FALSE; } synchronized (this) { // synchronized so only one table for each folder // can exist t = loadTable(arr[0]); } // JST: // had to split the code to do getAttr out of synchronized block // because the attribute can be serialized FileObject and // so the code returns back to FileSystem (that is usually synchronized) // // this leads to deadlocks between FS & DefaultAttributes implementation // // I do not know if the table should not be somehow synchronized, // but it seems ok. return t.getAttr(arr[1], attrName); }
/** Loads the table. Does no initialization. */ private Table load (String name) { String acceptNames[] = {(name.length()==0 ? "": (name + '/')) + getFileName(),// NOI18N (name.length()==0 ? "": (name + '/')) + ATTR_NAME_EXT}; // NOI18N for (int i = 0; i < acceptNames.length;i++) { if (info.size (acceptNames[i]) > 0L) { try { InputStream fis = info.inputStream (acceptNames[i]); try { return loadTable (fis,acceptNames[i]); } finally { try { fis.close (); } catch (IOException e) { // ignore--who cares? } } } catch (FileNotFoundException ex) { ExternalUtil.exception(ex); } } } return new Table (); }
change.delete(f+"/"+arr[0]); // NOI18N } catch (IOException ioe) {} arr[0] = getFileName(); if ((getFileName().equals(arr[0]) || ATTR_NAME_EXT_XML.equals(arr[0]) || ATTR_NAME_EXT.equals(arr[0]))) { try { change.delete(f+"/"+arr[0]); // NOI18N if ( ! fp.exists() ) { cache = null; copyVMSAttrFile (f); arr[i] = getFileName(); String safeNbAttrsCopy = getFileName()+"~";//NOI18N if (getFileName().equals(arr[i]) || ATTR_NAME_EXT.equals (arr[i]) || ATTR_NAME_EXT_XML.equals (arr[i]) || safeNbAttrsCopy.equals (arr[i])) {
change.createData (f+"/"+getFileName()); is = info.inputStream (f+"/"+"_nbattrs."); os = info.outputStream (f+"/"+getFileName());
public Object readAttribute(String name, String attrName) { if (attrName.equals("java.io.File")) // NOI18N return lfs.getFile(name); return super.readAttribute(name, attrName); } }
/** Remove itself from the cache if finalized. */ protected void finalize () { // System.out.println ("Finalizing table for: " + name); // NOI18N attrs.removeTable (name); }