use of dev.hawala.xns.level3.courier.StreamOf 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.level3.courier.StreamOf 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);
}
use of dev.hawala.xns.level3.courier.StreamOf in project dodo by devhawala.
the class TestCrData method testSequences.
/*
* Test embedded SEQUENCE and StreamOf
*/
@Test
public void testSequences() throws EndOfMessageException, NoMoreWriteSpaceException {
CrSequences rec = new CrSequences();
rec.check1.set(0x1111);
rec.check2.set(0x2222);
rec.check3.set(0x3333);
rec.check4.set(0x4444);
rec.check5.set(0x5555);
for (int i = 0; i < 5; i++) {
INTEGER integer = rec.seqInt.add();
integer.set(5000 + i);
}
for (int i = 0; i < 11; i++) {
Data data = rec.sOfData.add();
data.userdata1.set(7000 + i);
data.userdata2.set(1001000 + i);
}
for (int i = 0; i < 7; i++) {
STRING string = rec.seqString.add();
string.set("value of rec.seqString :: " + i);
}
Content_complex cc = (Content_complex) rec.sOfContent.add().setChoice(ContentType.complex);
cc.flags.get(0).set(true);
cc.flags.get(1).set(false);
cc.flags.get(2).set(true);
cc.flags.get(3).set(false);
cc.string.set("a test string");
cc.longCardinal.set(1234567890L);
rec.sOfContent.add().setChoice(ContentType.empty);
Content_integer ci = (Content_integer) rec.sOfContent.add().setChoice(ContentType.integer);
ci.integer.set(42);
StringBuilder sb = new StringBuilder();
String recStr = rec.append(sb, "", "rec").toString();
// System.out.printf("-------\n%s\n-------\n", recStr);
iWireStream iws = new MockWireStream();
rec.serialize(iws);
CrSequences recReread = new CrSequences();
recReread.deserialize(iws);
sb.setLength(0);
String recRereadStr = recReread.append(sb, "", "rec").toString();
assertEquals("recStr eq recRereadStr", recStr, recRereadStr);
assertTrue(iws.isAtEnd());
}
use of dev.hawala.xns.level3.courier.StreamOf in project dodo by devhawala.
the class Clearinghouse3Impl method listDomainsServed.
/*
* ListDomainServed: PROCEDURE [domains: BulkData.Sink, agent: Authenticator]
* REPORTS [AuthenticationError, CallError] = 1;
*
* problem: there is no definitive specification of what is to be
* transported through the bulk data transfer...
* ... according to "bfsgetdoms.c" it is: StreamOfDomainName
*/
private static void listDomainsServed(Clearinghouse3.ListDomainServedParams params, RECORD results) {
Log.C.printf("CHS3", "Clearinghouse3.listDomainServed() :: start\n");
// create data for transfer the single domain we serve
StreamOf<TwoPartName> streamData = new StreamOf<>(0, 1, 2, TwoPartName::make);
TwoPartName name1 = streamData.add();
name1.organization.set(chsDatabase.getOrganizationName());
name1.domain.set(chsDatabase.getDomainName());
// and send the bulk data
sendBulkData("listDomainsServed", params.domains, streamData);
Log.C.printf("CHS3", "Clearinghouse3.listDomainServed() :: end\n");
}
use of dev.hawala.xns.level3.courier.StreamOf in project dodo by devhawala.
the class MailingOldImpl method inbasket_list.
/*
* list
* = procedure 2
*/
private static void inbasket_list(ListParams params, RECORD results) {
// log ingoing data
if (logParamsAndResults) {
StringBuilder sb = new StringBuilder();
params.append(sb, " ", "params");
log("##\n## procedure MailingImpl.inbasket_list() -- params\n%s\n##\n", sb.toString());
}
// get the session (we do not check the verifier, as we trust our clients...)
MailSession session = mailService.getSession(params.session.token.get());
if (session == null) {
new SessionErrorRecord(SessionProblem.handleInvalid).raise();
}
// get the mail attributes to deliver for a mail
List<Long> reqAttributes = new ArrayList<>();
for (int i = 0; i < params.selections.mailAttributes.size(); i++) {
reqAttributes.add(params.selections.mailAttributes.get(i).get());
}
// collect the data for the requested mail index range
StreamOf<ListElementRecord> bulkData = new StreamOf<>(0, 1, 1, ListElementRecord::make);
for (int mailboxIndex = params.range.first.get(); mailboxIndex <= params.range.last.get(); mailboxIndex++) {
ListElementRecord elem = mailService.produceListEntry(session, mailboxIndex, params.selections.transportEnvelope.get(), params.selections.inbasketEnvelope.get(), reqAttributes);
if (elem != null) {
bulkData.add(elem);
}
}
// send the mail data as bulk-data-transfer
try {
params.listing.send(bulkData, false);
} catch (NoMoreWriteSpaceException e) {
// ignore if aborted...
}
// log outgoing data (in fact none)
if (logParamsAndResults) {
StringBuilder sb = new StringBuilder();
results.append(sb, " ", "results");
log("##\n## procedure MailingImpl.inbasket_list() -- (bulk-data sent, no results)\n##\n");
}
}
Aggregations