List of usage examples for java.lang Long Long
@Deprecated(since = "9") public Long(String s) throws NumberFormatException
From source file:de.iew.raspimotion.controllers.MotionJpegController.java
@RequestMapping(value = "image/{imagename:.+}") public void imageAction(HttpServletResponse response, @PathVariable String imagename) throws Exception { Assert.isTrue(validateImagename(imagename)); FileDescriptor file = this.fileDao.getFileLastCreated(imagename); if (file == null) { throw new NoSuchElementException("Image was not found"); }//from w w w. j av a 2 s. com sendCachingHeaders(response); response.setContentType("image/jpeg"); response.setContentLength(new Long(file.getFilesize()).intValue()); sendImageAsJpeg(file, response); }
From source file:es.pode.administracion.presentacion.planificador.eliminarTrabajoEjecutado.EliminarTrabajoControllerImpl.java
/** * metodo que obtiene los trabajos que se han seleccionado para eliminar *//*from w w w .j a v a 2s . co m*/ public final void obtenerTrabajos(org.apache.struts.action.ActionMapping mapping, es.pode.administracion.presentacion.planificador.eliminarTrabajoEjecutado.ObtenerTrabajosForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception { String[] arrayIds; String listaIds = ""; String nombreServidor = ""; String[] arrayNombreServidor; try { arrayIds = (String[]) form.getIdsAsArray(); String[] listaNombres = new String[arrayIds.length]; //Construimos el array de nombres for (int i = 0; i < arrayIds.length; i++) { nombreServidor = this.getSrvPlanificadorService().obtenerTrabajoEjecutado(new Long(arrayIds[i])) .getTrabajo(); arrayNombreServidor = nombreServidor.split("!!"); listaNombres[i] = new String(); listaNombres[i] = arrayNombreServidor[0]; log.debug("trabajo a eliminar: " + listaNombres[i]); listaIds = listaIds + arrayIds[i] + "#"; } form.setListaIds(listaIds); form.setListaNombres(listaNombres); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }
From source file:fr.keemto.core.JdbcEventRepositoryIT.java
@Test public void shouldReturnOnlyEventsNewerThan() throws Exception { Long newerThan = new Long(1301461284370L); List<Event> events = repository.getEvents(newerThan); assertThat(events.size(), equalTo(1)); }
From source file:eu.cloud4soa.relationalrepo.MonitoringStatisticRepositoryTest.java
@Test @Ignore//from w ww. ja v a 2s . c o m public void testSelect() throws ParseException { monitoringJob = new MonitoringJob(); monitoringJob.setId(new Long(18)); String[] pattern = new String[1]; pattern[0] = "yyyy-MM-dd HH:mm:ss"; Date start = DateUtils.parseDate("2012-07-02 04:06:56", pattern); Date end = DateUtils.parseDate("2012-07-02 16:01:33", pattern); List<MonitoringStatistic> list = monitoringStatisticRepository.retrieveAllInRangeLimited(monitoringJob, start, end, 500); System.out.println(list.size()); }
From source file:org.iwethey.forums.web.HeaderInterceptor.java
/** * Load the request attributes with the User object (if authenticated) * and start time for the page for audit purposes. * <p>/*from w w w . j a v a2 s . c o m*/ * @param request The servlet request object. * @param response The servlet response object. * @param handler The request handler processing this request. */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Date now = new Date(); request.setAttribute("now", now); long start = now.getTime(); request.setAttribute("start", new Long(start)); Integer id = (Integer) WebUtils.getSessionAttribute(request, USER_ID_ATTRIBUTE); User user = null; if (id == null) { user = (User) WebUtils.getSessionAttribute(request, USER_ATTRIBUTE); if (user == null) { user = new User("Anonymous"); WebUtils.setSessionAttribute(request, USER_ATTRIBUTE, user); } } else { user = mUserManager.getUserById(id.intValue()); user.setLastPresent(new Date()); mUserManager.saveUserAttributes(user); } request.setAttribute("username", user.getNickname()); request.setAttribute(USER_ATTRIBUTE, user); System.out.println("Local Address = [" + request.getLocalAddr() + "]"); System.out.println("Local Name = [" + request.getLocalName() + "]"); System.out.println("Remote Address = [" + request.getRemoteAddr() + "]"); System.out.println("Remote Host = [" + request.getRemoteHost() + "]"); System.out.println("Remote Port = [" + request.getRemotePort() + "]"); System.out.println("Remote User = [" + request.getRemoteUser() + "]"); System.out.println("Context Path = [" + request.getContextPath() + "]"); System.out.println("===================="); Cookie[] cookies = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { Cookie cookie = cookies[i]; System.out.println("Cookie Domain = [" + cookie.getDomain() + "]"); System.out.println("Cookie Name = [" + cookie.getName() + "]"); System.out.println("Cookie Value = [" + cookie.getValue() + "]"); System.out.println("Cookie Expire = [" + cookie.getMaxAge() + "]"); System.out.println("===================="); if ("iwt_cookie".equals(cookie.getName())) { cookie.setMaxAge(1000 * 60 * 60 * 24 * 30 * 6); response.addCookie(cookie); } } } else { System.out.println("No cookies were found in the request"); } Cookie newCookie = new Cookie("iwt_cookie", "harrr2!"); newCookie.setPath(request.getContextPath()); newCookie.setDomain(request.getLocalName()); newCookie.setMaxAge(1000 * 60 * 60 * 24 * 30 * 6); response.addCookie(newCookie); request.setAttribute(HEADER_IMAGE_ATTRIBUTE, "/images/iwethey-lrpd-small.png"); return true; }
From source file:com.nfwork.dbfound.json.JSONDynaBean.java
public Object get(String name) { Object value = dynaValues.get(name); if (value != null) { return value; }//from w w w.j a va2 s .c o m Class type = getDynaProperty(name).getType(); if (type == null) { throw new NullPointerException("Unspecified property type for " + name); } if (!type.isPrimitive()) { return value; } if (type == Boolean.TYPE) { return Boolean.FALSE; } else if (type == Byte.TYPE) { return new Byte((byte) 0); } else if (type == Character.TYPE) { return new Character((char) 0); } else if (type == Short.TYPE) { return new Short((short) 0); } else if (type == Integer.TYPE) { return new Integer(0); } else if (type == Long.TYPE) { return new Long(0); } else if (type == Float.TYPE) { return new Float(0.0); } else if (type == Double.TYPE) { return new Double(0); } return null; }
From source file:com.redhat.lightblue.ResponseTest.java
@Test public void testWithModifiedCount() { node = JsonNodeFactory.withExactBigDecimals(true).numberNode(Long.MAX_VALUE); builder.withModifiedCount(node);// ww w. j av a 2s. c o m assertTrue(new Long(Long.MAX_VALUE).equals(builder.buildResponse().getModifiedCount())); }
From source file:com.panet.imeta.core.playlist.FilePlayListReplayLineNumberFile.java
public boolean isProcessingNeeded(FileObject file, long lineNr, String filePart) throws KettleException { return lineNumbers.contains(new Long(lineNr)); }
From source file:br.com.wjaa.pagseguro.ws.PagSeguroWSImpl.java
/** * Class with a main method to illustrate the usage of the domain class PaymentRequest * @throws PagSeguroServiceException /*from ww w .j a va 2 s.c om*/ */ public URL criarPagamento(Pedido pedido, Cupom cupom) throws PagSeguroServiceException { // Instantiate a new payment request PaymentRequest paymentRequest = new PaymentRequest(); // Sets the currency paymentRequest.setCurrency(Currency.BRL); for (PedidoItem item : pedido.getItens()) { PortaRetrato pr = item.getPortaRetrato(); BigDecimal preco = createBigDecimal((item.getValor() - this.getDesconto(item.getValor(), cupom))); // Add an item for this payment request paymentRequest.addItem(item.getId().toString(), pr.getNome(), new Integer(1), preco, new Long(1000), null); } // Add another item for this payment request //paymentRequest.addItem("0002", "Notebook Rosa", new Integer(2), new BigDecimal("2560.00"), new Long(750), null); // Sets a reference code for this payment request, it's useful to // identify this payment in future notifications. paymentRequest.setReference("#" + pedido.getId()); // Sets shipping information for this payment request //paymentRequest.setShippingType(ShippingType.SEDEX); // paymentRequest.setShippingAddress("BRA", "SP", "Sao Paulo", "Jardim Paulistano", "01452002", // "Av. Brig. Faria Lima", "1384", "5o andar"); // Sets your customer information. //paymentRequest.setSender("Joao Comprador", "comprador@uol.com.br", "11", "56273440", "CPF", "888.263.551-18"); // Sets notificationURL information paymentRequest.setNotificationURL("http://www.meuportaretrato.com/notificacao"); // Sets redirectURL paymentRequest.setRedirectURL("http://www.meuportaretrato.com/retornoPagamento"); // Register this payment request in PagSeguro, to obtain the payment // URL for redirect your customer. URL paymentURL = paymentRequest.register(new AccountCredentials(USER_PS, TOKEN_PS)); //redirecionar o comprador para URL de pagamento. //https://pagseguro.uol.com.br/v2/checkout/payment.html?code=8CF4BE7DCECEF0F004A6DFA0A8243412 return paymentURL; }
From source file:hoot.services.models.osm.ModelDaoUtils.java
/** * Returns the record ID associated with the record request input string for the given DAO type. * First attempts to parse the request string as a record ID. If that is unsuccessful, it * treats the request string as a record display name. This currently only supports Map and User * types.//from w w w. j ava 2s . c o m * * @param requestStr can be either a map ID or a map name * @param conn JDBC Connection * @return if a record ID string is passed in, it is verified and returned; if a record name * string is passed in, it is verified that only one record of the requested type exists with * the given name, and its ID is returned * @throws Exception if the requested record doesn't exist or if multiple reccords of the same * type exist with the requested input name * @todo There must be a way to implement this generically for all DAO's but haven't been able to * figure out how to do it yet. */ public static long getRecordIdForInputString(final String requestStr, Connection dbConn, RelationalPathBase<?> table, NumberPath<Long> idField, StringPath nameField) throws Exception { if (StringUtils.isEmpty(requestStr)) { throw new Exception("No record exists with ID: " + requestStr + ". Please specify a valid record."); } boolean parsedAsNum = true; long idNum = -1; try { idNum = Long.parseLong(requestStr); } catch (NumberFormatException e) { parsedAsNum = false; } String requestStrType = parsedAsNum ? "ID" : "name"; boolean recordExists = false; boolean multipleRecordsExist = false; log.debug("Verifying record with " + requestStrType + ": " + requestStr + " has previously been " + "created ..."); if (idNum != -1) { //SQLQuery query = new SQLQuery(dbConn, DbUtils.getConfiguration()); recordExists = new SQLQuery(dbConn, DbUtils.getConfiguration()).from(table) .where(idField.eq(new Long(idNum))).exists(); } else if (!StringUtils.isEmpty(requestStr)) { //input wasn't parsed as a numeric ID, so let's try it as a name //TODO: there has to be a better way to do this against the generated code but haven't been //able to get it to work yet //SQLQuery query = new SQLQuery(dbConn, DbUtils.getConfiguration()); List<Long> records = new SQLQuery(dbConn, DbUtils.getConfiguration()).from(table) .where(nameField.eq(requestStr)).list(idField); if (records.size() == 1) { return records.get(0); } if (records.size() > 1) { recordExists = true; multipleRecordsExist = true; } } if (multipleRecordsExist) { throw new Exception("Multiple records exist with " + requestStrType + ": " + requestStr + ". Please specify " + "a single, valid record."); } if (!recordExists) { throw new Exception("No record exists with " + requestStrType + ": " + requestStr + ". Please specify a " + "valid record."); } return idNum; }