Skip to content

Commit

Permalink
#13424 fixes the mysql lockup issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wezell committed Jan 17, 2018
1 parent 2f20b7d commit 7be3033
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 59 deletions.
49 changes: 10 additions & 39 deletions dotCMS/src/main/java/com/dotmarketing/common/db/DotConnect.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import com.dotmarketing.util.json.JSONObject;
import static com.dotcms.util.CollectionsUtils.*;

import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.business.WrapInTransaction;

/**
* Description of the Class
*
Expand Down Expand Up @@ -1114,42 +1117,15 @@ public int executeUpdate (final String preparedStatement,
* @return int rows affected
* @throws DotDataException
*/

public int executeUpdate (final String preparedStatement, Boolean logException,
final Object... parameters) throws DotDataException {

final boolean isNewTransaction = DbConnectionFactory.startTransactionIfNeeded();
Connection connection = null;
int rowsAffected = 0;

try {
return this.executeUpdate(DbConnectionFactory.getConnection(),
preparedStatement, logException, parameters);

connection = DbConnectionFactory.getConnection();
rowsAffected = this.executeUpdate(connection,
preparedStatement, logException, parameters);

if (isNewTransaction) {
connection.commit();
}
} catch (DotDataException e) {

if (isNewTransaction) {
this.rollback(connection);
}
throw e;
} catch (Exception e) {

if (logException) {
Logger.error(DotConnect.class, e.getMessage(), e);
}
throw new DotDataException(e.getMessage(), e);
} finally {

if (isNewTransaction) {
closeQuietly(connection);
}
}

return rowsAffected;
} // executeUpdate.

protected void rollback(final Connection connection) throws DotDataException {
Expand Down Expand Up @@ -1186,29 +1162,24 @@ public int executeUpdate (final Connection connection, final String preparedStat
* @return int rows affected
* @throws DotDataException
*/
@CloseDBIfOpened
public int executeUpdate (final Connection connection, final String preparedStatementString, Boolean logException,
final Object... parameters) throws DotDataException {


PreparedStatement preparedStatement = null;
int rowsAffected = 0;

try {

preparedStatement = connection.prepareStatement(preparedStatementString);
PreparedStatement preparedStatement = connection.prepareStatement(preparedStatementString);
this.setParams(preparedStatement, parameters);
rowsAffected = preparedStatement.executeUpdate();
return preparedStatement.executeUpdate();
} catch (SQLException e) {
if (logException) {
Logger.error(DotConnect.class, e.getMessage(), e);
}
throw new DotDataException(e.getMessage(), e);
} finally {
}

closeQuietly(preparedStatement);
}

return rowsAffected;
} // executeUpdate.

private static void setTimestampWithTimezone(PreparedStatement statement, int parameterIndex, Object timestamp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.dotcms.business.CloseDB;
import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.content.elasticsearch.util.ESUtils;
import com.dotcms.enterprise.FormAJAXProxy;
import com.dotcms.enterprise.LicenseUtil;
Expand Down Expand Up @@ -383,7 +381,6 @@ private List<Map<String, String>> getContentSiblingsData(String inode) {//GIT-10
* @throws DotDataException
* @throws DotStateException
*/
@CloseDB
@SuppressWarnings("rawtypes")
public List searchContentlet(String structureInode, List<String> fields, List<String> categories, boolean showDeleted, boolean filterSystemHost, int page, int perPage, String orderBy) throws DotStateException, DotDataException, DotSecurityException {

Expand All @@ -400,7 +397,7 @@ public List searchContentlet(String structureInode, List<String> fields, List<St

return searchContentletsByUser(structureInode, fields, categories, showDeleted, filterSystemHost, false, false, page, orderBy, perPage, currentUser, sess, null, null);
}
@CloseDB

@SuppressWarnings("rawtypes")
public List searchContentlets(String structureInode, List<String> fields, List<String> categories, boolean showDeleted, boolean filterSystemHost, int page, String orderBy, String modDateFrom, String modDateTo) throws DotStateException, DotDataException, DotSecurityException {
return searchContentlets(structureInode, fields, categories, showDeleted, filterSystemHost, page, orderBy, modDateFrom, modDateTo, true);
Expand All @@ -424,14 +421,13 @@ public List searchContentlets(String structureInode, List<String> fields, List<S
return searchContentletsByUser(structureInode, fields, categories, showDeleted, filterSystemHost, false, false, page, orderBy, 0,currentUser, sess, modDateFrom, modDateTo);
}

@CloseDB
@SuppressWarnings("rawtypes")
public List searchContentlets(String structureInode, List<String> fields, List<String> categories, boolean showDeleted,
boolean filterSystemHost, boolean filterUnpublish, boolean filterLocked, int page, String orderBy, String modDateFrom,
String modDateTo) throws DotStateException, DotDataException, DotSecurityException {
return searchContentlets(structureInode,fields,categories,showDeleted,filterSystemHost,filterUnpublish,filterLocked,page,0,orderBy,modDateFrom,modDateTo);
}
@CloseDB

@SuppressWarnings("rawtypes")
public List searchContentlets(String structureInode, List<String> fields, List<String> categories, boolean showDeleted,
boolean filterSystemHost, boolean filterUnpublish, boolean filterLocked, int page, int perPage,String orderBy, String modDateFrom,
Expand Down Expand Up @@ -465,7 +461,6 @@ public List searchContentlets(String structureInode, List<String> fields, List<S
* @throws DotDataException
* @throws DotSecurityException
*/
@CloseDB
public Map<String, Object> searchFormWidget(String formStructureInode) throws DotDataException, DotSecurityException {
FormAJAXProxy fp = new FormAJAXProxy();
return fp.searchFormWidget(formStructureInode);
Expand Down Expand Up @@ -510,7 +505,6 @@ public Map<String, Object> searchFormWidget(String formStructureInode) throws Do
* @throws DotStateException
* A system error has occurred.
*/
@CloseDB
@SuppressWarnings("rawtypes")
@LogTime
public List searchContentletsByUser(String structureInode, List<String> fields, List<String> categories, boolean showDeleted, boolean filterSystemHost, boolean filterUnpublish, boolean filterLocked, int page, String orderBy,int perPage, final User currentUser, HttpSession sess,String modDateFrom, String modDateTo) throws DotStateException, DotDataException, DotSecurityException {
Expand Down Expand Up @@ -873,7 +867,7 @@ else if( fieldbcontentname.startsWith("date") ){

searchResult = new HashMap<String, String>();
Structure s = CacheLocator.getContentTypeCache().getStructureByInode(con.getStructureInode());
searchResult.put("typeVariable", s.getVelocityVarName());

for (String fieldContentlet : fieldsMapping.keySet()) {
String fieldValue = null;
if (con.getMap() != null && con.getMap().get(fieldContentlet) != null) {
Expand Down Expand Up @@ -1085,7 +1079,7 @@ else if( fieldbcontentname.startsWith("date") ){

return results;
}
@CloseDB

@NotNull
private JSONArray getAvailableWorkflowActionsJson(final User currentUser,
final Contentlet contentlet) throws DotDataException {
Expand Down Expand Up @@ -1147,7 +1141,7 @@ private JSONArray getAvailableWorkflowActionsJson(final User currentUser,
return wfActionMapList;
}

@CloseDB

public ArrayList<String[]> doSearchGlossaryTerm(String valueToComplete, String language) throws Exception {
ArrayList<String[]> list = new ArrayList<String[]>(15);

Expand Down Expand Up @@ -1180,7 +1174,6 @@ private List<LanguageKey> retrieveProperties(long langId) throws Exception {
* @param languageId if set to 0 will publish for all languages
* @return
*/
@CloseDB
public List<Map<String, Object>> publishContentlets(List<String> identifiersList, boolean isPublish, long languageId) {
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
Expand Down Expand Up @@ -1248,7 +1241,6 @@ public List<Map<String, Object>> publishContentlets(List<String> identifiersList
* @throws LanguageException
*/
//http://jira.dotmarketing.net/browse/DOTCMS-2273
@CloseDB
public Map<String,Object> saveContent(List<String> formData, boolean isAutoSave,boolean isCheckin, boolean publish) throws LanguageException, PortalException, SystemException {
Map<String,Object> contentletFormData = new HashMap<String,Object>();
Map<String,Object> callbackData = new HashMap<String,Object>();
Expand Down Expand Up @@ -1778,7 +1770,7 @@ else if(key.equals(DotContentletValidationException.VALIDATION_FAILED_BAD_CARDIN
callbackData.put("referer", referer);
return callbackData;
}
@CloseDB

//http://jira.dotmarketing.net/browse/DOTCMS-2273
public String cancelContentEdit(String workingContentletInode,String currentContentletInode,String referer,String language){

Expand Down Expand Up @@ -1819,7 +1811,7 @@ public String cancelContentEdit(String workingContentletInode,String currentCont
return referer;
}

@CloseDB

public Map<String,Object> saveContentProperties(String inode, List<String> formData, boolean isAutoSave,boolean isCheckin,boolean isPublish) throws PortalException, SystemException, DotDataException, DotSecurityException{
HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
User user = com.liferay.portal.util.PortalUtil.getUser((HttpServletRequest)req);
Expand Down Expand Up @@ -2011,15 +2003,15 @@ else if(key.equals(DotContentletValidationException.VALIDATION_FAILED_BAD_REL))
return callbackData;

}
@CloseDB

public void removeSiblingBinaryFromSession(String fieldContentlet){
//http://jira.dotmarketing.net/browse/DOTCMS-5802
if(UtilMethods.isSet(fieldContentlet)){
HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
req.getSession().removeAttribute(fieldContentlet+"-sibling");
}
}
@CloseDB

public String unrelateContent(String contentletIdentifier, String identifierToUnrelate, String relationshipInode){

// User info
Expand Down Expand Up @@ -2064,7 +2056,7 @@ public String unrelateContent(String contentletIdentifier, String identifierToU
return resultStr;
}

@CloseDB

public Map<String, String> lockContent(String contentletInode) throws DotContentletStateException, DotDataException, DotSecurityException, LanguageException{
// User info
HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
Expand Down Expand Up @@ -2095,7 +2087,7 @@ public Map<String, String> lockContent(String contentletInode) throws DotContent
}


@CloseDB

public Map<String, String> unlockContent(String contentletInode) throws DotContentletStateException, DotDataException, DotSecurityException, LanguageException{
// User info
HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
Expand All @@ -2111,7 +2103,7 @@ public Map<String, String> unlockContent(String contentletInode) throws DotConte
ret.put("lockedIdent", contentletInode );
return ret;
}
@CloseDB

public Map<String, Object> saveBinaryFileOnContent(String fileName, String fieldInode) throws DotContentletValidationException, Exception{

Map<String,Object> callbackData = new HashMap<String,Object>();
Expand Down

0 comments on commit 7be3033

Please sign in to comment.