List of usage examples for java.lang Boolean toString
public static String toString(boolean b)
From source file:org.inquidia.mondrian.dynamicschemaprocessor.ParameterHandler.java
public void getParameters(Util.PropertyList connectInfo, IPentahoSession session, TransMeta transMeta) { try {/*from w w w . ja va2 s. co m*/ Iterator<Pair<String, String>> itConnectInfo = connectInfo.iterator(); while (itConnectInfo.hasNext()) { Pair<String, String> connectInfoPair = itConnectInfo.next(); LOGGER.debug("Attempting to set Kettle parameter " + connectInfoPair.getKey() + " to " + connectInfoPair.getValue()); transMeta.setParameterValue(connectInfoPair.getKey(), connectInfoPair.getValue()); } Iterator<String> itAttributeNames = session.getAttributeNames(); while (itAttributeNames.hasNext()) { String attributeName = itAttributeNames.next(); Object attributeValue = session.getAttribute(attributeName); LOGGER.debug( "Attempting to set Kettle parameter " + attributeName + " to " + attributeValue.toString()); transMeta.setParameterValue(attributeName, attributeValue.toString()); if (attributeValue instanceof SecurityContextImpl) { SecurityContextImpl sci = (SecurityContextImpl) attributeValue; Authentication auth = sci.getAuthentication(); boolean isAuthenticated = auth.isAuthenticated(); LOGGER.debug("Attempting to set Kettle parameter Security.isAuthenticated to " + Boolean.toString(isAuthenticated)); transMeta.setParameterValue("Security.isAuthenticated", Boolean.toString(isAuthenticated)); GrantedAuthority[] authorities = auth.getAuthorities(); StringBuilder authorityList = new StringBuilder(); for (GrantedAuthority authority : authorities) { if (authorityList.length() == 0) { authorityList.append(authority.getAuthority()); } else { authorityList.append(",").append(authority.getAuthority()); } LOGGER.debug("Attempting to set Kettle parameter Security.role." + authority.getAuthority() + " to true"); transMeta.setParameterValue("Security.Role." + authority.getAuthority(), "true"); } LOGGER.debug("Attempting to set Kettle parameter Security.Authorities to " + authorityList.toString()); transMeta.setParameterValue("Security.Authorities", authorityList.toString()); if (auth.getPrincipal() instanceof User) { User user = (User) auth.getPrincipal(); LOGGER.debug("Attempting to set Kettle parameter Security.User.isAccountNonExpired to " + Boolean.toString(user.isAccountNonExpired())); transMeta.setParameterValue("Security.User.isAccountNonExpired", Boolean.toString(user.isAccountNonExpired())); LOGGER.debug("Attempting to set Kettle parameter Security.User.isAccountNonLocked to " + Boolean.toString(user.isAccountNonLocked())); transMeta.setParameterValue("Security.User.isAccountNonLocked", Boolean.toString(user.isAccountNonLocked())); LOGGER.debug("Attempting to set Kettle parameter Security.User.isCredentialsNonExpired to " + Boolean.toString(user.isCredentialsNonExpired())); transMeta.setParameterValue("Security.User.isCredentialsNonExpired", Boolean.toString(user.isCredentialsNonExpired())); LOGGER.debug("Attempting to set Kettle parameter Security.User.isEnabled to " + Boolean.toString(user.isEnabled())); transMeta.setParameterValue("Security.User.isEnabled", Boolean.toString(user.isEnabled())); } } else if (attributeValue instanceof IUserSettingService) { IUserSettingService userSettingService = (IUserSettingService) attributeValue; List<IUserSetting> userSettings = userSettingService.getUserSettings(); Iterator<IUserSetting> itUserSettings = userSettings.iterator(); while (itUserSettings.hasNext()) { IUserSetting setting = itUserSettings.next(); setting.getSettingName(); setting.getSettingValue(); LOGGER.debug("Attempting to set Kettle parameter UserSettting." + setting.getSettingName() + " to " + setting.getSettingValue()); transMeta.setParameterValue("UserSetting." + setting.getSettingName(), setting.getSettingValue()); } } } LOGGER.debug("Attempting to set Kettle parameter SessionName to " + session.getName()); transMeta.setParameterValue("SessionName", session.getName()); LOGGER.debug("Attempting to set Kettle parameter SessionLocale to " + session.getLocale().toString()); transMeta.setParameterValue("SessionLocale", session.getLocale().toString()); LOGGER.debug("Attempting to set Kettle parameter SessionId to " + session.getId()); transMeta.setParameterValue("SessionId", session.getId()); } catch (UnknownParamException ex) { //ignore } }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.DeckProfile.java
@Override public ProfileConfig generateFullConfig(ProfileConfig config, DeploymentConfiguration deploymentConfiguration, SpinnakerEndpoints endpoints) {// w ww .j a va 2 s. c om StringResource configTemplate = new StringResource(config.getPrimaryConfigContents()); // Configure apache2 JarResource spinnakerConfTemplate = new JarResource("/apache2/spinnaker.conf"); JarResource portsConfTemplate = new JarResource("/apache2/ports.conf"); Map<String, String> bindings = new HashMap<>(); bindings.put("deck-host", endpoints.getServices().getDeck().getHost()); bindings.put("deck-port", endpoints.getServices().getDeck().getPort() + ""); config.extendConfig("apache2/spinnaker.conf", spinnakerConfTemplate.setBindings(bindings).toString()); config.extendConfig("apache2/ports.conf", portsConfTemplate.setBindings(bindings).toString()); Features features = deploymentConfiguration.getFeatures(); bindings = new HashMap<>(); // Configure global settings bindings.put("gate.baseUrl", endpoints.getServices().getGate().getPublicEndpoint()); bindings.put("timezone", deploymentConfiguration.getTimezone()); // Configure feature-flags bindings.put("features.auth", Boolean.toString(features.isAuth(deploymentConfiguration))); bindings.put("features.chaos", Boolean.toString(features.isChaos())); bindings.put("features.fiat", Boolean.toString(features.isFiat())); bindings.put("features.jobs", Boolean.toString(features.isJobs())); // Configure Kubernetes KubernetesProvider kubernetesProvider = deploymentConfiguration.getProviders().getKubernetes(); bindings.put("kubernetes.default.account", kubernetesProvider.getPrimaryAccount()); bindings.put("kubernetes.default.namespace", "default"); bindings.put("kubernetes.default.proxy", "localhost:8001"); // Configure GCE GoogleProvider googleProvider = deploymentConfiguration.getProviders().getGoogle(); bindings.put("google.default.account", googleProvider.getPrimaryAccount()); bindings.put("google.default.region", "us-central1"); bindings.put("google.default.zone", "us-central1-f"); // Configure Appengine AppengineProvider appengineProvider = deploymentConfiguration.getProviders().getAppengine(); bindings.put("appengine.default.account", appengineProvider.getPrimaryAccount()); bindings.put("appengine.enabled", Boolean.toString(appengineProvider.getPrimaryAccount() != null)); // Configure Openstack OpenstackProvider openstackProvider = deploymentConfiguration.getProviders().getOpenstack(); bindings.put("openstack.default.account", openstackProvider.getPrimaryAccount()); if (openstackProvider.getPrimaryAccount() != null) { OpenstackAccount openstackAccount = (OpenstackAccount) accountService.getProviderAccount( deploymentConfiguration.getName(), "openstack", openstackProvider.getPrimaryAccount()); //Regions in openstack are a comma separated list. Use the first as primary. String firstRegion = StringUtils.substringBefore(openstackAccount.getRegions(), ","); bindings.put("openstack.default.region", firstRegion); } config.setConfig(config.getPrimaryConfigFile(), configTemplate.setBindings(bindings).toString()); return config; }
From source file:com.sawyer.advadapters.app.data.MovieItem.java
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(title);/* w w w .j a v a2s.c o m*/ dest.writeInt(year); dest.writeInt(mBarcode); dest.writeString(Boolean.toString(isRecommended)); }
From source file:com.screenslicer.core.nlp.NlpUtil.java
public static Collection<String> stems(String src, boolean ignoreCommonWords, boolean oneStemOnly) { if (stemsCache.size() > MAX_CACHE) { stemsCache.clear();/* w ww . j a v a 2 s . c om*/ } String cacheKey = src + "<<>>" + Boolean.toString(ignoreCommonWords) + "<<>>" + Boolean.toString(oneStemOnly); if (stemsCache.containsKey(cacheKey)) { return stemsCache.get(cacheKey); } ignoreCommonWords = false; Collection<String> tokens = tokens(src, true); Collection<String> stems = new LinkedHashSet<String>(); for (String word : tokens) { List<String> curStems = null; try { curStems = stemmer.findStems(word, null); } catch (Throwable t) { } if (curStems != null) { if (curStems.isEmpty()) { String cleanWord = word.toLowerCase().trim(); if (cleanWord.matches(".*?[^\\p{Punct}].*") && (!ignoreCommonWords || !ignoredTerms.contains(cleanWord) || validTermsByCase.contains(word.trim()))) { stems.add(cleanWord); } } else { if (!ignoreCommonWords) { if (oneStemOnly) { stems.add(curStems.get(0)); } else { stems.addAll(curStems); } } else { for (String curStem : curStems) { if (!ignoredTerms.contains(curStem) || validTermsByCase.contains(word.trim())) { stems.add(curStem); if (oneStemOnly) { break; } } } } } } } stemsCache.put(cacheKey, stems); return stems; }
From source file:net.cellcloud.talk.stuff.Stuff.java
/** */ public Stuff(StuffType type, boolean value) { this.type = type; this.value = Boolean.toString(value); this.literalBase = LiteralBase.BOOL; }
From source file:com.revo.deployr.client.call.repository.RepositoryFileUploadCall.java
/** * Internal use only, to execute call use RClient.execute(). *///from ww w .ja v a2 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")); if (options.filename != null) entity.addPart("filename", new StringBody(options.filename, "text/plain", Charset.forName("UTF-8"))); 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.newversionmsg != null) entity.addPart("newversionmsg", new StringBody(options.newversionmsg, "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("RepositoryFileUploadCall: unsupported encoding exception.", ueex); } catch (IOException ioex) { log.warn("RepositoryFileUploadCall: io exception.", ioex); } return pResult; }
From source file:com.intuit.tank.project.JobDetailFormatter.java
protected static String buildDetails(JobValidator validator, Workload workload, JobInstance proposedJobInstance, String scriptName) {// www . j a v a 2 s .c om StringBuilder sb = new StringBuilder(); StringBuilder errorSB = new StringBuilder(); TankConfig config = new TankConfig(); if (proposedJobInstance != null) { if (StringUtils.isBlank(proposedJobInstance.getName())) { addError(errorSB, "Name cannot be null"); } JobRegionDao jrd = new JobRegionDao(); List<JobRegion> regions = new ArrayList<JobRegion>(); for (EntityVersion ver : proposedJobInstance.getJobRegionVersions()) { JobRegion region = jrd.findById(ver.getObjectId()); if (region != null) { long users = TestParamUtil.evaluateExpression(region.getUsers(), proposedJobInstance.getExecutionTime(), proposedJobInstance.getSimulationTime(), proposedJobInstance.getRampTime()); if (users > 0) { regions.add(new JobRegion(region.getRegion(), Long.toString(users))); } } } Collections.sort(regions); long simulationTime = getSimulationTime(proposedJobInstance, workload, validator); addProperty(sb, "General Information", "", "emphasis"); addProperty(sb, "Name", StringUtils.isBlank(proposedJobInstance.getName()) ? "Name cannot be null" : proposedJobInstance.getName(), StringUtils.isBlank(proposedJobInstance.getName()) ? "error" : null); addProperty(sb, "Workload Type", proposedJobInstance.getIncrementStrategy().name()); addProperty(sb, "Tank Http Client", config.getAgentConfig().getTankClientName(proposedJobInstance.getTankClientClass())); addProperty(sb, "Agent VM Type", getVmDetails(config, proposedJobInstance.getVmInstanceType())); addProperty(sb, "Assign Elastic Ips", Boolean.toString(proposedJobInstance.isUseEips())); addProperty(sb, "Max Users per Agent", Integer.toString(proposedJobInstance.getNumUsersPerAgent())); addProperty(sb, "Estimated Cost", calculateCost(config, proposedJobInstance, regions, simulationTime)); addProperty(sb, "Location", proposedJobInstance.getLocation()); addProperty(sb, "Logging Profile", LoggingProfile.fromString(proposedJobInstance.getLoggingProfile()).getDisplayName()); addProperty(sb, "Stop Behavior", StopBehavior.fromString(proposedJobInstance.getStopBehavior()).getDisplay()); addProperty(sb, "Run Scripts Until", proposedJobInstance.getTerminationPolicy().getDisplay(), proposedJobInstance.getTerminationPolicy() == TerminationPolicy.time && proposedJobInstance.getSimulationTime() == 0 ? "error" : null); sb.append(BREAK); addProperty(sb, "Simulation Time", TimeUtil.toTimeString(simulationTime)); if (proposedJobInstance.getTerminationPolicy() == TerminationPolicy.time && proposedJobInstance.getSimulationTime() == 0) { addError(errorSB, "Simulation time not set."); } addProperty(sb, "Ramp Time", TimeUtil.toTimeString(proposedJobInstance.getRampTime())); addProperty(sb, "Initial Users", Integer.toString(proposedJobInstance.getBaselineVirtualUsers())); addProperty(sb, "User Increment", Integer.toString(proposedJobInstance.getUserIntervalIncrement())); // users and regions sb.append(BREAK); addProperty(sb, "Total Users", Integer.toString(proposedJobInstance.getTotalVirtualUsers()), proposedJobInstance.getTotalVirtualUsers() == 0 ? "error" : "emphasis"); if (proposedJobInstance.getTotalVirtualUsers() == 0) { addError(errorSB, "No users defined."); } for (JobRegion r : regions) { if (config.getStandalone()) { addProperty(sb, " Users", r.getUsers()); } else { addProperty(sb, " " + r.getRegion().getDescription(), r.getUsers()); } } sb.append(BREAK); sb.append(BREAK); int userPercentage = 0; for (TestPlan plan : workload.getTestPlans()) { userPercentage += plan.getUserPercentage(); } if (userPercentage != 100) { addError(errorSB, "User Percentage of Test Plans does not add up to 100%"); } // datafiles addProperty(sb, "Data Files", proposedJobInstance.getDataFileVersions().size() == 0 ? "None" : null, "emphasis"); DataFileDao dfd = new DataFileDao(); Set<String> datafiles = new HashSet<String>(); for (EntityVersion ver : proposedJobInstance.getDataFileVersions()) { DataFile df = dfd.findById(ver.getObjectId()); if (df != null) { addProperty(sb, " " + df.getPath(), null); datafiles.add(df.getPath()); } else { addProperty(sb, " " + ver.getObjectId(), "data file not found.", "error"); } } sb.append(BREAK); // variables addProperty(sb, "Global Variables", proposedJobInstance.getVariables().size() == 0 ? "None" : " (Allow Overide: " + proposedJobInstance.isAllowOverride() + ")", "emphasis"); for (Entry<String, String> entry : proposedJobInstance.getVariables().entrySet()) { addProperty(sb, " " + entry.getKey(), entry.getValue()); if (entry.getValue().toLowerCase().endsWith(".csv") && !datafiles.contains(entry.getValue())) { addProperty(sb, " WARNING", "This variable, " + entry.getKey() + " appears to be a reference to a datafile, " + entry.getValue() + " that is not declared.", "error"); } } sb.append(BREAK); // notifications addProperty(sb, "Notifications", proposedJobInstance.getNotificationVersions().size() == 0 ? "None" : null, "emphasis"); JobNotificationDao jnd = new JobNotificationDao(); for (EntityVersion ver : proposedJobInstance.getNotificationVersions()) { JobNotification not = jnd.findById(ver.getObjectId()); if (not != null) { if (not.getLifecycleEvents().size() > 0) { addProperty(sb, " " + not.getRecipientList(), StringUtils.join(not.getLifecycleEvents(), ", ")); } else { addProperty(sb, " " + not.getRecipientList(), "no events selected", "error"); } } } sb.append(BREAK); addProperty(sb, "Scripts", "", "emphasis"); // scripts List<ScriptGroupStep> stepsList = new ArrayList<ScriptGroupStep>(); for (TestPlan plan : workload.getTestPlans()) { int numUsers = plan.getUserPercentage() > 0 ? proposedJobInstance.getTotalVirtualUsers() : 0; if (plan.getUserPercentage() < 100 && plan.getUserPercentage() > 0) { numUsers = (int) Math.floor(numUsers * ((double) plan.getUserPercentage() / 100D)); } addProperty(sb, " " + plan.getName(), plan.getUserPercentage() + "% : (" + numUsers + " users) : estimated Time " + TimeUtil.toTimeString(validator.getExpectedTime(plan.getName())), userPercentage != 100 ? "error" : null); if (plan.getScriptGroups().size() == 0) { addProperty(sb, " " + plan.getName(), "contains no script groups", "error"); } for (ScriptGroup group : plan.getScriptGroups()) { addProperty(sb, " " + group.getName(), "loop " + group.getLoop() + " time(s)"); if (group.getScriptGroupSteps().size() == 0) { addProperty(sb, " " + group.getName(), "contains no scripts", "error"); } for (ScriptGroupStep s : group.getScriptGroupSteps()) { stepsList.add(s); addProperty(sb, " " + s.getScript().getName(), "loop " + s.getLoop() + " time(s)"); } } } sb.append(BREAK); if (stepsList.size() == 0) { addError(errorSB, "No scripts defined."); } } else { addProperty(sb, scriptName, "Estimated Time " + validator.getDuration(scriptName), "emphasis"); sb.append(BREAK); sb.append(BREAK); } addProperty(sb, "Variable Validation", "", "emphasis"); addProperty(sb, " Declared Variables", "", "emphasis"); for (Entry<String, Set<String>> entry : validator.getDeclaredVariables().entrySet()) { for (String value : entry.getValue()) { addProperty(sb, " " + entry.getKey(), value, validator.isSuperfluous(entry.getKey()) ? "error" : null); } } sb.append(BREAK); addProperty(sb, " Used Variables", "", "emphasis"); for (String s : validator.getUsedVariables()) { addProperty(sb, " ", s, validator.isOrphaned(s) ? "error" : null); } sb.append(BREAK); if (validator.isProcessAssignements()) { addProperty(sb, " Assignements", "", "emphasis"); for (Entry<String, Set<String>> entry : validator.getAssignments().entrySet()) { for (String value : entry.getValue()) { addProperty(sb, " " + entry.getKey(), value, validator.isSuperfluous(entry.getKey()) ? "error" : null); } } sb.append(BREAK); } sb.append(BREAK); if (!validator.getBestPracticeViolations().isEmpty()) { StringBuilder tsb = new StringBuilder(); addProperty(tsb, "Best Practice Violations", "", "emphasis"); for (String s : validator.getBestPracticeViolations()) { addError(tsb, s); } tsb.append(BREAK); tsb.append(BREAK); sb.insert(0, tsb.toString()); } if (errorSB.length() > 0) { sb = new StringBuilder().append("ERRORS").append(BREAK).append(errorSB.append(BREAK).toString()) .append(sb.toString()); } return sb.toString(); }
From source file:com.net2plan.internal.CommandLineParser.java
private static Map<String, String> getParameters(List<Triple<String, String, String>> defaultParameters, Set<Entry<Object, Object>> inputParameters) { Map<String, String> parameters = new LinkedHashMap<String, String>(); if (defaultParameters != null) { for (Triple<String, String, String> param : defaultParameters) { if (RunnableCodeType.find(param.getSecond()) == null) { //String defaultValue = param.getSecond().toLowerCase(Locale.getDefault()); String defaultValue = param.getSecond(); if (defaultValue.indexOf("#select#") != -1) { //String auxOptions = param.getSecond().replaceFirst("#select#", "").trim(); String auxOptions = defaultValue .substring(defaultValue.indexOf("#select#") + "#select#".length()).trim(); String[] options = StringUtils.split(auxOptions, ", "); if (options.length > 0) { parameters.put(param.getFirst(), options[0]); continue; }//from w w w . j ava2 s . c o m } else if (defaultValue.indexOf("#boolean#") != -1) { boolean isSelected = Boolean.parseBoolean(defaultValue .substring(defaultValue.indexOf("#boolean#") + "#boolean#".length()).trim()); parameters.put(param.getFirst(), Boolean.toString(isSelected)); continue; } parameters.put(param.getFirst(), param.getSecond()); } else { parameters.put(param.getFirst() + "_file", ""); parameters.put(param.getFirst() + "_classname", ""); parameters.put(param.getFirst() + "_parameters", ""); } } } if (inputParameters != null) for (Entry param : inputParameters) if (parameters.containsKey(param.getKey().toString())) parameters.put(param.getKey().toString(), param.getValue().toString()); return parameters; }
From source file:com.spectralogic.ds3cli.views.cli.GetPhysicalPlacementWithFullDetailsView.java
private String[][] formatBulkObjectList(final BulkObject obj) { final String[][] formatArray = new String[1][]; final String[] bulkObjectArray = new String[7]; bulkObjectArray[0] = nullGuard(obj.getName()); bulkObjectArray[1] = nullGuard(obj.getId() != null ? obj.getId().toString() : ""); bulkObjectArray[2] = nullGuard(obj.getInCache() != null ? obj.getInCache().toString() : "Unknown"); bulkObjectArray[3] = nullGuard(Long.toString(obj.getLength())); bulkObjectArray[4] = nullGuard(Long.toString(obj.getOffset())); bulkObjectArray[5] = nullGuard(Boolean.toString(obj.getLatest())); bulkObjectArray[6] = nullGuard(Long.toString(obj.getVersion())); formatArray[0] = bulkObjectArray;//from w ww. j av a2 s .c o m return formatArray; }
From source file:com.microsoft.tfs.core.util.serverlist.internal.ServerListSerializer.java
/** * {@inheritDoc}/*from www . j a v a 2s . c om*/ */ @Override protected Document createDocumentFromComponent(final Object object) { final ServerList serverList = (ServerList) object; final Document document = DOMCreateUtils.newDocument(SERVERS_ELEMENT_NAME); final Element rootElement = document.getDocumentElement(); rootElement.setAttribute(VERSION_ATTRIBUTE_NAME, String.valueOf(SCHEMA_VERSION)); for (final ServerListConfigurationEntry server : serverList.getServers()) { final Element serverElement = DOMUtils.appendChild(rootElement, SERVER_ELEMENT_NAME); serverElement.setAttribute(NAME_ATTRIBUTE_NAME, server.getName()); serverElement.setAttribute(TYPE_ATTRIBUTE_NAME, Integer.toString(server.getType().getValue())); serverElement.setAttribute(URI_ATTRIBUTE_NAME, URIUtils.removeTrailingSlash(server.getURI()).toString()); final Set<ServerListCollectionEntry> collections = server.getCollections(); if (collections != null && collections.size() > 0) { final Element collectionsElement = DOMUtils.appendChild(serverElement, COLLECTIONS_ELEMENT_NAME); for (final ServerListCollectionEntry collection : collections) { final Element collectionElement = DOMUtils.appendChild(collectionsElement, COLLECTION_ELEMENT_NAME); collectionElement.setAttribute(NAME_ATTRIBUTE_NAME, collection.getName()); if (collection.getOffline() != null) { collectionElement.setAttribute(OFFLINE_ATTRIBUTE_NAME, Boolean.toString(collection.getOffline())); } collectionElement.setAttribute(TYPE_ATTRIBUTE_NAME, Integer.toString(collection.getType().getValue())); collectionElement.setAttribute(URI_ATTRIBUTE_NAME, URIUtils.removeTrailingSlash(collection.getURI()).toString()); } } } return document; }