Skip to content

Commit

Permalink
fix: Adapt Portal MOP Services API changes - MEED-7663 - Meeds-io/MIP…
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker authored and rdenarie committed Nov 4, 2024
1 parent 59acb81 commit 7e007bf
Show file tree
Hide file tree
Showing 22 changed files with 109 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<priority>1</priority>
<page-nodes>
<node>
<uri>home</uri>
<name>home</name>
<label>Documents</label>
<page-reference>portal::clouddrive::homepage</page-reference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import javax.portlet.PortletPreferences;

import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.portal.config.Query;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.util.Util;
Expand Down Expand Up @@ -170,7 +170,7 @@ public ResourceResolver getTemplateResourceResolver(WebuiRequestContext context,
@SuppressWarnings("unchecked")
private List getPortalList() throws Exception {
List<SelectItemOption<String>> portals = new ArrayList<SelectItemOption<String>>();
DataStorage service = getApplicationComponent(DataStorage.class);
LayoutService service = getApplicationComponent(LayoutService.class);
Query<PortalConfig> query = new Query<PortalConfig>(null, null, null, null, PortalConfig.class);
List<PortalConfig> list = service.find(query, null).getAll();
portals.add(new SelectItemOption<String>(ALL_OPTION, ALL_OPTION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.component.RequestLifeCycle;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.portal.config.Query;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfig;
Expand All @@ -67,29 +67,28 @@
* Returns a page URI for a given location.
*
* @LevelAPI Provisional
*
* @anchor PortalLinkConnector
*/
@Path("/portalLinks/")
public class PortalLinkConnector implements ResourceContainer {

/** The RESOURC e_ type. */
final private String RESOURCE_TYPE = "PortalPageURI";
final private String RESOURCE_TYPE = "PortalPageURI";

/** The portal data storage. */
private DataStorage portalDataStorage;
private LayoutService portalDataStorage;

/** The portal user acl. */
private UserACL portalUserACL;
private UserACL portalUserACL;

/** The servlet context. */
private ServletContext servletContext;
private ServletContext servletContext;

/** The log. */
private static final Log LOG = ExoLogger.getLogger(PortalLinkConnector.class.getName());
private static final Log LOG = ExoLogger.getLogger(PortalLinkConnector.class.getName());

/** The Constant LAST_MODIFIED_PROPERTY. */
private static final String LAST_MODIFIED_PROPERTY = "Last-Modified";
private static final String LAST_MODIFIED_PROPERTY = "Last-Modified";

/** The Constant IF_MODIFIED_SINCE_DATE_FORMAT. */
private static final String IF_MODIFIED_SINCE_DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss z";
Expand All @@ -101,13 +100,13 @@ public class PortalLinkConnector implements ResourceContainer {
* @param dataStorage The data storage.
* @param userACL The user ACL.
* @param servletContext The servlet context.
*
* @throws Exception the exception
*/
public PortalLinkConnector(InitParams params,
DataStorage dataStorage,
LayoutService dataStorage,
UserACL userACL,
ServletContext servletContext) throws Exception {
ServletContext servletContext)
throws Exception {
this.portalDataStorage = dataStorage;
this.portalUserACL = userACL;
this.servletContext = servletContext;
Expand All @@ -121,15 +120,17 @@ public PortalLinkConnector(InitParams params,
* @param type The file type.
* @return The page URI.
* @throws Exception The exception
*
* @anchor PortalLinkConnector.getFoldersAndFiles
*/
@GET
@Path("/getFoldersAndFiles/")
// @OutputTransformer(XMLOutputTransformer.class)
public Response getPageURI(@QueryParam("currentFolder") String currentFolder,
@QueryParam("command") String command,
@QueryParam("type") String type) throws Exception {
public Response getPageURI(@QueryParam("currentFolder")
String currentFolder,
@QueryParam("command")
String command,
@QueryParam("type")
String type) throws Exception {
try {
String userId = getCurrentUser();
return buildReponse(currentFolder, command, userId);
Expand Down Expand Up @@ -165,9 +166,7 @@ private String getCurrentUser() {
* @param currentFolder The current folder.
* @param command The command.
* @param userId The user Id
*
* @return the response
*
* @throws Exception the exception
*/
private Response buildReponse(String currentFolder, String command, String userId) throws Exception {
Expand All @@ -193,9 +192,7 @@ private Response buildReponse(String currentFolder, String command, String userI
* @param currentFolder The current folder.
* @param command The command.
* @param userId The user Id.
*
* @return The document
*
* @throws Exception the exception
*/
private Document buildPortalXMLResponse(String currentFolder, String command, String userId) throws Exception {
Expand Down Expand Up @@ -232,9 +229,7 @@ public int compare(PortalConfig pconfig1, PortalConfig pconfig2) {
* @param currentFolder The current folder.
* @param command The command.
* @param userId The user Id.
*
* @return The document.
*
* @throws Exception the exception
*/
private Document buildNavigationXMLResponse(String currentFolder, String command, String userId) throws Exception {
Expand Down Expand Up @@ -290,9 +285,7 @@ private Document buildNavigationXMLResponse(String currentFolder, String command
*
* @param commandStr The command str.
* @param currentPath The current path.
*
* @return The element.
*
* @throws ParserConfigurationException the parser configuration exception
*/
private Element initRootElement(String commandStr, String currentPath) throws ParserConfigurationException {
Expand Down Expand Up @@ -320,7 +313,6 @@ private Element initRootElement(String commandStr, String currentPath) throws Pa
* @param filesElement
* @param userId The user Id.
* @param portalConfigService The portal config service.
*
* @throws Exception the exception
*/
private void processPageNode(String portalName,
Expand All @@ -333,8 +325,8 @@ private void processPageNode(String portalName,
PageContext page = portalConfigService.getPage(pageRef);
String pageUri = "";
if (page == null) {
pageUri = "/";
Element folderElement = foldersElement.getOwnerDocument().createElement("Folder");
pageUri = "/";
Element folderElement = foldersElement.getOwnerDocument().createElement("Folder");
folderElement.setAttribute("name", userNode.getName());
folderElement.setAttribute("folderType", "");
folderElement.setAttribute("url", pageUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<external-component-plugins>
<target-component>org.exoplatform.services.listener.ListenerService</target-component>
<component-plugin>
<name>org.exoplatform.portal.config.DataStorage.portalConfigCreated</name>
<name>org.exoplatform.portal.mop.service.LayoutService.portalConfigCreated</name>
<set-method>addListener</set-method>
<type>org.exoplatform.services.wcm.portal.listener.CreateLivePortalEventListener</type>
<description>this listener create new live portal content storage</description>
Expand All @@ -174,13 +174,13 @@
</init-params>
</component-plugin>
<component-plugin>
<name>org.exoplatform.portal.config.DataStorage.portalConfigRemoved</name>
<name>org.exoplatform.portal.mop.service.LayoutService.portalConfigRemoved</name>
<set-method>addListener</set-method>
<type>org.exoplatform.services.wcm.portal.listener.RemoveLivePortalEventListener</type>
<description>this listener new live portal content storage</description>
</component-plugin>
<component-plugin>
<name>org.exoplatform.portal.config.DataStorage.portalConfigUpdated</name>
<name>org.exoplatform.portal.mop.service.LayoutService.portalConfigUpdated</name>
<set-method>addListener</set-method>
<type>org.exoplatform.services.wcm.portal.listener.UpdateLivePortalEventListener</type>
<description>this listener new live portal content storage</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import javax.jcr.Node;

import org.exoplatform.commons.utils.PageList;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.portal.config.Query;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.PortalConfig;
Expand Down Expand Up @@ -74,7 +74,7 @@ public void init(Node node) throws Exception {
*/
private List<String> getRunningPortals(String userId) throws Exception {
List<String> listPortalName = new ArrayList<String>();
DataStorage service = WCMCoreUtils.getService(DataStorage.class);
LayoutService service = WCMCoreUtils.getService(LayoutService.class);
Query<PortalConfig> query = new Query<PortalConfig>(null, null, null, null, PortalConfig.class) ;
PageList pageList = service.find(query, null) ;
UserACL userACL = WCMCoreUtils.getService(UserACL.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,6 @@
</object-param>
</init-params>
</component-plugin>
<component-plugin>
<name>user.portal.config.listener</name>
<set-method>addListenerPlugin</set-method>
<type>org.exoplatform.portal.config.UserPortalConfigListener</type>
</component-plugin>
<component-plugin>
<name>group.portal.config.listener</name>
<set-method>addListenerPlugin</set-method>
<type>org.exoplatform.portal.config.GroupPortalConfigListener</type>
</component-plugin>
</external-component-plugins>

<external-component-plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static void findAppInstancesByContainerAndName(Container container, Stri
if(chidren == null) return ;
for(ModelObject object: chidren) {
if(object instanceof Application) {
Application<?> application = Application.class.cast(object);
Application application = Application.class.cast(object);
if(application.getId().contains(applicationName)) {
results.add(application.getId());
}
Expand All @@ -139,7 +139,7 @@ private static void removedAppInstancesInContainerByNames(Container container,
return;
for (ModelObject object : chidren) {
if (object instanceof Application) {
Application<?> application = Application.class.cast(object);
Application application = Application.class.cast(object);
if(!removingApplicationIds.contains(application.getId())) {
childrenTmp.add(object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.portal.config.Query;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfig;
Expand Down Expand Up @@ -239,7 +239,7 @@ public String getUserInfo(Node node, Locale locale) throws Exception {
*/
private List<String> getRunningPortals(String userId) throws Exception {
List<String> listPortalName = new ArrayList<String>();
DataStorage service = WCMCoreUtils.getService(DataStorage.class);
LayoutService service = WCMCoreUtils.getService(LayoutService.class);
Query<PortalConfig> query = new Query<PortalConfig>(null, null, null, null, PortalConfig.class) ;
ListAccess<PortalConfig> pageList = service.find2(query, null) ;
List<PortalConfig> portalConfigs = WCMCoreUtils.getAllElementsOfListAccess(pageList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.component.RequestLifeCycle;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.EventType;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.exoplatform.portal.mop.service.NavigationService;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.services.listener.Event;
import org.exoplatform.services.listener.Listener;
Expand Down Expand Up @@ -64,7 +64,7 @@ public class TestWCMPublicationService extends BasePublicationTestCase {
private final String testPortletPreferences = "portal#classic:/web/BannerPortlet/testPortletPreferences";

/** . */
private DataStorage storage_;
private LayoutService storage_;

/** . */
private NavigationService navService;
Expand Down Expand Up @@ -105,22 +105,22 @@ public void onEvent(Event event) throws Exception
};

PortalContainer container = PortalContainer.getInstance();
storage_ = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
storage_ = (LayoutService)container.getComponentInstanceOfType(LayoutService.class);
navService = (NavigationService)container.getComponentInstanceOfType(NavigationService.class);
events = new LinkedList<Event>();
listenerService = (ListenerService)container.getComponentInstanceOfType(ListenerService.class);
org = WCMCoreUtils.getService(OrganizationService.class);

listenerService.addListener(DataStorage.PAGE_CREATED, listener);
listenerService.addListener(DataStorage.PAGE_REMOVED, listener);
listenerService.addListener(DataStorage.PAGE_UPDATED, listener);
listenerService.addListener(LayoutService.PAGE_CREATED, listener);
listenerService.addListener(LayoutService.PAGE_REMOVED, listener);
listenerService.addListener(LayoutService.PAGE_UPDATED, listener);
listenerService.addListener(EventType
.NAVIGATION_CREATED, listener);
listenerService.addListener(EventType.NAVIGATION_DESTROYED, listener);
listenerService.addListener(EventType.NAVIGATION_UPDATED, listener);
listenerService.addListener(DataStorage.PORTAL_CONFIG_CREATED, listener);
listenerService.addListener(DataStorage.PORTAL_CONFIG_UPDATED, listener);
listenerService.addListener(DataStorage.PORTAL_CONFIG_REMOVED, listener);
listenerService.addListener(LayoutService.PORTAL_CONFIG_CREATED, listener);
listenerService.addListener(LayoutService.PORTAL_CONFIG_UPDATED, listener);
listenerService.addListener(LayoutService.PORTAL_CONFIG_REMOVED, listener);
}

public void tearDown() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,19 @@
<external-component-plugins>
<target-component>org.exoplatform.services.listener.ListenerService</target-component>
<component-plugin>
<name>org.exoplatform.portal.config.DataStorage.portalConfigCreated</name>
<name>org.exoplatform.portal.mop.service.LayoutService.portalConfigCreated</name>
<set-method>addListener</set-method>
<type>org.exoplatform.services.wcm.portal.listener.CreateLivePortalEventListener</type>
<description>this listener create new live portal content storage</description>
</component-plugin>
<component-plugin>
<name>org.exoplatform.portal.config.DataStorage.portalConfigRemoved</name>
<name>org.exoplatform.portal.mop.service.LayoutService.portalConfigRemoved</name>
<set-method>addListener</set-method>
<type>org.exoplatform.services.wcm.portal.listener.RemoveLivePortalEventListener</type>
<description>this listener new live portal content storage</description>
</component-plugin>
<component-plugin>
<name>org.exoplatform.portal.config.DataStorage.portalConfigUpdated</name>
<name>org.exoplatform.portal.mop.service.LayoutService.portalConfigUpdated</name>
<set-method>addListener</set-method>
<type>org.exoplatform.services.wcm.portal.listener.UpdateLivePortalEventListener</type>
<description>this listener new live portal content storage</description>
Expand Down Expand Up @@ -424,16 +424,6 @@
</object-param>
</init-params>
</component-plugin>
<component-plugin>
<name>user.portal.config.listener</name>
<set-method>addListenerPlugin</set-method>
<type>org.exoplatform.portal.config.UserPortalConfigListener</type>
</component-plugin>
<component-plugin>
<name>group.portal.config.listener</name>
<set-method>addListenerPlugin</set-method>
<type>org.exoplatform.portal.config.GroupPortalConfigListener</type>
</component-plugin>
</external-component-plugins>

<external-component-plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

import org.exoplatform.container.xml.InitParams;
import org.exoplatform.ecms.legacy.search.data.SearchContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.portal.config.model.Application;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.navigation.NavigationContext;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.exoplatform.portal.mop.service.NavigationService;
import org.exoplatform.portal.mop.navigation.NodeContext;
import org.exoplatform.portal.mop.navigation.NodeModel;
import org.exoplatform.portal.mop.navigation.Scope;
Expand Down Expand Up @@ -197,7 +197,7 @@ private String getPageName(SiteKey siteKey) throws Exception {

private boolean hasPortlet(NodeContext<?> pageCt, String plName) {
if (plName == null) return false;
DataStorage ds = WCMCoreUtils.getService(DataStorage.class);
LayoutService ds = WCMCoreUtils.getService(LayoutService.class);
try {
for (ModelObject mo : ds.getPage(pageCt.getState().getPageRef().format()).getChildren()) {
if (containApp(mo, plName)) {
Expand All @@ -211,10 +211,10 @@ private boolean hasPortlet(NodeContext<?> pageCt, String plName) {
}

private boolean containApp(ModelObject mo, String plName) {
DataStorage ds = WCMCoreUtils.getService(DataStorage.class);
if (mo instanceof Application<?>) {
LayoutService ds = WCMCoreUtils.getService(LayoutService.class);
if (mo instanceof Application) {
try {
if (ds.getId(((Application<?>)mo).getState()).contains(plName)) {
if (ds.getId(((Application)mo).getState()).contains(plName)) {
return true;
}
} catch (Exception e) {
Expand Down
Loading

0 comments on commit 7e007bf

Please sign in to comment.