Search in sources :

Example 1 with MarketplacePortletDefinition

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;
}
Also used : MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition)

Example 2 with MarketplacePortletDefinition

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";
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) IMarketplaceRating(org.apereo.portal.portlet.marketplace.IMarketplaceRating) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PortletPreferences(javax.portlet.PortletPreferences) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 3 with MarketplacePortletDefinition

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));
}
Also used : MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) Test(org.junit.Test)

Example 4 with MarketplacePortletDefinition

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));
}
Also used : MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) Test(org.junit.Test)

Example 5 with MarketplacePortletDefinition

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"));
}
Also used : MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) Test(org.junit.Test)

Aggregations

MarketplacePortletDefinition (org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition)16 PortletDefinitionBean (org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean)12 Test (org.junit.Test)10 IPortletDefinitionParameter (org.apereo.portal.portlet.om.IPortletDefinitionParameter)4 ArrayList (java.util.ArrayList)3 IPerson (org.apereo.portal.security.IPerson)3 HashMap (java.util.HashMap)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)2 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)2 MarketplaceEntry (org.apereo.portal.rest.layout.MarketplaceEntry)2 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)2 List (java.util.List)1 Locale (java.util.Locale)1 PortletPreferences (javax.portlet.PortletPreferences)1 Header (org.apache.http.Header)1 BasicHeader (org.apache.http.message.BasicHeader)1 IMarketplaceRating (org.apereo.portal.portlet.marketplace.IMarketplaceRating)1 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)1 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)1