List of usage examples for java.lang Long intValue
public int intValue()
From source file:org.shredzone.cilla.view.AbstractView.java
/** * Streams a {@link ResourceDataSource}. Also cares about setting proper HTTP response * headers.//from ww w . j a va2 s. co m * * @param ds * {@link ResourceDataSource} to stream * @param req * {@link HttpServletRequest} * @param resp * {@link HttpServletResponse} */ protected void streamDataSource(ResourceDataSource ds, HttpServletRequest req, HttpServletResponse resp) throws ViewException { try { if (isNotModifiedSince(req, ds.getLastModified())) { throw new ErrorResponseException(HttpServletResponse.SC_NOT_MODIFIED); } Long length = ds.getLength(); if (length != null && length <= Integer.MAX_VALUE) { // Converting long to int is safe here... resp.setContentLength(length.intValue()); } resp.setContentType(ds.getContentType()); resp.setDateHeader("Last-Modified", ds.getLastModified().getTime()); try (InputStream in = ds.getInputStream()) { FileCopyUtils.copy(in, resp.getOutputStream()); } } catch (IOException ex) { throw new ViewException(ex); } }
From source file:com.corejsf.UploadRenderer.java
public void decode(FacesContext context, UIComponent component) { log.debug("**** decode ="); ExternalContext external = context.getExternalContext(); HttpServletRequest request = (HttpServletRequest) external.getRequest(); String clientId = component.getClientId(context); FileItem item = (FileItem) request.getAttribute(clientId + UPLOAD); // check if file > maxSize allowed log.debug("clientId =" + clientId); log.debug("fileItem =" + item); // if (item!=null) log.debug("***UploadRender: fileItem size ="+ item.getSize()); Long maxSize = (Long) ((ServletContext) external.getContext()).getAttribute("FILEUPLOAD_SIZE_MAX"); // RU - typo. Stanford agrees, so this should be FINR if (item != null && item.getSize() / 1000 > maxSize.intValue()) { ((ServletContext) external.getContext()).setAttribute("TEMP_FILEUPLOAD_SIZE", Long.valueOf(item.getSize() / 1000)); ((EditableValueHolder) component).setSubmittedValue("SizeTooBig:" + item.getName()); return;// ww w . j a v a2 s. co m } Object target; ValueBinding binding = component.getValueBinding("target"); if (binding != null) target = binding.getValue(context); else target = component.getAttributes().get("target"); String repositoryPath = (String) ((ServletContext) external.getContext()) .getAttribute("FILEUPLOAD_REPOSITORY_PATH"); log.debug("****" + repositoryPath); if (target != null) { File dir = new File(repositoryPath + target.toString()); //directory where file would be saved if (!dir.exists()) dir.mkdirs(); if (item != null && !("").equals(item.getName())) { String fullname = item.getName(); fullname = fullname.replace('\\', '/'); // replace c:\fullname to c:/fullname fullname = fullname.substring(fullname.lastIndexOf("/") + 1); int dot_index = fullname.lastIndexOf("."); String filename = ""; if (dot_index < 0) { filename = fullname + "_" + (new Date()).getTime(); } else { filename = fullname.substring(0, dot_index) + "_" + (new Date()).getTime() + fullname.substring(dot_index); } File file = new File(dir.getPath() + "/" + filename); log.debug("**1. filename=" + file.getPath()); try { //if (mediaIsValid) item.write(file); item.write(file); // change value so we can evoke the listener ((EditableValueHolder) component).setSubmittedValue(file.getPath()); } catch (Exception ex) { throw new FacesException(ex); } } } }
From source file:mx.edu.um.mateo.general.dao.UsuarioDao.java
public Map<String, Object> lista(Map<String, Object> params) { log.debug("Buscando lista de usuarios con params {}", params); if (params == null) { params = new HashMap<>(); }//from w w w. j av a2s . c o m if (!params.containsKey("max")) { params.put("max", 10); } else { params.put("max", Math.min((Integer) params.get("max"), 100)); } if (params.containsKey("pagina")) { Long pagina = (Long) params.get("pagina"); Long offset = (pagina - 1) * (Integer) params.get("max"); params.put("offset", offset.intValue()); } if (!params.containsKey("offset")) { params.put("offset", 0); } Criteria criteria = currentSession().createCriteria(Usuario.class); Criteria countCriteria = currentSession().createCriteria(Usuario.class); if (params.containsKey("asociacion")) { criteria.createCriteria("asociacion").add(Restrictions.idEq(params.get("asociacion"))); countCriteria.createCriteria("asociacion").add(Restrictions.idEq(params.get("asociacion"))); } if (params.containsKey("filtro")) { String filtro = (String) params.get("filtro"); Disjunction propiedades = Restrictions.disjunction(); propiedades.add(Restrictions.ilike("username", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("nombre", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("apellido", filtro, MatchMode.ANYWHERE)); criteria.add(propiedades); countCriteria.add(propiedades); } if (params.containsKey("order")) { String campo = (String) params.get("order"); if (params.get("sort").equals("desc")) { criteria.addOrder(Order.desc(campo)); } else { criteria.addOrder(Order.asc(campo)); } } if (!params.containsKey("reporte")) { criteria.setFirstResult((Integer) params.get("offset")); criteria.setMaxResults((Integer) params.get("max")); } params.put("usuarios", criteria.list()); countCriteria.setProjection(Projections.rowCount()); params.put("cantidad", (Long) countCriteria.list().get(0)); return params; }
From source file:com.blackducksoftware.soleng.bdsplugin.BDSPluginSensor.java
/** * Sonar does not allow for longs, convert it. * * @param sensorContext//from www. j a va2s. c o m * @param value * @param metric */ private void saveMetricLong(final SensorContext sensorContext, final Long value, final Metric metric) { final Measure measure = new Measure(metric); measure.setIntValue(value.intValue()); if (sensorContext != null) { sensorContext.saveMeasure(measure); } log.info("Saved new measure: " + measure.toString()); }
From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java
public static SmsCampaign instance(final AppUser submittedBy, final Report report, final JsonCommand command) { final String campaignName = command.stringValueOfParameterNamed(SmsCampaignValidator.campaignName); final Long campaignType = command.longValueOfParameterNamed(SmsCampaignValidator.campaignType); final Long triggerType = command.longValueOfParameterNamed(SmsCampaignValidator.triggerType); final Long providerId = command.longValueOfParameterNamed(SmsCampaignValidator.providerId); final String paramValue = command.jsonFragment(SmsCampaignValidator.paramValue); final String message = command.stringValueOfParameterNamed(SmsCampaignValidator.message); LocalDate submittedOnDate = new LocalDate(); if (command.hasParameter(SmsCampaignValidator.submittedOnDateParamName)) { submittedOnDate = command.localDateValueOfParameterNamed(SmsCampaignValidator.submittedOnDateParamName); }//from w w w. j av a 2s .c o m String recurrence = null; LocalDateTime recurrenceStartDate = new LocalDateTime(); if (SmsCampaignTriggerType.fromInt(triggerType.intValue()).isSchedule()) { final Locale locale = command.extractLocale(); String dateTimeFormat = null; if (command.hasParameter(SmsCampaignValidator.dateTimeFormat)) { dateTimeFormat = command.stringValueOfParameterNamed(SmsCampaignValidator.dateTimeFormat); final DateTimeFormatter fmt = DateTimeFormat.forPattern(dateTimeFormat).withLocale(locale); if (command.hasParameter(SmsCampaignValidator.recurrenceStartDate)) { recurrenceStartDate = LocalDateTime.parse( command.stringValueOfParameterNamed(SmsCampaignValidator.recurrenceStartDate), fmt); } recurrence = constructRecurrence(command); } } else { recurrenceStartDate = null; } return new SmsCampaign(campaignName, campaignType.intValue(), triggerType.intValue(), report, providerId, paramValue, message, submittedOnDate, submittedBy, recurrence, recurrenceStartDate); }
From source file:cz.muni.fi.mir.db.dao.impl.ApplicationRunDAOImpl.java
@Override public List<ApplicationRun> getAllApplicationRunsFromRange(int start, int end) { List<ApplicationRun> resultList = new ArrayList<>(); // if there are no results yet (count is 0) do nothing and return empty resultList // otherwise jump in condition and do the select if (!entityManager.createQuery("SELECT COUNT(ar) FROM applicationRun ar", Long.class).getSingleResult() .equals(Long.valueOf("0"))) { resultList = entityManager//w w w. jav a 2s.com .createQuery("SELECT apr FROM applicationRun apr ORDER BY apr.id DESC", ApplicationRun.class) .setFirstResult(start).setMaxResults(end - start).getResultList(); for (ApplicationRun ar : resultList) { Long count = entityManager .createQuery("SELECT COUNT(co) FROM canonicOutput co WHERE co.applicationRun = :apprun", Long.class) .setParameter("apprun", ar).getSingleResult(); ar.setCanonicOutputCount(count.intValue()); } } return resultList; }
From source file:mx.edu.um.mateo.activos.dao.impl.TipoActivoDaoHibernate.java
@Override @Transactional(readOnly = true)/*w w w .jav a2s. c o m*/ public Map<String, Object> lista(Map<String, Object> params) { log.debug("Buscando lista de tipos de activos con params {}", params); if (params == null) { params = new HashMap<>(); } if (!params.containsKey("max")) { params.put("max", 10); } else { params.put("max", Math.min((Integer) params.get("max"), 100)); } if (params.containsKey("pagina")) { Long pagina = (Long) params.get("pagina"); Long offset = (pagina - 1) * (Integer) params.get("max"); params.put("offset", offset.intValue()); } if (!params.containsKey("offset")) { params.put("offset", 0); } Criteria criteria = currentSession().createCriteria(TipoActivo.class); Criteria countCriteria = currentSession().createCriteria(TipoActivo.class); if (params.containsKey("empresa")) { criteria.createCriteria("empresa").add(Restrictions.idEq(params.get("empresa"))); countCriteria.createCriteria("empresa").add(Restrictions.idEq(params.get("empresa"))); } if (params.containsKey("filtro")) { String filtro = (String) params.get("filtro"); Disjunction propiedades = Restrictions.disjunction(); propiedades.add(Restrictions.ilike("nombre", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("descripcion", filtro, MatchMode.ANYWHERE)); criteria.add(propiedades); countCriteria.add(propiedades); } if (params.containsKey("order")) { String campo = (String) params.get("order"); if (params.get("sort").equals("desc")) { criteria.addOrder(Order.desc(campo)); } else { criteria.addOrder(Order.asc(campo)); } } if (!params.containsKey("reporte")) { criteria.setFirstResult((Integer) params.get("offset")); criteria.setMaxResults((Integer) params.get("max")); } params.put("tiposDeActivo", criteria.list()); countCriteria.setProjection(Projections.rowCount()); params.put("cantidad", (Long) countCriteria.list().get(0)); return params; }
From source file:de.hybris.platform.acceleratorservices.store.pickup.impl.DefaultPickupPointOfServiceConsolidationStrategy.java
protected boolean checkStockAvailableAtPointOfService(final ProductModel productModel, final PointOfServiceModel posModel, final CartModel cartModel) { final Long stockLevel = getCommerceStockService().getStockLevelForProductAndPointOfService(productModel, posModel);/* w w w. j a va 2 s.co m*/ return (stockLevel == null) || (stockLevel.intValue() >= calculateCartLevel(productModel, cartModel)); }
From source file:com.clustercontrol.repository.factory.SearchNodeBySNMP.java
/** * ?????/*w w w. j a v a 2s .co m*/ * @param IPadder * @param ret * @param mode * @param locale * @return * @throws UnknownHostException */ private static NodeInfo stractProperty(String ipAddress, int port, String community, int version, String securityLevel, String user, String authPass, String privPass, String authProtocol, String privProtocol, DataTable ret) throws UnknownHostException { NodeInfo property = new NodeInfo(); String facilityId = null; /* * hinemos.properties?repository.device.search.verbose=true????? * IO?0??????search?? * ?false???0???search? * since 3.2.0 */ boolean verbose = HinemosPropertyUtil.getHinemosPropertyBool("repository.device.search.verbose", false); //""?? if (ret.getValue(getEntryKey(SearchDeviceProperties.getOidDescr())) != null) { if (((String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidDescr())).getValue()) .length() != 0) { property.setDescription("Auto detect at " + HinemosTime.getDateString()); } } int ipAddressVersion = 0; try { InetAddress address = InetAddress.getByName(ipAddress); if (address instanceof Inet4Address) { //IPv4?????String? if (ipAddress.matches(".{1,3}?\\..{1,3}?\\..{1,3}?\\..{1,3}?")) { property.setIpAddressV4(ipAddress); ipAddressVersion = 4; } } else if (address instanceof Inet6Address) { property.setIpAddressV6(ipAddress); ipAddressVersion = 6; } //IP?? property.setIpAddressVersion(ipAddressVersion); } catch (UnknownHostException e) { m_log.info("stractProperty() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); throw e; } //SNMP? property.setSnmpPort(port); property.setSnmpCommunity(community); property.setSnmpVersion(version); property.setSnmpSecurityLevel(securityLevel); property.setSnmpUser(user); property.setSnmpAuthPassword(authPass); property.setSnmpPrivPassword(privPass); property.setSnmpAuthProtocol(authProtocol); property.setSnmpPrivProtocol(privProtocol); //hostname ? if (ret.getValue(getEntryKey(SearchDeviceProperties.getOidName())) != null) { String hostname = (String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidName())).getValue(); m_log.debug("hostname=" + hostname); if (hostname.length() != 0) { //hosname.domain???hostname?? hostname = getShortName(hostname); //ID??? facilityId = hostname; property.setFacilityId(hostname); property.setFacilityName(hostname); //????????? ArrayList<NodeHostnameInfo> list = new ArrayList<NodeHostnameInfo>(); list.add(new NodeHostnameInfo(property.getFacilityId(), hostname)); property.setNodeHostnameInfo(list); property.setNodeName(hostname); } } else { m_log.info("hostname is null"); } //?snmpd.conf????? if (ret.getValue(getEntryKey(SearchDeviceProperties.getOidContact())) != null) { if (((String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidContact())).getValue()) .length() != 0) { property.setAdministrator( (String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidContact())).getValue()); } } //????Windows, Linux, Solaris?Other?? String platform = "OTHER"; if (ret.getValue(getEntryKey(SearchDeviceProperties.getOidDescr())) != null) { String description = ((String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidDescr())) .getValue()); if (description.length() != 0) { String OsName = ""; //OS????? if (description.matches(".*indows.*")) { OsName = "Windows"; platform = "WINDOWS"; } else if (description.matches(".*inux.*")) { OsName = "Linux"; platform = "LINUX"; } else if (solarisFlag && (description.matches(".*SunOS.*") || description.matches("Solaris"))) { // ?SOLARIS???????? // ??????SOLARIS? OsName = "Solaris"; platform = "SOLARIS"; } else { if (description.indexOf(" ") != -1) { OsName = description.substring(0, description.indexOf(" ")); } } //OS?????? property.setOsName(OsName); //OS? property.setOsVersion(description); } } // // ?OTHER property.setPlatformFamily(platform); HashMap<String, Boolean> diskNameDuplicateSet = createDiskNameDuplicateSet(ret); HashMap<String, Boolean> nicNameDuplicateSet = createNicNameDuplicateSet(ret); // ??????????? // ???????????????? int deviceCount = 0; // Disk? ArrayList<NodeDiskInfo> diskList = new ArrayList<NodeDiskInfo>(); for (String fullOid : ret.keySet()) { //DISK??? if (!fullOid.startsWith(getEntryKey(SearchDeviceProperties.getOidDiskIndex()) + ".")) { continue; } // SearchDeviceProperties.getOidDISK_INDEX=".1.3.6.1.4.1.2021.13.15.1.1.1"; // SearchDeviceProperties.getOidDISK_NAME =".1.3.6.1.4.1.2021.13.15.1.1.2"; if (ret.getValue(fullOid) == null || ret.getValue(fullOid).getValue() == null || ((Long) ret.getValue(fullOid).getValue()) == 0) { continue; } m_log.debug("Find Disk : fullOid = " + fullOid); String i = fullOid.substring(fullOid.lastIndexOf(".") + 1); String disk = (String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskName() + "." + i)) .getValue(); Long ionRead = ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskIonRead() + "." + i)) == null ? Long.valueOf(0) : (Long) ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskIonRead() + "." + i)) .getValue(); Long ionWrite = ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskIonWrite() + "." + i)) == null ? Long.valueOf(0) : (Long) ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskIonWrite() + "." + i)) .getValue(); Long ioRead = ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskIoRead() + "." + i)) == null ? Long.valueOf(0) : (Long) ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskIoRead() + "." + i)) .getValue(); Long ioWrite = ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskIoWrite() + "." + i)) == null ? Long.valueOf(0) : (Long) ret.getValue(getEntryKey(SearchDeviceProperties.getOidDiskIoWrite() + "." + i)) .getValue(); //DISK_IO?0????? if (verbose || (ionRead != 0 && ionWrite != 0 && ioRead != 0 && ioWrite != 0)) { // ???????????(OID)?? if (diskNameDuplicateSet != null && diskNameDuplicateSet.get(disk) != null && diskNameDuplicateSet.get(disk)) { disk = disk + "(" + i + ")"; } NodeDiskInfo diskInfo = new NodeDiskInfo(facilityId, ((Long) ret.getValue(fullOid).getValue()).intValue(), DeviceTypeConstant.DEVICE_DISK, disk); // ??? diskInfo.setDeviceDisplayName(disk); // ?(0) diskInfo.setDiskRpm(0); deviceCount++; diskList.add(diskInfo); } } Collections.sort(diskList, new Comparator<NodeDeviceInfo>() { @Override public int compare(NodeDeviceInfo o1, NodeDeviceInfo o2) { int ret = 0; ret = o1.getDeviceType().compareTo(o2.getDeviceType()); if (ret == 0) { ret = o1.getDeviceDisplayName().compareTo(o2.getDeviceDisplayName()); } return ret; } }); property.setNodeDiskInfo(diskList); // NIC? ArrayList<NodeNetworkInterfaceInfo> nicList = new ArrayList<NodeNetworkInterfaceInfo>(); for (String fullOid : ret.keySet()) { //SearchDeviceProperties.getOidNIC_INDEX =".1.3.6.1.2.1.2.2.1.1"; //SearchDeviceProperties.getOidNIC_NAME =".1.3.6.1.2.1.2.2.1.2"; //NIC??? if (!fullOid.startsWith(getEntryKey(SearchDeviceProperties.getOidNicIndex()) + ".")) { continue; } String tmpIndex = fullOid.substring(fullOid.lastIndexOf(".") + 1); String deviceName = ""; if (ret.getValue(fullOid) == null || ret.getValue(fullOid).getValue() == null || ((Long) ret.getValue(fullOid).getValue()) == 0) { continue; } m_log.debug("Find Nic : fullOid = " + fullOid); deviceName = (String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidNicName() + "." + tmpIndex)) .getValue(); String nicMacAddress = ""; if (ret.getValue(getEntryKey(SearchDeviceProperties.getOidNicMacAddress() + "." + tmpIndex)) != null) { nicMacAddress = (String) ret .getValue(getEntryKey(SearchDeviceProperties.getOidNicMacAddress() + "." + tmpIndex)) .getValue(); } String nicIpAddress = ""; if (ipAddressVersion == 4) { // IPv4 address from IP-MIB::ipAddressIfIndex.ipv4 // // (sample) // # snmpwalk -c public -v 2c localhost .1.3.6.1.2.1.4.34.1.3.1.4 // IP-MIB::ipAddressIfIndex.ipv4."127.0.0.1" = INTEGER: 1 // IP-MIB::ipAddressIfIndex.ipv4."192.168.10.211" = INTEGER: 3 // IP-MIB::ipAddressIfIndex.ipv4."192.168.10.255" = INTEGER: 3 // IP-MIB::ipAddressIfIndex.ipv4."192.168.11.211" = INTEGER: 2 // IP-MIB::ipAddressIfIndex.ipv4."192.168.11.255" = INTEGER: 2 Pattern ipAddrV4Pattern = Pattern.compile("(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})$"); if (ret.getValueSetStartWith(getEntryKey(SearchDeviceProperties.getOidNicIpAddressv4())) != null) { for (TableEntry entry : ret .getValueSetStartWith(getEntryKey(SearchDeviceProperties.getOidNicIpAddressv4()))) { if (entry.getValue() != null && tmpIndex.equals(((Long) entry.getValue()).toString())) { Matcher matcher = ipAddrV4Pattern.matcher(entry.getKey()); if (matcher.find()) { // check address type (allow only unicast) // # snmpwalk -On -c public -v 2c 192.168.10.101 IP-MIB::ipAddressType.ipv4 // .1.3.6.1.2.1.4.34.1.4.1.4.127.0.0.1 = INTEGER: unicast(1) // .1.3.6.1.2.1.4.34.1.4.1.4.192.168.10.101 = INTEGER: unicast(1) // .1.3.6.1.2.1.4.34.1.4.1.4.192.168.10.255 = INTEGER: broadcast(3) if (ret.getValue(getEntryKey(SearchDeviceProperties.getOidNicIpAddressv4Type() + "." + matcher.group(1))) != null) { if ((Long) ret .getValue(getEntryKey(SearchDeviceProperties.getOidNicIpAddressv4Type() + "." + matcher.group(1))) .getValue() != 1) { continue; } } // set first matched address nicIpAddress = matcher.group(1); break; } } } } } else { // IPv6 Address from IP-MIB::ipAddressIfIndex.ipv6 // // (sample) // # snmpwalk -c public -v 2c localhost .1.3.6.1.2.1.4.34.1.3.2.16 // IP-MIB::ipAddressIfIndex.ipv6."00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01" = INTEGER: 1 // IP-MIB::ipAddressIfIndex.ipv6."fe:80:00:00:00:00:00:00:50:54:00:ff:fe:be:83:2a" = INTEGER: 2 // IP-MIB::ipAddressIfIndex.ipv6."fe:80:00:00:00:00:00:00:50:54:00:ff:fe:ed:d4:3c" = INTEGER: 3 Pattern ipAddrV6Pattern = Pattern.compile( "((\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3}))$"); if (ret.getValueSetStartWith(getEntryKey(SearchDeviceProperties.getOidNicIpAddressv6())) != null) { for (TableEntry entry : ret .getValueSetStartWith(getEntryKey(SearchDeviceProperties.getOidNicIpAddressv6()))) { if (entry.getValue() != null && tmpIndex.equals(((Long) entry.getValue()).toString())) { m_log.debug(entry.getKey() + " : " + entry.getValue()); Matcher matcher = ipAddrV6Pattern.matcher(entry.getKey()); if (matcher.find()) { // check address type (allow only unicast) // # snmpwalk -On -c public -v 2c localhost IP-MIB::ipAddressType.ipv6 // .1.3.6.1.2.1.4.34.1.4.2.16.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1 = INTEGER: unicast(1) // .1.3.6.1.2.1.4.34.1.4.2.16.254.128.0.0.0.0.0.0.80.84.0.255.254.190.131.42 = INTEGER: unicast(1) if (ret.getValue(getEntryKey(SearchDeviceProperties.getOidNicIpAddressv6Type() + "." + matcher.group(1))) != null) { if ((Long) ret .getValue(getEntryKey(SearchDeviceProperties.getOidNicIpAddressv6Type() + "." + matcher.group(1))) .getValue() != 1) { continue; } } // set first matched address String hex = ""; for (int i = 1; i < 17; i++) { hex = String.format("%02x", Integer.parseInt(matcher.group(i + 1))) .toUpperCase(); nicIpAddress += "".equals(nicIpAddress) ? hex : ":" + hex; } break; } } } } } // NIC?IN/OUT?0???? String key = ""; key = getEntryKey(SearchDeviceProperties.getOidNicInOctet() + "." + tmpIndex); Long inOctet = ret.getValue(key) == null ? Long.valueOf(0) : (Long) ret.getValue(key).getValue(); key = getEntryKey(SearchDeviceProperties.getOidNicOutOctet() + "." + tmpIndex); Long outOctet = ret.getValue(key) == null ? Long.valueOf(0) : (Long) ret.getValue(key).getValue(); if (!verbose && inOctet == 0 && outOctet == 0) { continue; } // ???????????(OID)?? if (nicNameDuplicateSet != null && nicNameDuplicateSet.get(deviceName) != null && nicNameDuplicateSet.get(deviceName)) { deviceName = deviceName + "(." + tmpIndex + ")"; } Long deviceIndex = (Long) ret .getValue(getEntryKey(SearchDeviceProperties.getOidNicIndex() + "." + tmpIndex)).getValue(); NodeNetworkInterfaceInfo nicInfo = new NodeNetworkInterfaceInfo(facilityId, deviceIndex.intValue(), DeviceTypeConstant.DEVICE_NIC, deviceName); // ??? nicInfo.setDeviceDisplayName(deviceName); // ???? if (deviceName.length() > 128) { deviceName = deviceName.substring(0, 128); } nicInfo.setDeviceName(deviceName); // MAC? nicInfo.setNicMacAddress(nicMacAddress); // IP? nicInfo.setNicIpAddress(nicIpAddress); deviceCount++; nicList.add(nicInfo); } Collections.sort(nicList, new Comparator<NodeDeviceInfo>() { @Override public int compare(NodeDeviceInfo o1, NodeDeviceInfo o2) { int ret = 0; ret = o1.getDeviceType().compareTo(o2.getDeviceType()); if (ret == 0) { ret = o1.getDeviceDisplayName().compareTo(o2.getDeviceDisplayName()); } return ret; } }); property.setNodeNetworkInterfaceInfo(nicList); // deviceCount = 0; ArrayList<NodeFilesystemInfo> filesystemList = new ArrayList<NodeFilesystemInfo>(); for (String fullOid : ret.keySet()) { // SearchDeviceProperties.getOidFILESYSTEM_INDEX = ".1.3.6.1.2.1.25.2.3.1.1"; // SearchDeviceProperties.getOidFILESYSTEM_NAME = ".1.3.6.1.2.1.25.2.3.1.3"; //DISK??? if (!fullOid.startsWith(getEntryKey(SearchDeviceProperties.getOidFilesystemIndex()) + ".")) { continue; } if (ret.getValue(fullOid) == null || ret.getValue(fullOid).getValue() == null || ((Long) ret.getValue(fullOid).getValue()) == 0) { continue; } m_log.debug("Find FileSystem : fullOid = " + fullOid); //hrStrageFixedDisk????? //.1.3.6.1.2.1.25.2.1.4?hrStrageFixedDisk String i = fullOid.substring(fullOid.lastIndexOf(".") + 1); String strageType = ret.getValue(getEntryKey(SearchDeviceProperties.getOidFilesystemType() + "." + i)) .getValue().toString(); if (strageType.equals(".1.3.6.1.2.1.25.2.1.4")) { //hrStorageSize?0???? String hrStorageSize = getEntryKey(SearchDeviceProperties.getOidFilesystemSize() + "." + i); Long storageSize = ret.getValue(hrStorageSize) == null ? Long.valueOf(0) : (Long) ret.getValue(hrStorageSize).getValue(); if (!verbose && storageSize == 0) { continue; } NodeFilesystemInfo filesystem = new NodeFilesystemInfo(facilityId, ((Long) ret.getValue(getEntryKey(SearchDeviceProperties.getOidFilesystemIndex() + "." + i)) .getValue()).intValue(), DeviceTypeConstant.DEVICE_FILESYSTEM, ((String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidFilesystemName() + "." + i)) .getValue())); //?? filesystem.setDeviceDisplayName(convStringFilessystem( ((String) ret.getValue(getEntryKey(SearchDeviceProperties.getOidFilesystemName() + "." + i)) .getValue()))); deviceCount++; filesystemList.add(filesystem); } } Collections.sort(filesystemList, new Comparator<NodeDeviceInfo>() { @Override public int compare(NodeDeviceInfo o1, NodeDeviceInfo o2) { int ret = 0; ret = o1.getDeviceType().compareTo(o2.getDeviceType()); if (ret == 0) { ret = o1.getDeviceDisplayName().compareTo(o2.getDeviceDisplayName()); } return ret; } }); property.setNodeFilesystemInfo(filesystemList); // CPU deviceCount = 0; ArrayList<NodeCpuInfo> cpuList = new ArrayList<NodeCpuInfo>(); for (String fullOid : ret.keySet()) { // SearchDeviceProperties.getOidCPU_INDEX=".1.3.6.1.2.1.25.3.3.1.2"; if (!fullOid.startsWith(getEntryKey(SearchDeviceProperties.getOidCpuIndex()) + ".") || ret.getValue(fullOid) == null) { continue; } m_log.debug("Find Cpu : fullOid = " + fullOid); String indexStr = fullOid.replaceFirst(getEntryKey(SearchDeviceProperties.getOidCpuIndex()) + ".", ""); m_log.debug("cpu fullOid = " + fullOid + ", index = " + indexStr); NodeCpuInfo cpu = new NodeCpuInfo(facilityId, Integer.valueOf(indexStr), DeviceTypeConstant.DEVICE_CPU, indexStr); cpu.setDeviceDisplayName(DeviceTypeConstant.DEVICE_CPU + deviceCount); cpu.setDeviceName(indexStr); cpuList.add(cpu); deviceCount++; } Collections.sort(cpuList, new Comparator<NodeDeviceInfo>() { @Override public int compare(NodeDeviceInfo o1, NodeDeviceInfo o2) { int ret = 0; ret = o1.getDeviceType().compareTo(o2.getDeviceType()); if (ret == 0) { ret = o1.getDeviceDisplayName().compareTo(o2.getDeviceDisplayName()); } return ret; } }); property.setNodeCpuInfo(cpuList); property.setNodeMemoryInfo(new ArrayList<NodeMemoryInfo>()); m_log.debug("device search " + property.toString()); return property; }