List of usage examples for java.util Collections addAll
@SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements)
From source file:org.gvsig.framework.web.controllers.OGCInfoController.java
/** * Get information and layers of WMS server indicated by url parameter * * @param request the {@code HttpServletRequest}. * @return ResponseEntity with wmsInfo/*from ww w. ja va 2 s . c om*/ */ @RequestMapping(params = "findWmsCapabilities", headers = "Accept=application/json", produces = { "application/json; charset=UTF-8" }) @ResponseBody public ResponseEntity<WMSInfo> findWmsCapabilitiesByAjax(WebRequest request) { String urlServer = request.getParameter("url"); String format = request.getParameter("format"); boolean isCalledByWizard = Boolean.parseBoolean(request.getParameter("wizard")); WMSInfo wmsInfo = null; String crsParam = request.getParameter("crs"); TreeSet<String> listCrs = new TreeSet<String>(); if (StringUtils.isNotEmpty(crsParam)) { Collections.addAll(listCrs, crsParam.split(",")); } if (StringUtils.isNotEmpty(urlServer)) { wmsInfo = ogcInfoServ.getCapabilitiesFromWMS(urlServer, listCrs, format, isCalledByWizard); } return new ResponseEntity<WMSInfo>(wmsInfo, HttpStatus.OK); }
From source file:de.Keyle.MyPet.api.util.inventory.IconMenuItem.java
public IconMenuItem setLore(String... lore) { Validate.notNull(lore, "Lore cannot be null"); this.lore.clear(); Collections.addAll(this.lore, lore); hasChanged = true;/*from www. j a v a 2s . c o m*/ return this; }
From source file:com.beginner.core.utils.FileZip.java
/** * ??./* w ww .ja v a 2s . c o m*/ * <p> * dest??,?,?null"".<br /> * null""?,???,??????,.zip?;<br /> * (File.separator),,??????,.zip?,???. * </p> * @param src ? * @param dest * @param isCreateDir ?,.<br />false,. * @param passwd ? * @return ?,null. */ public static String zip(String src, String dest, boolean isCreateDir, String passwd) { File srcFile = new File(src); dest = buildDestinationZipFilePath(srcFile, dest); ZipParameters parameters = new ZipParameters(); parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); // ? parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); // if (!StringUtils.isEmpty(passwd)) { parameters.setEncryptFiles(true); parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD); // ? parameters.setPassword(passwd.toCharArray()); } try { ZipFile zipFile = new ZipFile(dest); if (srcFile.isDirectory()) { // ??,,? if (!isCreateDir) { File[] subFiles = srcFile.listFiles(); ArrayList<File> temp = new ArrayList<File>(); Collections.addAll(temp, subFiles); zipFile.addFiles(temp, parameters); return dest; } zipFile.addFolder(srcFile, parameters); } else { zipFile.addFile(srcFile, parameters); } return dest; } catch (ZipException e) { e.printStackTrace(); } return null; }
From source file:nl.surfnet.coin.shared.service.GenericServiceHibernateImpl.java
/** * Convenience method for subclasses to find domain objects that match the Criterion's * * @param criterion array of {@link Criterion}'s * @return List of domain objects//from w ww . j a v a 2s . co m */ @SuppressWarnings("unchecked") protected List<T> findByCriteria(Criterion... criterion) { List<Criterion> criterionList = new ArrayList<Criterion>(criterion.length); Collections.addAll(criterionList, criterion); return findByCriteriaOrdered(criterionList, Collections.<Order>emptyList()); }
From source file:net.mindengine.oculus.frontend.web.controllers.trm.customize.CustomizeSuiteParametersController.java
@Override public Map<String, Object> handleController(HttpServletRequest request) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); Long projectId = Long.parseLong(request.getParameter("projectId")); Project project = projectDAO.getProject(projectId); if (project == null) { throw new IllegalArgumentException("Project with id " + projectId + " doesn't exist"); }/*from www .j a v a 2 s .co m*/ map.put("project", project); String submit = request.getParameter("Submit"); if (submit != null && submit.equals("Save")) { String jsonParameters = request.getParameter("parameters"); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); if (jsonParameters != null) { TrmProperty[] propertiesFromJson = mapper.readValue(jsonParameters, TrmProperty[].class); List<TrmProperty> properties = new LinkedList<TrmProperty>(); if (propertiesFromJson != null) { Collections.addAll(properties, propertiesFromJson); } trmDAO.saveTrmPropertiesForProject(projectId, properties, TrmProperty._TYPE_SUITE_PARAMETER); } } List<TrmProperty> properties = trmDAO.getProperties(projectId, TrmProperty._TYPE_SUITE_PARAMETER); map.put("suiteProperties", properties); return map; }
From source file:com.wso2telco.dep.mediator.ResponseHandler.java
/** * Make sms send response.//from ww w . ja va 2 s.com * * @param mc * the mc * @param requestBody * the request body * @param responseMap * the response map * @param requestid * the requestid * @return the string */ public String makeSmsSendResponse(MessageContext mc, String requestBody, Map<String, SendSMSResponse> responseMap, String requestid) { log.info("Building Send SMS Response: " + requestBody + " Request ID: " + UID.getRequestID(mc)); Gson gson = new GsonBuilder().create(); SendSMSResponse finalResponse = gson.fromJson(requestBody, SendSMSResponse.class); DeliveryInfoList deliveryInfoListObj = new DeliveryInfoList(); List<DeliveryInfo> deliveryInfoList = new ArrayList<DeliveryInfo>(responseMap.size()); for (Map.Entry<String, SendSMSResponse> entry : responseMap.entrySet()) { SendSMSResponse smsResponse = entry.getValue(); if (smsResponse != null) { DeliveryInfoList resDeliveryInfoList = smsResponse.getOutboundSMSMessageRequest() .getDeliveryInfoList(); DeliveryInfo[] resDeliveryInfos = resDeliveryInfoList.getDeliveryInfo(); Collections.addAll(deliveryInfoList, resDeliveryInfos); } else { DeliveryInfo deliveryInfo = new DeliveryInfo(); deliveryInfo.setAddress(entry.getKey()); deliveryInfo.setDeliveryStatus("DeliveryImpossible"); deliveryInfoList.add(deliveryInfo); } } deliveryInfoListObj.setDeliveryInfo(deliveryInfoList.toArray(new DeliveryInfo[deliveryInfoList.size()])); String senderAddress = finalResponse.getOutboundSMSMessageRequest().getSenderAddress(); try { senderAddress = URLEncoder.encode(senderAddress, "UTF-8"); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); } String resourceURL = getResourceURL(mc, senderAddress) + "/requests/" + requestid; deliveryInfoListObj.setResourceURL(resourceURL + "/deliveryInfos"); finalResponse.getOutboundSMSMessageRequest().setDeliveryInfoList(deliveryInfoListObj); finalResponse.getOutboundSMSMessageRequest().setResourceURL(resourceURL); ((Axis2MessageContext) mc).getAxis2MessageContext().setProperty("HTTP_SC", 201); // Set Location Header Object headers = ((Axis2MessageContext) mc).getAxis2MessageContext() .getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (headers != null && headers instanceof Map) { Map headersMap = (Map) headers; headersMap.put("Location", resourceURL); } return gson.toJson(finalResponse); }
From source file:com.zd.vpn.fragments.AboutFragment.java
private void initGMSDonateOptions() { try {// w w w . j a va 2 s .c om int billingSupported = mService.isBillingSupported(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP); if (billingSupported != BILLING_RESPONSE_RESULT_OK) { Log.i("OpenVPN", "Play store billing not supported"); return; } ArrayList skuList = new ArrayList(); Collections.addAll(skuList, donationSkus); Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); Bundle ownedItems = mService.getPurchases(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP, null); if (ownedItems.getInt(RESPONSE_CODE) != BILLING_RESPONSE_RESULT_OK) return; final ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); Bundle skuDetails = mService.getSkuDetails(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP, querySkus); if (skuDetails.getInt(RESPONSE_CODE) != BILLING_RESPONSE_RESULT_OK) return; final ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { createPlayBuyOptions(ownedSkus, responseList); } }); } } catch (RemoteException e) { VpnStatus.logException(e); } }
From source file:com.emergya.spring.security.oauth.google.GoogleAccessTokenConverter.java
private Set<String> parseScopes(final Map<String, ?> map) { // Parsing of scopes coming back from Google are slightly different from the default implementation // Instead of it being a collection it is a String where multiple scopes are separated by a space. Object scopeAsObject = map.containsKey(SCOPE) ? map.get(SCOPE) : ""; Set<String> scope = new LinkedHashSet<>(); if (String.class.isAssignableFrom(scopeAsObject.getClass())) { String scopeAsString = (String) scopeAsObject; Collections.addAll(scope, scopeAsString.split(" ")); } else if (Collection.class.isAssignableFrom(scopeAsObject.getClass())) { Collection<String> scopes = (Collection<String>) scopeAsObject; scope.addAll(scopes);// ww w.j a va2 s.c o m } return scope; }
From source file:com.puppycrawl.tools.checkstyle.api.AbstractCheck.java
/** * Adds a set of tokens the check is interested in. * @param strRep the string representation of the tokens interested in *//*from w w w. ja va 2 s.com*/ public final void setTokens(String... strRep) { Collections.addAll(tokens, strRep); }
From source file:fr.inria.eventcloud.deployment.cli.launchers.EventCloudsManagementServiceDeployer.java
/** * Deploys an EventCloudsRegistry and an EventClouds Management Service in a * separate JVM according to the specified parameters. * /*from w ww.j ava2s . com*/ * @param onRelease * {@code true} if the lastest release of the EventCloud has to * be used, {@code false} to use the latest snapshot version. * @param port * the port used to deploy the EventClouds Management Service and * which will also be used to deploy WS-Notification services. * @param urlSuffix * the suffix appended to the end of the URL associated to the * EventClouds Management Service to be deployed. * @param activateLoggers * {@code true} if the loggers have to be activated, * {@code false} otherwise. * @param properties * additional Java properties set to the new JVM. * * @return the endpoint URL of the EventClouds Management Service. * * @throws IOException * if an error occurs during the deployment. */ public synchronized static String deploy(boolean onRelease, int port, String urlSuffix, boolean activateLoggers, String... properties) throws IOException { if (eventCloudsManagementServiceProcess == null) { String binariesBaseUrl = EVENTCLOUD_BINARIES_URL; if (onRelease) { binariesBaseUrl += "releases/latest/"; } else { binariesBaseUrl += "snapshots/latest/"; } List<String> cmd = new ArrayList<String>(); String javaBinaryPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; if (System.getProperty("os.name").startsWith("Windows")) { javaBinaryPath = javaBinaryPath + ".exe"; } cmd.add(javaBinaryPath); cmd.add("-cp"); cmd.add(addClassPath(binariesBaseUrl + "libs/")); cmd.addAll(addProperties(binariesBaseUrl + "resources/", activateLoggers)); Collections.addAll(cmd, properties); cmd.add(EventCloudsManagementServiceDeployer.class.getCanonicalName()); cmd.add(Integer.toString(port)); cmd.add(urlSuffix); final ProcessBuilder processBuilder = new ProcessBuilder(cmd.toArray(new String[cmd.size()])); processBuilder.redirectErrorStream(true); eventCloudsManagementServiceProcess = processBuilder.start(); final BufferedReader reader = new BufferedReader( new InputStreamReader(eventCloudsManagementServiceProcess.getInputStream())); Thread t = new Thread(new Runnable() { @Override public void run() { String line = null; try { while ((line = reader.readLine()) != null) { if (!servicesDeployed.getValue() && line.contains(LOG_MANAGEMENT_WS_DEPLOYED)) { servicesDeployed.setValue(true); synchronized (servicesDeployed) { servicesDeployed.notifyAll(); } } System.out.println("ECManagement " + line); } } catch (IOException ioe) { ioe.printStackTrace(); } } }); t.setDaemon(true); t.start(); synchronized (servicesDeployed) { while (!servicesDeployed.getValue()) { try { servicesDeployed.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } StringBuilder eventCloudsManagementWsEndpoint = new StringBuilder("http://"); eventCloudsManagementWsEndpoint.append(ProActiveInet.getInstance().getInetAddress().getHostAddress()); eventCloudsManagementWsEndpoint.append(':'); eventCloudsManagementWsEndpoint.append(port); eventCloudsManagementWsEndpoint.append('/'); eventCloudsManagementWsEndpoint.append(urlSuffix); return eventCloudsManagementWsEndpoint.toString(); } else { throw new IllegalStateException("EventClouds management process already deployed"); } }