GNDMS 0.6.0
RESTful verison of GNDMS
|
A TransformSliceAction converts its slice to a new created slice (using de.zib.gndms.logic.model.dspace.CreateSliceAction) and adds it to the subspace corresponding to new slice object. More...
Inherits de::zib::gndms::logic::model::AbstractModelEntityAction< Slice, Slice >.
Public Member Functions | |
TransformSliceAction (String uid, DateTime ttm, SliceKind kind, Subspace tgt, long ssize) | |
Creates a new CreateSliceAction instances with the parameters given in the signature and sets the model of createSliceAction to. | |
TransformSliceAction (String uid, DateTime ttm, SliceKind kind, Subspace tgt, long ssize, DirectoryAux da) | |
Creates a new CreateSliceAction instances with the parameters given in the signature and sets the model of createSliceAction to. | |
void | initialize () |
Slice | execute (@NotNull EntityManager em) |
Executes the slice transformation. | |
Private Attributes | |
final CreateSliceAction | createSliceAction |
DirectoryAux | directoryAux |
A TransformSliceAction converts its slice to a new created slice (using de.zib.gndms.logic.model.dspace.CreateSliceAction) and adds it to the subspace corresponding to new slice object.
The new slice instance is specified and will be created by the constructor of this class.
User: mjorra, Date: 13.08.2008, Time: 13:20:25
In this version the out-dated slices remains in the db and its directory on disk, the caller must take care of removing it with the appropriate action.
todo make uses of UUIdGen from AbstractEntityAction
de.zib.gndms.logic.model.dspace.TransformSliceAction.TransformSliceAction | ( | String | uid, |
DateTime | ttm, | ||
SliceKind | kind, | ||
Subspace | tgt, | ||
long | ssize | ||
) |
Creates a new CreateSliceAction instances with the parameters given in the signature and sets the model of createSliceAction to.
tgt
.
uid | name of the owner of the new slice, can be null, then the current user will become the owner. |
ttm | the termination time of the slice object |
kind | the sliceKind instance for the slice. (See Slice). |
tgt | a subspace the new created slice will be registered on |
ssize | total storage size for the slice instance |
{
createSliceAction = new CreateSliceAction( uid, ttm, kind, ssize );
createSliceAction.setModel( tgt );
}
de.zib.gndms.logic.model.dspace.TransformSliceAction.TransformSliceAction | ( | String | uid, |
DateTime | ttm, | ||
SliceKind | kind, | ||
Subspace | tgt, | ||
long | ssize, | ||
DirectoryAux | da | ||
) |
Creates a new CreateSliceAction instances with the parameters given in the signature and sets the model of createSliceAction to.
tgt
.
uid | name of the owner of the new slice, can be null, then the current user will become the owner. |
ttm | the termination time of the slice object |
kind | the sliceKind instance for the slice. (See Slice). |
tgt | a subspace the new created slice will be registered on |
ssize | total storage size for the slice instance |
da | an helper object for directory access |
{
directoryAux = da;
createSliceAction = new CreateSliceAction( uid, ttm, kind, ssize, da );
createSliceAction.setModel( tgt );
}
Slice de.zib.gndms.logic.model.dspace.TransformSliceAction.execute | ( | @NotNull EntityManager | em | ) |
Executes the slice transformation.
NOTE: Since this method uses DirectoryAux.copyDir the obeys the restriction of this method.
{ Slice sl = getModel( ); Subspace sp = sl.getSubspace( ); if( directoryAux == null ) { directoryAux = getInjector().getInstance( DirectoryAux.class ); } if(! sp.getCreatableSliceKinds( ).contains( createSliceAction.getSliceKind( ) ) ) return null; // create an new slice of the given kind Slice nsl = createSliceAction.execute( em ); if ( nsl == null ) throw new RuntimeException( "Can't create slice" ); // copy contents of old slice to the new one String src_pth = sp.getPathForSlice( sl ); String tgt_pth = createSliceAction.getModel( ).getPathForSlice( nsl ); AccessMask msk = createSliceAction.getSliceKind( ).getPermission( ); boolean ro = msk.queryFlagsOff( AccessMask.Ugo.USER, AccessMask.AccessFlags.WRITABLE ); // make slice path writable to copy content if ( ro ) { msk.addFlag( AccessMask.Ugo.USER, AccessMask.AccessFlags.WRITABLE ); directoryAux.setPermissions( nsl.getOwner(), msk, tgt_pth ); } directoryAux.move( src_pth, tgt_pth ); // restore slice path settings if ( ro ) { msk.removeFlag( AccessMask.Ugo.USER, AccessMask.AccessFlags.WRITABLE ); directoryAux.setPermissions( nsl.getOwner(), msk, tgt_pth ); } // TODO: update slice in database /* // sth went wrong destroy created slice if( ! suc ) { DeleteSliceAction.deleteSlice( sl, this ); throw new RuntimeException( "Can't copy slice content" ); } */ // no entries in BatchUpdateAction required, already done by the create action return nsl; }