mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Part of MOB-436: Cluster-wide Locking Service: Implement DB Changes and Service
- Unit test not checked in as it requires some schema change work that has been done manually - Moved activities DAO code and renamed data services to DAOs (as per iBatis and Wikipedia, etc) - DAO code should now go into org.alfresco.repo.domain... - DAO components are bean:xyzDAO and class:XyzDAO - Entity beans are XyzEntity, etc git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13922 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.activities.post;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Activity Post DAO
|
||||
*/
|
||||
public class ActivityPostDAO
|
||||
{
|
||||
public enum STATUS { POSTED, PENDING, PROCESSED, ERROR };
|
||||
|
||||
private Long id; // internal DB-generated sequence id
|
||||
private String activityData;
|
||||
private String activityType;
|
||||
private String userId;
|
||||
private int jobTaskNode = -1;
|
||||
private String siteNetwork;
|
||||
private String appTool;
|
||||
private String status;
|
||||
private Date postDate;
|
||||
private Date lastModified; // for debug
|
||||
|
||||
// for selector
|
||||
private long minId = -1;
|
||||
private long maxId = -1;
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getJobTaskNode()
|
||||
{
|
||||
return jobTaskNode;
|
||||
}
|
||||
|
||||
public void setJobTaskNode(int jobTaskNode)
|
||||
{
|
||||
this.jobTaskNode = jobTaskNode;
|
||||
}
|
||||
|
||||
public long getMinId()
|
||||
{
|
||||
return minId;
|
||||
}
|
||||
|
||||
public void setMinId(long minId)
|
||||
{
|
||||
this.minId = minId;
|
||||
}
|
||||
|
||||
public long getMaxId()
|
||||
{
|
||||
return maxId;
|
||||
}
|
||||
|
||||
public void setMaxId(long maxId)
|
||||
{
|
||||
this.maxId = maxId;
|
||||
}
|
||||
|
||||
public String getSiteNetwork()
|
||||
{
|
||||
return siteNetwork;
|
||||
}
|
||||
|
||||
public void setSiteNetwork(String siteNetwork)
|
||||
{
|
||||
this.siteNetwork = siteNetwork;
|
||||
}
|
||||
|
||||
public String getActivityData()
|
||||
{
|
||||
return activityData;
|
||||
}
|
||||
|
||||
public void setActivityData(String activityData)
|
||||
{
|
||||
this.activityData = activityData;
|
||||
}
|
||||
|
||||
public String getActivityType()
|
||||
{
|
||||
return activityType;
|
||||
}
|
||||
|
||||
public void setActivityType(String activityType)
|
||||
{
|
||||
this.activityType = activityType;
|
||||
}
|
||||
|
||||
public Date getPostDate()
|
||||
{
|
||||
return postDate;
|
||||
}
|
||||
|
||||
public void setPostDate(Date postDate)
|
||||
{
|
||||
this.postDate = postDate;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getLastModified()
|
||||
{
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
public void setLastModified(Date lastModified)
|
||||
{
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
|
||||
public String getAppTool()
|
||||
{
|
||||
return appTool;
|
||||
}
|
||||
|
||||
public void setAppTool(String appTool)
|
||||
{
|
||||
this.appTool = appTool;
|
||||
}
|
||||
|
||||
// for debug only
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("ActivityPost\n[");
|
||||
sb.append("id=").append(id).append(",");
|
||||
sb.append("status=").append(status).append(",");
|
||||
sb.append("postDate=").append(postDate).append(",");
|
||||
sb.append("userId=").append(userId).append(",");
|
||||
sb.append("siteNetwork=").append(siteNetwork).append(",");
|
||||
sb.append("appTool=").append(appTool).append(",");
|
||||
sb.append("type=").append(activityType).append(",");
|
||||
sb.append("jobTaskNode=").append(jobTaskNode).append(",");
|
||||
sb.append("data=\n").append(activityData).append("\n]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.activities.post;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.activities.ibatis.ActivityDaoService;
|
||||
|
||||
/**
|
||||
* Interface for activity post DAO service
|
||||
*/
|
||||
public interface ActivityPostDaoService extends ActivityDaoService
|
||||
{
|
||||
public List<ActivityPostDAO> selectPosts(ActivityPostDAO activityPost) throws SQLException;
|
||||
|
||||
public Long getMaxActivitySeq() throws SQLException;
|
||||
|
||||
public Long getMinActivitySeq() throws SQLException;
|
||||
|
||||
public Integer getMaxNodeHash() throws SQLException;
|
||||
|
||||
public int deletePosts(Date keepDate, ActivityPostDAO.STATUS status) throws SQLException;
|
||||
|
||||
public long insertPost(ActivityPostDAO activityPost) throws SQLException;
|
||||
|
||||
public int updatePost(long id, String network, String activityData, ActivityPostDAO.STATUS status) throws SQLException;
|
||||
|
||||
public int updatePostStatus(long id, ActivityPostDAO.STATUS status) throws SQLException;
|
||||
}
|
@@ -28,8 +28,8 @@ import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.activities.post.ActivityPostDAO;
|
||||
import org.alfresco.repo.activities.post.ActivityPostDaoService;
|
||||
import org.alfresco.repo.domain.activities.ActivityPostDAO;
|
||||
import org.alfresco.repo.domain.activities.ActivityPostEntity;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.alfresco.util.VmShutdownListener;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -47,11 +47,11 @@ public class PostCleaner
|
||||
|
||||
private int maxAgeMins = 0;
|
||||
|
||||
private ActivityPostDaoService postDaoService;
|
||||
private ActivityPostDAO postDAO;
|
||||
|
||||
public void setPostDaoService(ActivityPostDaoService postDaoService)
|
||||
public void setPostDAO(ActivityPostDAO postDAO)
|
||||
{
|
||||
this.postDaoService = postDaoService;
|
||||
this.postDAO = postDAO;
|
||||
}
|
||||
|
||||
public void setMaxAgeMins(int mins)
|
||||
@@ -64,7 +64,7 @@ public class PostCleaner
|
||||
*/
|
||||
private void checkProperties()
|
||||
{
|
||||
PropertyCheck.mandatory(this, "postDaoService", postDaoService);
|
||||
PropertyCheck.mandatory(this, "postDAO", postDAO);
|
||||
|
||||
// check the max age
|
||||
if (maxAgeMins <= 0)
|
||||
@@ -83,7 +83,7 @@ public class PostCleaner
|
||||
Date keepDate = new Date(keepTimeOffset);
|
||||
|
||||
// clean old entries - PROCESSED - does not clean POSTED or PENDING, which will need to be done manually, if stuck
|
||||
int deletedCount = postDaoService.deletePosts(keepDate, ActivityPostDAO.STATUS.PROCESSED);
|
||||
int deletedCount = postDAO.deletePosts(keepDate, ActivityPostEntity.STATUS.PROCESSED);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
|
@@ -29,8 +29,8 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.activities.post.ActivityPostDAO;
|
||||
import org.alfresco.repo.activities.post.ActivityPostDaoService;
|
||||
import org.alfresco.repo.domain.activities.ActivityPostDAO;
|
||||
import org.alfresco.repo.domain.activities.ActivityPostEntity;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
@@ -61,16 +61,16 @@ public class PostLookup
|
||||
|
||||
private static VmShutdownListener vmShutdownListener = new VmShutdownListener(PostLookup.class.getName());
|
||||
|
||||
private ActivityPostDaoService postDaoService;
|
||||
private ActivityPostDAO postDAO;
|
||||
private NodeService nodeService;
|
||||
private PermissionService permissionService;
|
||||
private TransactionService transactionService;
|
||||
private PersonService personService;
|
||||
private TenantService tenantService;
|
||||
|
||||
public void setPostDaoService(ActivityPostDaoService postDaoService)
|
||||
public void setPostDAO(ActivityPostDAO postDAO)
|
||||
{
|
||||
this.postDaoService = postDaoService;
|
||||
this.postDAO = postDAO;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
@@ -103,7 +103,7 @@ public class PostLookup
|
||||
*/
|
||||
private void checkProperties()
|
||||
{
|
||||
PropertyCheck.mandatory(this, "postDaoService", postDaoService);
|
||||
PropertyCheck.mandatory(this, "postDAO", postDAO);
|
||||
PropertyCheck.mandatory(this, "nodeService", nodeService);
|
||||
PropertyCheck.mandatory(this, "permissionService", permissionService);
|
||||
PropertyCheck.mandatory(this, "transactionService", transactionService);
|
||||
@@ -116,21 +116,21 @@ public class PostLookup
|
||||
checkProperties();
|
||||
try
|
||||
{
|
||||
ActivityPostDAO params = new ActivityPostDAO();
|
||||
params.setStatus(ActivityPostDAO.STATUS.PENDING.toString());
|
||||
ActivityPostEntity params = new ActivityPostEntity();
|
||||
params.setStatus(ActivityPostEntity.STATUS.PENDING.toString());
|
||||
|
||||
List<ActivityPostDAO> activityPosts = postDaoService.selectPosts(params);
|
||||
List<ActivityPostEntity> activityPosts = postDAO.selectPosts(params);
|
||||
|
||||
if (activityPosts.size() > 0)
|
||||
{
|
||||
logger.info("Update: " + activityPosts.size() + " activity posts");
|
||||
}
|
||||
|
||||
for (final ActivityPostDAO activityPost : activityPosts)
|
||||
for (final ActivityPostEntity activityPost : activityPosts)
|
||||
{
|
||||
try
|
||||
{
|
||||
postDaoService.startTransaction();
|
||||
postDAO.startTransaction();
|
||||
|
||||
final JSONObject jo = new JSONObject(new JSONTokener(activityPost.getActivityData()));
|
||||
final String postUserId = activityPost.getUserId();
|
||||
@@ -167,10 +167,10 @@ public class PostLookup
|
||||
|
||||
activityPost.setLastModified(new Date());
|
||||
|
||||
postDaoService.updatePost(activityPost.getId(), activityPost.getSiteNetwork(), activityPost.getActivityData(), ActivityPostDAO.STATUS.POSTED);
|
||||
postDAO.updatePost(activityPost.getId(), activityPost.getSiteNetwork(), activityPost.getActivityData(), ActivityPostEntity.STATUS.POSTED);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
activityPost.setStatus(ActivityPostDAO.STATUS.POSTED.toString()); // for debug output
|
||||
activityPost.setStatus(ActivityPostEntity.STATUS.POSTED.toString()); // for debug output
|
||||
logger.debug("Updated: " + activityPost);
|
||||
}
|
||||
|
||||
@@ -178,15 +178,15 @@ public class PostLookup
|
||||
}
|
||||
}, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantDomain));
|
||||
|
||||
postDaoService.commitTransaction();
|
||||
postDAO.commitTransaction();
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
// log error, but consume exception (skip this post)
|
||||
logger.error("Skipping activity post " + activityPost.getId() + ": " + e);
|
||||
postDaoService.updatePostStatus(activityPost.getId(), ActivityPostDAO.STATUS.ERROR);
|
||||
postDAO.updatePostStatus(activityPost.getId(), ActivityPostEntity.STATUS.ERROR);
|
||||
|
||||
postDaoService.commitTransaction();
|
||||
postDAO.commitTransaction();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@@ -195,7 +195,7 @@ public class PostLookup
|
||||
}
|
||||
finally
|
||||
{
|
||||
postDaoService.endTransaction();
|
||||
postDAO.endTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user