/** * Sets the {@link MediaType} and fileEntity for this {@link FormDataBodyPart}. * * @param fileEntity the entity of this body part. * @param mediaType the media type. */ public void setFileEntity(final File fileEntity, final MediaType mediaType) { super.setMediaType(mediaType); super.setEntity(fileEntity); this.fileEntity = fileEntity; if (fileEntity != null) { FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition.name(getName()); builder.fileName(fileEntity.getName()); if (fileEntity.exists()) { builder.size(fileEntity.length()); builder.modificationDate(new Date(fileEntity.lastModified())); } setFormDataContentDisposition(builder.build()); } }
/** * Sets the control name. * * @param name the control name. */ public void setName(String name) { if (name == null) { throw new IllegalArgumentException(LocalizationMessages.CONTROL_NAME_CANNOT_BE_NULL()); } if (getFormDataContentDisposition() == null) { FormDataContentDisposition contentDisposition; contentDisposition = FormDataContentDisposition.name(name).build(); super.setContentDisposition(contentDisposition); } else { FormDataContentDisposition formDataContentDisposition = FormDataContentDisposition.name(name) .fileName(contentDisposition.getFileName()) .creationDate(contentDisposition.getCreationDate()) .modificationDate(contentDisposition.getModificationDate()) .readDate(contentDisposition.getReadDate()) .size(contentDisposition.getSize()).build(); super.setContentDisposition(formDataContentDisposition); } }
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from " + TEST_TABLE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), mt)); final QueryHandle handle = target.request(mt).post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from " + TEST_TABLE)); mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); LensConf conf = new LensConf(); conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, "true"); conf.addProperty("deferPersistenceByMillis", 5000); // defer persistence for 5 secs mp3.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); final QueryHandle handle3 = target.request(mt).post(Entity.entity(mp3, MediaType.MULTIPART_FORM_DATA_TYPE),
final FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), "foo")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), "bar")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(), new LensConf(), mt)); setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), handle, mt)); setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("key").build(), "hivevar:myvar")); setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("value").build(), "10")); APIResult result = paramtarget.request(mt).put(Entity.entity(setpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), handle, mt)); setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("key").build(), "hiveconf:my.conf")); setpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("value").build(), "myvalue")); result = paramtarget.request(mt).put(Entity.entity(setpart, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class); Assert.assertEquals(result.getStatus(), APIResult.Status.SUCCEEDED);
final FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), "foo")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), "bar")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(), new LensConf(), MediaType.APPLICATION_XML_TYPE)); query.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, MediaType.APPLICATION_XML_TYPE)); query.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select id from test_table")); query.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); query.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), MediaType.APPLICATION_XML_TYPE));
LensConf conf = new LensConf(); conf.addProperty("my.property", "myvalue"); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); APIResult updateConf = target.path(theHandle.toString()).request(mt)
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR, IDARR, IDSTRARR from " + testTable)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); QueryHandle handle = target.request(mt) .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
LensConf conf = new LensConf(); conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false"); drop.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); drop.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "drop table if exists temp_output")); drop.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); drop.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); final QueryHandle dropHandle = target.request(mt).post(Entity.entity(drop, MediaType.MULTIPART_FORM_DATA_TYPE), conf = new LensConf(); conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false"); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "create table temp_output as select ID, IDSTR from " + TEST_TABLE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); final QueryHandle handle = target.request(mt).post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), fetch.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); fetch.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), select)); fetch.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); fetch.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); final QueryHandle handle2 = target.request(mt).post(Entity.entity(fetch, MediaType.MULTIPART_FORM_DATA_TYPE),
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + TEST_TABLE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "prepare")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), "testQuery1")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), mt)); LensConf conf = new LensConf(); conf.addProperty("my.property", "myvalue"); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); APIResult updateConf = target.path(pHandle.toString()).request(mt) confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), "testQueryName2"));
final FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), "foo")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), "bar")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(), new LensConf(), mt)); final WebTarget resourcetarget = target().path("session/resources"); final FormDataMultiPart mp1 = new FormDataMultiPart(); mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), handle, mt)); mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), "file")); mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(), lensSiteFilePath)); APIResult result = resourcetarget.path("add").request(mt) mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), handle, mt)); mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), "file")); mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(), lensSiteFilePath)); result = resourcetarget.path("delete").request(mt)
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + TEST_TABLE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain_and_prepare")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), mt)); LensConf conf = new LensConf(); conf.addProperty("my.property", "myvalue"); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); APIResult updateConf = target.path(plan.getPrepareHandle().toString()).request(mt)
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), query)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute_with_timeout")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("timeoutmillis").build(), timeOutMillis + "")); LensConf conf = new LensConf(); conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, "true"); conf.addProperty(LensConfConstants.QUERY_OUTPUT_FORMATTER, DeferredInMemoryResultFormatter.class.getName()); conf.addProperty("deferPersistenceByMillis", deferPersistenceByMillis); // property used for test only mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, APPLICATION_XML_TYPE)); QueryHandleWithResultSet result = target.request(APPLICATION_XML_TYPE)
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), connection .getSessionHandle(), MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), sql)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "EXECUTE_WITH_TIMEOUT")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("timeoutmillis").build(), "" + timeOutMillis)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), queryName == null ? "" : queryName)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, MediaType.APPLICATION_XML_TYPE)); WebTarget target = getQueryWebTarget(client);
conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, "false"); conf.addProperty(LensConfConstants.QUERY_MAIL_NOTIFY, "false"); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, defaultMT)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from " + TEST_TABLE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, defaultMT));
sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), "foo")); sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), "bar")); sessionForm.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf") .build(), new LensConf(), defaultMT)); mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), restartTestSession, defaultMT)); mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("type").build(), "file")); mp1.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("path").build(), "target/test-classes/lens-site.xml")); APIResult result = resourcetarget.path("add").request(defaultMT)
String createTable = "CREATE TABLE IF NOT EXISTS " + tblName + schemaStr; mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), createTable)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), "foo")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), "bar")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(), sessionconf, mt));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + TEST_TABLE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), mt)); mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + TEST_TABLE)); mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain_and_prepare")); mp2.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), mt));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), connection .getSessionHandle(), MediaType.APPLICATION_XML_TYPE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), sql)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "EXECUTE_WITH_TIMEOUT")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("timeoutmillis").build(), "" + timeOutMillis)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), queryName == null ? "" : queryName)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, MediaType.APPLICATION_XML_TYPE)); WebTarget target = getQueryWebTarget(client);
LensConf conf = new LensConf(); conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false"); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID, IDSTR from " + TEST_TABLE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), conf, mt)); final QueryHandle handle = target.request(mt).post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),