public String getFormattedExpiryDate() { if (detailedUser.getExpirationDate() != null) { String dateFormat = messages.get("global.pattern.date"); SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat); return dateFormatter.format(detailedUser.getExpirationDate()); } else { return ""; } }
@SetupRender void setupRender() throws BusinessException { if (getDisplayWidget() && userVo != null && userVo.getDomainIdentifier() != null) { // DomainVo domain = domainFacade.retrieveDomain(userVo.getDomainIdentifier()); globalQuota = documentFacade.isGlobalQuotaActive(userVo); canUpload = userVo.isUpload(); isGuest = userVo.isGuest(); // the formater for the displayed date : we hide the timeline date, and add our date in the // description localisedDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); if (canUpload) { if (!globalQuota) { long userAvailableQuota = documentFacade.getUserAvailableQuota(userVo); long userTotalQuota = documentFacade.getUserTotalQuota(userVo); long userUsedQuota = userTotalQuota - userAvailableQuota; if (userUsedQuota < 0) userUsedQuota = 0; if (userTotalQuota < 1) { usedQuotaPercent = 0; } else { usedQuotaPercent = (int) (100 * userUsedQuota / userTotalQuota); if (usedQuotaPercent > 100) usedQuotaPercent = 100; } FileUtils.Unit preferedUnity = FileUtils.getAppropriateUnitSize(userTotalQuota); usedQuota = FileUtils.getFriendlySize(userUsedQuota, messages, preferedUnity); totalQuota = FileUtils.getFriendlySize(userTotalQuota, messages, preferedUnity); } else { Long usedQuotaB = domainFacade.getUsedSpace(userVo.getDomainIdentifier()); Long globalQuotaB = documentFacade.getGlobalQuota(userVo); FileUtils.Unit preferedUnity = FileUtils.getAppropriateUnitSize(globalQuotaB); usedQuota = FileUtils.getFriendlySize(usedQuotaB, messages, preferedUnity); totalQuota = FileUtils.getFriendlySize(globalQuotaB, messages, preferedUnity); if (usedQuotaB < 1) { usedQuotaPercent = 0; } else { usedQuotaPercent = (int) (100 * usedQuotaB / globalQuotaB); if (usedQuotaPercent > 100) usedQuotaPercent = 100; } } } if (isGuest) { if (userVo.getExpirationDate() != null) expirationDate = localisedDateFormat.format(userVo.getExpirationDate()); else { logger.error("userVo.getExpirationDate() is null !"); expirationDate = "Null"; } } } }