Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing content resource test #13200

Merged
merged 6 commits into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ public void workflowTask() throws Exception {
// Save as Draft Step1 -> Step1
WorkflowAction saveDraft=new WorkflowAction();
saveDraft.setId(UUIDGenerator.generateUuid());
saveDraft.setSchemeId(scheme.getId());
saveDraft.setName("Save as Draft");
saveDraft.setOrder(1);
saveDraft.setNextStep(step1.getId());
Expand All @@ -582,10 +583,12 @@ public void workflowTask() throws Exception {
saveDraft.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
APILocator.getWorkflowAPI().saveAction(saveDraft.getId(), step1.getId(),user);

// Save as Draft Step1 -> Step1
// Save as Draft Step1 -> Step1
WorkflowAction escalate=new WorkflowAction();
escalate.setId(UUIDGenerator.generateUuid());
escalate.setSchemeId(scheme.getId());
escalate.setName("Save and Assign");
escalate.setOrder(2);
escalate.setNextStep(step1.getId());
Expand All @@ -601,10 +604,16 @@ public void workflowTask() throws Exception {
escalate.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
APILocator.getWorkflowAPI().saveAction(escalate.getId(), step1.getId(),user);

//Set mandatory workflow default action
scheme.setEntryActionId(saveDraft.getId());
APILocator.getWorkflowAPI().saveScheme(scheme);

// Send for review Step1 -> Step2
WorkflowAction sendReview=new WorkflowAction();
sendReview.setId(UUIDGenerator.generateUuid());
sendReview.setSchemeId(scheme.getId());
sendReview.setName("Send for review");
sendReview.setOrder(3);
sendReview.setNextStep(step2.getId());
Expand All @@ -618,10 +627,12 @@ public void workflowTask() throws Exception {
sendReview.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
APILocator.getWorkflowAPI().saveAction(sendReview.getId(), step1.getId(),user);

// reject Step2 -> Step1
WorkflowAction reject=new WorkflowAction();
reject.setId(UUIDGenerator.generateUuid());
reject.setSchemeId(scheme.getId());
reject.setName("Reject");
reject.setOrder(1);
reject.setNextStep(step1.getId());
Expand All @@ -635,10 +646,12 @@ public void workflowTask() throws Exception {
reject.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
APILocator.getWorkflowAPI().saveAction(sendReview.getId(), step2.getId(),user);

// publish Step2 -> Step3
WorkflowAction publish=new WorkflowAction();
publish.setId(UUIDGenerator.generateUuid());
publish.setSchemeId(scheme.getId());
publish.setName("Publish");
publish.setOrder(2);
publish.setNextStep(step3.getId());
Expand All @@ -652,6 +665,8 @@ public void workflowTask() throws Exception {
publish.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
APILocator.getWorkflowAPI().saveAction(publish.getId(), step2.getId(),user);

WorkflowActionClass publishlet=new WorkflowActionClass();
publishlet.setActionId(publish.getId());
publishlet.setClazz(com.dotmarketing.portlets.workflows.actionlet.PublishContentActionlet.class.getCanonicalName());
Expand Down
15 changes: 11 additions & 4 deletions dotCMS/src/integration-test/resources/db-config.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#Postgres Connection
postgres.db.driver=org.postgresql.Driver
postgres.db.base.url=jdbc:postgresql://localhost/dotcms
postgres.db.username=postgres
postgres.db.password=postgres
#postgres.db.driver=org.postgresql.Driver
#postgres.db.base.url=jdbc:postgresql://localhost/dotcms
#postgres.db.username=postgres
#postgres.db.password=postgres
#postgres.db.max.total=60
#postgres.db.max.idle=10
postgres.db.driver=com.mysql.jdbc.Driver
postgres.db.base.url=jdbc:mysql://localhost:3306/dotcms42master?characterEncoding=UTF-8
postgres.db.username=root
postgres.db.password=
postgres.db.max.total=60
postgres.db.max.idle=10


#MySQL Connection
mysql.db.driver=com.mysql.jdbc.Driver
mysql.db.base.url=jdbc:mysql://localhost/dotcms?characterEncoding=UTF-8&useLegacyDatetimeCode=false&serverTimezone=UTC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ELASTICSEARCH_USE_FILTERS_FOR_SEARCHING=true

## The name of your dotCMS cluster. Each dotCMS cluster
## should have a unique name (all servers in a cluster share the same name)
es.cluster.name=dotCMSContentIndex_3x
es.cluster.name=dotCMSContentIndexAlCarrer_3x

## Default settings
#es.node.master=true
Expand Down Expand Up @@ -137,12 +137,12 @@ es.query.bool.max_clause_count=10240
## Paths to your esdata and to the logs
## You are going to want your index on a fast disk
## generally the es.path.data will match the config val for DYNAMIC_CONTENT_PATH
es.path.data=dotsecure/esdata
es.path.work=dotsecure/esdata/work
es.path.repo=dotsecure/esdata/essnapshot/snapshots
es.path.data=/Users/jsanca/gitsources/4.2/tomcat8/webapps/ROOT/dotsecure/esdata
es.path.work=/Users/jsanca/gitsources/4.2/tomcat8/webapps/ROOT/dotsecure/esdata/work
es.path.repo=/Users/jsanca/gitsources/4.2/tomcat8/webapps/ROOT/dotsecure/esdata/essnapshot/snapshots

## Where logs go
es.path.logs=tomcat/logs
es.path.logs=/Users/jsanca/gitsources/4.2/tomcat8/tomcat/logs

## This enables the http restful API for elasticsearch. Recommended to run
## this in a production enviroment with access limited to the port/ip address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ DEFAULT_LANGUAGE_COUNTRY_CODE = US
## this aditional search is avoided
DEFAULT_CONTENT_TO_DEFAULT_LANGUAGE=false

## it is similar to DEFAULT_CONTENT_TO_DEFAULT_LANGUAGE but only applies for Widgets
## it is similar to MULTILINGUAGE_FALLBACK but only applies for Widgets
DEFAULT_WIDGET_TO_DEFAULT_LANGUAGE=true

## it is similar to DEFAULT_CONTENT_TO_DEFAULT_LANGUAGE but only applies for Pages
## it is similar to MULTILINGUAGE_FALLBACK but only applies for Pages
DEFAULT_PAGE_TO_DEFAULT_LANGUAGE=true

## it is similar to DEFAULT_CONTENT_TO_DEFAULT_LANGUAGE but only applies for Files
## it is similar to MULTILINGUAGE_FALLBACK but only applies for Files
DEFAULT_FILE_TO_DEFAULT_LANGUAGE = true


Expand Down Expand Up @@ -50,7 +50,7 @@ ASSET_PATH = /assets
## shared folder in unix/linux enviroments we encourage you to use symbolic links
## If this variable is commented the system will work as usual using
## the ASSET_PATH variable as the assets directory inside liferay web root
ASSET_REAL_PATH = /tomcat8/webapps/ROOT/assets
ASSET_REAL_PATH = /Users/jsanca/gitsources/4.2/tomcat8/webapps/ROOT/assets

## This variable should be used if the dynamic content is to be placed outside of the web application. By the default, the location
## is in dotCMS/dotsecure. If running as war inside an application server, it is important to move this data to a location
Expand Down Expand Up @@ -107,7 +107,7 @@ SHOW_VELOCITYFILES=false
LOG_VELOCITY_TEMPLATES=false

VELOCITY_PAGE_EXTENSION = html
VELOCITY_ROOT = /WEB-INF/velocity
VELOCITY_ROOT = /Users/jsanca/gitsources/4.2/tomcat8/webapps/ROOT/WEB-INF/velocity
VELOCITY_HTMLPAGE_EXTENSION = dotpage
VELOCITY_HOST_EXTENSION= host
VELOCITY_INCLUDE_EXTENSION = vtl
Expand Down Expand Up @@ -735,7 +735,7 @@ CONTENT_ESCAPE_HTML_TEXT=true
##SALESFORCE INTEGRATION. THESE VARIABLES ARE REQUIRED

#SALESFORCE_LOGIN_FILTER_ON=true
DYNAMIC_CONTENT_PATH=/tomcat8/webapps/ROOT/dotsecure
DYNAMIC_CONTENT_PATH=/Users/jsanca/gitsources/4.2/tomcat8/webapps/ROOT/dotsecure

## SALESFORCE URL FOR REQUESTING ACCESS TOKEN
#salesforce_token_request_url=https://test.salesforce.com/services/oauth2/token
Expand Down Expand Up @@ -822,9 +822,9 @@ api.system.ruleengine.actionlet.VisitorTagsActionlet.MAX_TAGS=20
#GOOGLE_TRANSLATE_SERVICE_API_KEY=put-your-key-here

## Path to the toolbox.xml file
#TOOLBOX_MANAGER_PATH=<tomcat8>/webapps/ROOT/WEB-INF/toolbox.xml
TOOLBOX_MANAGER_PATH=/Users/jsanca/gitsources/4.2/tomcat8/webapps/ROOT/WEB-INF/toolbox.xml

## Path to felix folder
#context.path.felix=<tomcat8>/webapps/ROOT/WEB-INF/felix
#felix.base.dir=<tomcat8>/webapps/ROOT/WEB-INF/felix
felix.base.dir=/Users/jsanca/gitsources/4.2/tomcat8/webapps/ROOT/WEB-INF/felix

2 changes: 1 addition & 1 deletion dotCMS/src/main/enterprise
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import com.dotcms.repackage.org.apache.commons.lang.StringUtils;
import com.dotmarketing.common.db.DotConnect;
import com.dotmarketing.db.DbConnectionFactory;
import com.dotmarketing.db.HibernateUtil;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotHibernateException;
import com.dotmarketing.exception.DotRuntimeException;
import com.dotmarketing.portlets.workflows.model.WorkflowAction;
import com.dotmarketing.startup.StartupTask;
import com.dotmarketing.util.Logger;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -53,10 +55,10 @@ public class Task04305UpdateWorkflowActionTable implements StartupTask {
private static final String MSSQL_FIND_SCHEME_ID_COLUMN = "SELECT scheme_id FROM workflow_action";
private static final String ORACLE_FIND_SCHEME_ID_COLUMN = "SELECT scheme_id FROM workflow_action";

private static final String MYSQL_ADD_SCHEME_ID_COLUMN = "ALTER TABLE workflow_action ADD scheme_id VARCHAR(36) NOT NULL";
private static final String MYSQL_ADD_SCHEME_ID_COLUMN = "ALTER TABLE workflow_action ADD scheme_id VARCHAR(36)";
private static final String POSTGRES_ADD_SCHEME_ID_COLUMN = MYSQL_ADD_SCHEME_ID_COLUMN;
private static final String MSSQL_ADD_SCHEME_ID_COLUMN = "ALTER TABLE workflow_action ADD scheme_id NVARCHAR(36) NOT NULL";
private static final String ORACLE_ADD_SCHEME_ID_COLUMN = "ALTER TABLE workflow_action ADD scheme_id varchar2(36) NOT NULL";
private static final String MSSQL_ADD_SCHEME_ID_COLUMN = "ALTER TABLE workflow_action ADD scheme_id NVARCHAR(36)";
private static final String ORACLE_ADD_SCHEME_ID_COLUMN = "ALTER TABLE workflow_action ADD scheme_id varchar2(36)";

private static final String MYSQL_ADD_REQUIRES_CHECKOUT_OPTION_COLUMN = "ALTER TABLE workflow_action ADD requires_checkout_option VARCHAR(16) default 'both'";
private static final String POSTGRES_ADD_REQUIRES_CHECKOUT_OPTION_COLUMN = "ALTER TABLE workflow_action ADD requires_checkout_option VARCHAR(16) default 'both'";
Expand Down Expand Up @@ -258,12 +260,16 @@ private void addSchemeIdColumn(final DotConnect dc) throws DotDataException {

Logger.info(this, "Column 'workflow_action.scheme_id' does not exists, creating it");
needToCreate = true;
// in some databases if an error is throw the transaction is not longer valid
this.closeAndStartTransaction();
}
if (needToCreate) {
try {
dc.executeStatement(addSchemeIdColumn());
} catch (SQLException e) {
throw new DotRuntimeException("The 'scheme_id' column could not be created.", e);
} finally {
this.closeCommitAndStartTransaction();
}
}
} // addSchemeIdColumn.
Expand All @@ -280,27 +286,44 @@ private void createWorkflowActionStepTable(final DotConnect dc) throws DotDataEx

Logger.info(this, "Table 'workflow_action_step' does not exists, creating it");
needToCreate = true;
// in some databases if an error is throw the transaction is not longer valid
this.closeAndStartTransaction();
}

if (needToCreate) {
try {
dc.executeStatement(createIntermediateTable());
dc.setSQL(createIntermediateTable()).loadResult();
// The SQL Server and Oracle table definition already include de PK creation
if (DbConnectionFactory.isMySql() || DbConnectionFactory.isPostgres()) {
dc.executeStatement(createIntermediateTablePk());
dc.setSQL(createIntermediateTablePk()).loadResult();
}

// adding the FK
Logger.info(this, "Creating the Workflow action step intermediate FKs.");
dc.executeStatement(this.createIntermediateTableForeignKeyActionId());
dc.executeStatement(this.createIntermediateTableForeignKeyStepId());
} catch (SQLException e) {
dc.setSQL(this.createIntermediateTableForeignKeyActionId()).loadResult();
dc.setSQL(this.createIntermediateTableForeignKeyStepId()).loadResult();
} catch (Exception e) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Catch a list of specific exception subtypes instead. rule

throw new DotRuntimeException(
"The 'workflow_action_step' table could not be created.", e);
} finally {
this.closeCommitAndStartTransaction();
}
}
} // createWorkflowActionStepTable.

private void closeCommitAndStartTransaction() throws DotHibernateException {
if (DbConnectionFactory.inTransaction()) {
HibernateUtil.closeAndCommitTransaction();
HibernateUtil.startTransaction();
}
}

private void closeAndStartTransaction() throws DotHibernateException {

HibernateUtil.closeSessionSilently();
HibernateUtil.startTransaction();
}

private boolean isLocked(final Object requiresCheckout) {

boolean isLocked = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEFAULT_CONTENT_TO_DEFAULT_LANGUAGE=true
2 changes: 1 addition & 1 deletion dotCMS/src/main/resources/dotcms-config-cluster.properties
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ELASTICSEARCH_USE_FILTERS_FOR_SEARCHING=true

## The name of your dotCMS cluster. Each dotCMS cluster
## should have a unique name (all servers in a cluster share the same name)
es.cluster.name=dotCMSContentIndex_3x
es.cluster.name=dotCMSContentIndexAlCarrer_3x

## Default settings
#es.node.master=true
Expand Down
9 changes: 7 additions & 2 deletions dotCMS/src/main/webapp/WEB-INF/log4j/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<Property name="PATTERN">%-5level %d %c:%M(%L): %m%n</Property>
<Property name="CONSOLE_PATTERN">%-5level %d %c:%M(%L): %m%n</Property>
<Property name="MESSAGE_PATTERN">[%d{dd/MM/yy HH:mm:ss:SSS z}] %5p %c{2}: %m%n</Property>
<Property name="MDC_MESSAGE_PATTERN">[%d{dd/MM/yy HH:mm:ss:SSS z}] %5p %m - %X{EndpointName} %X{BundleId} %n</Property>
</Properties>

<Appenders>
Expand Down Expand Up @@ -115,7 +114,7 @@
<RollingFile name="PUSHPUBLISH-FILE"
fileName="${PUSHPUBLISH_LOG_FILE}"
filePattern="${PUSHPUBLISH_FILENAME_PATTERN}">
<PatternLayout pattern="${MDC_MESSAGE_PATTERN}"/>
<PatternLayout pattern="${MESSAGE_PATTERN}"/>
<Policies>
<SizeBasedTriggeringPolicy size="20MB"/>
</Policies>
Expand Down Expand Up @@ -207,5 +206,11 @@
<Logger name="org.apache.velocity" level="warn" additivity="false">
<AppenderRef ref="velocity"/>
</Logger>
<Logger name="com.dotcms.api.aop" level="debug" additivity="false">
<AppenderRef ref="generic"/>
</Logger>
<Logger name="com.dotmarketing.util.ImportExportUtil" level="debug" additivity="false">
<AppenderRef ref="generic"/>
</Logger>
</Loggers>
</Configuration>
4 changes: 2 additions & 2 deletions dotCMS/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@
<listener-class>com.dotcms.listeners.RegisterMBeansListener</listener-class>
</listener>
<!-- this must be the last listener -->
<listener>
<!--listener>
<listener-class>com.dotmarketing.listeners.HibernateSessionsListener</listener-class>
</listener>
</listener-->
<!-- END DOTMARKETING LISTENERS -->


Expand Down