Search in sources :

Example 1 with AccessList

use of dev.hawala.xns.level4.filing.FilingCommon.AccessList 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)

Example 2 with AccessList

use of dev.hawala.xns.level4.filing.FilingCommon.AccessList in project dodo by devhawala.

the class AttributeUtils method courier2file_accessList.

private static void courier2file_accessList(Attribute a, FileEntry fe, boolean isDefaultAcl) {
    AccessList acl = null;
    try {
        // try as post-version 4 AccessLIst
        acl = a.decodeData(AccessList::make5or6);
    } catch (Exception e) {
    // does not seem to be version 5 or 6, so check for version 4
    }
    if (acl == null) {
        try {
            // try as version 4 AccessList
            acl = a.decodeData(AccessList::make4);
        } catch (Exception e) {
            // none of the supported versions was ok, so use defaults
            acl = AccessList.make5or6();
        }
    }
    if (isDefaultAcl) {
        fe.setDefaultAccessListDefaulted(acl.defaulted.get());
    } else {
        fe.setAccessListDefaulted(acl.defaulted.get());
    }
    List<AccessEntry> aes = (isDefaultAcl) ? fe.getDefaultAccessList() : fe.getAccessList();
    aes.clear();
    for (int i = 0; i < acl.entries.size(); i++) {
        FilingCommon.AccessEntry ac = acl.entries.get(i);
        String key = ac.key.getString();
        int access = 0;
        if (ac.access.has(AccessType.fullAccess)) {
            access |= FsConstants.fullAccess;
        }
        if (ac.access.has(AccessType.readAccess)) {
            access |= FsConstants.readAccess;
        }
        if (ac.access.has(AccessType.writeAccess)) {
            access |= FsConstants.writeAccess;
        }
        if (ac.access.has(AccessType.ownerAccess)) {
            access |= FsConstants.ownerAccess;
        }
        if (ac.access.has(AccessType.addAccess)) {
            access |= FsConstants.addAccess;
        }
        if (ac.access.has(AccessType.removeAccess)) {
            access |= FsConstants.removeAccess;
        }
        AccessEntry ae = new AccessEntry(key, access);
        aes.add(ae);
    }
    ;
}
Also used : AccessEntry(dev.hawala.xns.level4.filing.fs.AccessEntry) AccessList(dev.hawala.xns.level4.filing.FilingCommon.AccessList)

Aggregations

AccessList (dev.hawala.xns.level4.filing.FilingCommon.AccessList)2 AccessEntry (dev.hawala.xns.level4.filing.fs.AccessEntry)2 Attribute (dev.hawala.xns.level4.filing.FilingCommon.Attribute)1 FilterAttribute (dev.hawala.xns.level4.filing.FilingCommon.FilterAttribute)1 UndefinedErrorRecord (dev.hawala.xns.level4.filing.FilingCommon.UndefinedErrorRecord)1 UninterpretedAttribute (dev.hawala.xns.level4.filing.fs.UninterpretedAttribute)1