Lines 119-124
Link Here
|
119 |
private PrimaryFileListener primaryFileListener; |
119 |
private PrimaryFileListener primaryFileListener; |
120 |
|
120 |
|
121 |
private static final Object syncObject = new Object(); |
121 |
private static final Object syncObject = new Object(); |
|
|
122 |
|
123 |
/** private lock used at delete and rename methods. */ |
124 |
private final String privateLock = "DataObject.privateLock"; |
122 |
|
125 |
|
123 |
/** Create new data object. |
126 |
/** Create new data object. |
124 |
* @param pf primary file object for this data object |
127 |
* @param pf primary file object for this data object |
Lines 511-530
Link Here
|
511 |
* <p>Events are fired and atomicity is implemented. |
514 |
* <p>Events are fired and atomicity is implemented. |
512 |
* @exception IOException if an error occures |
515 |
* @exception IOException if an error occures |
513 |
*/ |
516 |
*/ |
514 |
public final synchronized void delete () throws IOException { |
517 |
public final void delete () throws IOException { |
515 |
// the object is ready to be closed |
518 |
synchronized ( privateLock ) { |
516 |
FileSystem fs = getPrimaryFile ().getFileSystem (); |
519 |
// the object is ready to be closed |
517 |
fs.runAtomicAction (new FileSystem.AtomicAction () { |
520 |
FileSystem fs = getPrimaryFile ().getFileSystem (); |
518 |
public void run () throws IOException { |
521 |
fs.runAtomicAction (new FileSystem.AtomicAction () { |
519 |
handleDelete (); |
522 |
public void run () throws IOException { |
520 |
item.deregister(false); |
523 |
handleDelete (); |
521 |
item.setDataObject(null); |
524 |
item.deregister(false); |
522 |
} |
525 |
item.setDataObject(null); |
523 |
}); |
526 |
} |
524 |
firePropertyChange (PROP_VALID, Boolean.TRUE, Boolean.FALSE); |
527 |
}); |
525 |
fireOperationEvent ( |
528 |
firePropertyChange (PROP_VALID, Boolean.TRUE, Boolean.FALSE); |
526 |
new OperationEvent (this), OperationEvent.DELETE |
529 |
fireOperationEvent (new OperationEvent (this), OperationEvent.DELETE); |
527 |
); |
530 |
} |
528 |
} |
531 |
} |
529 |
|
532 |
|
530 |
/** Delete this object (implemented by subclasses). |
533 |
/** Delete this object (implemented by subclasses). |
Lines 540-568
Link Here
|
540 |
* |
543 |
* |
541 |
* @exception IOException if an error occurs |
544 |
* @exception IOException if an error occurs |
542 |
*/ |
545 |
*/ |
543 |
public final synchronized void rename (final String name) throws IOException { |
546 |
public final void rename (final String name) throws IOException { |
544 |
String oldName = getName (); |
547 |
synchronized ( privateLock ) { |
545 |
|
548 |
String oldName = getName (); |
546 |
if (oldName.equals (name)) return; // the new name is the same as the old one |
549 |
|
|
|
550 |
if (oldName.equals (name)) return; // the new name is the same as the old one |
551 |
|
552 |
FileObject old = getPrimaryFile (); |
553 |
|
554 |
// executes atomic action with renaming |
555 |
FileSystem fs = old.getFileSystem (); |
556 |
fs.runAtomicAction (new FileSystem.AtomicAction () { |
557 |
public void run () throws IOException { |
558 |
FileObject mf = handleRename (name); |
559 |
item.changePrimaryFile (mf); |
560 |
} |
561 |
}); |
547 |
|
562 |
|
548 |
FileObject old = getPrimaryFile (); |
563 |
firePropertyChange (PROP_PRIMARY_FILE, old, getPrimaryFile ()); |
|
|
564 |
fireOperationEvent (new OperationEvent.Rename (this, oldName), OperationEvent.RENAME); |
549 |
|
565 |
|
550 |
// executes atomic action with renaming |
566 |
// rename succeed |
551 |
FileSystem fs = old.getFileSystem (); |
567 |
firePropertyChange(DataObject.PROP_NAME, oldName, getName ()); |
552 |
fs.runAtomicAction (new FileSystem.AtomicAction () { |
568 |
} |
553 |
public void run () throws IOException { |
|
|
554 |
FileObject mf = handleRename (name); |
555 |
item.changePrimaryFile (mf); |
556 |
} |
557 |
}); |
558 |
|
559 |
firePropertyChange (PROP_PRIMARY_FILE, old, getPrimaryFile ()); |
560 |
fireOperationEvent ( |
561 |
new OperationEvent.Rename (this, oldName), OperationEvent.RENAME |
562 |
); |
563 |
|
564 |
// rename succeed |
565 |
firePropertyChange(DataObject.PROP_NAME, oldName, getName ()); |
566 |
} |
569 |
} |
567 |
|
570 |
|
568 |
/** Rename this object (implemented in subclasses). |
571 |
/** Rename this object (implemented in subclasses). |