List of usage examples for org.apache.commons.lang StringUtils abbreviate
public static String abbreviate(String str, int maxWidth)
Abbreviates a String using ellipses.
From source file:org.projectforge.web.humanresources.HRPlanningEventsProvider.java
private void putEvent(final HRPlanningEntryDO entry, final DateTime start, final String suffix, final int durationDays, final BigDecimal hours) { if (NumberHelper.isGreaterZero(hours) == false) { return;//from www. j a v a 2 s . c o m } if (log.isDebugEnabled() == true) { log.debug("Date: " + start + ", hours=" + hours + ", duration: " + durationDays); } final Event event = new Event().setAllDay(true); event.setClassName(EVENT_CLASS_NAME); final String id = "" + entry.getId() + "-" + suffix; event.setId(id); event.setStart(start); if (durationDays > 0) { event.setEnd(start.plusDays(durationDays)); } else { event.setEnd(start); } final StringBuffer buf = new StringBuffer(); buf.append(NumberHelper.formatFraction2(hours)).append(parent.getString("calendar.unit.hour")).append(" ") .append(entry.getProjektNameOrStatus()); if (StringUtils.isNotBlank(entry.getDescription()) == true) { buf.append(": "); if (durationDays > 2) { buf.append(StringUtils.abbreviate(entry.getDescription(), 100)); } else if (durationDays > 1) { buf.append(StringUtils.abbreviate(entry.getDescription(), 50)); } else { buf.append(StringUtils.abbreviate(entry.getDescription(), 20)); } } event.setTitle(buf.toString()); events.put(id, event); }
From source file:org.projectforge.web.teamcal.event.MyWicketEvent.java
/** * //from w w w. java 2s . co m * @param title * @param labelValues {{"text without label"}{"value", "label"}, ...} * @return */ public MyWicketEvent setTooltip(final String title, final String[][] labelValues) { this.tooltipTitle = title; final StringBuffer buf = new StringBuffer(); boolean first = true; for (final String[] lv : labelValues) { if (lv == null || lv.length < 1 || lv.length > 2) { if (WebConfiguration.isDevelopmentMode() == true) { throw new IllegalArgumentException("labelValues must be string arrays of length 1 or 2!"); } continue; } String value = lv[0]; if (StringUtils.isBlank(value) == true) { continue; } value = StringUtils.abbreviate(value, 80); final String label = lv.length == 2 ? lv[1] : null; if (first == true) { first = false; } else { buf.append("\n"); } if (label != null) { buf.append(label).append(": ").append(value); } else { buf.append(value); } } if (first == false) { buf.append("\n"); } buf.append(ThreadLocalUserContext.getLocalizedString("timesheet.duration")).append(": ") .append(getDuration()); this.tooltipContent = HtmlHelper.escapeHtml(buf.toString(), true); return this; }
From source file:org.projectforge.web.timesheet.TimesheetEventsProvider.java
public static String getTitle(final TimesheetDO timesheet) { final Kost2DO kost2 = timesheet.getKost2(); final TaskDO task = timesheet.getTask(); if (kost2 == null) { return (task != null && task.getTitle() != null) ? HtmlHelper.escapeXml(task.getTitle()) : ""; }/*from w w w . j a v a 2 s .c o m*/ final StringBuffer buf = new StringBuffer(); final StringBuffer b2 = new StringBuffer(); final ProjektDO projekt = kost2.getProjekt(); if (projekt != null) { // final KundeDO kunde = projekt.getKunde(); // if (kunde != null) { // if (StringUtils.isNotBlank(kunde.getIdentifier()) == true) { // b2.append(kunde.getIdentifier()); // } else { // b2.append(kunde.getName()); // } // b2.append(" - "); // } if (StringUtils.isNotBlank(projekt.getIdentifier()) == true) { b2.append(projekt.getIdentifier()); } else { b2.append(projekt.getName()); } } else { b2.append(kost2.getDescription()); } buf.append(StringUtils.abbreviate(b2.toString(), 30)); return buf.toString(); }
From source file:org.sakaiproject.gradebook.logic.ExternalLogic.java
/** * Check if a name exists already and if so, adjusts it so it is now safe without doing too many checks * @param gradebookId the gradebook unique id (can also be the siteId) * @param name the current assignment name * @return a name which is safe (may be the original if unused) *//*from w ww . j a v a 2 s . c o m*/ protected String makeSafeAssignmentName(String gradebookId, String name) { String safeName = name; if (gradebookService.isAssignmentDefined(gradebookId, name)) { // try to find a safe one safeName = name + "-1"; if (gradebookService.isAssignmentDefined(gradebookId, name)) { // now make a name which we know will be safe safeName = StringUtils.abbreviate(name, 200) + "-" + System.currentTimeMillis(); } } return safeName; }
From source file:org.sakaiproject.iclicker.logic.IClickerLogic.java
/** * Sends a notification to the list of admins, * this is primarily for notifications of failures related to webservices failures * // ww w . j a va 2 s .co m * @param message the notification message to send * @param failure [OPTIONAL] the exception if there was one */ public void sendNotification(String message, Exception failure) { String body = "i>clicker Sakai integrate plugin notification (" + new Date() + ")\n" + message + "\n"; if (failure != null) { // get the stacktrace out StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); failure.printStackTrace(pw); String stacktrace = "Full stacktrace:\n" + failure.getClass().getSimpleName() + ":" + failure.getMessage() + ":\n" + sw.toString(); body = body + "\nFailure:\n" + failure.toString() + "\n\n" + stacktrace; // add to failures record and trim it SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); failures.add(df.format(new Date()) + " :: " + StringUtils.abbreviate(message, 300)); while (failures.size() > 3) { failures.remove(0); } } if (notifyEmails != null && notifyEmails.length > 0) { externalLogic.sendEmails(null, notifyEmails, "i>clicker Sakai integrate plugin notification", body); } else { log.warn("No emails set for sending notifications: logging notification: " + body); } }
From source file:org.sakaiproject.login.tool.SkinnableLogin.java
/** * Helper to log failed login attempts (SAK-22430) * @param credentials the credentials supplied * //from ww w .j a v a 2 s . co m * Note that this could easily be extedned to track login attempts per session and report on it here */ private void logFailedAttempt(LoginCredentials credentials) { if (serverConfigurationService.getBoolean("login.log-failed", true)) { // SAK-23672 Safe login string before log log.warn("Login attempt failed. ID=" + StringUtils.abbreviate(credentials.getIdentifier().replaceAll("(\\r|\\n)", ""), 255) + ", IP Address=" + credentials.getRemoteAddr()); } }
From source file:org.sakaiproject.portlets.PortletIFrame.java
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { response.setContentType("text/html"); // System.out.println("==== doView called ===="); // Grab that underlying request to get a GET parameter ServletRequest req = (ServletRequest) ThreadLocalManager.get(CURRENT_HTTP_REQUEST); String popupDone = req.getParameter("sakai.popup"); PrintWriter out = response.getWriter(); Context context = new VelocityContext(); Placement placement = ToolManager.getCurrentPlacement(); Properties config = getAllProperties(placement); response.setTitle(placement.getTitle()); String source = config.getProperty(SOURCE); if (source == null) source = ""; String height = config.getProperty(HEIGHT); if (height == null) height = "1200px"; String sakaiPropertiesUrlKey = config.getProperty(SAKAI_PROPERTIES_URL_KEY); String hideOptions = config.getProperty(HIDE_OPTIONS); String special = getSpecial(config); // Handle the situation where we are displaying the worksite information if (SPECIAL_WORKSITE.equals(special)) { try {/*from w w w . j av a2 s.c o m*/ // If the site does not have an info url, we show description or title Site s = SiteService.getSite(placement.getContext()); String rv = StringUtils.trimToNull(s.getInfoUrlFull()); if (rv == null) { String siteInfo = StringUtils.trimToNull(s.getDescription()); if (siteInfo == null) { siteInfo = StringUtils.trimToNull(s.getTitle()); } StringBuilder alertMsg = new StringBuilder(); if (siteInfo != null) siteInfo = validator.processFormattedText(siteInfo, alertMsg); context.put("siteInfo", siteInfo); vHelper.doTemplate(vengine, "/vm/info.vm", context, out); return; } } catch (Exception any) { any.printStackTrace(); } } boolean popup = "true".equals(placement.getPlacementConfig().getProperty(POPUP)); boolean maximize = "true".equals(placement.getPlacementConfig().getProperty(MAXIMIZE)); // set the pass_pid parameter String passPidStr = config.getProperty(PASS_PID, "false"); boolean passPid = "true".equalsIgnoreCase(passPidStr); // Set the macro expansion String macroExpansionStr = config.getProperty(MACRO_EXPANSION, "true"); boolean macroExpansion = !("false".equalsIgnoreCase(macroExpansionStr)); // Compute the URL String url = sourceUrl(special, source, placement.getContext(), macroExpansion, passPid, placement.getId(), sakaiPropertiesUrlKey); //System.out.println("special="+special+" source="+source+" pgc="+placement.getContext()+" macroExpansion="+macroExpansion+" passPid="+passPid+" PGID="+placement.getId()+" sakaiPropertiesUrlKey="+sakaiPropertiesUrlKey+" url="+url); if (url != null && url.trim().length() > 0) { url = sanitizeHrefURL(url); if (url == null || !validateURL(url)) { M_log.warn("invalid URL suppressed placement=" + placement.getId() + " site=" + placement.getContext() + " url=" + url); url = "about:blank"; } // Check if the site sets X-Frame options popup = popup || popupXFrame(request, placement, url); Session session = SessionManager.getCurrentSession(); String csrfToken = (String) session.getAttribute(UsageSessionService.SAKAI_CSRF_SESSION_ATTRIBUTE); if (csrfToken != null) context.put("sakai_csrf_token", csrfToken); context.put("tlang", rb); context.put("includeLatestJQuery", PortalUtils.includeLatestJQuery("PortletIFrame")); context.put("validator", validator); context.put("source", url); context.put("height", height); sendAlert(request, context); context.put("popup", Boolean.valueOf(popup)); context.put("popupdone", Boolean.valueOf(popupDone != null)); context.put("maximize", Boolean.valueOf(maximize)); context.put("placement", placement.getId().replaceAll("[^a-zA-Z0-9]", "_")); context.put("loadTime", new Long(xframeLoad)); // SAK-23566 capture the view calendar events if (placement != null && placement.getContext() != null && placement.getId() != null) { EventTrackingService ets = (EventTrackingService) ComponentManager.get(EventTrackingService.class); if (ets != null) { String eventRef = "/web/" + placement.getContext() + "/id/" + placement.getId() + "/url/" + URLEncoder.encode(url, "UTF-8"); eventRef = StringUtils.abbreviate(eventRef, 240); // ensure the ref won't pass 255 chars String etsProperty = (StringUtils .trimToNull(config.getProperty(EVENT_ACCESS_WEB_CONTENT)) != null) ? config.getProperty(EVENT_ACCESS_WEB_CONTENT) : EVENT_ACCESS_WEB_CONTENT; ets.post(ets.newEvent(etsProperty, eventRef, false)); } } // TODO: state.setAttribute(TARGETPAGE_URL,config.getProperty(TARGETPAGE_URL)); // TODO: state.setAttribute(TARGETPAGE_NAME,config.getProperty(TARGETPAGE_NAME)); vHelper.doTemplate(vengine, "/vm/main.vm", context, out); } else { out.println("Not yet configured"); } // TODO: state.setAttribute(EVENT_ACCESS_WEB_CONTENT, config.getProperty(EVENT_ACCESS_WEB_CONTENT)); // TODO: state.setAttribute(EVENT_REVISE_WEB_CONTENT, config.getProperty(EVENT_REVISE_WEB_CONTENT)); // System.out.println("==== doView complete ===="); }
From source file:org.sakaiproject.portlets.PortletIFrame.java
public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException { // System.out.println("==== doEdit called ===="); response.setContentType("text/html"); PrintWriter out = response.getWriter(); String title = getTitleString(request); if (title != null) response.setTitle(title);//from w w w .j av a2 s .c o m Context context = new VelocityContext(); Session session = SessionManager.getCurrentSession(); String csrfToken = (String) session.getAttribute(UsageSessionService.SAKAI_CSRF_SESSION_ATTRIBUTE); if (csrfToken != null) context.put("sakai_csrf_token", csrfToken); context.put("tlang", rb); context.put("includeLatestJQuery", PortalUtils.includeLatestJQuery("PortletIFrame")); context.put("validator", validator); sendAlert(request, context); PortletURL url = response.createActionURL(); context.put("actionUrl", url.toString()); context.put("doCancel", "sakai.cancel"); context.put("doUpdate", "sakai.update"); Placement placement = ToolManager.getCurrentPlacement(); Properties config = getAllProperties(placement); String special = getSpecial(config); context.put("title", validator.escapeHtml(placement.getTitle(), false)); String fa_icon = placement.getPlacementConfig().getProperty("imsti.fa_icon"); if (fa_icon != null) context.put("fa_icon", fa_icon); String source = placement.getPlacementConfig().getProperty(SOURCE); if (source == null) source = ""; if (special == null) context.put("source", source); String height = placement.getPlacementConfig().getProperty(HEIGHT); if (height == null) height = "1200px"; context.put("height", height); ToolConfiguration toolConfig = SiteService.findTool(placement.getId()); if (toolConfig != null) { try { Site site = SiteService.getSite(toolConfig.getSiteId()); String siteId = site.getId(); SitePage page = site.getPage(toolConfig.getPageId()); context.put("siteId", siteId); // if this is the only tool on that page, update the page's title also if ((page.getTools() != null) && (page.getTools().size() == 1)) { context.put("showPopup", Boolean.TRUE); boolean popup = "true".equals(placement.getPlacementConfig().getProperty(POPUP)); context.put("popup", Boolean.valueOf(popup)); boolean maximize = "true".equals(placement.getPlacementConfig().getProperty(MAXIMIZE)); context.put("maximize", Boolean.valueOf(maximize)); context.put("pageTitleEditable", Boolean.TRUE); context.put("page_title", validator.escapeHtml(page.getTitle(), false)); } } catch (Throwable e) { } } if (special == null) { context.put("heading", rb.getString("gen.custom")); } // set the heading based on special else { if (SPECIAL_SITE.equals(special)) { context.put("heading", rb.getString("gen.custom.site")); } else if (SPECIAL_WORKSPACE.equals(special)) { context.put("heading", rb.getString("gen.custom.workspace")); } else if (SPECIAL_WORKSITE.equals(special)) { context.put("heading", rb.getString("gen.custom.worksite")); // for worksite, also include the Site's infourl and description try { Site s = SiteService.getSite(ToolManager.getCurrentPlacement().getContext()); String siteId = s.getId(); String infoUrl = StringUtils.trimToNull(s.getInfoUrl()); if (infoUrl != null) { context.put("info_url", FormattedText.escapeHtmlFormattedTextarea(infoUrl)); } String description = StringUtils.trimToNull(s.getDescription()); if (description != null) { description = FormattedText.escapeHtmlFormattedTextarea(description); context.put("description", description); } } catch (Throwable e) { } } else if (SPECIAL_ANNOTATEDURL.equals(special)) { context.put("heading", rb.getString("gen.custom.annotatedurl")); // for Annotated URL Tool page, also include the description try { String desp = config.getProperty(ANNOTATED_TEXT); context.put("description", desp); } catch (Throwable e) { } } else { context.put("heading", rb.getString("gen.custom")); } } boolean selected = false; for (int i = 0; i < ourPixels.length; i++) { if (height.equals(ourPixels[i])) { selected = true; continue; } } if (!selected) { String[] strings = height.trim().split("px"); context.put("custom_height", strings[0]); height = rb.getString("gen.heisomelse"); } context.put("height", height); // output the max limit context.put("max_length_title", MAX_TITLE_LENGTH); context.put("max_length_info_url", MAX_SITE_INFO_URL_LENGTH); String template = "/vm/edit.vm"; if (SPECIAL_SITE.equals(special)) template = "/vm/edit-site.vm"; if (SPECIAL_WORKSITE.equals(special)) template = "/vm/edit-site.vm"; if (SPECIAL_ANNOTATEDURL.equals(special)) template = "/vm/edit-annotatedurl.vm"; // System.out.println("EDIT TEMP="+template+" special="+special); // capture the revise events if (placement != null && placement.getContext() != null && placement.getId() != null) { EventTrackingService ets = (EventTrackingService) ComponentManager.get(EventTrackingService.class); if (ets != null) { String eventRef = "/web/" + placement.getContext() + "/id/" + placement.getId() + "/url/" + URLEncoder.encode(source, "UTF-8"); eventRef = StringUtils.abbreviate(eventRef, 240); // ensure the ref won't pass 255 chars String etsProperty = (StringUtils.trimToNull(config.getProperty(EVENT_REVISE_WEB_CONTENT)) != null) ? config.getProperty(EVENT_REVISE_WEB_CONTENT) : EVENT_REVISE_WEB_CONTENT; ets.post(ets.newEvent(etsProperty, eventRef, false)); } } vHelper.doTemplate(vengine, template, context, out); // System.out.println("==== doEdit done ===="); }
From source file:org.sakaiproject.profile2.tool.pages.MySearch.java
public MySearch() { log.debug("MySearch()"); disableLink(searchLink);//w w w. j av a2 s. co m //check for current search cookie CookieUtils utils = new CookieUtils(); searchCookie = utils.getCookie(ProfileConstants.SEARCH_COOKIE); //setup model to store the actions in the modal windows final FriendAction friendActionModel = new FriendAction(); //get current user info final String currentUserUuid = sakaiProxy.getCurrentUserId(); final String currentUserType = sakaiProxy.getUserType(currentUserUuid); /* * Combined search form */ //heading Label searchHeading = new Label("searchHeading", new ResourceModel("heading.search")); add(searchHeading); //setup form final StringModel searchStringModel = new StringModel(); Form<StringModel> searchForm = new Form<StringModel>("searchForm", new Model<StringModel>(searchStringModel)); searchForm.setOutputMarkupId(true); //search field searchForm.add(new Label("searchLabel", new ResourceModel("text.search.terms.label"))); searchField = new TextField<String>("searchField", new PropertyModel<String>(searchStringModel, "string")); searchField.setRequired(true); searchField.setMarkupId("searchinput"); searchField.setOutputMarkupId(true); searchForm.add(searchField); searchForm.add(new IconWithClueTip("searchToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.search.terms.tooltip"))); //by name or by interest radio group searchTypeRadioGroup = new RadioGroup<String>("searchTypeRadioGroup"); // so we can repaint after clicking on search history links searchTypeRadioGroup.setOutputMarkupId(true); searchTypeRadioGroup.setRenderBodyOnly(false); Radio<String> searchTypeRadioName = new Radio<String>("searchTypeName", new Model<String>(ProfileConstants.SEARCH_TYPE_NAME)); searchTypeRadioName.setMarkupId("searchtypenameinput"); searchTypeRadioName.setOutputMarkupId(true); searchTypeRadioName .add(new AttributeModifier("title", true, new ResourceModel("text.search.byname.tooltip"))); searchTypeRadioGroup.add(searchTypeRadioName); Radio<String> searchTypeRadioInterest = new Radio<String>("searchTypeInterest", new Model<String>(ProfileConstants.SEARCH_TYPE_INTEREST)); searchTypeRadioInterest.setMarkupId("searchtypeinterestinput"); searchTypeRadioInterest.setOutputMarkupId(true); searchTypeRadioInterest .add(new AttributeModifier("title", true, new ResourceModel("text.search.byinterest.tooltip"))); searchTypeRadioGroup.add(searchTypeRadioInterest); searchTypeRadioGroup.add(new Label("searchTypeNameLabel", new ResourceModel("text.search.byname.label"))); searchTypeRadioGroup .add(new Label("searchTypeInterestLabel", new ResourceModel("text.search.byinterest.label"))); searchForm.add(searchTypeRadioGroup); searchForm.add(new Label("connectionsLabel", new ResourceModel("text.search.include.connections"))); // model is true (include connections by default) connectionsCheckBox = new CheckBox("connectionsCheckBox", new Model<Boolean>(true)); connectionsCheckBox.setMarkupId("includeconnectionsinput"); connectionsCheckBox.setOutputMarkupId(true); //hide if connections disabled globally connectionsCheckBox.setVisible(sakaiProxy.isConnectionsEnabledGlobally()); searchForm.add(connectionsCheckBox); final List<Site> worksites = sakaiProxy.getUserSites(); final boolean hasWorksites = worksites.size() > 0; searchForm.add(new Label("worksiteLabel", new ResourceModel("text.search.include.worksite"))); // model is false (include all worksites by default) worksiteCheckBox = new CheckBox("worksiteCheckBox", new Model<Boolean>(false)); worksiteCheckBox.setMarkupId("limittositeinput"); worksiteCheckBox.setOutputMarkupId(true); worksiteCheckBox.setEnabled(hasWorksites); searchForm.add(worksiteCheckBox); final IModel<String> defaultWorksiteIdModel; if (hasWorksites) { defaultWorksiteIdModel = new Model<String>(worksites.get(0).getId()); } else { defaultWorksiteIdModel = new ResourceModel("text.search.no.worksite"); } final LinkedHashMap<String, String> worksiteMap = new LinkedHashMap<String, String>(); if (hasWorksites) { for (Site worksite : worksites) { worksiteMap.put(worksite.getId(), worksite.getTitle()); } } else { worksiteMap.put(defaultWorksiteIdModel.getObject(), defaultWorksiteIdModel.getObject()); } IModel worksitesModel = new Model() { public ArrayList<String> getObject() { return new ArrayList<String>(worksiteMap.keySet()); } }; worksiteChoice = new DropDownChoice("worksiteChoice", defaultWorksiteIdModel, worksitesModel, new HashMapChoiceRenderer(worksiteMap)); worksiteChoice.setMarkupId("worksiteselect"); worksiteChoice.setOutputMarkupId(true); worksiteChoice.setNullValid(false); worksiteChoice.setEnabled(hasWorksites); searchForm.add(worksiteChoice); /* * * RESULTS * */ //search results label/container numSearchResultsContainer = new WebMarkupContainer("numSearchResultsContainer"); numSearchResultsContainer.setOutputMarkupPlaceholderTag(true); numSearchResults = new Label("numSearchResults"); numSearchResults.setOutputMarkupId(true); numSearchResults.setEscapeModelStrings(false); numSearchResultsContainer.add(numSearchResults); //clear results button Form<Void> clearResultsForm = new Form<Void>("clearResults"); clearResultsForm.setOutputMarkupPlaceholderTag(true); clearButton = new AjaxButton("clearButton", clearResultsForm) { private static final long serialVersionUID = 1L; protected void onSubmit(AjaxRequestTarget target, Form<?> form) { // clear cookie if present if (null != searchCookie) { CookieUtils utils = new CookieUtils(); utils.remove(ProfileConstants.SEARCH_COOKIE); } //clear the fields, hide self, then repaint searchField.clearInput(); searchField.updateModel(); numSearchResultsContainer.setVisible(false); resultsContainer.setVisible(false); clearButton.setVisible(false); target.add(searchField); target.add(numSearchResultsContainer); target.add(resultsContainer); target.add(this); } }; clearButton.setOutputMarkupPlaceholderTag(true); if (null == searchCookie) { clearButton.setVisible(false); //invisible until we have something to clear } clearButton.setModel(new ResourceModel("button.search.clear")); clearResultsForm.add(clearButton); numSearchResultsContainer.add(clearResultsForm); add(numSearchResultsContainer); // model to wrap search results LoadableDetachableModel<List<Person>> resultsModel = new LoadableDetachableModel<List<Person>>() { private static final long serialVersionUID = 1L; protected List<Person> load() { return results; } }; //container which wraps list resultsContainer = new WebMarkupContainer("searchResultsContainer"); resultsContainer.setOutputMarkupPlaceholderTag(true); if (null == searchCookie) { resultsContainer.setVisible(false); //hide initially } //connection window final ModalWindow connectionWindow = new ModalWindow("connectionWindow"); //search results final PageableListView<Person> resultsListView = new PageableListView<Person>("searchResults", resultsModel, sakaiProxy.getMaxSearchResultsPerPage()) { private static final long serialVersionUID = 1L; protected void populateItem(final ListItem<Person> item) { Person person = (Person) item.getModelObject(); //get basic values final String userUuid = person.getUuid(); final String displayName = person.getDisplayName(); final String userType = person.getType(); //get connection status int connectionStatus = connectionsLogic.getConnectionStatus(currentUserUuid, userUuid); boolean friend = (connectionStatus == ProfileConstants.CONNECTION_CONFIRMED) ? true : false; //image wrapper, links to profile Link<String> friendItem = new Link<String>("searchResultPhotoWrap") { private static final long serialVersionUID = 1L; public void onClick() { setResponsePage(new ViewProfile(userUuid)); } }; //image ProfileImage searchResultPhoto = new ProfileImage("searchResultPhoto", new Model<String>(userUuid)); searchResultPhoto.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL); friendItem.add(searchResultPhoto); item.add(friendItem); //name and link to profile (if allowed or no link) Link<String> profileLink = new Link<String>("searchResultProfileLink", new Model<String>(userUuid)) { private static final long serialVersionUID = 1L; public void onClick() { //if user found themself, go to own profile, else show other profile if (userUuid.equals(currentUserUuid)) { setResponsePage(new MyProfile()); } else { //gets userUuid of other user from the link's model setResponsePage(new ViewProfile((String) getModelObject())); } } }; profileLink.add(new Label("searchResultName", displayName)); item.add(profileLink); //status component ProfileStatusRenderer status = new ProfileStatusRenderer("searchResultStatus", person, "search-result-status-msg", "search-result-status-date") { @Override public boolean isVisible() { return sakaiProxy.isProfileStatusEnabled(); } }; status.setOutputMarkupId(true); item.add(status); /* ACTIONS */ boolean isFriendsListVisible = privacyLogic.isActionAllowed(userUuid, currentUserUuid, PrivacyType.PRIVACY_OPTION_MYFRIENDS); boolean isConnectionAllowed = sakaiProxy.isConnectionAllowedBetweenUserTypes(userType, currentUserType); //ADD CONNECTION LINK final WebMarkupContainer c1 = new WebMarkupContainer("connectionContainer"); c1.setOutputMarkupId(true); if (!isConnectionAllowed && !sakaiProxy.isConnectionsEnabledGlobally()) { //add blank components - TODO turn this into an EmptyLink component AjaxLink<Void> emptyLink = new AjaxLink<Void>("connectionLink") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { } }; emptyLink.add(new Label("connectionLabel")); c1.add(emptyLink); c1.setVisible(false); } else { //render the link final Label connectionLabel = new Label("connectionLabel"); connectionLabel.setOutputMarkupId(true); final AjaxLink<String> connectionLink = new AjaxLink<String>("connectionLink", new Model<String>(userUuid)) { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { //get this item, reinit some values and set content for modal final String userUuid = (String) getModelObject(); connectionWindow.setContent(new AddFriend(connectionWindow.getContentId(), connectionWindow, friendActionModel, currentUserUuid, userUuid)); // connection modal window handler connectionWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { if (friendActionModel.isRequested()) { connectionLabel.setDefaultModel(new ResourceModel("text.friend.requested")); add(new AttributeModifier("class", true, new Model<String>("instruction icon connection-request"))); setEnabled(false); target.add(c1); } } }); //in preparation for the window being closed, update the text. this will only //be put into effect if its a successful model update from the window close //connectionLabel.setModel(new ResourceModel("text.friend.requested")); //this.add(new AttributeModifier("class", true, new Model("instruction"))); //this.setEnabled(false); //friendActionModel.setUpdateThisComponentOnSuccess(this); connectionWindow.show(target); target.appendJavaScript("fixWindowVertical();"); } }; connectionLink.add(connectionLabel); //setup 'add connection' link if (StringUtils.equals(userUuid, currentUserUuid)) { connectionLabel.setDefaultModel(new ResourceModel("text.friend.self")); connectionLink.add(new AttributeModifier("class", true, new Model<String>("instruction icon profile"))); connectionLink.setEnabled(false); } else if (friend) { connectionLabel.setDefaultModel(new ResourceModel("text.friend.confirmed")); connectionLink.add(new AttributeModifier("class", true, new Model<String>("instruction icon connection-confirmed"))); connectionLink.setEnabled(false); } else if (connectionStatus == ProfileConstants.CONNECTION_REQUESTED) { connectionLabel.setDefaultModel(new ResourceModel("text.friend.requested")); connectionLink.add(new AttributeModifier("class", true, new Model<String>("instruction icon connection-request"))); connectionLink.setEnabled(false); } else if (connectionStatus == ProfileConstants.CONNECTION_INCOMING) { connectionLabel.setDefaultModel(new ResourceModel("text.friend.pending")); connectionLink.add(new AttributeModifier("class", true, new Model<String>("instruction icon connection-request"))); connectionLink.setEnabled(false); } else { connectionLabel.setDefaultModel(new ResourceModel("link.friend.add")); } connectionLink.setOutputMarkupId(true); c1.add(connectionLink); } item.add(c1); //VIEW FRIENDS LINK WebMarkupContainer c2 = new WebMarkupContainer("viewFriendsContainer"); c2.setOutputMarkupId(true); final AjaxLink<String> viewFriendsLink = new AjaxLink<String>("viewFriendsLink") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { //if user found themself, go to MyFriends, else, ViewFriends if (userUuid.equals(currentUserUuid)) { setResponsePage(new MyFriends()); } else { setResponsePage(new ViewFriends(userUuid)); } } }; final Label viewFriendsLabel = new Label("viewFriendsLabel", new ResourceModel("link.view.friends")); viewFriendsLink.add(viewFriendsLabel); //hide if not allowed if (!isFriendsListVisible && !sakaiProxy.isConnectionsEnabledGlobally()) { viewFriendsLink.setEnabled(false); c2.setVisible(false); } viewFriendsLink.setOutputMarkupId(true); c2.add(viewFriendsLink); item.add(c2); WebMarkupContainer c3 = new WebMarkupContainer("emailContainer"); c3.setOutputMarkupId(true); ExternalLink emailLink = new ExternalLink("emailLink", "mailto:" + person.getProfile().getEmail(), new ResourceModel("profile.email").getObject()); c3.add(emailLink); if (StringUtils.isBlank(person.getProfile().getEmail()) || false == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_CONTACTINFO)) { c3.setVisible(false); } item.add(c3); WebMarkupContainer c4 = new WebMarkupContainer("websiteContainer"); c4.setOutputMarkupId(true); // TODO home page, university profile URL or academic/research URL (see PRFL-35) ExternalLink websiteLink = new ExternalLink("websiteLink", person.getProfile().getHomepage(), new ResourceModel("profile.homepage").getObject()).setPopupSettings(new PopupSettings()); c4.add(websiteLink); if (StringUtils.isBlank(person.getProfile().getHomepage()) || false == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_CONTACTINFO)) { c4.setVisible(false); } item.add(c4); // TODO personal, academic or business (see PRFL-35) if (true == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_BASICINFO)) { item.add(new Label("searchResultSummary", StringUtils .abbreviate(ProfileUtils.stripHtml(person.getProfile().getPersonalSummary()), 200))); } else { item.add(new Label("searchResultSummary", "")); } } }; resultsListView.add(new MySearchCookieBehavior(resultsListView)); resultsContainer.add(resultsListView); final PagingNavigator searchResultsNavigator = new PagingNavigator("searchResultsNavigator", resultsListView); searchResultsNavigator.setOutputMarkupId(true); searchResultsNavigator.setVisible(false); resultsContainer.add(searchResultsNavigator); add(connectionWindow); //add results container add(resultsContainer); /* * SEARCH HISTORY */ final WebMarkupContainer searchHistoryContainer = new WebMarkupContainer("searchHistoryContainer"); searchHistoryContainer.setOutputMarkupPlaceholderTag(true); Label searchHistoryLabel = new Label("searchHistoryLabel", new ResourceModel("text.search.history")); searchHistoryContainer.add(searchHistoryLabel); IModel<List<ProfileSearchTerm>> searchHistoryModel = new LoadableDetachableModel<List<ProfileSearchTerm>>() { private static final long serialVersionUID = 1L; @Override protected List<ProfileSearchTerm> load() { List<ProfileSearchTerm> searchHistory = searchLogic.getSearchHistory(currentUserUuid); if (null == searchHistory) { return new ArrayList<ProfileSearchTerm>(); } else { return searchHistory; } } }; ListView<ProfileSearchTerm> searchHistoryList = new ListView<ProfileSearchTerm>("searchHistoryList", searchHistoryModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<ProfileSearchTerm> item) { AjaxLink<String> link = new AjaxLink<String>("previousSearchLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (null != target) { // post view event sakaiProxy.postEvent(ProfileConstants.EVENT_SEARCH_BY_NAME, "/profile/" + currentUserUuid, false); ProfileSearchTerm searchTerm = item.getModelObject(); // this will update its position in list searchLogic.addSearchTermToHistory(currentUserUuid, searchTerm); searchStringModel.setString(searchTerm.getSearchTerm()); searchTypeRadioGroup.setModel(new Model<String>(searchTerm.getSearchType())); connectionsCheckBox.setModel(new Model<Boolean>(searchTerm.isConnections())); if (null == searchTerm.getWorksite()) { worksiteCheckBox.setModel(new Model<Boolean>(false)); worksiteChoice.setModel(new Model(defaultWorksiteIdModel)); } else { worksiteCheckBox.setModel(new Model<Boolean>(true)); worksiteChoice.setModel(new Model(searchTerm.getWorksite())); } setSearchCookie(searchTerm.getSearchType(), searchTerm.getSearchTerm(), searchTerm.getSearchPageNumber(), searchTerm.isConnections(), searchTerm.getWorksite()); if (ProfileConstants.SEARCH_TYPE_NAME.equals(searchTerm.getSearchType())) { searchByName(resultsListView, searchResultsNavigator, searchHistoryContainer, target, searchTerm.getSearchTerm(), searchTerm.isConnections(), searchTerm.getWorksite()); } else if (ProfileConstants.SEARCH_TYPE_INTEREST.equals(searchTerm.getSearchType())) { searchByInterest(resultsListView, searchResultsNavigator, searchHistoryContainer, target, searchTerm.getSearchTerm(), searchTerm.isConnections(), searchTerm.getWorksite()); } } } }; link.add(new Label("previousSearchLabel", item.getModelObject().getSearchTerm())); item.add(link); } }; searchHistoryContainer.add(searchHistoryList); add(searchHistoryContainer); if (null == searchLogic.getSearchHistory(currentUserUuid)) { searchHistoryContainer.setVisible(false); } //clear button Form<Void> clearHistoryForm = new Form<Void>("clearHistory"); clearHistoryForm.setOutputMarkupPlaceholderTag(true); clearHistoryButton = new AjaxButton("clearHistoryButton", clearHistoryForm) { private static final long serialVersionUID = 1L; protected void onSubmit(AjaxRequestTarget target, Form<?> form) { searchLogic.clearSearchHistory(currentUserUuid); //clear the fields, hide self, then repaint searchField.clearInput(); searchField.updateModel(); searchHistoryContainer.setVisible(false); clearHistoryButton.setVisible(false); target.add(searchField); target.add(searchHistoryContainer); target.add(this); } }; clearHistoryButton.setOutputMarkupPlaceholderTag(true); if (null == searchLogic.getSearchHistory(currentUserUuid)) { clearHistoryButton.setVisible(false); //invisible until we have something to clear } clearHistoryButton.setModel(new ResourceModel("button.search.history.clear")); clearHistoryForm.add(clearHistoryButton); searchHistoryContainer.add(clearHistoryForm); /* * Combined search submit */ IndicatingAjaxButton searchSubmitButton = new IndicatingAjaxButton("searchSubmit", searchForm) { private static final long serialVersionUID = 1L; protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (target != null) { //get the model and text entered StringModel model = (StringModel) form.getModelObject(); //PRFL-811 - dont strip this down, we will lose i18n chars. //And there is no XSS risk since its only for the current user. String searchText = model.getString(); //get search type String searchType = searchTypeRadioGroup.getModelObject(); log.debug("MySearch search by " + searchType + ": " + searchText); if (StringUtils.isBlank(searchText)) { return; } // save search terms ProfileSearchTerm searchTerm = new ProfileSearchTerm(); searchTerm.setUserUuid(currentUserUuid); searchTerm.setSearchType(searchType); searchTerm.setSearchTerm(searchText); searchTerm.setSearchPageNumber(0); searchTerm.setSearchDate(new Date()); searchTerm.setConnections(connectionsCheckBox.getModelObject()); // set to worksite or empty depending on value of checkbox searchTerm.setWorksite( (worksiteCheckBox.getModelObject() == true) ? worksiteChoice.getValue() : null); searchLogic.addSearchTermToHistory(currentUserUuid, searchTerm); // set cookie for current search (page 0 when submitting new search) setSearchCookie(searchTerm.getSearchType(), URLEncoder.encode(searchTerm.getSearchTerm()), searchTerm.getSearchPageNumber(), searchTerm.isConnections(), searchTerm.getWorksite()); if (ProfileConstants.SEARCH_TYPE_NAME.equals(searchType)) { searchByName(resultsListView, searchResultsNavigator, searchHistoryContainer, target, searchTerm.getSearchTerm(), searchTerm.isConnections(), searchTerm.getWorksite()); //post view event sakaiProxy.postEvent(ProfileConstants.EVENT_SEARCH_BY_NAME, "/profile/" + currentUserUuid, false); } else if (ProfileConstants.SEARCH_TYPE_INTEREST.equals(searchType)) { searchByInterest(resultsListView, searchResultsNavigator, searchHistoryContainer, target, searchTerm.getSearchTerm(), searchTerm.isConnections(), searchTerm.getWorksite()); //post view event sakaiProxy.postEvent(ProfileConstants.EVENT_SEARCH_BY_INTEREST, "/profile/" + currentUserUuid, false); } } } }; searchSubmitButton.setModel(new ResourceModel("button.search.generic")); searchForm.add(searchSubmitButton); add(searchForm); if (null != searchCookie) { String searchString = getCookieSearchString(searchCookie.getValue()); searchStringModel.setString(searchString); Boolean filterConnections = getCookieFilterConnections(searchCookie.getValue()); String worksiteId = getCookieFilterWorksite(searchCookie.getValue()); Boolean filterWorksite = (null == worksiteId) ? false : true; connectionsCheckBox.setModel(new Model<Boolean>(filterConnections)); worksiteCheckBox.setModel(new Model<Boolean>(filterWorksite)); worksiteChoice.setModel(new Model((null == worksiteId) ? defaultWorksiteIdModel : worksiteId)); if (searchCookie.getValue().startsWith(ProfileConstants.SEARCH_TYPE_NAME)) { searchTypeRadioGroup.setModel(new Model<String>(ProfileConstants.SEARCH_TYPE_NAME)); searchByName(resultsListView, searchResultsNavigator, searchHistoryContainer, null, searchString, filterConnections, worksiteId); } else if (searchCookie.getValue().startsWith(ProfileConstants.SEARCH_TYPE_INTEREST)) { searchTypeRadioGroup.setModel(new Model<String>(ProfileConstants.SEARCH_TYPE_INTEREST)); searchByInterest(resultsListView, searchResultsNavigator, searchHistoryContainer, null, searchString, filterConnections, worksiteId); } } else { // default search type is name searchTypeRadioGroup.setModel(new Model<String>(ProfileConstants.SEARCH_TYPE_NAME)); } }
From source file:org.sakaiproject.profile2.tool.pages.panels.ConfirmedFriends.java
public ConfirmedFriends(final String id, final String userUuid) { super(id);/*from www. j a va 2 s . c om*/ log.debug("ConfirmedFriends()"); //setup model to store the actions in the modal windows final FriendAction friendActionModel = new FriendAction(); //get info for user viewing this page (will be the same if user is viewing own list, different if viewing someone else's) final String currentUserUuid = sakaiProxy.getCurrentUserId(); //User currentUser = sakaiProxy.getUserQuietly(currentUserUuid); //final String currentUserType = currentUser.getType(); //to be used for checking if connection between users is allowed, when this is added //if viewing own friends, you can manage them. if (userUuid.equals(currentUserUuid)) { ownList = true; } //get our list of confirmed friends as an IDataProvider ConfirmedFriendsDataProvider provider = new ConfirmedFriendsDataProvider(userUuid); //init number of friends numConfirmedFriends = (int) provider.size(); //model so we can update the number of friends IModel<Integer> numConfirmedFriendsModel = new Model<Integer>() { private static final long serialVersionUID = 1L; public Integer getObject() { return numConfirmedFriends; } }; //heading final WebMarkupContainer confirmedFriendsHeading = new WebMarkupContainer("confirmedFriendsHeading"); Label confirmedFriendsLabel = new Label("confirmedFriendsLabel"); //if viewing own list, "my friends", else, "their name's friends" if (ownList) { confirmedFriendsLabel.setDefaultModel(new ResourceModel("heading.friends.my")); } else { String displayName = sakaiProxy.getUserDisplayName(userUuid); confirmedFriendsLabel.setDefaultModel( new StringResourceModel("heading.friends.view", null, new Object[] { displayName })); } confirmedFriendsHeading.add(confirmedFriendsLabel); confirmedFriendsHeading.add(new Label("confirmedFriendsNumber", numConfirmedFriendsModel)); confirmedFriendsHeading.setOutputMarkupId(true); add(confirmedFriendsHeading); // actions Form<Void> confirmedFriendsButtonForm = new Form<Void>("confirmedFriendsButtonForm"); add(confirmedFriendsButtonForm); //create worksite panel final CreateWorksitePanel createWorksitePanel = new CreateWorksitePanel("createWorksitePanel", connectionsLogic.getConnectionsForUser(userUuid)); //create placeholder and set invisible initially createWorksitePanel.setOutputMarkupPlaceholderTag(true); createWorksitePanel.setVisible(false); confirmedFriendsButtonForm.add(createWorksitePanel); final AjaxButton createWorksiteButton = new AjaxButton("createWorksiteButton", confirmedFriendsButtonForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { createWorksitePanel.setVisible(true); target.add(createWorksitePanel); target.appendJavaScript("fixWindowVertical();"); } }; createWorksiteButton.setModel(new ResourceModel("link.worksite.create")); createWorksiteButton .add(new AttributeModifier("title", true, new ResourceModel("link.title.worksite.create"))); createWorksiteButton.setVisible(sakaiProxy.isUserAllowedAddSite(userUuid)); confirmedFriendsButtonForm.add(createWorksiteButton); //search for connections AjaxButton searchConnectionsButton = new AjaxButton("searchConnectionsButton", confirmedFriendsButtonForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { setResponsePage(new MySearch()); } }; searchConnectionsButton.setModel(new ResourceModel("link.my.friends.search")); confirmedFriendsButtonForm.add(searchConnectionsButton); //container which wraps list final WebMarkupContainer confirmedFriendsContainer = new WebMarkupContainer("confirmedFriendsContainer"); confirmedFriendsContainer.setOutputMarkupId(true); //connection window final ModalWindow connectionWindow = new ModalWindow("connectionWindow"); //results DataView<Person> confirmedFriendsDataView = new DataView<Person>("connections", provider) { private static final long serialVersionUID = 1L; protected void populateItem(final Item<Person> item) { Person person = (Person) item.getDefaultModelObject(); final String personUuid = person.getUuid(); //setup values String displayName = person.getDisplayName(); boolean friend; //get friend status if (ownList) { friend = true; //viewing own page of conenctions, must be friend! } else { friend = connectionsLogic.isUserXFriendOfUserY(userUuid, personUuid); //other person viewing, check if they are friends } //get other objects ProfilePrivacy privacy = person.getPrivacy(); ProfilePreferences prefs = person.getPreferences(); //image wrapper, links to profile Link<String> friendItem = new Link<String>("connectionPhotoWrap", new Model<String>(personUuid)) { private static final long serialVersionUID = 1L; public void onClick() { setResponsePage(new ViewProfile(getModelObject())); } }; //image ProfileImage connectionPhoto = new ProfileImage("connectionPhoto", new Model<String>(personUuid)); connectionPhoto.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL); friendItem.add(connectionPhoto); item.add(friendItem); //name and link to profile Link<String> profileLink = new Link<String>("connectionLink", new Model<String>(personUuid)) { private static final long serialVersionUID = 1L; public void onClick() { setResponsePage(new ViewProfile(getModelObject())); } }; profileLink.add(new Label("connectionName", displayName)); item.add(profileLink); //status component ProfileStatusRenderer status = new ProfileStatusRenderer("connectionStatus", person, "connection-status-msg", "connection-status-date"); status.setOutputMarkupId(true); item.add(status); /* ACTIONS */ WebMarkupContainer c1 = new WebMarkupContainer("removeConnectionContainer"); c1.setOutputMarkupId(true); //REMOVE FRIEND LINK AND WINDOW final AjaxLink<String> removeConnectionLink = new AjaxLink<String>("removeConnectionLink", new Model<String>(personUuid)) { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { //get this item, and set content for modalwindow String friendUuid = getModelObject(); connectionWindow.setContent(new RemoveFriend(connectionWindow.getContentId(), connectionWindow, friendActionModel, userUuid, friendUuid)); //modalwindow handler connectionWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { if (friendActionModel.isRemoved()) { //decrement number of friends numConfirmedFriends--; //remove friend item from display target.appendJavaScript("$('#" + item.getMarkupId() + "').slideUp();"); //update label target.add(confirmedFriendsHeading); //if none left, hide whole thing if (numConfirmedFriends == 0) { target.appendJavaScript( "$('#" + confirmedFriendsContainer.getMarkupId() + "').fadeOut();"); } } } }); connectionWindow.show(target); target.appendJavaScript("fixWindowVertical();"); } }; //ContextImage removeConnectionIcon = new ContextImage("removeConnectionIcon",new Model<String>(ProfileConstants.DELETE_IMG)); removeConnectionLink.add(new AttributeModifier("alt", true, new StringResourceModel( "accessibility.connection.remove", null, new Object[] { displayName }))); //removeConnectionLink.add(removeConnectionIcon); removeConnectionLink .add(new AttributeModifier("title", true, new ResourceModel("link.title.removefriend"))); removeConnectionLink .add(new Label("removeConnectionLabel", new ResourceModel("button.friend.remove")) .setOutputMarkupId(true)); c1.add(removeConnectionLink); item.add(c1); //can only delete if own connections if (!ownList) { removeConnectionLink.setEnabled(false); removeConnectionLink.setVisible(false); } WebMarkupContainer c2 = new WebMarkupContainer("viewFriendsContainer"); c2.setOutputMarkupId(true); final AjaxLink<String> viewFriendsLink = new AjaxLink<String>("viewFriendsLink") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { // always ViewFriends because a user isn't connected to himself setResponsePage(new ViewFriends(personUuid)); } }; final Label viewFriendsLabel = new Label("viewFriendsLabel", new ResourceModel("link.view.friends")); viewFriendsLink.add(viewFriendsLabel); //hide if not allowed if (!privacyLogic.isActionAllowed(userUuid, currentUserUuid, PrivacyType.PRIVACY_OPTION_MYFRIENDS)) { viewFriendsLink.setEnabled(false); c2.setVisible(false); } viewFriendsLink.setOutputMarkupId(true); c2.add(viewFriendsLink); item.add(c2); WebMarkupContainer c3 = new WebMarkupContainer("emailContainer"); c3.setOutputMarkupId(true); ExternalLink emailLink = new ExternalLink("emailLink", "mailto:" + person.getProfile().getEmail(), new ResourceModel("profile.email").getObject()); c3.add(emailLink); if (StringUtils.isBlank(person.getProfile().getEmail()) || false == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_CONTACTINFO)) { c3.setVisible(false); } item.add(c3); WebMarkupContainer c4 = new WebMarkupContainer("websiteContainer"); c4.setOutputMarkupId(true); // TODO home page, university profile URL or academic/research URL (see PRFL-35) ExternalLink websiteLink = new ExternalLink("websiteLink", person.getProfile().getHomepage(), new ResourceModel("profile.homepage").getObject()).setPopupSettings(new PopupSettings()); c4.add(websiteLink); if (StringUtils.isBlank(person.getProfile().getHomepage()) || false == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_CONTACTINFO)) { c4.setVisible(false); } item.add(c4); // basic info can be set to 'only me' so still need to check if (true == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_BASICINFO)) { item.add(new Label("connectionSummary", StringUtils .abbreviate(ProfileUtils.stripHtml(person.getProfile().getPersonalSummary()), 200))); } else { item.add(new Label("connectionSummary", "")); } item.setOutputMarkupId(true); } }; confirmedFriendsDataView.setOutputMarkupId(true); confirmedFriendsDataView.setItemsPerPage(ProfileConstants.MAX_CONNECTIONS_PER_PAGE); confirmedFriendsContainer.add(confirmedFriendsDataView); //add results container add(confirmedFriendsContainer); //add window add(connectionWindow); //add pager AjaxPagingNavigator pager = new AjaxPagingNavigator("navigator", confirmedFriendsDataView); add(pager); //initially, if no friends, hide container and pager if (numConfirmedFriends == 0) { confirmedFriendsContainer.setVisible(false); pager.setVisible(false); } //also, if num less than num required for pager, hide it if (numConfirmedFriends <= ProfileConstants.MAX_CONNECTIONS_PER_PAGE) { pager.setVisible(false); } }