Search in sources :

Example 1 with ReadContext

use of one.kii.summer.io.context.ReadContext 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 ReadContext

use of one.kii.summer.io.context.ReadContext in project kiimate by SINeWang.

the class SearchSubscriptionsCtl method search.

@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<SearchSubscriptionsApi.Subscriptions>> search(@RequestHeader(value = ErestHeaders.REQUEST_ID, required = false) String requestId, @RequestHeader(ErestHeaders.VISITOR_ID) String visitorId, @PathVariable(OWNER_ID) String ownerId, @RequestParam("q") String query) {
    ReadContext context = buildContext(requestId, ownerId, visitorId);
    SearchSubscriptionsApi.QueryForm form = new SearchSubscriptionsApi.QueryForm();
    form.setGroup(query);
    try {
        return ErestResponse.ok(requestId, searchSubscriptionsApi.search(context, form));
    } catch (BadRequest badRequest) {
        return ErestResponse.badRequest(requestId, badRequest.getKeys());
    }
}
Also used : BadRequest(one.kii.summer.io.exception.BadRequest) ReadContext(one.kii.summer.io.context.ReadContext) SearchSubscriptionsApi(one.kii.kiimate.model.core.api.SearchSubscriptionsApi)

Example 3 with ReadContext

use of one.kii.summer.io.context.ReadContext in project kiimate by SINeWang.

the class VisitIntensionCtl method visit.

private ResponseEntity<VisitIntensionsApi.Receipt> visit(String requestId, String ownerId, String visitorId, String group, String name, String tree) {
    ReadContext context = buildContext(requestId, ownerId, visitorId);
    VisitIntensionsApi.Form form = new VisitIntensionsApi.Form();
    form.setGroup(group);
    form.setName(name);
    form.setTree(tree);
    return VisitApiCaller.sync(api, context, form);
}
Also used : VisitIntensionsApi(one.kii.kiimate.model.core.api.VisitIntensionsApi) ReadContext(one.kii.summer.io.context.ReadContext)

Example 4 with ReadContext

use of one.kii.summer.io.context.ReadContext in project kiimate by SINeWang.

the class SearchExtensionsCtl method visit.

@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<?> visit(@RequestHeader(value = ErestHeaders.REQUEST_ID, required = false) String requestId, @RequestHeader(ErestHeaders.VISITOR_ID) String visitorId, @PathVariable(OWNER_ID) String ownerId, @RequestParam("group") String group) {
    ReadContext context = buildContext(requestId, ownerId, visitorId);
    SearchExtensionsApi.QueryForm queryForm = new SearchExtensionsApi.QueryForm();
    queryForm.setOwnerId(ownerId);
    queryForm.setGroup(group);
    List<SearchExtensionsApi.Extension> extensions = searchExtensionsApi.search(context, queryForm);
    return ErestResponse.ok(requestId, extensions);
}
Also used : SearchExtensionsApi(one.kii.kiimate.model.core.api.SearchExtensionsApi) ReadContext(one.kii.summer.io.context.ReadContext)

Example 5 with ReadContext

use of one.kii.summer.io.context.ReadContext in project kiimate by SINeWang.

the class SearchStatusesCtl method exploreModels.

@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<SearchStatusesApi.Statuses>> exploreModels(@RequestHeader(value = ErestHeaders.REQUEST_ID, required = false) String requestId, @RequestHeader(ErestHeaders.VISITOR_ID) String visitorId, @RequestParam("q") String query, @RequestParam("ownerId") String ownerId) {
    ReadContext context = buildContext(requestId, ownerId, visitorId);
    SearchStatusesApi.QueryForm form = new SearchStatusesApi.QueryForm();
    form.setQuery(query);
    List<SearchStatusesApi.Statuses> models = api.search(context, form);
    return ErestResponse.ok(requestId, models);
}
Also used : ReadContext(one.kii.summer.io.context.ReadContext) SearchStatusesApi(one.kii.kiimate.status.core.api.SearchStatusesApi)

Aggregations

ReadContext (one.kii.summer.io.context.ReadContext)11 BadRequest (one.kii.summer.io.exception.BadRequest)2 Panic (one.kii.summer.io.exception.Panic)2 SearchExtensionsApi (one.kii.kiimate.model.core.api.SearchExtensionsApi)1 SearchModelsApi (one.kii.kiimate.model.core.api.SearchModelsApi)1 SearchSubscriptionsApi (one.kii.kiimate.model.core.api.SearchSubscriptionsApi)1 VisitExtensionApi (one.kii.kiimate.model.core.api.VisitExtensionApi)1 VisitIntensionsApi (one.kii.kiimate.model.core.api.VisitIntensionsApi)1 VisitModelApi (one.kii.kiimate.model.core.api.VisitModelApi)1 SearchStatusesApi (one.kii.kiimate.status.core.api.SearchStatusesApi)1 VisitFatAssetApi (one.kii.kiimate.status.core.api.VisitFatAssetApi)1 VisitFatStatusApi (one.kii.kiimate.status.core.api.VisitFatStatusApi)1 VisitRawAssetApi (one.kii.kiimate.status.core.api.VisitRawAssetApi)1 SearchSubjectsApi (one.kii.kiimate.subject.core.api.SearchSubjectsApi)1 NotFound (one.kii.summer.io.exception.NotFound)1 DumperOptions (org.yaml.snakeyaml.DumperOptions)1 Yaml (org.yaml.snakeyaml.Yaml)1