Skip to content

Commit

Permalink
Merge branch 'issue-29480-resource-job-queue' of https://github.com/d…
Browse files Browse the repository at this point in the history
…otCMS/core into issue-29480-resource-job-queue
  • Loading branch information
fabrizzio-dotCMS committed Oct 9, 2024
2 parents 691e971 + 8ebc660 commit e018540
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 65 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/cicd_post_sync-main-with-master.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ cube('request', {
CASE
WHEN MAX(CASE WHEN event_type = 'FILE_REQUEST' THEN 1 ELSE 0 END) = 1 THEN 'FILE'
WHEN MAX(CASE WHEN event_type = 'PAGE_REQUEST' THEN 1 ELSE 0 END) = 1 THEN 'PAGE'
ELSE 'NOTHING'
WHEN MAX(CASE WHEN event_type = 'VANITY_REQUEST' AND object_response != '200' THEN 1 ELSE 0 END) = 1 THEN 'VANITY_REDIRECT'
ELSE 'OTHER'
END AS what_am_i
FROM events
GROUP BY request_id`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
match.get(whoIAM).collect(innerCollectorContextMap, collectorPayloadBean);
}

collectorPayloadBean.put("comeFromVanityURL", "true");
collectorPayloadBean.put("comeFromVanityURL", true);
return collectorPayloadBean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
WebAPILocator.getPersonalizationWebAPI().getContainerPersonalization(request));

collectorPayloadBean.put("renderMode", PageMode.get(request).toString().replace("_MODE", ""));

//Include default vakue for other Bool fiedls in the Clickhouse table

collectorPayloadBean.put("comeFromVanityURL", false);
collectorPayloadBean.put("isexperimentpage", false);
collectorPayloadBean.put("istargetpage", false);

return collectorPayloadBean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.List;

import com.dotmarketing.beans.Host;
import com.dotmarketing.util.UtilMethods;
import com.liferay.util.StringPool;
import org.apache.velocity.tools.view.tools.ViewTool;

import com.dotmarketing.business.APILocator;
Expand Down Expand Up @@ -58,8 +60,18 @@ public List<Folder> getSubFolders (String parentFolder, long hostId) {
public List<Folder> getSubFolders (String parentFolder, String hostId) {
List<Folder> subFolders = new ArrayList<>();
try {
Folder folder = APILocator.getFolderAPI().findFolderByPath(parentFolder, hostId,APILocator.getUserAPI().getSystemUser(),false);
subFolders = APILocator.getFolderAPI().findSubFoldersTitleSort(folder, APILocator.getUserAPI().getSystemUser(),false);
if (StringPool.FORWARD_SLASH.equals(parentFolder)) {
final Host host = getHost(hostId);
if (!UtilMethods.isSet(hostId)) {
Logger.debug(this, () -> "Website getSubFolders Method : Host not found "
+ hostId);
return subFolders;
}
subFolders = APILocator.getFolderAPI().findSubFolders(host,APILocator.getUserAPI().getSystemUser(),false);
} else {
Folder folder = APILocator.getFolderAPI().findFolderByPath(parentFolder, hostId, APILocator.getUserAPI().getSystemUser(), false);
subFolders = APILocator.getFolderAPI().findSubFoldersTitleSort(folder, APILocator.getUserAPI().getSystemUser(), false);
}
} catch (Exception e) {
Logger.error(this,e.getMessage(),e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
import io.vavr.control.Try;
import org.apache.commons.lang.time.StopWatch;
import org.apache.commons.lang3.concurrent.ConcurrentUtils;
import org.apache.felix.framework.OSGIUtil;
import org.elasticsearch.search.query.QueryPhaseExecutionException;
import org.osgi.framework.BundleContext;

Expand Down Expand Up @@ -367,16 +368,23 @@ private FriendClass getFriendClass () {
}

public void registerBundleService () {
if(System.getProperty(WebKeys.OSGI_ENABLED)!=null){
// Register main service
BundleContext context = HostActivator.instance().getBundleContext();
if (null != context) {
Hashtable<String, String> props = new Hashtable<>();
context.registerService(WorkflowAPIOsgiService.class.getName(), this, props);
} else {
Logger.error(this, "Bundle Context is null, WorkflowAPIOsgiService has been not registered");
}

// force init if not already done
OSGIUtil.getInstance().initializeFramework();
if (System.getProperty(WebKeys.OSGI_ENABLED) == null) {
// OSGI is not inited
throw new DotRuntimeException("Unable to register WorkflowAPIOsgiService as OSGI is not inited");
}

BundleContext context = HostActivator.instance().getBundleContext();
if (context == null) {
throw new DotRuntimeException("Bundle Context is null, WorkflowAPIOsgiService has been not registered");
}
if (context.getServiceReference(WorkflowAPIOsgiService.class.getName()) == null) {
Hashtable<String, String> props = new Hashtable<>();
context.registerService(WorkflowAPIOsgiService.class.getName(), this, props);
}

}

/**
Expand Down Expand Up @@ -1690,7 +1698,7 @@ public List<WorkflowAction> findAvailableActionsEditing(final Contentlet content

return this.findAvailableActions(contentlet, user, RenderMode.EDITING);
}

/**
* This method will return the list of workflows actions available to a user on any give
* piece of content, based on how and who has the content locked and what workflow step the content
Expand All @@ -1703,7 +1711,7 @@ public List<WorkflowAction> findAvailableActionsListing(final Contentlet content

return this.findAvailableActions(contentlet, user, RenderMode.LISTING);
}

/**
* This method will return the list of workflows actions available to a user on any give
* piece of content, based on how and who has the content locked and what workflow step the content
Expand Down Expand Up @@ -2224,13 +2232,13 @@ public void deleteActionClass(final WorkflowActionClass actionClass, final User
// Delete action class
final int orderOfActionClassToDelete = actionClass.getOrder();
workFlowFactory.deleteActionClass(actionClass);
// We don't need to get "complete" base action object from the database

// We don't need to get "complete" base action object from the database
// to retrieve all action classes from him. So, we can create the base action object
// with the "action id" contain in actionClass parameter.
WorkflowAction baseAction = new WorkflowAction();
baseAction.setId(actionClass.getActionId());

// Reorder the action classes in the database
final List<WorkflowActionClass> actionClasses = findActionClasses(baseAction);
if((actionClasses.size() > 1) && (actionClasses.size() != orderOfActionClassToDelete)) {
Expand Down Expand Up @@ -2273,12 +2281,12 @@ public void reorderActionClass(final WorkflowActionClass actionClass,

List<WorkflowActionClass> actionClasses = null;
try {
// We don't need to get "complete" base action object from the database
// We don't need to get "complete" base action object from the database
// to retrieve all action classes from him. So, we can create the base action object
// with the "action id" contain in actionClass parameter.
final WorkflowAction baseAction = new WorkflowAction();
baseAction.setId(actionClass.getActionId());

actionClasses = findActionClasses(baseAction);
} catch (Exception e) {
throw new DotDataException(e.getLocalizedMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
com.dotcms.rendering.velocity.viewtools.content.util.ContentUtilsTest.class,
com.dotcms.rendering.velocity.viewtools.content.ContentToolTest.class,
com.dotcms.rendering.velocity.viewtools.WorkflowToolTest.class,
com.dotcms.rendering.velocity.viewtools.WebsiteToolTest.class,
com.dotcms.browser.BrowserAPITest.class,
com.dotcms.rendering.velocity.viewtools.LanguageWebAPITest.class,
com.dotcms.rendering.velocity.viewtools.ContainerWebAPIIntegrationTest.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.dotcms.rendering.velocity.viewtools;

import com.dotcms.IntegrationTestBase;
import com.dotcms.datagen.FolderDataGen;
import com.dotcms.datagen.SiteDataGen;
import com.dotcms.util.IntegrationTestInitService;
import com.dotmarketing.beans.Host;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.portlets.folders.model.Folder;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class WebsiteToolTest extends IntegrationTestBase {

@BeforeClass
public static void prepare() throws Exception {
//Setting web app environment
IntegrationTestInitService.getInstance().init();
}

@Test
public void testGetSubFoldersUnderRoot() throws DotDataException, DotSecurityException {

Host testSite = null;
try {
// Create test host and folders
testSite = new SiteDataGen().nextPersisted();
final Folder testFolder1 = new FolderDataGen()
.site(testSite).title("testFolder1").nextPersisted();
final Folder testFolder2 = new FolderDataGen()
.site(testSite).title("testFolder2").nextPersisted();

// Test getSubFolders
WebsiteWebAPI websiteTool = new WebsiteWebAPI();
final List<Folder> folderList = websiteTool.getSubFolders(
"/", testSite.getIdentifier());

// Verify results
assertNotNull(folderList);
assertEquals(2, folderList.size());
assertTrue(folderList.stream().map(Folder::getInode)
.allMatch(inode -> inode.equals(testFolder1.getInode())
|| inode.equals(testFolder2.getInode())));

} finally {
if (testSite != null) {
APILocator.getHostAPI().archive(testSite, APILocator.getUserAPI().getSystemUser(), false);
APILocator.getHostAPI().delete(testSite, APILocator.getUserAPI().getSystemUser(), false);
}
}
}

}
2 changes: 1 addition & 1 deletion tools/dotcms-cli/action/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# This is how we instruct the cli to create the workspace if it does not exist
DOT_CREATE_WORKSPACE: ${{ vars.DOT_CREATE_WORKSPACE || 'true' }}
# This is the CLI version to use, but we can always override this value
DOT_CLI_JAR_DOWNLOAD_URL: ${{ vars.DOT_CLI_JAR_DOWNLOAD_URL || 'https://repo.dotcms.com/artifactory/libs-snapshot-local/com/dotcms/dotcms-cli/1.0.0-SNAPSHOT/dotcms-cli-1.0.0-20231002.205953-1.jar' }}
DOT_CLI_JAR_DOWNLOAD_URL: ${{ vars.DOT_CLI_JAR_DOWNLOAD_URL || 'https://repo.dotcms.com/artifactory/libs-release-local/com/dotcms/dotcms-cli/24.10.02/dotcms-cli-24.10.02-runner.jar' }}
# In case we want to force the download of the CLI jar
DOT_FORCE_DOWNLOAD: ${{ vars.DOT_FORCE_DOWNLOAD || 'false' }}
steps:
Expand Down

0 comments on commit e018540

Please sign in to comment.