Search in sources :

Example 16 with EUnexpected

use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.

the class Http1to2Framing method channelRead.

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    if (!(msg instanceof Http2Frame))
        throw new EUnexpected();
    var frame = (Http2Frame) msg;
    var httpObjs = translateResponseFrame(frame);
    for (var httpObj : httpObjs) ctx.fireChannelRead(httpObj);
}
Also used : EUnexpected(com.accenture.trac.common.exception.EUnexpected)

Example 17 with EUnexpected

use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.

the class ConfigHelpers method copyConfigFromJar.

public static void copyConfigFromJar(String jarPath, String rootConfigPath, Path targetDir) throws IOException {
    try (var jar = new JarFile(jarPath)) {
        for (var entries = jar.entries(); entries.hasMoreElements(); ) {
            var entry = entries.nextElement();
            var name = entry.getName();
            if (!name.startsWith(rootConfigPath))
                continue;
            if (entry.isDirectory())
                Files.createDirectory(targetDir.resolve(name));
            else {
                try (var stream = jar.getInputStream(entry)) {
                    var size = entry.getSize();
                    var bytes = new byte[(int) size];
                    var sizeRead = stream.read(bytes);
                    if (sizeRead != size)
                        throw new EUnexpected();
                    Files.write(targetDir.resolve(name), bytes);
                }
            }
        }
    }
}
Also used : EUnexpected(com.accenture.trac.common.exception.EUnexpected) JarFile(java.util.jar.JarFile)

Example 18 with EUnexpected

use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.

the class ValidationContext method pushList.

private ValidationContext pushList(Integer index) {
    var parentLoc = location.peek();
    if (!parentLoc.field().isRepeated() || parentLoc.field().isMapField())
        throw new EUnexpected();
    var list = (List<?>) parentLoc.target();
    var priorList = (List<?>) parentLoc.prior();
    var obj = list.get(index);
    var priorObj = priorList != null ? priorList.get(index) : null;
    var fieldName = String.format("[%d]", index);
    var loc = new ValidationLocation(parentLoc, null, obj, priorObj, null, parentLoc.field(), fieldName);
    if (parentLoc.skipped())
        loc.skip();
    location.push(loc);
    return this;
}
Also used : EUnexpected(com.accenture.trac.common.exception.EUnexpected)

Example 19 with EUnexpected

use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.

the class ValidationContext method applyList.

public <TMsg extends Message> ValidationContext applyList(ValidationFunction.Typed<TMsg> validator, Class<TMsg> msgClass) {
    if (done())
        return this;
    var loc = location.peek();
    if (!loc.field().isRepeated() || loc.field().isMapField())
        throw new EUnexpected();
    var list = (List<?>) loc.target();
    if (list == null)
        throw new EUnexpected();
    var resultCtx = this;
    for (var i = 0; i < list.size(); i++) {
        resultCtx = resultCtx.pushList(i).apply(validator, msgClass).pop();
    }
    return resultCtx;
}
Also used : EUnexpected(com.accenture.trac.common.exception.EUnexpected)

Example 20 with EUnexpected

use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.

the class Http1Router method processRequestContent.

private void processRequestContent(ChannelHandlerContext ctx, HttpContent msg) {
    try {
        var request = requests.getOrDefault(currentInboundRequest, null);
        if (request == null)
            throw new EUnexpected();
        if (REQUEST_STATUS_FINISHED.contains(request.status))
            return;
        if (!REQUEST_STATUS_CAN_RECEIVE.contains(request.status))
            throw new EUnexpected();
        var target = targets.getOrDefault(request.routeIndex, null);
        if (target == null)
            throw new EUnexpected();
        msg.retain();
        if (target.channel.isActive())
            target.channel.write(msg);
        else
            target.outboundQueue.add(msg);
    } finally {
        ReferenceCountUtil.release(msg);
    }
}
Also used : EUnexpected(com.accenture.trac.common.exception.EUnexpected)

Aggregations

EUnexpected (com.accenture.trac.common.exception.EUnexpected)44 IOException (java.io.IOException)8 EDataCorruption (com.accenture.trac.common.exception.EDataCorruption)4 ArrayList (java.util.ArrayList)3 ECacheTicket (com.accenture.trac.common.exception.ECacheTicket)2 EInputValidation (com.accenture.trac.common.exception.EInputValidation)2 ByteSeekableChannel (com.accenture.trac.common.util.ByteSeekableChannel)2 Http1to2Framing (com.accenture.trac.gateway.proxy.http.Http1to2Framing)2 JacksonException (com.fasterxml.jackson.core.JacksonException)2 JsonToken (com.fasterxml.jackson.core.JsonToken)2 ByteString (com.google.protobuf.ByteString)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ByteBufInputStream (io.netty.buffer.ByteBufInputStream)2 MetadataBatchRequest (com.accenture.trac.api.MetadataBatchRequest)1 MetadataBatchResponse (com.accenture.trac.api.MetadataBatchResponse)1 MetadataWriteRequest (com.accenture.trac.api.MetadataWriteRequest)1 TrustedMetadataApiGrpc (com.accenture.trac.api.TrustedMetadataApiGrpc)1 EMetadataNotFound (com.accenture.trac.common.exception.EMetadataNotFound)1 EPluginNotAvailable (com.accenture.trac.common.exception.EPluginNotAvailable)1 EStartup (com.accenture.trac.common.exception.EStartup)1