Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dotCMS/core
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyDOTCMS committed Sep 20, 2017
2 parents 9b9b358 + effde18 commit cbca707
Show file tree
Hide file tree
Showing 144 changed files with 4,262 additions and 3,321 deletions.
4 changes: 2 additions & 2 deletions dotCMS/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 12 15:56:57 EST 2017
#Fri Sep 01 13:41:38 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class ContentResourceTest {
public void before() throws Exception{
LicenseTestUtil.getLicense();

client=RestClientBuilder.newClient();
client=RestClientBuilder.getClient();
HttpServletRequest request = ServletTestRunner.localRequest.get();
String serverName = request.getServerName();
long serverPort = request.getServerPort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RoleResourceTest {

@Before
public void init() {
client = RestClientBuilder.newClient();
client = RestClientBuilder.getClient();
request = ServletTestRunner.localRequest.get();
serverName = request.getServerName();
serverPort = request.getServerPort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class WebResourceTest {

@Before
public void init() {
client = RestClientBuilder.newClient();
client = RestClientBuilder.getClient();
request = ServletTestRunner.localRequest.get();
serverName = request.getServerName();
serverPort = request.getServerPort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public FunctionalTestConfig() {
this.defaultHost = defaultHost;
this.defaultHostId = defaultHost.getIdentifier();

client = RestClientBuilder.newClient();
client = RestClientBuilder.getClient();
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("[email protected]", "admin");
client.register(feature);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void before() throws Exception{

LicenseTestUtil.getLicense();

client=RestClientBuilder.newClient();
client=RestClientBuilder.getClient();
HttpServletRequest request = ServletTestRunner.localRequest.get();
String serverName = request.getServerName();
long serverPort = request.getServerPort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,43 @@ public void testAllFieldBuilders() throws Exception {

@Test
public void testImplTypeBuilder() throws Exception {


final String value = "testest";


for(LegacyFieldTypes types : LegacyFieldTypes.values()){
FieldBuilder.instanceOf(types.implClass());
FieldBuilder.builder(types.implClass()).id("asd");
Class clazz = types.implClass();
Field test = FieldBuilder.builder(clazz)
.name(value)
.variable(value)
.required(true)
.listed(true)
.indexed(true)
.sortOrder(1)
.contentTypeId(value)
.fixed(true)
.searchable(true)
.values(value)
.build();


assertThat("value is set", value.equals(test.values()));
assertThat("variable is set", value.equals(test.variable()));
assertThat("contentTypeId is set", value.equals(test.contentTypeId()));
assertThat("name is set", value.equals(test.name()));
Field test2 = FieldBuilder.builder(test).build();
assertThat("fieldbuilder works ",test.equals(test2));

}
}







@Test
public void testCopy() throws Exception {

Expand All @@ -110,6 +139,7 @@ public void testCopy() throws Exception {
.contentTypeId("test")
.fixed(true)
.searchable(true)
.values("testest")
.build();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public void init() throws Exception {
FactoryLocator.init();
APILocator.init();

//For these tests fire the reindex immediately
Config.setProperty("REINDEX_ON_SAVE_IN_SEPARATE_THREAD", false);

// Init other dotCMS services.
DotInitializationService.getInstance().initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ MAX_DAYS_HEARTBEAT_INACTIVE=1
ENABLE_REMOVE_INACTIVE_CLUSTER_SERVER=true
REMOVE_INACTIVE_CLUSTER_SERVER_CRON_EXPRESSION=59 59 23 * * ?

## This variable specify the maximun amount of time a server without heartbeats will be allowed in
## the cluster. The variable is composed by a unique amountUnit value, the first value it's for the
## quantity followed by the initial of the time unit, for example 30M means 30 minutes, 2D means 2 days,
##1W means one week. These are the time units values allowed/valids : M (for Minutes),H (for Hours),
##D (for Days) or W (for Weeks)
REMOVE_INACTIVE_CLUSTER_SERVER_PERIOD=2W
#DIST_INDEXATION_ENABLED=true
CACHE_DISK_SHOULD_DELETE=false

Expand Down
2 changes: 1 addition & 1 deletion dotCMS/src/main/enterprise
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.dotcms.api.system.event.dao.SystemEventsDAO;
import com.dotcms.api.system.event.dto.SystemEventDTO;
import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.business.WrapInTransaction;
import com.dotcms.concurrent.DotConcurrentFactory;
import com.dotcms.concurrent.DotSubmitter;
import com.dotcms.notifications.bean.Notification;
Expand Down Expand Up @@ -158,6 +160,12 @@ private void push(final SystemEvent systemEvent, boolean forceNewTransaction) th
+ "]: " + e.getMessage();
Logger.error(this, msg, e);
throw new DotDataException(msg, e);
} finally {

if (localTransaction) {

DbConnectionFactory.closeSilently();
}
}
}

Expand Down Expand Up @@ -193,6 +201,7 @@ public void pushAsync(final SystemEventType event, final Payload payload) throws
}

@Override
@CloseDBIfOpened
public Collection<SystemEvent> getEventsSince(final long createdDate) throws DotDataException {
if (createdDate <= 0) {
final String msg = "System Event creation date must be greater than zero.";
Expand All @@ -201,9 +210,7 @@ public Collection<SystemEvent> getEventsSince(final long createdDate) throws Dot
}
try {
final List<SystemEventDTO> result = (List<SystemEventDTO>) this.systemEventsDAO.getEventsSince(createdDate);
return this.conversionUtils.convert(result, (SystemEventDTO record) -> {
return convertSystemEventDTO(record);
});
return this.conversionUtils.convert(result, this::convertSystemEventDTO);
} catch (DotDataException e) {
final String msg = "An error occurred when retreiving system events created since: ["
+ new Date(createdDate) + "]";
Expand All @@ -213,19 +220,19 @@ public Collection<SystemEvent> getEventsSince(final long createdDate) throws Dot
}

@Override
@CloseDBIfOpened
public Collection<SystemEvent> getAll() throws DotDataException {
try {
final List<SystemEventDTO> result = (List<SystemEventDTO>) this.systemEventsDAO.getAll();
return this.conversionUtils.convert(result, (SystemEventDTO record) -> {
return convertSystemEventDTO(record);
});
return this.conversionUtils.convert(result, this::convertSystemEventDTO);
} catch (DotDataException e) {
final String msg = "An error occurred when retreiving all system events.";
Logger.error(this, msg, e);
throw new DotDataException(msg, e);
}
}

@WrapInTransaction
@Override
public void deleteEvents(final long toDate) throws DotDataException {
if (toDate <= 0) {
Expand All @@ -234,36 +241,18 @@ public void deleteEvents(final long toDate) throws DotDataException {
throw new IllegalArgumentException(msg);
}

boolean localTransaction = false;

try {

//Check for a transaction and start one if required
localTransaction = HibernateUtil.startLocalTransactionIfNeeded();

this.systemEventsDAO.deleteEvents(toDate);

//Everything ok..., committing the transaction
if ( localTransaction ) {
HibernateUtil.commitTransaction();
}
} catch (Exception e) {

try {
//On error rolling back the changes
if ( localTransaction ) {
HibernateUtil.rollbackTransaction();
}
} catch (DotHibernateException hibernateException) {
Logger.error(SystemEventsAPIImpl.class, hibernateException.getMessage(), hibernateException);
}

final String msg = "An error occurred when deleting system events created up to: [" + new Date(toDate) + "]";
Logger.error(this, msg, e);
throw new DotDataException(msg, e);
}
}

@WrapInTransaction
@Override
public void deleteEvents(final long fromDate, final long toDate) throws DotDataException {
if (fromDate <= 0) {
Expand All @@ -282,64 +271,27 @@ public void deleteEvents(final long fromDate, final long toDate) throws DotDataE
throw new IllegalArgumentException(msg);
}

boolean localTransaction = false;

try {

//Check for a transaction and start one if required
localTransaction = HibernateUtil.startLocalTransactionIfNeeded();

this.systemEventsDAO.deleteEvents(fromDate, toDate);

//Everything ok..., committing the transaction
if ( localTransaction ) {
HibernateUtil.commitTransaction();
}
} catch (Exception e) {

try {
//On error rolling back the changes
if ( localTransaction ) {
HibernateUtil.rollbackTransaction();
}
} catch (DotHibernateException hibernateException) {
Logger.error(SystemEventsAPIImpl.class, hibernateException.getMessage(), hibernateException);
}

final String msg = "An error occurred when deleting system events created from: [" + new Date(fromDate)
+ "] to: [" + new Date(toDate) + "]";
Logger.error(this, msg, e);
throw new DotDataException(msg, e);
}
}

@WrapInTransaction
@Override
public void deleteAll() throws DotDataException {

boolean localTransaction = false;

try {

//Check for a transaction and start one if required
localTransaction = HibernateUtil.startLocalTransactionIfNeeded();

this.systemEventsDAO.deleteAll();

//Everything ok..., committing the transaction
if ( localTransaction ) {
HibernateUtil.commitTransaction();
}
} catch (Exception e) {

try {
//On error rolling back the changes
if ( localTransaction ) {
HibernateUtil.rollbackTransaction();
}
} catch (DotHibernateException hibernateException) {
Logger.error(SystemEventsAPIImpl.class, hibernateException.getMessage(), hibernateException);
}

final String msg = "An error occurred when deleting all system events.";
Logger.error(this, msg, e);
throw new DotDataException(msg, e);
Expand Down Expand Up @@ -395,19 +347,15 @@ public Collection<SystemEventDTO> getEventsSince(final long fromDate) throws Dot
dc.setSQL("SELECT identifier, event_type, payload, created FROM system_event WHERE created >= ? order by created");
dc.addParam(fromDate);
final List<Map<String, Object>> systemEvents = dc.loadObjectResults();
return this.conversionUtils.convert(systemEvents, (Map<String, Object> record) -> {
return convertSystemEventRecord(record);
});
return this.conversionUtils.convert(systemEvents, this::convertSystemEventRecord);
}

@Override
public Collection<SystemEventDTO> getAll() throws DotDataException {
final DotConnect dc = new DotConnect();
dc.setSQL("SELECT identifier, event_type, payload, created FROM system_event");
final List<Map<String, Object>> systemEvents = dc.loadObjectResults();
return this.conversionUtils.convert(systemEvents, (Map<String, Object> record) -> {
return convertSystemEventRecord(record);
});
return this.conversionUtils.convert(systemEvents, this::convertSystemEventRecord);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface ServerAPI {
* @param serverId Server identifier
* @throws DotDataException
*/
void removeServerFromClusterTable(String serverId) throws DotDataException,IOException;
void removeServerFromClusterTable(String serverId) throws DotDataException;

/**
* Get the list of inactive servers
Expand Down
Loading

0 comments on commit cbca707

Please sign in to comment.