List of usage examples for java.lang Long Long
@Deprecated(since = "9") public Long(String s) throws NumberFormatException
From source file:com.googlecode.psiprobe.beans.stats.listeners.MemoryPoolMailingListener.java
protected void sendMail(StatsCollectionEvent sce, String message, boolean flappingStop) { String name = sce.getName();/*ww w . java 2 s . c o m*/ if (isSeriesDisabled(name)) { return; } Long value = new Long(sce.getValue()); Long threshold = new Long(this.getThreshold(name)); String subjectInfix = ""; String bodyPrefix = ""; if (flappingStop) { subjectInfix = getMessageSourceAccessor().getMessage(BASE_PROPERTY + "flappingStop.subject.infix"); bodyPrefix = getMessageSourceAccessor().getMessage(BASE_PROPERTY + "flappingStop.body.prefix"); } String subject = getMessageSourceAccessor().getMessage(BASE_PROPERTY + message + ".subject", new Object[] { subjectInfix, name, value, threshold }); String body = getMessageSourceAccessor().getMessage(BASE_PROPERTY + message + ".body", new Object[] { bodyPrefix, name, value, threshold }); MailMessage mail = new MailMessage(null, subject, body); try { getMailer().send(mail); } catch (MessagingException ex) { logger.error("Cannot send message", ex); } }
From source file:de.uhh.l2g.plugins.guest.OpenAccessVideos.java
@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { String resourceID = resourceRequest.getResourceID(); String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); if (cmd.equals("get_search_words")) { getSearchWords(resourceRequest, resourceResponse); }/* w w w. j a v a 2s .c o m*/ try { if (resourceID.equals("showSegments")) { String vId = ParamUtil.getString(resourceRequest, "videoId"); Long vID = new Long(vId); com.liferay.portal.kernel.json.JSONArray ja = JSONFactoryUtil.createJSONArray(); //get segments for video and convert to json array try { List<Segment> sl = SegmentLocalServiceUtil.getSegmentsByVideoId(vID); ListIterator<Segment> sIt = sl.listIterator(); while (sIt.hasNext()) { Segment s = sIt.next(); JSONObject jo = JSONFactoryUtil.createJSONObject(); jo.put("chapter", s.getChapter()); jo.put("description", s.getDescription()); jo.put("end", s.getEnd()); jo.put("image", s.getImage()); jo.put("number", s.getNumber()); jo.put("segmentId", s.getPrimaryKey()); jo.put("seconds", s.getSeconds()); jo.put("start", s.getStart()); jo.put("title", s.getTitle()); jo.put("userId", s.getUserId()); jo.put("videoId", s.getVideoId()); jo.put("previousSegmentId", SegmentLocalServiceUtil.getPreviusSegmentId(s.getSegmentId())); ja.put(jo); } } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } writeJSON(resourceRequest, resourceResponse, ja); } } catch (NullPointerException npe) { } }
From source file:com.jd.bdp.hydra.hbase.service.impl.HbaseUtils.java
byte[] long2ByteArray(Long value) { long v = value.longValue(); byte[] b = new byte[8]; for (int i = 0; i < b.length; i++) { b[i] = new Long(v & 0xff).byteValue(); v = v >> 8;//from w w w. j a v a 2 s . c om } return b; }
From source file:com.npower.dm.hibernate.entity.CarrierIdentifierGenerator.java
public Serializable generate(SessionImplementor session, Object entity) throws HibernateException { if (!(entity instanceof Carrier)) { throw new HibernateException("Entity not implements Carrier interface."); }//from w w w . j av a 2 s.co m Carrier carrier = (Carrier) entity; if (StringUtils.isEmpty(carrier.getExternalID())) { throw new HibernateException("Could not generate a identifier, missing carrier externalID."); } StringBuffer buf = new StringBuffer(carrier.getExternalID().toLowerCase().trim()); int id = (int) buf.toString().hashCode(); // Keep > 0, unsigned number if (id < 0) { id = Integer.MAX_VALUE + id; } return new Long(id); }
From source file:edu.amrita.aview.gclm.helpers.UserHelper.java
/** * Creates the user./*from w w w. ja v a 2 s .c om*/ * * @param user the user * @param creatorId the creator id * @param statusId the status id * @throws AViewException */ public static void createUser(User user, Long creatorId, Integer statusId) throws AViewException { // Code added to use the master admin id, if the user registers through aview website User adminUser = null; logger.info( "User creation " + user.getUserName() + " by creator: " + creatorId + " with status " + statusId); //Fix for Bug #13729 start if (creatorId.equals(new Long(0))) //Fix for Bug #13729 end { statusId = StatusHelper.getPendingStatusId(); //adminUser = getUsersByRole(Constant.MASTER_ADMIN_ROLE); adminUser = getUserByUserName(Constant.MASTER_ADMIN_USER_NAME); creatorId = adminUser.getUserId(); //Fix for Bug #13729 start user.setCreatedFrom(Constant.CREATED_FROM_WEB); //Fix for Bug #13729 end } user.setCreatedAuditData(creatorId, TimestampUtils.getCurrentTimestamp(), statusId); UserDAO.createUser(user); if (adminUser != null) { EmailHelper.sendEmailForNewUserRegistration(user.getEmail()); EmailHelper.sendEmailToAdminForNewUserRegistration(user.getUserName(), user.getFname(), user.getLname(), user.getEmail()); } }
From source file:com.cemeterylistingswebtest.test.rest.CemeteryControllerTest.java
@Test(enabled = false, dependsOnMethods = "testCreate") public void testClubUpdate() { // LEFT AS AN EXERCISE FOR YOU // GET THE CLUB and THEN CHANGE AND MAKE A COPY //THEN SEND TO THE SERVER USING A PUT OR POST // THEN READ BACK TO SEE IF YOUR CHANGE HAS HAPPENED Long me = new Long(17); Cemetery oldCemetery = cs.find(me);/*from ww w . ja v a2s . c o m*/ Cemetery updateCemetery = new Cemetery.Builder().Cemetery(oldCemetery).setContactNumber("0215554412") .build(); repo.save(updateCemetery); id = updateCemetery.getId(); HttpEntity<Cemetery> requestEntity = new HttpEntity<>(updateCemetery, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/cemetery/update", HttpMethod.PUT, requestEntity, String.class); System.out.println(" THE RESPONSE BODY " + responseEntity.getBody()); System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode()); System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders()); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); }
From source file:fr.univrouen.poste.domain.PosteCandidatureFile.java
public static Long getSumNbPages() { String sql = "SELECT SUM(nb_pages) FROM poste_candidature_file"; Query q = entityManager().createNativeQuery(sql); BigDecimal bigValue = (BigDecimal) q.getSingleResult(); if (bigValue != null) { return bigValue.longValue(); } else {//w w w . j a v a 2s . co m return new Long(0); } }
From source file:models.db.User.java
public Long getPartnerId() { if (this.getPartner() == null) { return new Long(0); } else {// w w w . j ava 2 s. co m return this.getPartner().getId(); } }
From source file:org.geoserver.geofence.gui.server.service.impl.GsUsersManagerServiceImpl.java
public PagingLoadResult<GSUserModel> getGsUsers(int offset, int limit, boolean full) throws ApplicationException { int start = offset; List<GSUserModel> usersListDTO = new ArrayList<GSUserModel>(); if (full) {//from w ww .ja v a2 s . c om GSUserModel all_user = new GSUserModel(); all_user.setId(-1); all_user.setName("*"); all_user.setFullName("*"); all_user.setEnabled(true); all_user.setAdmin(false); all_user.setEmailAddress(null); all_user.setDateCreation(null); usersListDTO.add(all_user); } long usersCount = geofenceRemoteService.getUserAdminService().getCount(null) + 1; Long t = new Long(usersCount); int page = (start == 0) ? start : (start / limit); List<ShortUser> usersList = geofenceRemoteService.getUserAdminService().getList(null, page, limit); if (usersList == null) { if (logger.isErrorEnabled()) { logger.error("No user found on server"); } throw new ApplicationException("No user found on server"); } for (ShortUser short_usr : usersList) { org.geoserver.geofence.core.model.GSUser remote_user; try { remote_user = geofenceRemoteService.getUserAdminService().getFull(short_usr.getId()); } catch (NotFoundServiceEx e) { if (logger.isErrorEnabled()) { logger.error("Details for profile " + short_usr.getName() + " not found on Server!"); } throw new ApplicationException(e); } GSUserModel local_user = new GSUserModel(); local_user.setId(short_usr.getId()); local_user.setName(remote_user.getName()); local_user.setFullName(remote_user.getFullName()); local_user.setEnabled(remote_user.getEnabled()); local_user.setAdmin(remote_user.isAdmin()); local_user.setEmailAddress(remote_user.getEmailAddress()); local_user.setDateCreation(remote_user.getDateCreation()); local_user.setPassword(remote_user.getPassword()); /*logger.error("TODO: profile refactoring!!!");*/ //org.geoserver.geofence.core.model.UserGroup remote_profile = remote_user.getGroups().iterator().next(); for (org.geoserver.geofence.core.model.UserGroup remote_profile : remote_user.getGroups()) { UserGroupModel local_group = new UserGroupModel(); local_group.setId(remote_profile.getId()); local_group.setName(remote_profile.getName()); local_group.setDateCreation(remote_profile.getDateCreation()); local_group.setEnabled(remote_profile.getEnabled()); local_user.getUserGroups().add(local_group); } usersListDTO.add(local_user); } return new RpcPageLoadResult<GSUserModel>(usersListDTO, offset, t.intValue()); }
From source file:com.klinker.android.twitter.utils.api_helper.TwitterDMPicHelper.java
public Bitmap getDMPicture(String picUrl, Twitter twitter) { try {// w w w . ja va 2 s . com AccessToken token = twitter.getOAuthAccessToken(); String oauth_token = token.getToken(); String oauth_token_secret = token.getTokenSecret(); // generate authorization header String get_or_post = "GET"; String oauth_signature_method = "HMAC-SHA1"; String uuid_string = UUID.randomUUID().toString(); uuid_string = uuid_string.replaceAll("-", ""); String oauth_nonce = uuid_string; // any relatively random alphanumeric string will work here // get the timestamp Calendar tempcal = Calendar.getInstance(); long ts = tempcal.getTimeInMillis();// get current time in milliseconds String oauth_timestamp = (new Long(ts / 1000)).toString(); // then divide by 1000 to get seconds // the parameter string must be in alphabetical order, "text" parameter added at end String parameter_string = "oauth_consumer_key=" + AppSettings.TWITTER_CONSUMER_KEY + "&oauth_nonce=" + oauth_nonce + "&oauth_signature_method=" + oauth_signature_method + "&oauth_timestamp=" + oauth_timestamp + "&oauth_token=" + encode(oauth_token) + "&oauth_version=1.0"; String twitter_endpoint = picUrl; String twitter_endpoint_host = picUrl.substring(0, picUrl.indexOf("1.1")).replace("https://", "") .replace("/", ""); String twitter_endpoint_path = picUrl.replace("ton.twitter.com", "").replace("https://", ""); String signature_base_string = get_or_post + "&" + encode(twitter_endpoint) + "&" + encode(parameter_string); String oauth_signature = computeSignature(signature_base_string, AppSettings.TWITTER_CONSUMER_SECRET + "&" + encode(oauth_token_secret)); Log.v("talon_dm_image", "endpoint_host: " + twitter_endpoint_host); Log.v("talon_dm_image", "endpoint_path: " + twitter_endpoint_path); String authorization_header_string = "OAuth oauth_consumer_key=\"" + AppSettings.TWITTER_CONSUMER_KEY + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_timestamp=\"" + oauth_timestamp + "\",oauth_nonce=\"" + oauth_nonce + "\",oauth_version=\"1.0\",oauth_signature=\"" + encode(oauth_signature) + "\",oauth_token=\"" + encode(oauth_token) + "\""; HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); HttpProtocolParams.setUserAgent(params, "HttpCore/1.1"); HttpProtocolParams.setUseExpectContinue(params, false); HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] { // Required protocol interceptors new RequestContent(), new RequestTargetHost(), // Recommended protocol interceptors new RequestConnControl(), new RequestUserAgent(), new RequestExpectContinue() }); HttpRequestExecutor httpexecutor = new HttpRequestExecutor(); HttpContext context = new BasicHttpContext(null); HttpHost host = new HttpHost(twitter_endpoint_host, 443); DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn); context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, host); SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, null, null); SSLSocketFactory ssf = sslcontext.getSocketFactory(); Socket socket = ssf.createSocket(); socket.connect(new InetSocketAddress(host.getHostName(), host.getPort()), 0); conn.bind(socket, params); BasicHttpEntityEnclosingRequest request2 = new BasicHttpEntityEnclosingRequest("GET", twitter_endpoint_path); request2.setParams(params); request2.addHeader("Authorization", authorization_header_string); httpexecutor.preProcess(request2, httpproc, context); HttpResponse response2 = httpexecutor.execute(request2, conn, context); response2.setParams(params); httpexecutor.postProcess(response2, httpproc, context); StatusLine statusLine = response2.getStatusLine(); int statusCode = statusLine.getStatusCode(); if (statusCode == 200 || statusCode == 302) { HttpEntity entity = response2.getEntity(); byte[] bytes = EntityUtils.toByteArray(entity); Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); return bitmap; } else { Log.v("talon_dm_image", statusCode + ""); } conn.close(); } catch (Exception e) { e.printStackTrace(); } return null; }