use of dev.hawala.xns.level4.filing.FilingCommon.AttributeSequence in project dodo by devhawala.
the class FilingImpl method copy.
/*
* Copy: PROCEDURE [ file, destinationDirectory: Handle ,
* attributes: AttributeSequence, controls: ControlSequence,
* session: Session ]
* RETURNS [ newFile: Handle ]
* REPORTS [ AccessError, AttributeTypeError, AttributeValueError,
* AuthenticationError, ControlTypeError, ControlValueError,
* HandleError, InsertionError, SessionError, SpaceError,
* UndefinedError ]
* = 10;
*/
private static void copy(CopyParams params, CopyResults results) {
logParams("copy", params);
// check session
Session session = resolveSession(params.session);
Volume vol = session.getService().getVolume();
// check specified file handle
Handle fileHandle = Handle.get(params.handle);
if (fileHandle.isVolumeRoot()) {
// the file system root cannot be copied
new AccessErrorRecord(AccessProblem.accessRightsInsufficient).raise();
}
if (fileHandle.isNullHandle()) {
new HandleErrorRecord(HandleProblem.nullDisallowed).raise();
}
FileEntry fe = fileHandle.getFe();
if (fe.getParentID() == FsConstants.rootFileID) {
// file system root folders cannot be copied
new AccessErrorRecord(AccessProblem.accessRightsInsufficient).raise();
}
// check the destination
Handle destinationDirHandle = Handle.get(params.destinationDirectory);
if (destinationDirHandle.isVolumeRoot()) {
// the file system root cannot be target
new AccessErrorRecord(AccessProblem.accessRightsInsufficient).raise();
}
if (destinationDirHandle.isNullHandle()) {
new HandleErrorRecord(HandleProblem.nullDisallowed).raise();
}
FileEntry destinationDirectory = destinationDirHandle.getFe();
// copy the file and return new file
List<iValueSetter> attrSetters = getCourier2FileAttributeSetters(params.attributes);
try (Volume.Session modSession = vol.startModificationSession()) {
// do the copy
FileEntry newFe = modSession.copy(fe, destinationDirectory, attrSetters, session.getUsername());
// prepare results
Handle newFeHandle = new Handle(session, newFe);
newFeHandle.setIdTo(results.newHandle);
logResult("copy", results);
} catch (InterruptedException e) {
new UndefinedErrorRecord(FilingCommon.UNDEFINEDERROR_CANNOT_MODIFY_VOLUME).raise();
} catch (Exception e) {
new SpaceErrorRecord(SpaceProblem.mediumFull).raise();
}
// prolongate the sessions life if this took longer
session.continueUse();
}
use of dev.hawala.xns.level4.filing.FilingCommon.AttributeSequence in project dodo by devhawala.
the class FilingImpl method changeAttributes.
/*
* ChangeAttributes: PROCEDURE [ file: Handle, attributes: AttributeSequence,
* session: Session ]
* REPORTS [ AccessError, AttributeTypeError, AttributeValueError,
* AuthenticationError, HandleError, InsertionError,
* SessionError, SpaceError, UndefinedError ]
* = 9;
*/
private static void changeAttributes(ChangeAttributesParams params, RECORD results) {
logParams("changeAttributes", params);
// check session
Session session = resolveSession(params.session);
Volume vol = session.getService().getVolume();
// check specified file handle
Handle fileHandle = Handle.get(params.handle);
if (fileHandle == null || fileHandle.isNullHandle()) {
new HandleErrorRecord(HandleProblem.nullDisallowed).raise();
}
if (fileHandle.isVolumeRoot()) {
// the file system root cannot be modified
new AccessErrorRecord(AccessProblem.accessRightsInsufficient).raise();
}
FileEntry fe = fileHandle.getFe();
if (fe == null) {
new HandleErrorRecord(HandleProblem.nullDisallowed).raise();
}
// change attributes
List<iValueSetter> attrSetters = getCourier2FileAttributeSetters(params.attributes);
try (Volume.Session modSession = vol.startModificationSession()) {
modSession.updateFileAttributes(fe, attrSetters, session.getUsername());
} catch (InterruptedException e) {
new UndefinedErrorRecord(FilingCommon.UNDEFINEDERROR_CANNOT_MODIFY_VOLUME).raise();
} catch (EndOfMessageException e) {
new ConnectionErrorRecord(ConnectionProblem.otherCallProblem).raise();
} catch (CourierException ce) {
// this is a RuntimeException, why is it catch-ed by Exception ???????
throw ce;
} catch (Exception e1) {
new SpaceErrorRecord(SpaceProblem.mediumFull).raise();
}
}
use of dev.hawala.xns.level4.filing.FilingCommon.AttributeSequence in project dodo by devhawala.
the class FilingImpl method list.
/*
* List: PROCEDURE [ directory: Handle, types: AttributeTypeSequence,
* scope: ScopeSequence, listing: BulkData.Sink,
* session: Session ]
* REPORTS [ AccessError, AttributeTypeError,
* AuthenticationError, ConnectionError,
* HandleError,
* ScopeTypeError, ScopeValueError,
* SessionError, TransferError, UndefinedError ]
* = 18;
*/
private static void list(ListParams params, RECORD results) {
logParams("list", params);
// check session
Session session = resolveSession(params.session);
// check specified file handle
Handle dirHandle = Handle.get(params.directory);
long dirFileID = (dirHandle == null || dirHandle.isNullHandle() || dirHandle.isVolumeRoot()) ? 0 : dirHandle.getFe().getFileID();
// do the enumeration
final List<FileEntry> hits = getFileHits(session, dirFileID, new ScopeData(params.scope));
// prepare the attribute getters
List<iValueGetter<FilingCommon.AttributeSequence>> getters = getFile2CourierAttributeGetters(params.types, session.getFilingVersion());
// build the result stream and send it
StreamOf<AttributeSequence> stream = new StreamOf<>(0, 1, 16, AttributeSequence::make);
for (FileEntry fe : hits) {
AttributeSequence as = stream.add();
for (iValueGetter<FilingCommon.AttributeSequence> getter : getters) {
getter.access(as, fe);
}
}
sendBulkData("list", params.listing, stream);
}
use of dev.hawala.xns.level4.filing.FilingCommon.AttributeSequence in project dodo by devhawala.
the class FilingImpl method create.
/*
* Create: PROCEDURE [ directory: Handle, attributes: AttributeSequence,
* controls: ControlSequence, session: Session ]
* RETURNS [ file: Handle ]
* REPORTS [ AccessError, AttributeTypeError, AttributeValueError,
* AuthenticationError, ControlTypeError, ControlValueError,
* HandleError, InsertionError, SessionError, SpaceError,
* UndefinedError ]
* = 4;
*/
private static void create(CreateParams params, FileHandleRecord results) {
logParams("create", params);
// check session
Session session = resolveSession(params.session);
// check specified directory file handle
Handle dirHandle = Handle.get(params.directory);
if (dirHandle.isVolumeRoot()) {
// the file system root cannot be modified
new AccessErrorRecord(AccessProblem.accessRightsInsufficient).raise();
}
if (dirHandle.isNullHandle()) {
new HandleErrorRecord(HandleProblem.directoryRequired).raise();
}
// TODO: check (access-)controls on directory
// let the file be created
FileEntry fe = createFile(null, session, dirHandle.getFe().getFileID(), params.attributes, null, null);
// prepare results
Handle fileHandle = new Handle(session, fe);
fileHandle.setIdTo(results.file);
logResult("create", results);
// prolongate the sessions life
session.continueUse();
}
use of dev.hawala.xns.level4.filing.FilingCommon.AttributeSequence in project dodo by devhawala.
the class FilingImpl method list4.
private static void list4(ListParams4 params, RECORD results) {
logParams("list4", params);
// check session
Session session = resolveSession(params.session);
// check specified file handle
Handle dirHandle = Handle.get(params.directory);
long dirFileID = (dirHandle == null || dirHandle.isNullHandle() || dirHandle.isVolumeRoot()) ? 0 : dirHandle.getFe().getFileID();
// do the enumeration
final List<FileEntry> hits = getFileHits(session, dirFileID, new ScopeData(params.scope));
// prepare the attribute getters
List<iValueGetter<FilingCommon.AttributeSequence>> getters = getFile2CourierAttributeGetters(params.types, session.getFilingVersion());
// build the result stream and send it
StreamOf<AttributeSequence> stream = new StreamOf<>(0, 1, 16, AttributeSequence::make);
for (FileEntry fe : hits) {
AttributeSequence as = stream.add();
for (iValueGetter<FilingCommon.AttributeSequence> getter : getters) {
getter.access(as, fe);
}
}
sendBulkData("list", params.listing, stream);
}
Aggregations