List of usage examples for org.springframework.util StringUtils hasLength
public static boolean hasLength(@Nullable String str)
From source file:org.openo.sdnhub.overlayvpndriver.sbi.impl.VxLanSvcImpl.java
/** * Adds new Vxlan configuration using a specific Controller.<br> * * @param ctrlUuid Controller UUID//w w w. j av a 2 s. com * @param deviceId device id * @param netVxLanDeviceModelList collection of controller vxlan device model structure * @return ResultRsp object with collection of VxLan added configuration status data * @throws ServiceException when input validation fails * @since SDNHUB 0.5 */ public static ResultRsp<List<VxLanDeviceModel>> createVxLanByDevice(String ctrlUuid, String deviceId, List<VxLanDeviceModel> netVxLanDeviceModelList) throws ServiceException { ResultRsp<List<VxLanDeviceModel>> resultRsp = new ResultRsp<>(ErrorCode.OVERLAYVPN_SUCCESS); String createVxlanUrl = MessageFormat.format(ControllerUrlConst.CONST_CONFIG_VXLAN, deviceId); Map<String, List<VxLanDeviceModel>> ctrlInfoMap = new ConcurrentHashMap<>(); ctrlInfoMap.put(CommConst.VXLAN_LIST, netVxLanDeviceModelList); HTTPReturnMessage httpMsg = OverlayVpnDriverProxy.getInstance().sendPutMsg(createVxlanUrl, JsonUtil.toJson(ctrlInfoMap), ctrlUuid); String body = httpMsg.getBody(); if (httpMsg.isSuccess() || StringUtils.hasLength(body)) { OverlayVpnDriverResponse<List<VxLanDeviceModel>> overlayVpnResponse = JsonUtil.fromJson(body, new TypeReference<OverlayVpnDriverResponse<List<VxLanDeviceModel>>>() { }); if (overlayVpnResponse.isSucess()) { resultRsp.setData(overlayVpnResponse.getData()); return resultRsp; } else { return new ResultRsp<>(ErrorCode.OVERLAYVPN_FAILED, overlayVpnResponse.getData()); } } else { return new ResultRsp<>(ErrorCode.OVERLAYVPN_FAILED); } }
From source file:org.openo.sdnhub.overlayvpndriver.sbi.impl.VxLanSvcImpl.java
/** * Queries device for Vxlan configuration using a specific Controller.<br> * * @param ctrlUuid Controller UUID/*from ww w. jav a 2s . c o m*/ * @param deviceId device id * @return ResultRsp object with collection of VxLan queried configuration status data * @throws ServiceException when input validation fails * @since SDNHUB 0.5 */ public static ResultRsp<List<VxLanDeviceModel>> queryVxlanByDevice(String ctrlUuid, String deviceId) throws ServiceException { ResultRsp<List<VxLanDeviceModel>> resultRsp = new ResultRsp<>(ErrorCode.OVERLAYVPN_SUCCESS); String queryUrl = MessageFormat.format(ControllerUrlConst.CONST_CONFIG_VXLAN, deviceId); HTTPReturnMessage httpMsg = OverlayVpnDriverProxy.getInstance().sendGetMsg(queryUrl, null, ctrlUuid); String body = httpMsg.getBody(); LOGGER.debug("queryVxlanByDevice return body: " + body); if ((!httpMsg.isSuccess()) || (!StringUtils.hasLength(body))) { LOGGER.error("queryVxlanByDevice: httpMsg return error."); throw new ServiceException(ErrorCode.ADAPTER_CONNECTOR_RESPONSE_FAIL, "queryVxlanByDevice: httpMsg return error."); } OverlayVpnDriverResponse<List<VxLanDeviceModel>> acresponse = JsonUtil.fromJson(body, new TypeReference<OverlayVpnDriverResponse<List<VxLanDeviceModel>>>() { }); if (!acresponse.isSucess()) { LOGGER.error("createTunnelByDevice: acresponse return error, errMsg: " + acresponse.getErrmsg()); throw new ServiceException(ErrorCode.ADAPTER_CONNECTOR_RESPONSE_FAIL, acresponse.getErrmsg()); } resultRsp.setData(acresponse.getData()); return resultRsp; }
From source file:org.openo.sdnhub.overlayvpndriver.sbi.impl.VxLanSvcImpl.java
/** * Deletes Vxlan configuration using a specific Controller.<br> * * @param ctrlUuid Controller UUID/*from w w w . ja v a 2s . c o m*/ * @param deviceId device id * @param idList collection of vxlan id * @return ResultRsp object with VxLan deleted configuration status data * @throws ServiceException when input validation fails * @since SDNHUB 0.5 */ public static ResultRsp<ACDelResponse> deleteVxlanByDevice(String ctrlUuid, String deviceId, List<String> idList) throws ServiceException { ResultRsp<ACDelResponse> resultRsp = new ResultRsp<>(ErrorCode.OVERLAYVPN_SUCCESS); if (CollectionUtils.isEmpty(idList)) { LOGGER.debug("id list is null"); return resultRsp; } String deleteVxlanUrl = MessageFormat.format(ControllerUrlConst.CONST_CONFIG_VXLAN, deviceId); Map<String, List<String>> ctrlInfoMap = new HashMap<>(); ctrlInfoMap.put(DELETE_VXLN_PARAMETER, idList); HTTPReturnMessage httpmsg = OverlayVpnDriverProxy.getInstance().sendDeleteMsg(deleteVxlanUrl, JsonUtil.toJson(ctrlInfoMap), ctrlUuid); String body = httpmsg.getBody(); if (httpmsg.isSuccess() && StringUtils.hasLength(body)) { ACDelResponse acresponse = JsonUtil.fromJson(body, new TypeReference<ACDelResponse>() { }); if (!acresponse.isSucess()) { LOGGER.error("Delete vxlanByDevice:acresponse return error " + acresponse.getAllErrmsg()); resultRsp.setErrorCode(ErrorCode.OVERLAYVPN_FAILED); resultRsp.setMessage(acresponse.getAllErrmsg()); return resultRsp; } LOGGER.error("deletevxlanBydevice: httpmsg return error."); resultRsp.setErrorCode(ErrorCode.OVERLAYVPN_SUCCESS); resultRsp.setMessage(acresponse.getAllErrmsg()); resultRsp.setData(acresponse); } return resultRsp; }
From source file:org.openo.sdnhub.overlayvpndriver.translator.StaticRouteConvert.java
/** * Get same tunnel from Ac matching with all given fields. * * @param existingAllRoutingList list of ControllerNbiStaticRoute * @param tempCreateStaticRoute ControllerNbiStaticRoute * @return ControllerNbiStaticRoute//from www. ja va 2s.c o m */ public static ControllerNbiStaticRoute getSameTunnelFromAc( List<ControllerNbiStaticRoute> existingAllRoutingList, ControllerNbiStaticRoute tempCreateStaticRoute) { for (ControllerNbiStaticRoute existing : existingAllRoutingList) { if (existing.getUuid().equals(tempCreateStaticRoute.getUuid())) { continue; } if (StringUtils.hasLength(tempCreateStaticRoute.getNextHop()) && tempCreateStaticRoute.getNextHop().equals(existing.getNextHop())) { continue; } if (StringUtils.hasLength(tempCreateStaticRoute.getOutInterface()) && tempCreateStaticRoute.getOutInterface().equals(existing.getOutInterface())) { continue; } if (StringUtils.hasLength(tempCreateStaticRoute.getIpv6Address())) { String ipv6 = existing.getIpv6Address(); if (CheckIpV6Util.isValidIpV6(ipv6) && (ipv6.equals(tempCreateStaticRoute.getIpv6Address()))) { continue; } } if (StringUtils.hasLength(tempCreateStaticRoute.getIp()) && !isRouteDestIPExisted(tempCreateStaticRoute.getIp(), tempCreateStaticRoute.getMask(), existing.getIp(), existing.getMask())) { continue; } return existing; } return null; }
From source file:org.openo.sdnhub.overlayvpndriver.translator.StaticRouteConvert.java
private static boolean isRouteDestIPExisted(String destIpForCreate, String destMaskForCreate, String destIpInAc, String destMaskInACc) {// w w w .j a va2s . co m int destIpMaskForCreate = -1; if (StringUtils.hasLength(destMaskForCreate)) { destIpMaskForCreate = Integer.valueOf(IpUtils.maskToPrefix(destMaskForCreate)); } int destIpMaskInDb = IpUtils.maskToPrefix(destMaskInACc); if (destIpMaskForCreate != destIpMaskInDb) { return false; } String ipForCreate = IpAddressUtil.calcSubnet(destIpForCreate, destIpMaskForCreate); String ipInAc = IpAddressUtil.calcSubnet(destIpInAc, destIpMaskInDb); if (null == ipForCreate || null == ipInAc || !ipForCreate.equals(ipInAc)) { return false; } return true; }
From source file:org.openo.sdnhub.overlayvpndriver.translator.StaticRouteConvert.java
/** * convert the SbiNeStaticRoute to ControllerNbiStaticRoute. * * @param neStaticRoutes list of SbiNeStaticRoute * @param createOrUpdate whether this operation is create of update * @return Map of converted ControllerNbiStaticRoute list. *//* w w w . j a va 2 s . co m*/ public static Map<String, List<ControllerNbiStaticRoute>> convert2Route(List<SbiNeStaticRoute> neStaticRoutes, boolean createOrUpdate) { Map<String, List<ControllerNbiStaticRoute>> neId2Tunnels = new ConcurrentHashMap<>(); for (SbiNeStaticRoute neStaticRoute : neStaticRoutes) { Ip destIpData = neStaticRoute.getDestIpData(); Ip nextHopData = neStaticRoute.getNextHopData(); ControllerNbiStaticRoute staticRoute = new ControllerNbiStaticRoute(); if (destIpData.isTypeV4()) { staticRoute = new ControllerNbiStaticRoute(destIpData.getIpv4(), destIpData.getIpMask(), null, neStaticRoute.getOutInterface(), neStaticRoute.getEnableDhcp()); if (null != nextHopData) { staticRoute.setNextHop(nextHopData.getIpv4()); } } else { staticRoute = new ControllerNbiStaticRoute(destIpData.getIpv6(), Integer.valueOf(destIpData.getPrefixLength()), null, neStaticRoute.getOutInterface(), neStaticRoute.getEnableDhcp()); if (null != nextHopData) { staticRoute.setNextHop(nextHopData.getIpv6()); } } staticRoute.setUuid(neStaticRoute.getExternalId()); if (StringUtils.hasLength(neStaticRoute.getPriority())) { staticRoute.setPriority(Long.valueOf(neStaticRoute.getPriority())); } staticRoute.setNbiRouteId(neStaticRoute.getUuid()); staticRoute.setNqaId(neStaticRoute.getNqa()); groupByNe(neId2Tunnels, neStaticRoute, staticRoute); } return neId2Tunnels; }
From source file:org.openo.sdnhub.overlayvpndriver.translator.StaticRouteConvert.java
public static void backWriteId2NeStaticRoute(List<ControllerNbiStaticRoute> dataList, List<SbiNeStaticRoute> neRouteList, String deviceId, List<SbiNeStaticRoute> successedDatas) { if (CollectionUtils.isEmpty(dataList)) { return;/* ww w . ja v a 2 s . co m*/ } for (ControllerNbiStaticRoute tempRoute : dataList) { if (!StringUtils.hasLength(tempRoute.getUuid())) { LOGGER.warn("do not get static router id, outInfer = " + tempRoute.getOutInterface()); continue; } for (SbiNeStaticRoute tempNeRouter : neRouteList) { if (tempRoute.getUuid().equals(tempNeRouter.getExternalId())) { successedDatas.add(tempNeRouter); } } } }
From source file:org.openspaces.core.gateway.GSCForkHandler.java
private String[] createGSCExtraCommandLineArguments() { List<String> arguments = new LinkedList<String>(); if (lrmiPort != 0) arguments.add(createLrmiPortProperty(lrmiPort)); if (startEmbeddedLus) arguments.add(createDiscoveryPortProperty(discoveryPort)); if (StringUtils.hasLength(customJvmProperties)) arguments.addAll(Arrays.asList(customJvmProperties.split(" "))); return arguments.toArray(new String[arguments.size()]); }
From source file:org.openspaces.remoting.RemotingAnnotationBeanPostProcessor.java
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean == null) { return bean; }// ww w . j a v a2 s.c o m Class beanClass = AopUtils.getTargetClass(bean); if (beanClass == null) { return bean; } RemotingService remotingService = AnnotationUtils.findAnnotation(beanClass, RemotingService.class); if (remotingService != null) { SpaceRemotingServiceExporter exporter; if (StringUtils.hasLength(remotingService.exporter())) { exporter = (SpaceRemotingServiceExporter) applicationContext.getBean(remotingService.exporter()); if (exporter == null) { throw new IllegalArgumentException("Failed to find exporter under name [" + remotingService.exporter() + "] for bean [" + beanName + "]"); } } else { Map exporters = applicationContext.getBeansOfType(SpaceRemotingServiceExporter.class); if (exporters.isEmpty()) { throw new IllegalArgumentException( "No service exporters are defined within the context, can't register remote service bean [" + beanName + "]"); } if (exporters.size() > 1) { throw new IllegalStateException( "More than one service exporter are defined within the context, please specify the exact service exported to register with"); } exporter = (SpaceRemotingServiceExporter) exporters.values().iterator().next(); } exporter.addService(beanName, bean); } return bean; }
From source file:org.patientview.patientview.logon.EmailChangeAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { /**/*from w w w . j a v a2 s . c o m*/ * This allows to change their email address. * * Note: there is also struts validation, see validation.xml */ // receive data from submitted form User user = LegacySpringUtils.getUserManager().getLoggedInUser(); String emailAddress = BeanUtils.getProperty(form, "emailAddress"); String emailAddressAgain = BeanUtils.getProperty(form, "emailAddressAgain"); boolean errorFound = false; boolean sendVerificationEmail = true; // if both email boxes empty -> fine, and no validation email sent (this if (!StringUtils.hasLength(emailAddress) && !StringUtils.hasLength(emailAddressAgain)) { sendVerificationEmail = false; } else if (!emailAddress.equals(emailAddressAgain)) { // emails supplied, they must match request.setAttribute("emailError", "Email addresses don't match"); errorFound = true; } else { // update the user's email with that supplied user.setEmail(emailAddress); user.setEmailverified(false); user.setUpdated(new Date()); } if (errorFound) { return mapping.findForward("input"); } else { // ok so it worked, save the email // change if it was made. LegacySpringUtils.getUserManager().save(user); // db logging AddLog.addLog(user.getUsername(), AddLog.EMAIL_CHANGED, user.getUsername(), UserUtils.retrieveUsersRealNhsnoBestGuess(user.getUsername()), UserUtils.retrieveUsersRealUnitcodeBestGuess(user.getUsername()), ""); // email verification - only required if the user has supplied an email address // (regardless of if it is the same as the one used to create by the admin) if (sendVerificationEmail) { EmailVerificationUtils.createEmailVerification(user.getUsername(), user.getEmail(), request); request.setAttribute("verificationMailSent", true); } request.setAttribute("emailMsg", "Email was updated successfully."); return mapping.findForward("success"); } }