List of usage examples for java.lang Long Long
@Deprecated(since = "9") public Long(String s) throws NumberFormatException
From source file:dao.ColStreamBlobAddQuery.java
/** * This method is used to add blobstreams for directory. * @param conn - the connection/*from ww w .j av a 2 s. c om*/ * @param blob - the blob stream * @param blobType - the blob type (1 - photos, 2-music, 3-video 4 - * documents, 5 - archives) * @param mimeType - the mime type (image/jpeg, * application/octet-stream) * @param btitle - the title for this blob * @param bsize - the size of the blob * @param zoom - the zoom for the blob (used for displaying for * image/jpeg) * @param collabrumid - the collabrumid * @param loginId - the loginId * @param caption - caption * @throws Dao Exception - when an error or exception occurs while * inserting this blob in DB. * **/ public void run(Connection conn, byte[] blob, int blobtype, String mimetype, String btitle, long bsize, int zoom, String collabrumid, String loginid, String caption) throws BaseDaoException { // long dt = new java.util.Date().getTime(); byte[] capBytes = { ' ' }; if (!RegexStrUtil.isNull(caption)) { capBytes = caption.getBytes(); } long dt = System.currentTimeMillis(); PreparedStatement s = null; String stmt = "insert into collblob values(?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP(), ?, ?, ?, ?)"; try { s = conn.prepareStatement(stmt); s.setLong(1, 0); s.setLong(2, new Long(collabrumid)); s.setLong(3, new Long(loginid)); s.setInt(4, new Integer(blobtype)); s.setString(5, mimetype); s.setString(6, btitle); //s.setDate(7, new Date(dt)); s.setBytes(7, blob); s.setLong(8, bsize); s.setInt(9, new Integer(zoom)); s.setBytes(10, capBytes); s.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error adding a blob to collabrum query stmt " + stmt, e); } }
From source file:BeanUtilsExampleV4.java
public MyLongConverter() { this(true, new Long(0)); }
From source file:com.ewcms.plugin.vote.manager.service.PersonService.java
private void updVoteNumber(Person person) { List<Record> records = person.getRecords(); for (Record record : records) { String subjectName = record.getSubjectName(); String subjectValue = record.getSubjectValue(); String[] recordNames = subjectName.split("_"); if (recordNames.length == 2) { if (recordNames[0].equals("Subject")) { if (!recordNames[1].equals("") && StringUtils.isNumeric(recordNames[1])) { Long subjectId = new Long(recordNames[1]); Subject subject = subjectDAO.get(subjectId); if (subject == null) continue; if (subject.getStatus() == Subject.Status.INPUT) { SubjectItem subjectItem = subjectItemDAO .findSubjectItemBySubjectAndInputStatus(subjectId); if (subjectItem == null) continue; try { subjectItem.setVoteNumber(subjectItem.getVoteNumber() + 1); } catch (NullPointerException e) { subjectItem.setVoteNumber(1L); }/* ww w .j av a 2 s . co m*/ subjectItemDAO.merge(subjectItem); } else { if (!subjectValue.equals("") && StringUtils.isNumeric(subjectValue)) { Long subjectItemId = new Long(subjectValue); SubjectItem subjectItem = subjectItemDAO.get(subjectItemId); try { subjectItem.setVoteNumber(subjectItem.getVoteNumber() + 1); } catch (NullPointerException e) { subjectItem.setVoteNumber(1L); } subjectItemDAO.merge(subjectItem); } } } } } else if (recordNames.length == 4) { if (recordNames[0].equals("Subject") && recordNames[2].equals("Item")) { if (!recordNames[3].equals("") && StringUtils.isNumeric(recordNames[3])) { Long subjectItemId = new Long(recordNames[3]); SubjectItem subjectItem = subjectItemDAO.get(subjectItemId); try { subjectItem.setVoteNumber(subjectItem.getVoteNumber() + 1); } catch (NullPointerException e) { subjectItem.setVoteNumber(1L); } subjectItemDAO.merge(subjectItem); } } } } }
From source file:com.twosigma.cook.jobclient.JobTest.java
@Test public void testParseFromJSON() throws JSONException { final JSONObject json = Job.jsonizeJob(_initializedJob); json.put("instances", new JSONArray()); json.put("status", "INITIALIZED"); final String jsonString = new JSONArray().put(json).toString(); final List<Job> jobs = Job.parseFromJSON(jsonString); Assert.assertEquals(jobs.size(), 1); Assert.assertEquals(jobs.get(0), _initializedJob); Assert.assertEquals(jobs.get(0).getMaxRuntime(), new Long(1000L)); Assert.assertEquals(jobs.get(0).getApplication().getName(), "baz-app"); Assert.assertEquals(jobs.get(0).getApplication().getVersion(), "1.2.3"); Assert.assertEquals(jobs.get(0).getExpectedRuntime(), new Long(500L)); }
From source file:net.mindengine.oculus.frontend.web.controllers.admin.user.UserEditController.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { verifyPermissions(request);/* www.j ava2 s. c o m*/ Long id = new Long(request.getParameter("id")); if (id.intValue() == 1) throw new Exception("Admin account cannot be changed"); User user = (User) command; WebApplicationContext wac = WebApplicationContextUtils .getWebApplicationContext(request.getSession().getServletContext()); List<Permission> permissions = ((PermissionList) wac.getBean("permissionList")).getPermissions(); // Getting state of permission checkboxes List<Integer> newPermissionCodes = new ArrayList<Integer>(); for (Permission p : permissions) { int code = p.getCode(); String state = request.getParameter("p_" + code); if ("on".equals(state)) { newPermissionCodes.add(code); } user.getClass(); } BitCrypter bitCrypter = new BitCrypter(); String encryptedPermissions = bitCrypter.encrypt(newPermissionCodes); user.setPermissions(encryptedPermissions); if (user != null) { userDAO.updateUser(id, user); } return new ModelAndView(new RedirectView("../admin/edit-user?id=" + id)); }
From source file:com.aegiswallet.objects.SMSTransactionPojo.java
public SMSTransactionPojo(String base64EncodedJSONString) { byte[] decoded = Base64.decode(base64EncodedJSONString.getBytes(), Base64.NO_WRAP); String jsonString = new String(decoded); try {/* w ww . ja v a2 s .c o m*/ JSONObject object = new JSONObject(jsonString); this.phoneNumber = object.getString("number"); this.name = object.getString("name"); this.amount = new BigInteger(object.getString("amount")); this.btcAddress = object.getString("address"); this.timestamp = new Long(object.getString("timestamp")).longValue(); this.status = new Integer(object.getString("status")).intValue(); this.tag = object.getString("tag"); } catch (JSONException e) { Log.d(TAG, e.getMessage()); } }
From source file:net.mindengine.oculus.frontend.web.controllers.project.ProjectEditController.java
@Override protected Object formBackingObject(HttpServletRequest request) throws Exception { Long id = new Long(request.getParameter("id")); Project project = projectDAO.getProject(id); if (project == null) throw new UnexistentResource("project"); return project; }
From source file:com.mockey.ui.TwistInfoToggleServlet.java
/** * Handles the following activities for <code>TwistInfo</code> * /*from w w w .ja v a2s . c om*/ */ public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String responseType = req.getParameter("response-type"); // If type is JSON, then respond with JSON // Otherwise, direct to JSP Long twistInfoId = null; TwistInfo twistInfo = null; String coachingMessage = null; JSONObject jsonObject = new JSONObject(); try { twistInfoId = new Long(req.getParameter(PARAMETER_KEY_TWIST_ID)); boolean enable = Boolean.parseBoolean(req.getParameter(PARAMETER_KEY_TWIST_ENABLE)); twistInfo = store.getTwistInfoById(twistInfoId); if (enable) { store.setUniversalTwistInfoId(twistInfo.getId()); if (twistInfo != null) { jsonObject.put(PARAMETER_KEY_TWIST_ID, "" + twistInfo.getId()); jsonObject.put(PARAMETER_KEY_TWIST_NAME, "" + twistInfo.getName()); coachingMessage = "Twist configuration on"; } } else if (store.getUniversalTwistInfoId() != null && store.getUniversalTwistInfoId().equals(twistInfoId)) { // Disable // The only way to DISABLE _all_ twist configurations, both ENABLE (false) and TWIST-ID value (equal // to the current universal twist-id have to be passed in. // Why? To prevent random 'ENABLE=false' arguments past to this service from users // clicking OFF/disable when things are already disabled. // store.setUniversalTwistInfoId(null); coachingMessage = "Twist configuration off"; } } catch (Exception e) { logger.error("Unable to properly set Twist configuration.", e); } if (PARAMETER_KEY_RESPONSE_TYPE_VALUE_JSON.equalsIgnoreCase(responseType)) { // *********************** // BEGIN - JSON response // *********************** resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); try { JSONObject jsonResponseObject = new JSONObject(); if (twistInfo != null) { jsonObject.put("success", coachingMessage); } else { jsonObject.put("fail", "Unable to set twist configuration."); } jsonResponseObject.put("result", jsonObject); out.println(jsonResponseObject.toString()); } catch (JSONException jsonException) { throw new ServletException(jsonException); } out.flush(); out.close(); return; // *********************** // END - JSON response // *********************** } else { List<TwistInfo> twistInfoList = store.getTwistInfoList(); Util.saveSuccessMessage("Twist configuration updated", req); req.setAttribute("twistInfoList", twistInfoList); req.setAttribute("twistInfoIdEnabled", store.getUniversalTwistInfoId()); RequestDispatcher dispatch = req.getRequestDispatcher("/twistinfo_setup.jsp"); dispatch.forward(req, resp); return; } }
From source file:org.opentides.dao.impl.AuditLogDaoImpl.java
/** * Saves the log event into the database. * @param shortMessage//from w w w. ja v a2s. c o m * @param message * @param entity */ public static void logEvent(String message, BaseEntity entity) { Long userId = entity.getAuditUserId(); String username = entity.getAuditUsername(); if (ApplicationStartupListener.isApplicationStarted()) { if (userId == null) { _log.error("No userId specified for audit logging on object [" + entity.getClass().getName() + "] for message [" + message + "]. Retrieving user from interceptor."); SessionUser user = SecurityUtil.getSessionUser(); userId = user.getId(); username = user.getUsername(); } } else { userId = new Long(0); username = "System Evolve"; } EntityManager em = DatabaseUtil.getEntityManager(); try { em.getTransaction().begin(); AuditLog record = new AuditLog(message, entity.getId(), entity.getClass(), entity.getReference(), userId, username); em.persist(record); em.flush(); em.getTransaction().commit(); } finally { if (em != null && em.isOpen()) { em.close(); } } }
From source file:org.opensourcebank.batch.reader.HazelcastMapItemReader.java
public void update(ExecutionContext executionContext) throws ItemStreamException { // save the current item ID to make this step restartable executionContext.putLong(CURRENT_ITEM_ID, new Long(currentItemId).longValue()); }