List of usage examples for java.lang Boolean toString
public static String toString(boolean b)
From source file:com.revo.deployr.client.call.repository.RepositoryDirectoryUploadCall.java
/** * Internal use only, to execute call use RClient.execute(). *///w w w . ja v a 2 s . c o m public RCoreResult call() { RCoreResultImpl pResult = null; try { HttpPost httpPost = new HttpPost(serverUrl + API); super.httpUriRequest = httpPost; List<NameValuePair> postParams = new ArrayList<NameValuePair>(); postParams.add(new BasicNameValuePair("format", "json")); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); entity.addPart("file", new InputStreamBody(((InputStream) zipStream), "application/zip")); if (options.directory != null) entity.addPart("directory", new StringBody(options.directory, "text/plain", Charset.forName("UTF-8"))); if (options.descr != null) entity.addPart("descr", new StringBody(options.descr, "text/plain", Charset.forName("UTF-8"))); entity.addPart("newversion", new StringBody(Boolean.toString(options.newversion), "text/plain", Charset.forName("UTF-8"))); if (options.restricted != null) entity.addPart("restricted", new StringBody(options.restricted, "text/plain", Charset.forName("UTF-8"))); entity.addPart("shared", new StringBody(Boolean.toString(options.shared), "text/plain", Charset.forName("UTF-8"))); entity.addPart("published", new StringBody(Boolean.toString(options.published), "text/plain", Charset.forName("UTF-8"))); if (options.inputs != null) entity.addPart("inputs", new StringBody(options.inputs, "text/plain", Charset.forName("UTF-8"))); if (options.outputs != null) entity.addPart("outputs", new StringBody(options.outputs, "text/plain", Charset.forName("UTF-8"))); entity.addPart("format", new StringBody("json", "text/plain", Charset.forName("UTF-8"))); httpPost.setEntity(entity); // set any custom headers on the request for (Map.Entry<String, String> entry : httpHeaders.entrySet()) { httpPost.addHeader(entry.getKey(), entry.getValue()); } HttpResponse response = httpClient.execute(httpPost); StatusLine statusLine = response.getStatusLine(); HttpEntity responseEntity = response.getEntity(); String markup = EntityUtils.toString(responseEntity); pResult = new RCoreResultImpl(response.getAllHeaders()); pResult.parseMarkup(markup, API, statusLine.getStatusCode(), statusLine.getReasonPhrase()); } catch (UnsupportedEncodingException ueex) { log.warn("RepositoryDirectoryUploadCall: unsupported encoding exception.", ueex); } catch (IOException ioex) { log.warn("RepositoryDirectoryUploadCall: io exception.", ioex); } return pResult; }
From source file:org.ambraproject.wombat.controller.WombatController.java
/** * Interpret a URL parameter as a boolean. In general, interpret {@code null} as false and all non-null strings, * including the empty string, as true. But the string {@code "false"} is (case-insensitively) false. * <p/>//from ww w . j a va 2 s .c om * The empty string is true because it represents a URL parameter as being present but with no value, e.g. {@code * http://example.com/page?foo}. Contrast {@link Boolean#valueOf(String)}, which returns false for the empty string. * * @param parameterValue a URL parameter value * @return the boolean value */ protected static boolean booleanParameter(String parameterValue) { return (parameterValue != null) && !Boolean.toString(false).equalsIgnoreCase(parameterValue); }
From source file:fr.paris.lutece.plugins.workflow.modules.rest.service.formatters.WorkflowFormatterJson.java
/** * {@inheritDoc }/*from w w w . j a v a2 s . c om*/ */ @Override public String format(Workflow workflow) { JSONObject jsonObject = new JSONObject(); DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, I18nService.getDefaultLocale()); String strDate = dateFormat.format(workflow.getCreationDate()); jsonObject.element(WorkflowRestConstants.TAG_ID_WORKFLOW, workflow.getId()); jsonObject.element(WorkflowRestConstants.TAG_NAME, workflow.getName()); jsonObject.element(WorkflowRestConstants.TAG_DESCRIPTION, workflow.getDescription()); jsonObject.element(WorkflowRestConstants.TAG_CREATION_DATE, strDate); jsonObject.element(WorkflowRestConstants.TAG_IS_ENABLE, Boolean.toString(workflow.isEnabled())); jsonObject.element(WorkflowRestConstants.TAG_WORKGROUP_KEY, workflow.getWorkgroup()); return jsonObject.toString(); }
From source file:com.netflix.simianarmy.aws.conformity.RDSConformityClusterTracker.java
public Object value(boolean value) { return Boolean.toString(value); }
From source file:fr.paris.lutece.plugins.workflow.modules.rest.service.formatters.ResourceWorkflowFormatterJson.java
/** * {@inheritDoc }/* w w w . j a va2 s . c o m*/ */ @Override public String format(ResourceWorkflow resource) { JSONObject jsonObject = new JSONObject(); jsonObject.element(WorkflowRestConstants.TAG_ID_RESOURCE, resource.getIdResource()); jsonObject.element(WorkflowRestConstants.TAG_RESOURCE_TYPE, resource.getResourceType()); jsonObject.element(WorkflowRestConstants.TAG_ID_WORKFLOW, resource.getWorkflow().getId()); jsonObject.element(WorkflowRestConstants.TAG_ID_STATE, resource.getState().getId()); jsonObject.element(WorkflowRestConstants.TAG_ID_EXTERNAL_PARENT, resource.getExternalParentId()); jsonObject.element(WorkflowRestConstants.TAG_IS_ASSOCIATED_WITH_WORKGROUP, Boolean.toString(resource.isAssociatedWithWorkgroup())); if (!CollectionUtils.isEmpty(resource.getWorkgroups())) { JSONArray jsonArrayWorkgroups = new JSONArray(); for (String strWorkgroupKey : resource.getWorkgroups()) { JSONObject jsonWorkgroup = new JSONObject(); jsonWorkgroup.element(WorkflowRestConstants.TAG_WORKGROUP_KEY, strWorkgroupKey); jsonArrayWorkgroups.add(jsonWorkgroup); } jsonObject.element(WorkflowRestConstants.TAG_WORKGROUPS, jsonArrayWorkgroups); } return jsonObject.toString(); }
From source file:net.greghaines.jesque.WorkerStatus.java
/** * {@inheritDoc}/*from w w w . j a va2s .c o m*/ */ @Override public String toString() { return "WorkerStatus [queue=" + this.queue + ", runAt=" + this.runAt + ", paused=" + Boolean.toString(this.paused) + ", payload=" + this.payload + "]"; }
From source file:com.medvision360.medrecord.basex.XmlWrappedArchetypeConverter.java
@Override public WrappedArchetype serialize(WrappedArchetype archetype, OutputStream os, String encoding) throws IOException, SerializeException { String asString = archetype.getAsString(); if (asString == null || "".equals(asString)) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); m_delegate.serialize(archetype, bos, encoding); byte[] bytes = bos.toByteArray(); asString = new String(bytes, encoding); }/*from www . j a v a2s.c om*/ Element root = new Element("archetype"); set(root, "/asString", asString); set(root, "/locked", Boolean.toString(archetype.isLocked())); Document d = new Document(root); outputDocument(d, os, encoding); return new WrappedArchetype(asString, archetype.getArchetype(), archetype.isLocked()); }
From source file:org.alfresco.sync.DesktopSyncAbstract.java
public void setupContext() throws Exception { List<String> contextXMLList = new ArrayList<String>(); contextXMLList.add("desktopsync-test-context.xml"); ctx = new ClassPathXmlApplicationContext(contextXMLList.toArray(new String[contextXMLList.size()])); DesktopSyncProperties t = (DesktopSyncProperties) ctx.getBean("desktopSyncProperties"); shareUrl = t.getShareUrl();/* ww w .j a va 2 s . c om*/ username = t.getUsername(); password = t.getPassword(); googleusername = t.getGoogleUserName(); googlepassword = t.getGooglePassword(); location = t.getLocation(); siteName = t.getSiteName(); downloadPath = t.getFiledirectoryPath(); installerPath = t.getInstallerpath(); syncImmediately = t.getSyncImmediately(); displayProperties("Client Sync Location", location); displayProperties("Share URL", shareUrl); displayProperties("SiteName", siteName); displayProperties("downloadPath", downloadPath); displayProperties("Sync Immediately", Boolean.toString(syncImmediately)); }
From source file:com.revo.deployr.client.call.project.ProjectDirectoryUploadCall.java
/** * Internal use only, to execute call use RClient.execute(). *//* w ww .j av a 2 s. co m*/ public RCoreResult call() { RCoreResultImpl pResult = null; try { HttpPost httpPost = new HttpPost(serverUrl + API); super.httpUriRequest = httpPost; List<NameValuePair> postParams = new ArrayList<NameValuePair>(); postParams.add(new BasicNameValuePair("format", "json")); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); entity.addPart("file", new InputStreamBody(((InputStream) fileStream), "application/zip")); entity.addPart("project", new StringBody(project, "text/plain", Charset.forName("UTF-8"))); entity.addPart("filename", new StringBody(options.filename, "text/plain", Charset.forName("UTF-8"))); if (options.descr != null) entity.addPart("descr", new StringBody(options.descr, "text/plain", Charset.forName("UTF-8"))); entity.addPart("overwrite", new StringBody(Boolean.toString(options.overwrite), "text/plain", Charset.forName("UTF-8"))); entity.addPart("format", new StringBody("json", "text/plain", Charset.forName("UTF-8"))); httpPost.setEntity(entity); // set any custom headers on the request for (Map.Entry<String, String> entry : httpHeaders.entrySet()) { httpPost.addHeader(entry.getKey(), entry.getValue()); } HttpResponse response = httpClient.execute(httpPost); StatusLine statusLine = response.getStatusLine(); HttpEntity responseEntity = response.getEntity(); String markup = EntityUtils.toString(responseEntity); pResult = new RCoreResultImpl(response.getAllHeaders()); pResult.parseMarkup(markup, API, statusLine.getStatusCode(), statusLine.getReasonPhrase()); } catch (UnsupportedEncodingException ueex) { log.warn("ProjectDirectoryUploadCall: unsupported encoding exception.", ueex); } catch (IOException ioex) { log.warn("ProjectDirectoryUploadCall: io exception.", ioex); } return pResult; }
From source file:brooklyn.rest.resources.CatalogResetTest.java
private void reset(String bundleLocation, boolean ignoreErrors) throws Exception { String xml = ResourceUtils.create(this).getResourceAsString("classpath://reset-catalog.xml"); client().resource("/v1/catalog/reset").queryParam("ignoreErrors", Boolean.toString(ignoreErrors)) .header("Content-type", MediaType.APPLICATION_XML) .post(xml.replace("${bundle-location}", bundleLocation)); //if above succeeds assert catalog contents assertItems();//from w w w . jav a 2s. c o m }