Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 28 Apr 2001 19:58:38 -0000 1.12 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 30 Apr 2001 01:34:58 -0000 1.13 @@ -191,6 +191,9 @@ content_type varchar(100) constraint cr_items_rev_type_fk references acs_object_types, + storage_type varchar(10) default 'text' not null + constraint cr_revisions_storage_type + check (storage_type in ('lob','text','file')), tree_sortkey varchar(4000) ); @@ -392,10 +395,7 @@ constraint cr_revisions_mime_type_ref references cr_mime_types, nls_language varchar(50), - -- use Don's postgresql lob hack for now. - storage_type varchar(10) default 'lob' not null - constraint cr_revisions_storage_type - check (storage_type in ('lob','text','file')), + storage_type varchar(10) not null, -- lob_id if storage_type = lob. lob integer, -- content holds the file name if storage type = file Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-extlink.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-extlink.sql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-extlink.sql 28 Apr 2001 19:58:39 -0000 1.6 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-extlink.sql 30 Apr 2001 01:34:58 -0000 1.7 @@ -29,13 +29,13 @@ v_name cr_items.name%TYPE; begin - if new__label is null or new__label = '''' then + if new__label is null then v_label := new__url; else v_label := new__label; end if; - if new__name is null or new__name = '''' then + if new__name is null then select acs_object_id_seq.nextval into v_extlink_id from dual; v_name := ''link'' || v_extlink_id; else @@ -58,7 +58,7 @@ ''text/plain'', null, null, - null + ''text'' ); insert into cr_extlinks Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql,v diff -u -r1.13 -r1.14 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql 28 Apr 2001 19:58:39 -0000 1.13 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-folder.sql 30 Apr 2001 01:34:58 -0000 1.14 @@ -81,7 +81,7 @@ ''text/plain'', null, null, - null + ''text'' ); insert into cr_folders ( Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql,v diff -u -r1.14 -r1.15 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 28 Apr 2001 19:58:39 -0000 1.14 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 30 Apr 2001 01:34:58 -0000 1.15 @@ -63,7 +63,7 @@ -- function new -create function content_item__new (varchar,integer,integer,varchar,timestamp,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,integer) +create function content_item__new (varchar,integer,integer,varchar,timestamp,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar,varchar) returns integer as ' declare new__name alias for $1; @@ -81,8 +81,7 @@ new__mime_type alias for $13; -- default ''text/plain'' new__nls_language alias for $14; -- default null new__text alias for $15; -- default null --- changed to integer for blob_id - new__data alias for $16; -- default null + new__storage_type alias for $16; -- check in (''text'',''file'') -- relation_tag alias for $17; -- is_live alias for $18; new__relation_tag varchar default null; @@ -98,11 +97,6 @@ v_context_id acs_objects.context_id%TYPE; begin - -- if content_item.is_subclass(item_subtype,''content_item'') = ''f'' then - -- raise_application_error(-20000, ''The object_type '' || item_subtype || - -- '' does not inherit from content_item.''); - -- end if; - -- place the item in the context of the pages folder if no -- context specified @@ -157,16 +151,10 @@ v_context_id ); - -- Turn off security inheritance if there is no security context - --if context_id is null then - -- update acs_objects set security_inherit_p = ''f'' - -- where object_id = v_item_id; - --end if; - insert into cr_items ( - item_id, name, content_type, parent_id + item_id, name, content_type, parent_id, storage_type ) values ( - v_item_id, new__name, new__content_type, v_parent_id + v_item_id, new__name, new__content_type, v_parent_id, new__storage_type ); -- if the parent is not a folder, insert into cr_child_rels @@ -183,7 +171,7 @@ v_parent_id ); - if new__relation_tag is null or new__relation_tag = '''' then + if new__relation_tag is null then v_rel_tag := content_item__get_content_type(v_parent_id) || ''-'' || new__content_type; else @@ -199,64 +187,197 @@ end if; -- use the name of the item if no title is supplied - if new__title is null or new__title = '''' then + if new__title is null then v_title := new__name; else v_title := new__title; end if; - -- create the revision if data or title or text is not null - -- note that the caller could theoretically specify both text - -- and data, in which case the text is ignored. + if new__title is not null or + new__text is not null then - if new__data is not null then - v_revision_id := content_revision__new( v_title, new__description, now(), new__mime_type, - new__nls_language, - new__data, - v_item_id, null, + new__text, + v_item_id, + null, new__creation_date, new__creation_user, new__creation_ip ); - else if (new__title is not null and new__title != '''') or - (new__text is not null and new__text != '''') then + end if; + -- make the revision live if is_live is true + if new__is_live = ''t'' then + PERFORM content_item__set_live_revision(v_revision_id); + end if; + + return v_item_id; + +end;' language 'plpgsql'; + +create function content_item__new (varchar,integer,integer,varchar,timestamp,integer,integer,varchar,varchar,varchar,varchar,varchar,varchar,varchar,integer) +returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__item_id alias for $3; -- default null + new__locale alias for $4; -- default null + new__creation_date alias for $5; -- default now() + new__creation_user alias for $6; -- default null + new__context_id alias for $7; -- default null + new__creation_ip alias for $8; -- default null + new__item_subtype alias for $9; -- default ''content_item'' + new__content_type alias for $10; -- default ''content_revision'' + new__title alias for $11; -- default null + new__description alias for $12; -- default null + new__mime_type alias for $13; -- default ''text/plain'' + new__nls_language alias for $14; -- default null +-- changed to integer for blob_id + new__data alias for $15; -- default null +-- relation_tag alias for $17; +-- is_live alias for $18; + new__relation_tag varchar default null; + new__is_live boolean default ''f''; + + v_parent_id cr_items.parent_id%TYPE; + v_parent_type acs_objects.object_type%TYPE; + v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + v_title cr_revisions.title%TYPE; + v_rel_id acs_objects.object_id%TYPE; + v_rel_tag cr_child_rels.relation_tag%TYPE; + v_context_id acs_objects.context_id%TYPE; +begin + + -- place the item in the context of the pages folder if no + -- context specified + + if new__parent_id is null then + v_parent_id := content_item_globals.c_root_folder_id; + else + v_parent_id := new__parent_id; + end if; + + -- Determine context_id + if new__context_id is null then + v_context_id := v_parent_id; + else + v_context_id := new__context_id; + end if; + + if v_parent_id = 0 or + content_folder__is_folder(v_parent_id) = ''t'' then + + if v_parent_id != 0 and + content_folder__is_registered( + v_parent_id, new__content_type, ''f'') = ''f'' then + + raise EXCEPTION ''-20000: This item\\\'s content type % is not registered to this folder %'', new__content_type, v_parent_id; + end if; + + else if v_parent_id != 0 then + + select object_type into v_parent_type from acs_objects + where object_id = v_parent_id; + + if NOT FOUND then + raise EXCEPTION ''-20000: Invalid parent ID % specified in content_item.new'', v_parent_id; + end if; + + if content_item__is_subclass(v_parent_type, ''content_item'') = ''t'' and + content_item__is_valid_child(v_parent_id, new__content_type) = ''f'' then + + raise EXCEPTION ''-20000: This item\\\'s content type % is not allowed in this container %'', new__content_type, v_parent_id; + end if; + + end if; end if; + + -- Create the object + + v_item_id := acs_object__new( + new__item_id, + new__item_subtype, + new__creation_date, + new__creation_user, + new__creation_ip, + v_context_id + ); + + insert into cr_items ( + item_id, name, content_type, parent_id, storage_type + ) values ( + v_item_id, new__name, new__content_type, v_parent_id, ''lob'' + ); + + -- if the parent is not a folder, insert into cr_child_rels + if v_parent_id != 0 and + content_folder__is_folder(v_parent_id) = ''f'' and + content_item__is_valid_child(v_parent_id, new__content_type) = ''t'' then + + v_rel_id := acs_object__new( + null, + ''cr_item_child_rel'', + now(), + null, + null, + v_parent_id + ); + + if new__relation_tag is null or new__relation_tag = '''' then + v_rel_tag := content_item__get_content_type(v_parent_id) + || ''-'' || new__content_type; + else + v_rel_tag := new__relation_tag; + end if; + + insert into cr_child_rels ( + rel_id, parent_id, child_id, relation_tag, order_n + ) values ( + v_rel_id, v_parent_id, v_item_id, v_rel_tag, v_item_id + ); + + end if; + + -- use the name of the item if no title is supplied + if new__title is null or new__title = '''' then + v_title := new__name; + else + v_title := new__title; + end if; + + -- create the revision if data or title or text is not null + -- note that the caller could theoretically specify both text + -- and data, in which case the text is ignored. + + if new__data is not null then + v_revision_id := content_revision__new( v_title, new__description, now(), new__mime_type, + new__nls_language, + new__data, + v_item_id, null, - new__text, - v_item_id, - null, new__creation_date, new__creation_user, new__creation_ip - ); + ); - end if; end if; + end if; -- make the revision live if is_live is true if new__is_live = ''t'' then PERFORM content_item__set_live_revision(v_revision_id); end if; - -- Have the new item inherit the permission of the parent item - -- if no security context was specified - --if parent_id is not null and context_id is null then - -- content_permission.inherit_permissions ( - -- parent_id, v_item_id, creation_user - -- ); - --end if; - return v_item_id; end;' language 'plpgsql'; @@ -285,7 +406,7 @@ ''text/plain'', null, new__text, - null + ''text'' ); end;' language 'plpgsql'; @@ -1162,6 +1283,35 @@ end;' language 'plpgsql'; +create function content_item__set_live_revision (integer) returns integer as ' +declare + set_live_revision__revision_id alias for $1; + set_live_revision__publish_status cr_items.publish_status%TYPE default ''ready''; +begin + + update + cr_items + set + live_revision = set_live_revision__revision_id, + publish_status = set_live_revision__publish_status + where + item_id = (select + item_id + from + cr_revisions + where + revision_id = set_live_revision__revision_id); + + update + cr_revisions + set + publish_date = now() + where + revision_id = set_live_revision__revision_id; + + return 0; +end;' language 'plpgsql'; + -- procedure set_live_revision create function content_item__set_live_revision (integer,varchar) returns integer as ' @@ -1383,6 +1533,7 @@ v_is_registered boolean; v_old_revision_id cr_revisions.revision_id%TYPE; v_new_revision_id cr_revisions.revision_id%TYPE; + v_storage_type cr_items.storage_type%TYPE; begin -- call content_folder.copy if the item is a folder @@ -1418,9 +1569,9 @@ select content_type, name, locale, - coalesce(live_revision, latest_revision) + coalesce(live_revision, latest_revision), storage_type into - v_content_type, v_name, v_locale, v_revision_id + v_content_type, v_name, v_locale, v_revision_id, v_storage_type from cr_items where @@ -1451,7 +1602,7 @@ ''text/plain'', null, null, - null + v_storage_type ); -- get the latest revision of the old item Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql,v diff -u -r1.13 -r1.14 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql 28 Apr 2001 19:58:39 -0000 1.13 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-revision.sql 30 Apr 2001 01:34:58 -0000 1.14 @@ -102,6 +102,7 @@ new__creation_ip alias for $11; -- default null v_revision_id integer; v_content_type acs_object_types.object_type%TYPE; + v_storage_type cr_items.storage_type%TYPE; begin v_content_type := content_item__get_content_type(new__item_id); @@ -115,6 +116,10 @@ new__item_id ); + select storage_type into v_storage_type + from cr_items + where item_id = new__item_id; + -- text data is stored directly in cr_revisions using text datatype. insert into cr_revisions ( @@ -124,7 +129,7 @@ v_revision_id, new__title, new__description, new__mime_type, new__publish_date, new__nls_language, - new__text, new__item_id, ''text'', + new__text, new__item_id, v_storage_type, length(new__text) ); Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-symlink.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-symlink.sql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-symlink.sql 28 Apr 2001 19:58:39 -0000 1.8 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-symlink.sql 30 Apr 2001 01:34:58 -0000 1.9 @@ -72,7 +72,7 @@ end if; -- Select default label if the label is null - if new__label is null or new__label = '''' then + if new__label is null then v_label := ''Symlink to '' || v_name; else v_label := new__label; @@ -94,7 +94,7 @@ ''text/plain'', null, null, - null + ''text'' ); insert into cr_symlinks Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql 18 Apr 2001 23:27:46 -0000 1.5 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql 30 Apr 2001 01:34:58 -0000 1.6 @@ -77,7 +77,7 @@ ''text/plain'', null, null, - null + ''text'' ); insert into cr_templates ( Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-kernel/sql/test/acs-objects-test.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-kernel/sql/test/groups-test.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-kernel/sql/test/rel-constraints-test.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-kernel/sql/test/rel-segments-test-types-create.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-kernel/sql/test/rel-segments-test-types-drop.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-kernel/sql/test/rel-segments-test.sql'. Fisheye: No comparison available. Pass `N' to diff?