use of one.kii.summer.io.exception.Panic 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());
}
}
use of one.kii.summer.io.exception.Panic in project kiimate by SINeWang.
the class DefaultSearchGlimpseIntensionsApi method search.
@Override
public List<Intension> search(ReadContext context, ZoomOutBySet form) throws BadRequest, Panic {
GlimpsesDai.Publication publication = glimpsesDai.load(form);
ModelSubscriptionDai.ClueModelSubId modelSubId = new ModelSubscriptionDai.ClueModelSubId();
modelSubId.setId(publication.getModelSubId());
ModelSubscriptionDai.Instance instance;
try {
instance = modelSubscriptionDai.load(modelSubId);
} catch (NotFound notFound) {
throw new Panic(notFound.getKeys());
}
IntensionDai.ChannelPubSet set = ValueMapping.from(IntensionDai.ChannelPubSet.class, instance);
List<IntensionDai.Record> records = intensionDai.loadLast(set);
List<Intension> intensions = ValueMapping.from(Intension.class, records);
return NotBadResponse.of(intensions);
}
use of one.kii.summer.io.exception.Panic in project kiimate by SINeWang.
the class TestDeclareReceiptApi method testSave.
@Test
public void testSave() {
String group = "testGroup";
String name = "testName";
String tree = "testTree";
DeclareExtensionApi.CommitForm commitForm = new DeclareExtensionApi.CommitForm();
commitForm.setGroup(group);
commitForm.setName(name);
commitForm.setTree(tree);
WriteContext context = new WriteContext(requestId, ownerId, operatorId);
commitForm.setVisibility("protected");
DeclareExtensionApi.CommitReceipt response = null;
try {
response = declareExtensionApi.commit(context, commitForm);
} catch (Exception e) {
e.printStackTrace();
}
String id = response.getId();
Assert.assertNotNull(id);
ExtensionDai.ChannelId extId = new ExtensionDai.ChannelId();
extId.setId(Long.valueOf(id));
ExtensionDai.Record record = null;
try {
record = extensionDai.loadLast(extId);
} catch (Panic panic) {
panic.printStackTrace();
}
Assert.assertNotNull(record);
extensionMapper.deleteExtensionById(Long.valueOf(id));
}
use of one.kii.summer.io.exception.Panic in project kiimate by SINeWang.
the class SearchModelsCtl method exploreModels.
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<SearchModelsApi.Models>> exploreModels(@RequestHeader(value = ErestHeaders.REQUEST_ID, required = false) String requestId, @RequestHeader(ErestHeaders.VISITOR_ID) String visitorId, @RequestParam("q") String query) {
ReadContext context = buildContext(requestId, null, visitorId);
SearchModelsApi.QueryModelsForm form = new SearchModelsApi.QueryModelsForm();
form.setGroup(query);
try {
return ErestResponse.ok(requestId, searchModelsApi.search(context, form));
} catch (Panic panic) {
return ErestResponse.panic(requestId, panic.getKeys());
}
}
Aggregations