Search in sources :

Example 11 with MarketplacePortletDefinition

use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.

the class ChannelListController method preparePortletDefinitionBean.

private PortletDefinitionBean preparePortletDefinitionBean(WebRequest req, IPortletDefinition portlet, Locale locale, Boolean favorite) {
    MarketplacePortletDefinition mktpd = marketplaceService.getOrCreateMarketplacePortletDefinition(portlet);
    PortletDefinitionBean rslt = PortletDefinitionBean.fromMarketplacePortletDefinition(mktpd, locale, favorite);
    // See api docs for postProcessIconUrlParameter() below
    IPortletDefinitionParameter iconParameter = rslt.getParameters().get(ICON_URL_PARAMETER_NAME);
    if (iconParameter != null) {
        IPortletDefinitionParameter evaluated = postProcessIconUrlParameter(iconParameter, req);
        rslt.putParameter(evaluated);
    }
    return rslt;
}
Also used : MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IPortletDefinitionParameter(org.apereo.portal.portlet.om.IPortletDefinitionParameter) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean)

Example 12 with MarketplacePortletDefinition

use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.

the class MarketplaceRESTController method marketplaceEntryFeed.

@RequestMapping(value = "/marketplace/entry/{fname}.json")
public ModelAndView marketplaceEntryFeed(HttpServletRequest request, HttpServletResponse response, @PathVariable String fname) {
    final IPerson user = personManager.getPerson(request);
    final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
    final MarketplacePortletDefinition marketplacePortletDefinition = marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists(fname);
    if (marketplacePortletDefinition != null && marketplaceService.mayBrowsePortlet(principal, marketplacePortletDefinition)) {
        MarketplaceEntry entry = new MarketplaceEntry(marketplacePortletDefinition, true, user);
        entry.setCanAdd(marketplaceService.mayAddPortlet(user, marketplacePortletDefinition));
        return new ModelAndView("json", "entry", entry);
    }
    response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    return null;
}
Also used : IPerson(org.apereo.portal.security.IPerson) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with MarketplacePortletDefinition

use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.

the class PortletDefinitionBeanTest method testFromMarketplacePortletDefinitionNoKeywords.

@Test
public void testFromMarketplacePortletDefinitionNoKeywords() {
    Long id = 345L;
    String name = "testName";
    // Create a non-keyword list
    String[] nonKeywords = new String[] { "val1", "val2" };
    List<IPortletPreference> prefs = new ArrayList<>();
    prefs.add(portletPref);
    Mockito.when(portletPref.getName()).thenReturn("non-keywords");
    Mockito.when(portletPref.getValues()).thenReturn(nonKeywords);
    MarketplacePortletDefinition mpd = buildMarketplacePortletDefinition(id, name, prefs, null);
    PortletDefinitionBean pdb = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd, Locale.ENGLISH, false);
    assertEquals(Collections.EMPTY_LIST, pdb.getKeywords());
}
Also used : IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) ArrayList(java.util.ArrayList) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) Test(org.junit.Test)

Example 14 with MarketplacePortletDefinition

use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.

the class PortletDefinitionBeanTest method testEqualsSelf.

@Test
public void testEqualsSelf() {
    MarketplacePortletDefinition mpd1 = buildMarketplacePortletDefinition(45L, "testName", null, null);
    PortletDefinitionBean pdb1 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd1, Locale.ENGLISH, false);
    assertTrue(pdb1.equals(pdb1));
}
Also used : MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) Test(org.junit.Test)

Example 15 with MarketplacePortletDefinition

use of org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition in project uPortal by Jasig.

the class PortletDefinitionBeanTest method testEqualsDifferentID.

@Test
public void testEqualsDifferentID() {
    Long id1 = 678L;
    Long id2 = 732L;
    MarketplacePortletDefinition mpd1 = buildMarketplacePortletDefinition(id1, "testName", null, null);
    MarketplacePortletDefinition mpd2 = buildMarketplacePortletDefinition(id2, "testName", null, null);
    PortletDefinitionBean pdb1 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd1, Locale.ENGLISH, false);
    PortletDefinitionBean pdb2 = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd2, Locale.ENGLISH, false);
    assertFalse(pdb1.equals(pdb2));
}
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