List of usage examples for java.lang Long intValue
public int intValue()
From source file:com.att.archive.restful.repositories.mongo.ArchiveRepositoryImplTest.java
@Test public void testDeleteAll() { archiveRepository.deleteAll();//w w w .j av a2s . c o m int expected = 0; Long result = archiveRepository.count(); assertEquals(result.intValue(), expected); }
From source file:org.dspace.app.webui.cris.servlet.ResearcherPictureServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { String idString = req.getPathInfo(); String[] pathInfo = idString.split("/", 2); String authorityKey = pathInfo[1]; Integer id = ResearcherPageUtils.getRealPersistentIdentifier(authorityKey, ResearcherPage.class); if (id == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return;/*w w w . ja v a 2 s . c o m*/ } ResearcherPage rp = ResearcherPageUtils.getCrisObject(id, ResearcherPage.class); File file = new File(ConfigurationManager.getProperty(CrisConstants.CFG_MODULE, "researcherpage.file.path") + File.separatorChar + JDynATagLibraryFunctions.getFileFolder(rp.getPict().getValue()) + File.separatorChar + JDynATagLibraryFunctions.getFileName(rp.getPict().getValue())); InputStream is = null; try { is = new FileInputStream(file); response.setContentType(req.getSession().getServletContext().getMimeType(file.getName())); Long len = file.length(); response.setContentLength(len.intValue()); response.setHeader("Content-Disposition", "attachment; filename=" + file.getName()); FileCopyUtils.copy(is, response.getOutputStream()); response.getOutputStream().flush(); } finally { if (is != null) { IOUtils.closeQuietly(is); } } }
From source file:com.nec.harvest.service.impl.MonthlyPurchaseServiceImpl.java
/** {@inheritDoc} */ @Override// w w w . ja v a2 s. c o m public int findByOrgCodeAndMonth(String strCode, String month) throws ServiceException { if (StringUtils.isEmpty(strCode)) { throw new IllegalArgumentException("Organization's code must not be null or empty"); } if (StringUtils.isEmpty(month)) { throw new IllegalArgumentException("Month must not be null or empty"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; int recordsNo = 0; try { tx = session.beginTransaction(); Query namedQuery = repository.getNamedQuery(session, SqlConstants.SQL_FIND_MONTHLY_PURCHASE_BY_ORGANIZATION_AND_MONTH); namedQuery.setString("strCode", strCode); namedQuery.setString("getSudo", month); Long result = (Long) namedQuery.uniqueResult(); recordsNo = result.intValue(); tx.commit(); } catch (HibernateException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while count purchase change for organization " + strCode + " month " + month, ex); } finally { HibernateSessionManager.closeSession(session); } return recordsNo; }
From source file:persistence.NoticeDao.java
public Integer getTodayNewOrderNoticesSentCount() { Calendar c = Calendar.getInstance(); Date now = c.getTime();/*from ww w. j a v a 2s . co m*/ c.add(Calendar.DAY_OF_MONTH, -1); Date dayBefore = c.getTime(); String hql = "select count(noticeId) from Notice where systemEventType=:newOrder and authorDelivery is not null and noticeDate<:end and noticeDate>:start and sent is not null"; Query query = getCurrentSession().createQuery(hql); query.setParameter("newOrder", SystemEventType.NEW_ORDER); query.setParameter("end", now); query.setParameter("start", dayBefore); Long res = (Long) query.uniqueResult(); return res.intValue(); }
From source file:it.cilea.osd.jdyna.web.controller.FileServiceController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String idString = request.getPathInfo(); String[] pathInfo = idString.split("/", 4); String folder = pathInfo[3];/* w w w. j a v a2s. co m*/ String fileName = request.getParameter("filename"); File dir = new File(getPath() + File.separatorChar + folder); File file = new File(dir, fileName); if (file.getCanonicalPath().replace("\\", "/").startsWith(dir.getCanonicalPath().replace("\\", "/"))) { if (file.exists()) { InputStream is = null; try { is = new FileInputStream(file); response.setContentType(request.getSession().getServletContext().getMimeType(file.getName())); Long len = file.length(); response.setContentLength(len.intValue()); response.setHeader("Content-Disposition", "attachment; filename=" + file.getName()); FileCopyUtils.copy(is, response.getOutputStream()); response.getOutputStream().flush(); } finally { if (is != null) { is.close(); } } } else { throw new RuntimeException("File doesn't exists!"); } } else { throw new RuntimeException("No permission to download this file"); } return null; }
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);//w ww. j a va 2s .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:org.soyatec.windowsazure.internal.util.HttpUtilities.java
/** * Get the HttpWebResponse with a HttpRequest. * /*from w w w . ja va2 s . c o m*/ * @param request * @return HttpWebResponse * @throws Exception */ public static HttpWebResponse getResponse(HttpRequest request) throws Exception { HttpClient httpClient = createHttpClient(); HttpParams params = httpClient.getParams(); try { Long parseLong = Long.parseLong(request.getLastHeader(HeaderNames.Sotimeout).getValue()); request.removeHeader(request.getLastHeader(HeaderNames.Sotimeout)); // so timeout HttpConnectionParams.setConnectionTimeout(params, parseLong.intValue()); // connection timeout HttpConnectionParams.setSoTimeout(params, parseLong.intValue()); } catch (Exception e) { // Use default timeout setting... } try { if (request instanceof HttpUriRequest) { return new HttpWebResponse(httpClient.execute((HttpUriRequest) request)); } else { throw new IllegalArgumentException("Request is invalid"); } } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources // httpClient.getConnectionManager().shutdown(); } }
From source file:pl.hycom.jira.plugins.gitlab.integration.service.CommitService.java
@Override public Commit getOneCommit(Long projectId, String shaSum) throws SQLException { return commitRepository.getOneCommit(dao.getProjectConfig(projectId.intValue()), shaSum); }
From source file:org.spc.ofp.tubs.importer.CopyFromObserver.java
public void doCopy() { existsFilterProcessor.setSourceName(SOURCE_NAME); // tripIdRepository is the driving query final List<Long> tripIds = tripIdRepository.findTripIdsByGearAndYear("S", 12L, "1999", "2000"); for (final Long tripId : tripIds) { final String id = Integer.toString(tripId.intValue()); System.out.println("Processing tripId: " + id); final ImportStatus status = new ImportStatus(); status.setSourceId(id);/*w w w.j av a 2 s. c om*/ status.setSourceName(SOURCE_NAME); status.setStatus("F"); // Assume import will fail status.setAuditEntry(getAuditEntry()); try { // Check to see if trip already exists final String checkedId = existsFilterProcessor.process(id); // existsFilterProcessor returns null to signal that this ID has already been copied if (null == checkedId || "".equalsIgnoreCase(checkedId.trim())) { continue; } System.out.println("...doesn't exist in target system..."); // Convert the ID to an Observer trip final org.spc.ofp.observer.domain.ITrip sourceTrip = observerTripProcessor.process(checkedId); // Convert the Observer trip to a TUBS trip final org.spc.ofp.tubs.domain.purseseine.PurseSeineTrip targetTrip = (PurseSeineTrip) tubsTripProcessor .process(sourceTrip); if (null == targetTrip) { continue; } System.out.println("...can be converted to a TUBS object..."); // Write the trip using JPA targetTripRepository.save(targetTrip); System.out.println("...written to target DB with ID=" + targetTrip.getId()); status.setTripId(targetTrip.getId()); status.setStatus("S"); } catch (Exception ex) { status.setComments(String.format("Error summary: {%s}\nFull stack trace:\n%s", ex.getMessage(), Throwables.getStackTraceAsString(ex))); System.out.println(String.format("Skipping trip %s due to error {%s}", id, ex.getMessage())); ex.printStackTrace(System.err); } commonRepo.saveImportStatus(status); } }
From source file:net.bitnine.agensgraph.graph.property.Jsonb.java
public Integer getInt() { Long value = getLong(); return (value == null) ? null : value.intValue(); }