use of com.qlangtech.tis.manage.biz.dal.pojo.UploadResource in project tis by qlangtech.
the class ResSynManager method createNewResource.
/**
* @param context
* @param uploadContent
* @param md5
* @param fileGetter
* @param messageHandler
* @param runContext
* @return 新创建的主键
* @throws UnsupportedEncodingException
* @throws SchemaFileInvalidException
*/
public static Integer createNewResource(Context context, ISchemaPluginContext schemaPluginContext, final byte[] uploadContent, final String md5, PropteryGetter fileGetter, IMessageHandler messageHandler, RunContext runContext) throws SchemaFileInvalidException {
UploadResource resource = new UploadResource();
resource.setContent(uploadContent);
resource.setCreateTime(new Date());
resource.setResourceType(fileGetter.getFileName());
resource.setMd5Code(md5);
ConfigFileValidateResult validateResult = fileGetter.validate(schemaPluginContext, resource);
// 校验文件格式是否正确,通用用DTD来校验
if (!validateResult.isValid()) {
messageHandler.addErrorMessage(context, ERROR_MSG_SCHEMA_TITLE);
messageHandler.addErrorMessage(context, validateResult.getValidateResult());
throw new SchemaFileInvalidException(validateResult.getValidateResult());
}
return runContext.getUploadResourceDAO().insertSelective(resource);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.UploadResource in project tis by qlangtech.
the class SnapshotDomainUtils method mockEmployeeSnapshotDomain.
public static SnapshotDomain mockEmployeeSnapshotDomain() throws Exception {
SnapshotDomain snapshotDomain = new SnapshotDomain();
try (InputStream i = SnapshotDomainUtils.class.getResourceAsStream("search4employee-schema")) {
Objects.requireNonNull(i, "schema stream can not be null");
UploadResource schema = new UploadResource();
schema.setContent(IOUtils.toByteArray(i));
schema.setMd5Code(ConfigFileReader.md5file(schema.getContent()));
snapshotDomain.setSolrSchema(schema);
}
try (InputStream i = SnapshotDomainUtils.class.getResourceAsStream("search4employee-solrconfig")) {
Objects.requireNonNull(i, "solrconfig stream can not be null");
UploadResource solrCfg = new UploadResource();
solrCfg.setContent(IOUtils.toByteArray(i));
solrCfg.setMd5Code(ConfigFileReader.md5file(solrCfg.getContent()));
snapshotDomain.setSolrConfig(solrCfg);
}
// System.out.println(snapshotDomain);
return snapshotDomain;
}
use of com.qlangtech.tis.manage.biz.dal.pojo.UploadResource in project tis by qlangtech.
the class TestSchemaAction method testDoSaveByExpertModel.
/**
* 测试专家模式Schema保存, 将mall_id类型由string改成test类型,并且去掉了一个动态字段pt_*
*
* @throws Exception
*/
public void testDoSaveByExpertModel() throws Exception {
// event_submit_do_save_by_expert_model: y
request.setParameter("emethod", "saveByExpertModel");
request.setParameter("action", "schema_action");
// request.addHeader("appname", collection);
setCollection(collection);
try (InputStream post = this.getClass().getResourceAsStream("schema-action-do-save-by-expert-model.json")) {
request.setContent(IOUtils.toByteArray(post));
}
ActionProxy proxy = getActionProxy();
String result = proxy.execute();
assertEquals("SchemaAction_ajax", result);
AjaxValve.ActionExecResult aResult = showBizResult();
assertNotNull(aResult);
assertTrue(aResult.isSuccess());
// this.verifyAll();
SchemaAction.CreateSnapshotResult bizResult = (SchemaAction.CreateSnapshotResult) aResult.getBizResult();
assertNotNull(bizResult);
Integer newSnapshotId = bizResult.getNewId();
assertTrue("newSnapshotId can not be null", newSnapshotId > 0);
SnapshotDomain snapshotView = runContext.getSnapshotViewDAO().getView(newSnapshotId);
assertNotNull("snapshotView can not be null", snapshotView);
UploadResource solrSchema = snapshotView.getSolrSchema();
String mallIdTypeModifiedXml = StringUtils.remove(new String(solrSchema.getContent(), TisUTF8.get()), '\r');
try (InputStream input = this.getClass().getResourceAsStream("schema-action-do-save-by-expert-model-modify-mallid-type-assert.xml")) {
assertNotNull(input);
String mallIdTypeModifiedXmlExpect = StringUtils.trimToEmpty(IOUtils.toString(input, TisUTF8.get()));
assertEquals(mallIdTypeModifiedXmlExpect, StringUtils.trimToEmpty(mallIdTypeModifiedXml));
}
// JsonUtil.assertJSONEqual(TestSchemaAction.class, "schema-action-do-save-by-expert-model-modify-mallid-type-assert.xml"
// , mallIdTypeModifiedXml, (msg, e, a) -> {
// assertEquals(msg, e, a);
// });
}
use of com.qlangtech.tis.manage.biz.dal.pojo.UploadResource in project tis by qlangtech.
the class UploadJarAction method processFormItem.
public static Snapshot processFormItem(RunContext runContext, ConfigContentGetter getter, Snapshot snapshot) throws IOException {
// InputStream reader = null;
// try {
// reader = getter.formItem.getInputStream();
UploadResource solrCoreDependedResource = new UploadResource();
solrCoreDependedResource.setCreateTime(new Date());
solrCoreDependedResource.setContent(getter.getContent());
solrCoreDependedResource.setMd5Code(ConfigFileReader.md5file(solrCoreDependedResource.getContent()));
solrCoreDependedResource.setResourceType(getter.getterStrategy.getFileName());
Integer newid = runContext.getUploadResourceDAO().insertSelective(solrCoreDependedResource);
return getter.getterStrategy.createNewSnapshot(newid, snapshot);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.UploadResource in project tis by qlangtech.
the class TestGetAppConfigBySnid method testGetResource.
public void testGetResource() {
try {
SnapshotDomain domain = HttpConfigFileReader.getResource("http://localhost", 222);
UploadResource resource = domain.getSolrSchema();
Assert.assertNotNull(resource);
Assert.assertNotNull(resource.getContent());
} catch (RepositoryException e) {
Assert.assertFalse(e.getMessage(), true);
}
}
Aggregations