mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Activity Service
- add PostgreSQL support - add generic schema generation, plus extras (indexes, sequences, workaround for Derby) - fix feed cleaner keepDate, also increase default from 14 to 31 days - fix Oracle-specifc issue (when retrieving site feed) - reformatting sqlMap config files - improve exception handling Add Derby warning message git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9649 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
<bean id="feedCleaner" class="org.alfresco.repo.activities.feed.cleanup.FeedCleaner">
|
||||
<property name="feedDaoService" ref="feedDaoService"/>
|
||||
<property name="maxAgeMins">
|
||||
<value>20160</value> <!-- 20160 mins = 2 weeks -->
|
||||
<value>44640</value> <!-- 44640 mins = 31 days -->
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
@@ -48,7 +48,7 @@
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, post_user_id as postUserId, site_network as siteNetwork, post_date postDate
|
||||
from alf_activity_feed
|
||||
where feed_user_id = ''
|
||||
where (feed_user_id = '' or feed_user_id is null)
|
||||
and site_network = #siteNetwork#
|
||||
and activity_format = #activitySummaryFormat#
|
||||
order by post_date desc
|
||||
|
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!DOCTYPE sqlMap
|
||||
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
|
||||
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
|
||||
|
||||
<sqlMap namespace="ActivityFeed">
|
||||
|
||||
<typeAlias alias="ActivityFeed" type="org.alfresco.repo.activities.feed.ActivityFeedDAO"/>
|
||||
|
||||
<resultMap id="ActivityFeedResult" class="ActivityFeed">
|
||||
<result property="id" column="ID"/>
|
||||
<result property="feedUserId" column="FEED_USER_ID"/>
|
||||
<result property="postUserId" column="POST_USER_ID"/>
|
||||
<result property="postDate" column="POST_DATE"/>
|
||||
<result property="postId" column="POST_ID"/> <!-- not an explicit FK constraint, can dangle if and when activity post is deleted -->
|
||||
<result property="siteNetwork" column="SITE_NETWORK"/>
|
||||
<result property="activityType" column="ACTIVITY_TYPE"/>
|
||||
<result property="activitySummary" column="ACTIVITY_SUMMARY"/>
|
||||
<result property="activitySummaryFormat" column="ACTIVITY_FORMAT"/>
|
||||
<result property="feedDate" column="FEED_DATE"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="select.activity.feed.for.feeduser" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, feed_user_id as feedUserId, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
where feed_user_id = #feedUserId#
|
||||
and post_user_id != #feedUserId#
|
||||
and activity_format = #activitySummaryFormat#
|
||||
order by post_date desc
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="select.activity.feed.for.feeduser.and.site" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, feed_user_id as feedUserId, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
where feed_user_id = #feedUserId#
|
||||
and post_user_id != #feedUserId#
|
||||
and site_network = #siteNetwork#
|
||||
and activity_format = #activitySummaryFormat#
|
||||
order by post_date desc
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="select.activity.feed.for.site" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
where feed_user_id = ''
|
||||
and site_network = #siteNetwork#
|
||||
and activity_format = #activitySummaryFormat#
|
||||
order by post_date desc
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<insert id="insert.activity.feed" parameterClass="ActivityFeed">
|
||||
|
||||
<selectKey keyProperty="id" resultClass="long">
|
||||
select nextVal('alf_activity_feed_seq')
|
||||
</selectKey>
|
||||
|
||||
insert into alf_activity_feed (id, activity_type, activity_summary, activity_format, feed_user_id, post_user_id, post_date, post_id, site_network, app_tool, feed_date)
|
||||
values (#id#, #activityType#, #activitySummary#, #activitySummaryFormat#, #feedUserId#, #postUserId#, #postDate#, #postId#, #siteNetwork#, #appTool#, #feedDate#)
|
||||
|
||||
</insert>
|
||||
|
||||
<delete id="delete.activity.feed.entries.older.than.date" parameterClass="Date">
|
||||
<![CDATA[
|
||||
delete from alf_activity_feed where post_date < #keepdate#
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
</sqlMap>
|
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!DOCTYPE sqlMap
|
||||
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
|
||||
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
|
||||
|
||||
<sqlMap namespace="ActivityFeedControl">
|
||||
|
||||
<typeAlias alias="FeedControl" type="org.alfresco.repo.activities.feed.control.FeedControlDAO"/>
|
||||
|
||||
<resultMap id="FeedControlResult" class="FeedControl">
|
||||
<result property="id" column="ID"/>
|
||||
<result property="feedUserId" column="FEED_USER_ID"/>
|
||||
<result property="siteNetwork" column="SITE_NETWORK"/>
|
||||
<result property="appTool" column="APP_TOOL"/>
|
||||
<result property="lastModified" column="LAST_MODIFIED"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="select.activity.feedcontrols.for.user" parameterClass="FeedControl" resultClass="FeedControl">
|
||||
<![CDATA[
|
||||
select id as id, feed_user_id as feedUserId, site_network as siteNetwork, app_tool as appTool
|
||||
from alf_activity_feed_control
|
||||
where feed_user_id = #feedUserId#
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="select.activity.feedcontrol" parameterClass="FeedControl" resultClass="long">
|
||||
<![CDATA[
|
||||
select id as id
|
||||
from alf_activity_feed_control
|
||||
where feed_user_id = #feedUserId#
|
||||
and site_network = #siteNetwork#
|
||||
and app_tool = #appTool#
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<insert id="insert.activity.feedcontrol" parameterClass="FeedControl">
|
||||
|
||||
<selectKey keyProperty="id" resultClass="long">
|
||||
select nextVal('alf_activity_feed_control_seq')
|
||||
</selectKey>
|
||||
|
||||
insert into alf_activity_feed_control (id, feed_user_id, site_network, app_tool, last_modified)
|
||||
values (#id#, #feedUserId#, #siteNetwork#, #appTool#, #lastModified#)
|
||||
|
||||
</insert>
|
||||
|
||||
<delete id="delete.activity.feedcontrol" parameterClass="FeedControl">
|
||||
<![CDATA[
|
||||
delete from alf_activity_feed_control
|
||||
where feed_user_id = #feedUserId#
|
||||
and site_network = #siteNetwork#
|
||||
and app_tool = #appTool#
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
</sqlMap>
|
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!DOCTYPE sqlMap
|
||||
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
|
||||
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
|
||||
|
||||
<sqlMap namespace="ActivityPost">
|
||||
|
||||
<typeAlias alias="ActivityPost" type="org.alfresco.repo.activities.post.ActivityPostDAO"/>
|
||||
|
||||
<resultMap id="ActivityPostResult" class="ActivityPost">
|
||||
<result property="id" column="SEQUENCE_ID"/>
|
||||
<result property="activityData" column="ACTIVITY_DATA"/>
|
||||
<result property="activityType" column="ACTIVITY_TYPE"/>
|
||||
<result property="userId" column="POST_USER_ID"/>
|
||||
<result property="postDate" column="POST_DATE"/>
|
||||
<result property="jobTaskNode" column="JOB_TASK_NODE"/>
|
||||
<result property="siteNetwork" column="SITE_NETWORK"/>
|
||||
<result property="appTool" column="APP_TOOL"/>
|
||||
<result property="status" column="STATUS"/>
|
||||
<result property="lastModified" column="LAST_MODIFIED"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="select.activity.posts" parameterClass="ActivityPost" resultClass="ActivityPost">
|
||||
<![CDATA[
|
||||
select
|
||||
sequence_id as id,
|
||||
activity_data as activityData,
|
||||
activity_type as activityType,
|
||||
post_user_id as userId,
|
||||
post_date as postDate,
|
||||
job_task_node as jobTaskNode,
|
||||
site_network as siteNetwork,
|
||||
app_tool as appTool,
|
||||
status as status
|
||||
from
|
||||
alf_activity_post
|
||||
where
|
||||
job_task_node = #jobTaskNode# and
|
||||
sequence_id >= #minId# and
|
||||
sequence_id <= #maxId# and
|
||||
status = #status#
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="select.activity.posts.by.status.only" parameterClass="ActivityPost" resultClass="ActivityPost">
|
||||
<![CDATA[
|
||||
select
|
||||
sequence_id as id,
|
||||
activity_data as activityData,
|
||||
activity_type as activityType,
|
||||
post_user_id as userId,
|
||||
post_date as postDate,
|
||||
job_task_node as jobTaskNode,
|
||||
site_network as siteNetwork,
|
||||
app_tool as appTool,
|
||||
status as status
|
||||
from
|
||||
alf_activity_post
|
||||
where
|
||||
status = #status#
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="select.activity.post.max.seq" resultClass="long">
|
||||
select max(sequence_id) as maxId
|
||||
from alf_activity_post
|
||||
where status = 'POSTED'
|
||||
</select>
|
||||
|
||||
<select id="select.activity.post.min.seq" resultClass="long">
|
||||
select min(sequence_id) as minId
|
||||
from alf_activity_post
|
||||
where status = 'POSTED'
|
||||
</select>
|
||||
|
||||
<select id="select.activity.post.max.jobtasknode" resultClass="int">
|
||||
select max(job_task_node) as maxJobTaskNode
|
||||
from alf_activity_post
|
||||
where status = 'POSTED'
|
||||
</select>
|
||||
|
||||
<insert id="insert.activity.post" parameterClass="ActivityPost">
|
||||
|
||||
<selectKey keyProperty="id" resultClass="long">
|
||||
select nextVal('alf_activity_post_seq')
|
||||
</selectKey>
|
||||
|
||||
insert into alf_activity_post (sequence_id, status, activity_data, post_user_id, post_date, activity_type, site_network, app_tool, job_task_node, last_modified)
|
||||
values (#id#, #status#, #activityData#, #userId#, #postDate#, #activityType#, #siteNetwork#, #appTool#, #jobTaskNode#, #lastModified#)
|
||||
|
||||
</insert>
|
||||
|
||||
<delete id="delete.activity.posts.older.than.date" parameterClass="ActivityPost">
|
||||
<![CDATA[
|
||||
delete from alf_activity_post
|
||||
where post_date < #postDate#
|
||||
and status = #status#
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<update id="update.activity.post.data" parameterClass="ActivityPost">
|
||||
update alf_activity_post set status = #status#, activity_data=#activityData#, site_network=#siteNetwork#, last_modified=#lastModified#
|
||||
where sequence_id = #id#
|
||||
and status != #status#
|
||||
</update>
|
||||
|
||||
<update id="update.activity.post.status" parameterClass="ActivityPost">
|
||||
update alf_activity_post set status = #status#, last_modified=#lastModified#
|
||||
where sequence_id = #id#
|
||||
and status != #status#
|
||||
</update>
|
||||
|
||||
</sqlMap>
|
@@ -49,7 +49,7 @@
|
||||
<list>
|
||||
<value>classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/AlfrescoPostCreate-2.2-MappedFKIndexes.sql</value>
|
||||
<value>classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/AlfrescoPostCreate-2.2-Extra.sql</value>
|
||||
<value>classpath:alfresco/dbscripts/create/3.0/${db.script.dialect}/create-activities-tables.sql</value>
|
||||
<value>classpath:alfresco/dbscripts/create/3.0/${db.script.dialect}/create-activities-extras.sql</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="validateUpdateScriptPatches">
|
||||
@@ -66,7 +66,7 @@
|
||||
<ref bean="patch.db-V2.2-1-DropIndexesAndConstraints" />
|
||||
<ref bean="patch.db-V2.2-2-MoveQNames" />
|
||||
<ref bean="patch.db-V2.2-3-PropTypes" />
|
||||
<ref bean="patch.db-V3.0-0-CreateActivitiesTables" />
|
||||
<ref bean="patch.db-V3.0-0-CreateActivitiesExtras" />
|
||||
</list>
|
||||
</property>
|
||||
<property name="postUpdateScriptPatches">
|
||||
|
@@ -1,12 +1,13 @@
|
||||
--
|
||||
-- Title: Activities Schema
|
||||
-- Title: Activities Schema - Extras (Indexes, Identity)
|
||||
-- Database: Derby
|
||||
-- Since: V3.0.0 Schema
|
||||
--
|
||||
-- Note: The Activities schema is NOT managed by Hibernate
|
||||
--
|
||||
|
||||
-- Activity Post
|
||||
|
||||
-- Hibernate workaround - to add identity column
|
||||
DROP TABLE alf_activity_post;
|
||||
CREATE TABLE alf_activity_post (
|
||||
sequence_id bigint generated by default as identity (start with 1),
|
||||
post_date timestamp NOT NULL,
|
||||
@@ -21,10 +22,13 @@ CREATE TABLE alf_activity_post (
|
||||
primary key (sequence_id)
|
||||
);
|
||||
|
||||
CREATE INDEX jobtasknode_idx on alf_activity_post(job_task_node);
|
||||
CREATE INDEX status_idx on alf_activity_post(status);
|
||||
CREATE INDEX post_jobtasknode_idx ON alf_activity_post(job_task_node);
|
||||
CREATE INDEX post_status_idx ON alf_activity_post(status);
|
||||
|
||||
-- Activity Feed
|
||||
|
||||
-- Hibernate workaround - to add identity column
|
||||
DROP TABLE alf_activity_feed;
|
||||
CREATE TABLE alf_activity_feed (
|
||||
id bigint generated by default as identity (start with 1),
|
||||
post_id bigint default NULL,
|
||||
@@ -40,13 +44,16 @@ CREATE TABLE alf_activity_feed (
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
CREATE INDEX postdate_idx ON alf_activity_feed(post_date);
|
||||
CREATE INDEX feeduserid_idx ON alf_activity_feed(feed_user_id);
|
||||
CREATE INDEX postuserid_idx ON alf_activity_feed(post_user_id);
|
||||
CREATE INDEX sitenetwork_idx ON alf_activity_feed(site_network);
|
||||
CREATE INDEX activityformat_idx ON alf_activity_feed(activity_format);
|
||||
CREATE INDEX feed_postdate_idx ON alf_activity_feed(post_date);
|
||||
CREATE INDEX feed_postuserid_idx ON alf_activity_feed(post_user_id);
|
||||
CREATE INDEX feed_feeduserid_idx ON alf_activity_feed(feed_user_id);
|
||||
CREATE INDEX feed_sitenetwork_idx ON alf_activity_feed(site_network);
|
||||
CREATE INDEX feed_activityformat_idx ON alf_activity_feed(activity_format);
|
||||
|
||||
-- Activity Feed Control
|
||||
|
||||
-- Hibernate workaround - to add identity column
|
||||
DROP TABLE alf_activity_feed_control;
|
||||
CREATE TABLE alf_activity_feed_control (
|
||||
id bigint generated by default as identity (start with 1),
|
||||
feed_user_id varchar(255) NOT NULL,
|
||||
@@ -56,16 +63,17 @@ CREATE TABLE alf_activity_feed_control (
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
CREATE INDEX feedcontroluserid_idx ON alf_activity_feed_control(feed_user_id);
|
||||
CREATE INDEX feedctrl_feeduserid_idx ON alf_activity_feed_control(feed_user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.0-0-CreateActivitiesTables';
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.0-0-CreateActivitiesExtras';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.0-0-CreateActivitiesTables', 'Executed script create V3.0: Created activities tables',
|
||||
'patch.db-V3.0-0-CreateActivitiesExtras', 'Executed script create V3.0: Created activities extras',
|
||||
0, 125, -1, 126, CURRENT_TIMESTAMP, 'UNKNOWN', 1, 1, 'Script completed'
|
||||
);
|
@@ -0,0 +1,28 @@
|
||||
--
|
||||
-- Title: Activities Schema - Extras (Indexes)
|
||||
-- Database: Generic
|
||||
-- Since: V3.0.0 Schema
|
||||
--
|
||||
|
||||
CREATE INDEX post_jobtasknode_idx ON alf_activity_post(job_task_node);
|
||||
CREATE INDEX post_status_idx ON alf_activity_post(status);
|
||||
|
||||
CREATE INDEX feed_postdate_idx ON alf_activity_feed(post_date);
|
||||
CREATE INDEX feed_postuserid_idx ON alf_activity_feed(post_user_id);
|
||||
CREATE INDEX feed_feeduserid_idx ON alf_activity_feed(feed_user_id);
|
||||
CREATE INDEX feed_sitenetwork_idx ON alf_activity_feed(site_network);
|
||||
CREATE INDEX feed_activityformat_idx ON alf_activity_feed(activity_format);
|
||||
|
||||
CREATE INDEX feedctrl_feeduserid_idx ON alf_activity_feed_control(feed_user_id);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.0-0-CreateActivitiesExtras';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.0-0-CreateActivitiesExtras', 'Executed script create V3.0: Created activities extras',
|
||||
0, 125, -1, 126, null, 'UNKNOWN', 1, 1, 'Script completed'
|
||||
);
|
@@ -1,71 +0,0 @@
|
||||
--
|
||||
-- Title: Activities Schema
|
||||
-- Database: HSQL
|
||||
-- Since: V3.0.0 Schema
|
||||
--
|
||||
-- Note: The Activities schema is NOT managed by Hibernate
|
||||
--
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_post (
|
||||
sequence_id bigint generated by default as identity (start with 1),
|
||||
post_date timestamp NOT NULL,
|
||||
status varchar(10) NOT NULL,
|
||||
activity_data varchar(4000) NOT NULL,
|
||||
post_user_id varchar(255) NOT NULL,
|
||||
job_task_node integer NOT NULL,
|
||||
site_network varchar(255) default NULL,
|
||||
app_tool varchar(36) default NULL,
|
||||
activity_type varchar(255) NOT NULL,
|
||||
last_modified timestamp NOT NULL,
|
||||
primary key (sequence_id)
|
||||
);
|
||||
|
||||
CREATE INDEX jobtasknode_idx on alf_activity_post(job_task_node);
|
||||
CREATE INDEX status_idx on alf_activity_post(status);
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_feed (
|
||||
id bigint generated by default as identity (start with 1),
|
||||
post_id bigint default NULL,
|
||||
post_date timestamp NOT NULL,
|
||||
activity_summary varchar(4000) default NULL,
|
||||
feed_user_id varchar(255) NOT NULL,
|
||||
activity_type varchar(255) NOT NULL,
|
||||
activity_format varchar(10) default NULL,
|
||||
site_network varchar(255) default NULL,
|
||||
app_tool varchar(36) default NULL,
|
||||
post_user_id varchar(255) NOT NULL,
|
||||
feed_date timestamp NOT NULL,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
CREATE INDEX postdate_idx ON alf_activity_feed(post_date);
|
||||
CREATE INDEX feeduserid_idx ON alf_activity_feed(feed_user_id);
|
||||
CREATE INDEX postuserid_idx ON alf_activity_feed(post_user_id);
|
||||
CREATE INDEX sitenetwork_idx ON alf_activity_feed(site_network);
|
||||
CREATE INDEX activityformat_idx ON alf_activity_feed(activity_format);
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_feed_control (
|
||||
id bigint generated by default as identity (start with 1),
|
||||
feed_user_id varchar(255) NOT NULL,
|
||||
site_network varchar(255) NOT NULL,
|
||||
app_tool varchar(36) default NULL,
|
||||
last_modified timestamp NOT NULL,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
CREATE INDEX feedcontroluserid_idx ON alf_activity_feed_control(feed_user_id);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.0-0-CreateActivitiesTables';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.0-0-CreateActivitiesTables', 'Executed script create V3.0: Created activities tables',
|
||||
0, 125, -1, 126, NOW, 'UNKNOWN', 1, 1, 'Script completed'
|
||||
);
|
@@ -1,68 +0,0 @@
|
||||
--
|
||||
-- Title: Activities Schema
|
||||
-- Database: MySQL
|
||||
-- Since: V3.0.0 Schema
|
||||
--
|
||||
-- Note: The Activities schema is NOT managed by Hibernate
|
||||
--
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_post (
|
||||
sequence_id bigint NOT NULL auto_increment,
|
||||
post_date timestamp NOT NULL,
|
||||
status varchar(10) NOT NULL,
|
||||
activity_data varchar(4000) NOT NULL,
|
||||
post_user_id varchar(255) NOT NULL,
|
||||
job_task_node int(11) NOT NULL,
|
||||
site_network varchar(255) default NULL,
|
||||
app_tool varchar(36) default NULL,
|
||||
activity_type varchar(255) NOT NULL,
|
||||
last_modified timestamp NOT NULL,
|
||||
PRIMARY KEY (sequence_id),
|
||||
KEY jobtasknode_idx (job_task_node),
|
||||
KEY status_idx (status)
|
||||
) type=InnoDB;
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_feed (
|
||||
id bigint NOT NULL auto_increment,
|
||||
post_id bigint default NULL,
|
||||
post_date timestamp NOT NULL,
|
||||
activity_summary varchar(4000) default NULL,
|
||||
feed_user_id varchar(255) NOT NULL,
|
||||
activity_type varchar(255) NOT NULL,
|
||||
activity_format varchar(10) default NULL,
|
||||
site_network varchar(255) default NULL,
|
||||
app_tool varchar(36) default NULL,
|
||||
post_user_id varchar(255) NOT NULL,
|
||||
feed_date timestamp NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY postdate_idx (post_date),
|
||||
KEY feeduserid_idx (feed_user_id),
|
||||
KEY postuserid_idx (post_user_id),
|
||||
KEY sitenetwork_idx (site_network),
|
||||
KEY activityformat_idx (activity_format)
|
||||
) type=InnoDB;
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_feed_control (
|
||||
id bigint NOT NULL auto_increment,
|
||||
feed_user_id varchar(255) NOT NULL,
|
||||
site_network varchar(255) NOT NULL,
|
||||
app_tool varchar(36) NOT NULL,
|
||||
last_modified timestamp NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY feedcontroluserid_idx (feed_user_id)
|
||||
) type=InnoDB;
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.0-0-CreateActivitiesTables';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.0-0-CreateActivitiesTables', 'Executed script create V3.0: Created activities tables',
|
||||
0, 125, -1, 126, now(), 'UNKNOWN', 1, 1, 'Script completed'
|
||||
);
|
@@ -0,0 +1,38 @@
|
||||
--
|
||||
-- Title: Activities Schema - Extras (Indexes, Sequences)
|
||||
-- Database: Oracle
|
||||
-- Since: V3.0.0 Schema
|
||||
--
|
||||
|
||||
-- Activity Post
|
||||
CREATE SEQUENCE alf_activity_post_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX post_jobtasknode_idx ON alf_activity_post(job_task_node);
|
||||
CREATE INDEX post_status_idx ON alf_activity_post(status);
|
||||
|
||||
-- Activity Feed
|
||||
CREATE SEQUENCE alf_activity_feed_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX feed_postdate_idx ON alf_activity_feed(post_date);
|
||||
CREATE INDEX feed_postuserid_idx ON alf_activity_feed(post_user_id);
|
||||
CREATE INDEX feed_feeduserid_idx ON alf_activity_feed(feed_user_id);
|
||||
CREATE INDEX feed_sitenetwork_idx ON alf_activity_feed(site_network);
|
||||
CREATE INDEX feed_activityformat_idx ON alf_activity_feed(activity_format);
|
||||
|
||||
-- Activity Feed Control
|
||||
CREATE SEQUENCE alf_activity_feed_control_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX feedctrl_feeduserid_idx ON alf_activity_feed_control(feed_user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.0-0-CreateActivitiesExtras';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.0-0-CreateActivitiesExtras', 'Executed script create V3.0: Created activities extras',
|
||||
0, 125, -1, 126, SYSDATE, 'UNKNOWN', 1, 1, 'Script completed'
|
||||
);
|
@@ -1,77 +0,0 @@
|
||||
--
|
||||
-- Title: Activities Schema
|
||||
-- Database: Oracle
|
||||
-- Since: V3.0.0 Schema
|
||||
--
|
||||
-- Note: The Activities schema is NOT managed by Hibernate
|
||||
--
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_post (
|
||||
sequence_id number(19,0) NOT NULL,
|
||||
post_date timestamp NOT NULL,
|
||||
status varchar2(10) NOT NULL,
|
||||
activity_data varchar2(4000) NOT NULL,
|
||||
post_user_id varchar2(255) NOT NULL,
|
||||
job_task_node number(19,0) NOT NULL,
|
||||
site_network varchar2(255) default NULL,
|
||||
app_tool varchar2(36) default NULL,
|
||||
activity_type varchar2(255) NOT NULL,
|
||||
last_modified timestamp NOT NULL,
|
||||
primary key (sequence_id)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE alf_activity_post_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX jobtasknode_idx on alf_activity_post(job_task_node);
|
||||
CREATE INDEX status_idx on alf_activity_post(status);
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_feed (
|
||||
id number(19,0) NOT NULL,
|
||||
post_id number(19,0) default NULL,
|
||||
post_date timestamp NOT NULL,
|
||||
activity_summary varchar2(4000) default NULL,
|
||||
feed_user_id varchar2(255) default NULL,
|
||||
activity_type varchar2(255) NOT NULL,
|
||||
activity_format varchar2(10) default NULL,
|
||||
site_network varchar2(255) default NULL,
|
||||
app_tool varchar2(36) default NULL,
|
||||
post_user_id varchar2(255) NOT NULL,
|
||||
feed_date timestamp NOT NULL,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE alf_activity_feed_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX postdate_idx ON alf_activity_feed(post_date);
|
||||
CREATE INDEX feeduserid_idx ON alf_activity_feed(feed_user_id);
|
||||
CREATE INDEX postuserid_idx ON alf_activity_feed(post_user_id);
|
||||
CREATE INDEX sitenetwork_idx ON alf_activity_feed(site_network);
|
||||
CREATE INDEX activityformat_idx ON alf_activity_feed(activity_format);
|
||||
|
||||
|
||||
CREATE TABLE alf_activity_feed_control (
|
||||
id number(19,0) NOT NULL,
|
||||
feed_user_id varchar2(255) NOT NULL,
|
||||
site_network varchar2(255) NOT NULL,
|
||||
app_tool varchar2(36) NOT NULL,
|
||||
last_modified timestamp NOT NULL,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE alf_activity_feed_control_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX feedcontroluserid_idx ON alf_activity_feed_control(feed_user_id);
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.0-0-CreateActivitiesTables';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.0-0-CreateActivitiesTables', 'Executed script create V3.0: Created activities tables',
|
||||
0, 125, -1, 126, SYSDATE, 'UNKNOWN', 1, 1, 'Script completed'
|
||||
);
|
@@ -0,0 +1,37 @@
|
||||
--
|
||||
-- Title: Activities Schema - Extras (Indexes, Sequences)
|
||||
-- Database: PostgreSQL
|
||||
-- Since: V3.0.0 Schema
|
||||
--
|
||||
|
||||
-- Activity Post
|
||||
CREATE SEQUENCE alf_activity_post_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE INDEX post_jobtasknode_idx ON alf_activity_post(job_task_node);
|
||||
CREATE INDEX post_status_idx ON alf_activity_post(status);
|
||||
|
||||
-- Activity Feed
|
||||
CREATE SEQUENCE alf_activity_feed_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX feed_postdate_idx ON alf_activity_feed(post_date);
|
||||
CREATE INDEX feed_postuserid_idx ON alf_activity_feed(post_user_id);
|
||||
CREATE INDEX feed_feeduserid_idx ON alf_activity_feed(feed_user_id);
|
||||
CREATE INDEX feed_sitenetwork_idx ON alf_activity_feed(site_network);
|
||||
CREATE INDEX feed_activityformat_idx ON alf_activity_feed(activity_format);
|
||||
|
||||
-- Activity Feed Control
|
||||
CREATE SEQUENCE alf_activity_feed_control_seq START WITH 1 INCREMENT BY 1;
|
||||
|
||||
CREATE INDEX feedctrl_feeduserid_idx ON alf_activity_feed_control(feed_user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.0-0-CreateActivitiesExtras';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V3.0-0-CreateActivitiesExtras', 'Executed script create V3.0: Created activities extras',
|
||||
0, 125, -1, 126, null, 'UNKNOWN', TRUE, TRUE, 'Script completed'
|
||||
);
|
@@ -10,6 +10,7 @@ schema.update.msg.executing_statement= Executing statement: {0}
|
||||
schema.update.msg.optional_statement_failed=Optional statement execution failed:\n SQL: {0}\n Error: {1}\n File: {2}\n Line: {3}
|
||||
schema.update.warn.dialect_unsupported=Alfresco should not be used with database dialect {0}.
|
||||
schema.update.warn.dialect_hsql=Alfresco is using the HSQL default database. Please only use this while evaluating Alfresco, it is NOT recommended for production or deployment!
|
||||
schema.update.warn.dialect_derby=Alfresco is using the Apache Derby default database. Please only use this while evaluating Alfresco, it is NOT recommended for production or deployment!
|
||||
schema.update.err.found_multiple=\nMore than one Alfresco schema was found when querying the database metadata.\n Limit the database user's permissions or set the 'hibernate.default_schema' property in 'custom-hibernate-dialect.properties'.
|
||||
schema.update.err.previous_failed=A previous schema upgrade failed or was not completed. Revert to the original database before attempting the upgrade again.
|
||||
schema.update.err.statement_failed=Statement execution failed:\n SQL: {0}\n Error: {1}\n File: {2}\n Line: {3}
|
||||
|
@@ -1468,14 +1468,14 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="patch.db-V3.0-0-CreateActivitiesTables" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
|
||||
<property name="id"><value>patch.db-V3.0-0-CreateActivitiesTables</value></property>
|
||||
<bean id="patch.db-V3.0-0-CreateActivitiesExtras" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
|
||||
<property name="id"><value>patch.db-V3.0-0-CreateActivitiesExtras</value></property>
|
||||
<property name="description"><value>patch.schemaUpgradeScript.description</value></property>
|
||||
<property name="fixesFromSchema"><value>0</value></property>
|
||||
<property name="fixesToSchema"><value>125</value></property>
|
||||
<property name="targetSchema"><value>126</value></property>
|
||||
<property name="scriptUrl">
|
||||
<value>classpath:alfresco/dbscripts/create/3.0/${db.script.dialect}/create-activities-tables.sql</value>
|
||||
<value>classpath:alfresco/dbscripts/create/3.0/${db.script.dialect}/create-activities-extras.sql</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
@@ -262,12 +262,16 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to post activity: " + e, e);
|
||||
throw new AlfrescoRuntimeException("Failed to post activity: " + e, e);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to post activity: " + t, t);
|
||||
}
|
||||
}
|
||||
catch (AlfrescoRuntimeException e)
|
||||
{
|
||||
// log error, subsume exception
|
||||
// log error, subsume exception (for post activity)
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
@@ -313,11 +317,15 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException se)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to get user feed entries: " + se.getMessage());
|
||||
AlfrescoRuntimeException are = new AlfrescoRuntimeException("Unable to get user feed entries: " + se.getMessage());
|
||||
logger.error(are);
|
||||
throw are;
|
||||
}
|
||||
catch (JSONException je)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to get user feed entries: " + je.getMessage());
|
||||
AlfrescoRuntimeException are = new AlfrescoRuntimeException("Unable to get user feed entries: " + je.getMessage());
|
||||
logger.error(are);
|
||||
throw are;
|
||||
}
|
||||
|
||||
return activityFeedEntries;
|
||||
@@ -350,11 +358,15 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException se)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to get site feed entries: " + se.getMessage());
|
||||
AlfrescoRuntimeException are = new AlfrescoRuntimeException("Unable to get site feed entries: " + se.getMessage());
|
||||
logger.error(are);
|
||||
throw are;
|
||||
}
|
||||
catch (JSONException je)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to get site feed entries: " + je.getMessage());
|
||||
AlfrescoRuntimeException are = new AlfrescoRuntimeException("Unable to get site feed entries: " + je.getMessage());
|
||||
logger.error(are);
|
||||
throw are;
|
||||
}
|
||||
|
||||
return activityFeedEntries;
|
||||
@@ -382,7 +394,9 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to set feed control: " + e, e);
|
||||
AlfrescoRuntimeException are = new AlfrescoRuntimeException("Failed to set feed control: " + e, e);
|
||||
logger.error(are);
|
||||
throw are;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +447,9 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to get feed controls: " + e, e);
|
||||
AlfrescoRuntimeException are = new AlfrescoRuntimeException("Failed to get feed controls: " + e, e);
|
||||
logger.error(are);
|
||||
throw are;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +472,9 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to unset feed control: " + e, e);
|
||||
AlfrescoRuntimeException are = new AlfrescoRuntimeException("Failed to unset feed control: " + e, e);
|
||||
logger.error(are);
|
||||
throw are;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +499,9 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to query feed control: " + e, e);
|
||||
AlfrescoRuntimeException are = new AlfrescoRuntimeException("Failed to query feed control: " + e, e);
|
||||
logger.error(are);
|
||||
throw are;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ public class FeedCleaner
|
||||
try
|
||||
{
|
||||
long nowTimeOffset = new Date().getTime();
|
||||
long keepTimeOffset = nowTimeOffset - (maxAgeMins*60*1000); // millsecs = mins * 60 secs * 1000 msecs
|
||||
long keepTimeOffset = nowTimeOffset - ((long)maxAgeMins*60000L); // millsecs = mins * 60 secs * 1000 msecs
|
||||
Date keepDate = new Date(keepTimeOffset);
|
||||
|
||||
// clean old entries
|
||||
|
@@ -64,6 +64,7 @@ import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.connection.UserSuppliedConnectionProvider;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.dialect.DerbyDialect;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.HSQLDialect;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
@@ -102,6 +103,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
private static final String MSG_OPTIONAL_STATEMENT_FAILED = "schema.update.msg.optional_statement_failed";
|
||||
private static final String WARN_DIALECT_UNSUPPORTED = "schema.update.warn.dialect_unsupported";
|
||||
private static final String WARN_DIALECT_HSQL = "schema.update.warn.dialect_hsql";
|
||||
private static final String WARN_DIALECT_DERBY = "schema.update.warn.dialect_derby";
|
||||
private static final String ERR_MULTIPLE_SCHEMAS = "schema.update.err.found_multiple";
|
||||
private static final String ERR_PREVIOUS_FAILED_BOOTSTRAP = "schema.update.err.previous_failed";
|
||||
private static final String ERR_STATEMENT_FAILED = "schema.update.err.statement_failed";
|
||||
@@ -905,6 +907,10 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
{
|
||||
LogUtil.info(logger, WARN_DIALECT_HSQL);
|
||||
}
|
||||
if (dialectClazz.equals(DerbyDialect.class))
|
||||
{
|
||||
LogUtil.info(logger, WARN_DIALECT_DERBY);
|
||||
}
|
||||
|
||||
int maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
|
||||
// Adjust the maximum allowable String length according to the dialect
|
||||
|
Reference in New Issue
Block a user