List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:fr.univlr.cri.planning.factory.HugICalendarFactory.java
/** * Recupere l'objet <code>CalendarObject</code> a partir du cache. Si ce * dernier est trouve avec une duree de vie maximal non depassee, alors on le * retourne. Si l'objet est trouve mais perime, il est supprime. Si l'objet * est non trouve ou perime, alors on retourne <code>null</code> *///from w w w . j a va 2 s . co m public CalendarObject getCalendarObjectFromCache(String iCalendarUrl) { CalendarObject calendar = null; NSDictionary dico = (NSDictionary) dicoICalendarObjects().objectForKey(iCalendarUrl); if (dico != null) { Long maxTime = (Long) dico.valueForKey(CACHE_KEY_TIMEOUT); long timeRemaining = (maxTime != null ? maxTime.longValue() - System.currentTimeMillis() : 0); // pas perime if (timeRemaining > 0) { // CktlLog.trace("cache retrevied : ["+iCalendarUrl+"] - " + // timeRemaining +"ms remaining"); calendar = (CalendarObject) dico.valueForKey(CACHE_KEY_ICALENDAR_OBJECT); } else { // obsolete : on efface // CktlLog.trace("cache removed : ["+iCalendarUrl+"] - out-of-date since " // + (-timeRemaining) +"ms"); dicoICalendarObjects().removeObjectForKey(iCalendarUrl); } } /* * else { CktlLog.trace("calendar not in cache : ["+iCalendarUrl+"]"); } */ return calendar; }
From source file:com.daro.persistence.generic.dao.GenericDaoImpl.java
/** * Returns a entity t (clazz type) that it corresponds to the id passed. * Made a searching by id./*from w w w . j a va2 s . c o m*/ * * @param id * @return T Data type of entity * @throws PersistenceException */ @Override @SuppressWarnings("unchecked") public T getById(Long id) throws PersistenceException { Session session = this.getCurrentSession(); if (id == null) { logger.error("Persistence layer error: Illegal Argument in getById method, Id is null (" + PersistenceError.ARGUMENT_NULL.getMessage() + ")"); throw new PersistenceException(PersistenceError.ARGUMENT_NULL); } T t = (T) session.load(clazz, id.longValue()); if (loggerInfoEnabled) logger.debug("Persistence layer info: " + clazz.getSimpleName() + " loaded successfully, details=" + t); return t; }
From source file:es.pode.localizador.negocio.servicios.SrvLocalizadorServiceImpl.java
/** * Consulta de espacio ocupado por una lista de identificadores * @param identificadores Lista de identificadores de localizaciones de las que se quiere consultar el espacio ocupado en disco. * @return devuelve el espacio ocupado en disco por la lista de localizaciones en el mismo orden que se le pasa. Si alguno de los localizadores * no es valido, devuelve 0 en su posicin. * @throws Exception//from w w w . j a v a 2 s .c om * */ protected Long[] handleConsultaEspacioLocalizadores(String[] identificadores) throws Exception { Long[] listaConsumo = null; Collection coleccion = null; if (identificadores != null && identificadores.length > 0) { HashMap hashMap = new HashMap(); listaConsumo = new Long[identificadores.length]; try { LocalizadorDao localizadorDao = this.getLocalizadorDao(); IdentificadoresCriteria identificadoresCriteria = new IdentificadoresCriteria(); identificadoresCriteria.setIdentificadores(identificadores); if (logger.isDebugEnabled()) { for (int i = 0; i < identificadores.length; i++) { logger.debug("Iedentificador" + i + ":[" + identificadores[i]); } } String[] identifCr = identificadoresCriteria.getIdentificadores(); List localizadores = (List) localizadorDao.buscarLocalizadoresPorIdentificadores( LocalizadorDao.TRANSFORM_LOCALIZADORVO, identificadoresCriteria); for (int i = 0; i < localizadores.size(); i++) { long consumo = 0; LocalizadorVO localizadorVO = (LocalizadorVO) localizadores.get(i); boolean encontrado = false; if (localizadorVO != null && !encontrado) { String identifVuelta = localizadorVO.getIdentificador(); for (int j = 0; j < identificadores.length && !encontrado; j++) { logger.debug("El identificador de entrada:[" + identificadores[j] + "Y el identificador de vuelta:[" + identifVuelta); if (identificadores[j].equals(identifVuelta) && !encontrado) { encontrado = true; logger.debug("El identificador de entrada:[" + identificadores[j] + "Y el identificador de vuelta:[" + identifVuelta + "ha sido encontrado"); if (localizadorVO.getConsumoEspacio() != null && !localizadorVO.getConsumoEspacio().equals("0")) { logger.debug("El tamaino:[" + localizadorVO.getConsumoEspacio().longValue() + " del identificador:" + localizadorVO.getIdentificador()); consumo = localizadorVO.getConsumoEspacio(); // hashMap.put(localizadorVO.getIdentificador(), localizadorVO.getConsumoEspacio()); } else {//Si el tamiano del ODE no est clacula todava, lo calculamos y lo insertamos en la tabla logger.debug( "El tamaino no esta en la tabla, lo calculamos y lo insertamos con el PATH:[" + localizadorVO.getPath()); Long tamai = this.calculaEspacio(new File(localizadorVO.getPath())); logger.debug("Hemos calculado el tamaino:[" + tamai.longValue() + "]del ODE con identificador:[" + localizadorVO.getIdentificador() + "]"); localizadorVO.setConsumoEspacio(tamai); logger.debug("La transformacion:[" + localizadorVO.getIdentificador()); logger.debug("El identificador para buscar el entity:" + localizadorVO.getIdentificador()); Localizador localizador = localizadorDao .buscarLocalizadorPorIdentificador(localizadorVO.getIdentificador()); localizadorDao.fromLocalizadorVO(localizadorVO, localizador); logger.debug("Modifico el entity con el VO con : identificador[" + localizador.getIdentificador() + "]y consumo[" + localizador.getConsumoEspacio().longValue() + "]"); localizadorDao.update(localizador); consumo = tamai; logger.debug("El tamaino:[" + consumo + "]"); // hashMap.put(localizadorVO.getIdentificador(), tamai); } listaConsumo[j] = consumo; } } } // listaConsumo[i]=consumo; // coleccion.add(hashMap); } } catch (Exception e) { logger.debug("Error al realizar la consulta de espacio de localizadores: " + e.getMessage()); throw new Exception( "Error al realizar la consulta de espacio de localizadores con identificadores"); } } return listaConsumo; }
From source file:com.jaspersoft.jasperserver.war.action.ReportJobEditAction.java
protected Object createFormObject(RequestContext context) { ReportJob job;/*from w w w.ja v a2 s . c o m*/ if (isNewMode(context)) { job = createNewReportJob(context); } else { Long jobIdParam = context.getRequestParameters().getRequiredLong(getEditJobIdParamName()); long jobId = jobIdParam.longValue(); job = schedulingService.getScheduledJob(JasperServerUtil.getExecutionContext(context), jobId); if (job == null) { throw new ReportJobNotFoundException(jobId); } } if (job.getMailNotification() == null) { job.setMailNotification(new ReportJobMailNotification()); } return job; }
From source file:com.amazonaws.services.s3.model.ObjectMetadata.java
/** * <p>// w w w. j a v a 2 s . c om * Gets the Content-Length HTTP header indicating the size of the * associated object in bytes. * </p> * <p> * This field is required when uploading objects to S3, but the AWS S3 Java * client will automatically set it when working directly with files. When * uploading directly from a stream, set this field if * possible. Otherwise the client must buffer the entire stream in * order to calculate the content length before sending the data to * Amazon S3. * </p> * <p> * For more information on the Content-Length HTTP header, see <a * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13"> * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13</a> * </p> * * @return The Content-Length HTTP header indicating the size of the * associated object in bytes. Returns <code>null</code> * if it hasn't been set yet. * * @see ObjectMetadata#setContentLength(long) */ public long getContentLength() { Long contentLength = (Long) metadata.get(Headers.CONTENT_LENGTH); if (contentLength == null) return 0; return contentLength.longValue(); }
From source file:io.ucoin.ucoinj.core.client.service.bma.BlockchainRemoteServiceImpl.java
@Override public long getLastUD(Peer peer) { // get block number with UD String blocksWithUdResponse = executeRequest(peer, URL_BLOCK_WITH_UD, String.class); Integer blockNumber = getLastBlockNumberFromJson(blocksWithUdResponse); // If no result (this could happen when no UD has been send if (blockNumber == null) { // get the first UD from currency parameter BlockchainParameters parameter = getParameters(peer); return parameter.getUd0(); }/* w w w . j a va2s . c om*/ // Get the UD from the last block with UD String path = String.format(URL_BLOCK, blockNumber); String json = executeRequest(peer, path, String.class); Long lastUD = getDividendFromBlockJson(json); // Check not null (should never append) if (lastUD == null) { throw new TechnicalException("Unable to get last UD from server"); } return lastUD.longValue(); }
From source file:org.squale.squaleweb.util.graph.AuditsSizeMaker.java
/** * Effectue les pr-traitements ncessaires l'affichage 1)efface les doublons en ne rcuprant que le maximum 2) * tri par ordre chronologique// w w w . j av a2 s . co m * * @param pValues le tableau des valeurs * @return la list tri sans doublons avec la valeur maximum (sous forme d'un tableau d'objets 2 cases, la * premire la date (String) la deuxime la taille max du FS sur les audits de la journe). */ private List getSortedList(List pValues) { List result = new ArrayList(0); for (int i = 0; i < pValues.size(); i++) { Object[] combo = (Object[]) pValues.get(i); String date = (String) combo[0]; Number size = (Number) combo[1]; int j; for (j = 0; j < result.size(); j++) { // on est sur la meme journe, on prend le maximum if (((String) ((Object[]) result.get(j))[0]).equals(date)) { Long currentStoredSize = (Long) ((Object[]) result.get(j))[1]; // Si la valeur actuellement stocke est null, on insre de toute facon la nouvelle // Si la nouvelle est null, a ne change rien sinon on insre une bonne valeur if (currentStoredSize == null) { ((Object[]) result.get(j))[1] = size; } else { // La valeur actuelle n'est pas null, on doit grer l'ajout ventuel if (size != null) { // 2 valeurs, on prend le maximum ((Object[]) result.get(j))[1] = new Long( Math.max(currentStoredSize.longValue(), size.longValue())); } // sinon on garde la valeur actuellement stocke } // coupe la boucle j = result.size() + 1; } } // on ne l'a pas trouve, nouvelle valeur on insre le tableau tel quel if (j == result.size()) { result.add(combo); } } return result; }
From source file:com.ext.portal.events.HomeLandingPageAction.java
public void run(HttpServletRequest request, HttpServletResponse response) { _log.error("Starting HomeLandingPageAction"); java.lang.Long userId = (java.lang.Long) request.getAttribute(WebKeys.USER_ID); if (request.getSession() != null) { userId = (java.lang.Long) request.getSession().getAttribute(WebKeys.USER_ID); }//from ww w . ja va 2 s . co m String path = null; if (userId != null) { _log.error("user id: " + userId.toString()); List<UserGroup> userGroups = null; // 10106 appears to be the default company id long company = 0; try { userGroups = UserGroupLocalServiceUtil.getUserUserGroups(userId.longValue()); _log.error("user group count: " + userGroups.size()); } catch (Exception e) { // error getting user groups _log.error("*** USER GROUPS ERROR *** " + e.getMessage()); } try { _log.error("user id: " + userId.longValue()); User user = UserLocalServiceUtil.getUserById(userId.longValue()); if (user != null) { _log.error("user -- " + user.getFullName()); company = user.getCompanyId(); _log.error("company-- " + company); } else { _log.error("user is null"); } } catch (PortalException e) { _log.error("*** USER PORTAL EXCEPTION *** " + e.getMessage()); e.printStackTrace(); } catch (SystemException e) { _log.error("*** USER SYSTEM EXCEPTION *** " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { _log.error("*** USER EXCEPTION *** " + e.getMessage()); e.printStackTrace(); } if (userGroups.size() > 0) { Group group = null; List<Group> groups = null; try { groups = GroupLocalServiceUtil.search(PortalUtil.getCompanyId(request), null, null, null, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } catch (SystemException e) { _log.error("*** GROUPS SYSTEM EXCEPTION *** " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { _log.error("*** GROUPS EXCEPTION *** " + e.getMessage()); e.printStackTrace(); } if (groups.size() > 0) { _log.error("groups count-- " + groups.size()); Iterator<UserGroup> itu = userGroups.iterator(); _log.error("User Group iterator instantiated"); while (itu.hasNext()) { _log.error("Inside User Group Loop"); UserGroup tempUG = itu.next(); _log.error("user group-- " + tempUG.getName() + "/" + tempUG.getUserGroupId()); Iterator<Group> itg = groups.iterator(); while (itg.hasNext()) { _log.error("Inside Group Loop"); try { Group tempG = itg.next(); _log.error("group-- " + tempG.getGroupId() + "/" + tempG.getName()); if (UserGroupLocalServiceUtil.hasGroupUserGroup(tempG.getGroupId(), tempUG.getUserGroupId())) { _log.error("Group has user group!"); int pageCount = tempG.getPrivateLayoutsPageCount() + tempG.getPublicLayoutsPageCount(); _log.error("page count-- " + pageCount); if (pageCount != 0) { group = tempG; _log.error( "We have a group-- " + group.getName() + "/" + group.getGroupId()); break; } } } catch (SystemException e) { _log.error("*** FIND GROUP SYSTEM EXCEPTION *** " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { _log.error("*** FIND GROUP EXCEPTION *** " + e.getMessage()); e.printStackTrace(); } } if (group != null) { break; } else { _log.error("*** NO COMMUNITIES FOUND FOR USER GROUP *** "); } } } else { _log.error("*** NO COMMUNITIES FOUND IN SYSTEM *** "); } try { // if we have user groups, try to find all the communities // that user is a part of // based on the user group list if (group != null) { _log.error("group-- " + group.getGroupId() + "/" + group.getName()); // if we have communities, pick the first from the list // and get the url path = ((GroupImpl) group).getFriendlyURL(); _log.error("path-- " + path); } else { // no communities = can't do much _log.error("*** NO COMMUNITIES ***"); } } catch (Exception e) { // error getting communities _log.error("*** COMMUNITIES ERROR *** " + e.getMessage()); } } else { // no user group = can't do much _log.error("*** NO USER GROUPS ***"); } } else { // no user = can't do much _log.error("*** NULL USER_ID ***"); } if (_log.isInfoEnabled()) { _log.info("HomeLandingPageAction=" + (path != null ? path : "<null>")); } if (Validator.isNotNull(path)) { // if we don't have a null path, go there //LastPath lastPath = new LastPath("/web", path, LastPath lastPath = new LastPath("/group", path, new HashMap<String, String[]>()); HttpSession session = request.getSession(); session.setAttribute(WebKeys.LAST_PATH, lastPath); } }
From source file:freenet.support.TimeUtil.java
/** * Tests formatTime(long) method//from w ww . j a v a 2 s .c o m * using known values. * They could be checked using Google Calculator * http://www.google.com/intl/en/help/features.html#calculator */ public void testFormatTime_KnownValues() { Long methodLong; String[][] valAndExpected = { //one week { "604800000", "1w" }, //one day { "86400000", "1d" }, //one hour { "3600000", "1h" }, //one minute { "60000", "1m" }, //one second { "1000", "1s" } }; for (int i = 0; i < valAndExpected.length; i++) { methodLong = Long.valueOf(valAndExpected[i][0]); assertEquals(TimeUtil.formatTime(methodLong.longValue()), valAndExpected[i][1]); } }
From source file:io.ucoin.ucoinj.core.client.service.bma.BlockchainRemoteServiceImpl.java
@Override public long getLastUD(long currencyId) { // get block number with UD String blocksWithUdResponse = executeRequest(currencyId, URL_BLOCK_WITH_UD, String.class); Integer blockNumber = getLastBlockNumberFromJson(blocksWithUdResponse); // If no result (this could happen when no UD has been send if (blockNumber == null) { // get the first UD from currency parameter BlockchainParameters parameter = getParameters(currencyId); return parameter.getUd0(); }//w ww.j av a 2 s.c om // Get the UD from the last block with UD Long lastUD = getBlockDividend(currencyId, blockNumber); // Check not null (should never append) if (lastUD == null) { throw new TechnicalException("Unable to get last UD from server"); } return lastUD.longValue(); }