use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class MarketplaceEntry method getRelatedPortlets.
public Set<MarketplaceEntry> getRelatedPortlets() {
if (!generateRelatedPortlets) {
// disabled so we don't have infinite related portlets.
return null;
}
if (relatedEntries == null) {
relatedEntries = new HashSet<MarketplaceEntry>(MarketplacePortletDefinition.QUANTITY_RELATED_PORTLETS_TO_SHOW);
final Set<MarketplacePortletDefinition> randomSamplingRelatedPortlets = pdef.getRandomSamplingRelatedPortlets(user);
for (MarketplacePortletDefinition def : randomSamplingRelatedPortlets) {
relatedEntries.add(new MarketplaceEntry(def, false, user));
}
}
return relatedEntries;
}
use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class PortletMarketplaceController method entryView.
@RenderMapping(params = "action=view")
public String entryView(RenderRequest renderRequest, RenderResponse renderResponse, WebRequest webRequest, PortletRequest portletRequest, Model model) {
IPortletDefinition result = this.portletDefinitionRegistry.getPortletDefinitionByFname(portletRequest.getParameter("fName"));
if (result == null) {
this.setUpInitialView(webRequest, portletRequest, model, null);
return "jsp/Marketplace/portlet/view";
}
final HttpServletRequest servletRequest = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
final IPerson user = personManager.getPerson(servletRequest);
final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
if (!this.marketplaceService.mayBrowsePortlet(principal, result)) {
// TODO: provide an error experience
// currently at least blocks rendering the entry for the portlet the user is not
// authorized to see.
this.setUpInitialView(webRequest, portletRequest, model, null);
return "jsp/Marketplace/portlet/view";
}
MarketplacePortletDefinition mpDefinition = marketplaceService.getOrCreateMarketplacePortletDefinition(result);
IMarketplaceRating tempRatingImpl = marketplaceRatingDAO.getRating(portletRequest.getRemoteUser(), portletDefinitionDao.getPortletDefinitionByFname(result.getFName()));
final MarketplaceEntry marketplaceEntry = new MarketplaceEntry(mpDefinition, user);
marketplaceEntry.setPersonalizer(personalizer);
model.addAttribute("marketplaceRating", tempRatingImpl);
model.addAttribute("reviewMaxLength", IMarketplaceRating.REVIEW_MAX_LENGTH);
model.addAttribute("marketplaceEntry", marketplaceEntry);
model.addAttribute("shortURL", mpDefinition.getShortURL());
// User allowed to favorite this portlet?
final String targetString = PermissionHelper.permissionTargetIdForPortletDefinition(mpDefinition);
final boolean canFavorite = principal.hasPermission(IPermission.PORTAL_SYSTEM, IPermission.PORTLET_FAVORITE_ACTIVITY, targetString);
model.addAttribute("canFavorite", canFavorite);
// Reviews feature enabled?
final PortletPreferences prefs = renderRequest.getPreferences();
final String enableReviewsPreferenceValue = prefs.getValue(ENABLE_REVIEWS_PREFERENCE, ENABLE_REVIEWS_DEFAULT);
model.addAttribute("enableReviews", Boolean.valueOf(enableReviewsPreferenceValue));
return "jsp/Marketplace/portlet/entry";
}
use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class PortletDefinitionBeanTest method testEqualsNull.
@Test
public void testEqualsNull() {
MarketplacePortletDefinition mpd1 = buildMarketplacePortletDefinition(45L, "testName", null, null);
PortletDefinitionBean pdb1 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd1, Locale.ENGLISH, false);
assertFalse(pdb1.equals(null));
}
use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class PortletDefinitionBeanTest method testCompareToSimilar.
@Test
public void testCompareToSimilar() {
String name1 = "testName1";
String name2 = "testName1";
MarketplacePortletDefinition mpd1 = buildMarketplacePortletDefinition(678L, name1, null, null);
MarketplacePortletDefinition mpd2 = buildMarketplacePortletDefinition(678L, name2, null, null);
PortletDefinitionBean pdb1 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd1, Locale.ENGLISH, false);
PortletDefinitionBean pdb2 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd2, Locale.ENGLISH, false);
assertEquals(name1.compareTo(name2), pdb1.compareTo(pdb2));
}
use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.
the class PortletDefinitionBeanTest method testEqualsOtherObject.
@Test
public void testEqualsOtherObject() {
MarketplacePortletDefinition mpd1 = buildMarketplacePortletDefinition(45L, "testName", null, null);
PortletDefinitionBean pdb1 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd1, Locale.ENGLISH, false);
assertFalse(pdb1.equals("id1"));
}
Aggregations