Search in sources :

Example 1 with UndefinedErrorRecord

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();
}
Also used : UndefinedErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord)

Example 2 with UndefinedErrorRecord

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();
}
Also used : AccessErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.AccessErrorRecord) HandleErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.HandleErrorRecord) SpaceErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.SpaceErrorRecord) dev.hawala.xns.level4.filing.fs.iValueSetter(dev.hawala.xns.level4.filing.fs.iValueSetter) NoMoreWriteSpaceException(dev.hawala.xns.level3.courier.iWireStream.NoMoreWriteSpaceException) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) IOException(java.io.IOException) CourierException(dev.hawala.xns.level3.courier.exception.CourierException) UndefinedErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord) Volume(dev.hawala.xns.level4.filing.fs.Volume) FileEntry(dev.hawala.xns.level4.filing.fs.FileEntry)

Example 3 with UndefinedErrorRecord

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();
    }
}
Also used : AccessErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.AccessErrorRecord) HandleErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.HandleErrorRecord) SpaceErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.SpaceErrorRecord) dev.hawala.xns.level4.filing.fs.iValueSetter(dev.hawala.xns.level4.filing.fs.iValueSetter) ConnectionErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.ConnectionErrorRecord) NoMoreWriteSpaceException(dev.hawala.xns.level3.courier.iWireStream.NoMoreWriteSpaceException) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) IOException(java.io.IOException) CourierException(dev.hawala.xns.level3.courier.exception.CourierException) UndefinedErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord) CourierException(dev.hawala.xns.level3.courier.exception.CourierException) Volume(dev.hawala.xns.level4.filing.fs.Volume) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) FileEntry(dev.hawala.xns.level4.filing.fs.FileEntry)

Example 4 with UndefinedErrorRecord

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;
}
Also used : AttributeValueErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.AttributeValueErrorRecord) Attribute(dev.hawala.xns.level4.filing.FilingCommon.Attribute) UninterpretedAttribute(dev.hawala.xns.level4.filing.fs.UninterpretedAttribute) SpaceErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.SpaceErrorRecord) dev.hawala.xns.level4.filing.fs.iValueSetter(dev.hawala.xns.level4.filing.fs.iValueSetter) ConnectionErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.ConnectionErrorRecord) NoMoreWriteSpaceException(dev.hawala.xns.level3.courier.iWireStream.NoMoreWriteSpaceException) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) IOException(java.io.IOException) CourierException(dev.hawala.xns.level3.courier.exception.CourierException) UndefinedErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord) CourierException(dev.hawala.xns.level3.courier.exception.CourierException) Volume(dev.hawala.xns.level4.filing.fs.Volume) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) FileEntry(dev.hawala.xns.level4.filing.fs.FileEntry)

Example 5 with UndefinedErrorRecord

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);
}
Also used : UndefinedErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord) AccessEntry(dev.hawala.xns.level4.filing.fs.AccessEntry) FilterAttribute(dev.hawala.xns.level4.filing.FilingCommon.FilterAttribute) Attribute(dev.hawala.xns.level4.filing.FilingCommon.Attribute) UninterpretedAttribute(dev.hawala.xns.level4.filing.fs.UninterpretedAttribute) AccessList(dev.hawala.xns.level4.filing.FilingCommon.AccessList)

Aggregations

UndefinedErrorRecord (dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord)8 CourierException (dev.hawala.xns.level3.courier.exception.CourierException)5 EndOfMessageException (dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException)5 NoMoreWriteSpaceException (dev.hawala.xns.level3.courier.iWireStream.NoMoreWriteSpaceException)5 SpaceErrorRecord (dev.hawala.xns.level4.filing.FilingCommon.SpaceErrorRecord)5 FileEntry (dev.hawala.xns.level4.filing.fs.FileEntry)5 Volume (dev.hawala.xns.level4.filing.fs.Volume)5 IOException (java.io.IOException)5 AccessErrorRecord (dev.hawala.xns.level4.filing.FilingCommon.AccessErrorRecord)4 HandleErrorRecord (dev.hawala.xns.level4.filing.FilingCommon.HandleErrorRecord)4 dev.hawala.xns.level4.filing.fs.iValueSetter (dev.hawala.xns.level4.filing.fs.iValueSetter)4 Attribute (dev.hawala.xns.level4.filing.FilingCommon.Attribute)3 UninterpretedAttribute (dev.hawala.xns.level4.filing.fs.UninterpretedAttribute)3 ConnectionErrorRecord (dev.hawala.xns.level4.filing.FilingCommon.ConnectionErrorRecord)2 FilterAttribute (dev.hawala.xns.level4.filing.FilingCommon.FilterAttribute)2 AccessList (dev.hawala.xns.level4.filing.FilingCommon.AccessList)1 AttributeValueErrorRecord (dev.hawala.xns.level4.filing.FilingCommon.AttributeValueErrorRecord)1 Ordering (dev.hawala.xns.level4.filing.FilingCommon.Ordering)1 AccessEntry (dev.hawala.xns.level4.filing.fs.AccessEntry)1