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;
}
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;
}
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());
}
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));
}
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));
}
Aggregations