use of dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord in project dodo by devhawala.
the class FilingImpl method notImplemented.
/*
* temp
*/
private static void notImplemented(String methodName, RECORD params) {
StringBuilder sb = new StringBuilder();
params.append(sb, " ", "arguments");
log("##\n## procedure FilingImpl.%s (\n%s\n## ) => UndefinedErrorRecord(42).raise()\n##\n", methodName, sb.toString());
new UndefinedErrorRecord(FilingCommon.UNDEFINEDERROR_UNIMPLEMENTED).raise();
}
use of dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord 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.UndefinedErrorRecord 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.UndefinedErrorRecord in project dodo by devhawala.
the class FilingImpl method createFile.
private static FileEntry createFile(Volume.Session modificationSession, Session session, long directoryFileID, AttributeSequence pAttributes, iContentSource source, ExceptionHandler exceptionHandler) {
// get the volume
Volume vol = session.getService().getVolume();
// extract the minimal attributes => required: name ; optional: isDirectory(false), version(1/next), type(unknown)
String name = null;
boolean isDirectory = false;
Integer version = null;
Long type = null;
for (int i = 0; i < pAttributes.value.size(); i++) {
Attribute attr = pAttributes.value.get(i);
switch((int) (attr.type.get() & 0xFFFF)) {
case FilingCommon.atName:
name = attr.getAsString();
break;
case FilingCommon.atIsDirectory:
isDirectory = attr.getAsBoolean();
break;
case FilingCommon.atVersion:
version = attr.getAsCardinal();
break;
case FilingCommon.atType:
type = attr.getAsLongCardinal();
break;
}
}
if (name == null) {
new AttributeValueErrorRecord(ArgumentProblem.missing, FilingCommon.atName).raise();
}
// create the new file
List<iValueSetter> attrSetters = getCourier2FileAttributeSetters(pAttributes);
System.out.printf("volStartModificationsession()\n");
try {
System.out.printf("createFile( dirId = %d , isdirectory = %s , name = '%s' )\n", directoryFileID, "" + isDirectory, name);
Volume.Session modSession = (modificationSession == null) ? vol.startModificationSession() : modificationSession;
final FileEntry fe;
try {
fe = modSession.createFile(directoryFileID, isDirectory, name, version, type, session.getUsername(), attrSetters, source);
} finally {
if (modificationSession == null) {
modSession.close();
}
}
System.out.printf("-> done createFile(): fileID = %d\n", (fe != null) ? fe.getFileID() : -2);
return fe;
} catch (InterruptedException e) {
System.out.printf("!!! InterruptedException !!!\n");
new UndefinedErrorRecord(FilingCommon.UNDEFINEDERROR_CANNOT_MODIFY_VOLUME).raise();
} catch (EndOfMessageException e) {
System.out.printf("!!! EndOfMessageException !!!\n");
new ConnectionErrorRecord(ConnectionProblem.otherCallProblem).raise();
} catch (CourierException ce) {
// this is a RuntimeException, why is it catch-ed by Exception ???????
System.out.printf("!!! CourierException !!!\n");
throw ce;
} catch (Exception e) {
System.out.printf("!!! Exception: %s -- %s !!!\n", e.getClass().getName(), e.getMessage());
if (exceptionHandler != null) {
exceptionHandler.accept(e);
} else {
new SpaceErrorRecord(SpaceProblem.mediumFull).raise();
}
}
// keep the compiler happy
return null;
}
use of dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord in project dodo by devhawala.
the class AttributeUtils method file2courier_accessList.
/*
* FileEntry => Courier
*/
private static void file2courier_accessList(AttributeSequence s, long atCode, boolean isDefaulted, List<AccessEntry> accessEntries, boolean forFiling4) {
AccessList acl = forFiling4 ? AccessList.make4() : AccessList.make5or6();
acl.defaulted.set(isDefaulted);
for (AccessEntry a : accessEntries) {
FilingCommon.AccessEntry fa = acl.entries.add();
fa.key.from(a.key);
if (a.access == FsConstants.fullAccess) {
// fa.access.add().set(AccessType.fullAccess);
fa.access.add(AccessType.readAccess);
fa.access.add(AccessType.writeAccess);
fa.access.add(AccessType.ownerAccess);
fa.access.add(AccessType.addAccess);
fa.access.add(AccessType.removeAccess);
} else {
if ((a.access & FsConstants.readAccess) != 0) {
fa.access.add(AccessType.readAccess);
}
if ((a.access & FsConstants.writeAccess) != 0) {
fa.access.add(AccessType.writeAccess);
}
if ((a.access & FsConstants.ownerAccess) != 0) {
fa.access.add(AccessType.ownerAccess);
}
if ((a.access & FsConstants.addAccess) != 0) {
fa.access.add(AccessType.addAccess);
}
if ((a.access & FsConstants.removeAccess) != 0) {
fa.access.add(AccessType.removeAccess);
}
}
}
Attribute attr = s.value.add();
try {
attr.encodeData(acl);
} catch (Exception e) {
new UndefinedErrorRecord(FilingCommon.UNDEFINEDERROR_ENCODE_ERROR).raise();
}
attr.type.set(atCode);
}
Aggregations