Search in sources :

Example 1 with NotFound

use of one.kii.summer.io.exception.NotFound in project kiimate by SINeWang.

the class VisitRawAssetCtl method visit.

@RequestMapping(value = "/{" + GROUP + "}/{" + NAME + "}/{" + STABILITY + "}/{" + VERSION + ":.+}/raw")
public ResponseEntity<?> visit(@RequestHeader(value = ErestHeaders.REQUEST_ID, required = false) String requestId, @RequestHeader(ErestHeaders.VISITOR_ID) String visitorId, @PathVariable(OWNER_ID) String ownerId, @PathVariable(GROUP) String group, @PathVariable(NAME) String name, @PathVariable(STABILITY) String stability, @PathVariable(VERSION) String version, @RequestParam(value = FORMAT_YML, required = false) String yml) {
    ReadContext context = buildContext(requestId, ownerId, visitorId);
    VisitRawAssetApi.GroupNameForm form = new VisitRawAssetApi.GroupNameForm();
    form.setGroup(group);
    form.setName(name);
    if (null != stability) {
        form.setStability(stability);
    }
    if (null != version) {
        form.setVersion(version);
    }
    try {
        if (yml == null) {
            return VisitApiCaller.sync(api, context, form);
        } else {
            DumperOptions options = new DumperOptions();
            options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
            try {
                Yaml yaml = new Yaml(options);
                return ErestResponse.ok(requestId, yaml.dump(api.visit(context, form)));
            } catch (BadRequest badRequest) {
                return ErestResponse.badRequest(requestId, badRequest.getKeys());
            } catch (Panic panic) {
                return ErestResponse.badRequest(requestId, panic.getKeys());
            }
        }
    } catch (NotFound notFound) {
        return ErestResponse.notFound(requestId, notFound.getKeys());
    }
}
Also used : BadRequest(one.kii.summer.io.exception.BadRequest) Panic(one.kii.summer.io.exception.Panic) ReadContext(one.kii.summer.io.context.ReadContext) DumperOptions(org.yaml.snakeyaml.DumperOptions) VisitRawAssetApi(one.kii.kiimate.status.core.api.VisitRawAssetApi) Yaml(org.yaml.snakeyaml.Yaml) NotFound(one.kii.summer.io.exception.NotFound)

Example 2 with NotFound

use of one.kii.summer.io.exception.NotFound in project kiimate by SINeWang.

the class DefaultVisitExtensionSpi method visit.

@Override
public String visit(GroupForm form) throws Panic {
    String url = baseUrl + URI;
    ErestGetBasic erest = new ErestGetBasic(visitorId);
    try {
        return erest.execute(url, String.class, ownerId, form.getGroup(), NAME_ROOT, TREE);
    } catch (NotFound notFound) {
        notFound.printStackTrace();
    } catch (BadRequest badRequest) {
        badRequest.printStackTrace();
    } catch (Panic panic) {
        panic.printStackTrace();
    }
    throw new Panic();
}
Also used : ErestGetBasic(one.kii.summer.io.sender.ErestGetBasic) BadRequest(one.kii.summer.io.exception.BadRequest) Panic(one.kii.summer.io.exception.Panic) NotFound(one.kii.summer.io.exception.NotFound)

Example 3 with NotFound

use of one.kii.summer.io.exception.NotFound in project kiimate by SINeWang.

the class DefaultVisitExtensionSpi method visit.

@Override
public String visit(GroupNameForm form) throws Panic {
    String url = baseUrl + URI;
    ErestGetBasic erest = new ErestGetBasic(visitorId);
    try {
        return erest.execute(url, String.class, ownerId, form.getGroup(), form.getName(), TREE);
    } catch (NotFound notFound) {
        notFound.printStackTrace();
    } catch (BadRequest badRequest) {
        badRequest.printStackTrace();
    } catch (Panic panic) {
        panic.printStackTrace();
    }
    throw new Panic();
}
Also used : ErestGetBasic(one.kii.summer.io.sender.ErestGetBasic) BadRequest(one.kii.summer.io.exception.BadRequest) Panic(one.kii.summer.io.exception.Panic) NotFound(one.kii.summer.io.exception.NotFound)

Aggregations

BadRequest (one.kii.summer.io.exception.BadRequest)3 NotFound (one.kii.summer.io.exception.NotFound)3 Panic (one.kii.summer.io.exception.Panic)3 ErestGetBasic (one.kii.summer.io.sender.ErestGetBasic)2 VisitRawAssetApi (one.kii.kiimate.status.core.api.VisitRawAssetApi)1 ReadContext (one.kii.summer.io.context.ReadContext)1 DumperOptions (org.yaml.snakeyaml.DumperOptions)1 Yaml (org.yaml.snakeyaml.Yaml)1