diff --git a/docs/upgrades/upgrade_6.2.11-6.3.0.pl b/docs/upgrades/upgrade_6.2.11-6.3.0.pl index 698a0119e..2057ef102 100644 --- a/docs/upgrades/upgrade_6.2.11-6.3.0.pl +++ b/docs/upgrades/upgrade_6.2.11-6.3.0.pl @@ -99,7 +99,7 @@ foreach my $namespace (@allWobjects) { } $sth->finish; } -walkTree('0','PBasset000000000000001','000001','1'); +walkTree('0','PBasset000000000000001','000001','2'); print "\t\tMaking second round of table structure changes\n" unless ($quiet); my $sth = WebGUI::SQL->read("select distinct(namespace) from wobject where namespace is not null"); while (my ($namespace) = $sth->array) { @@ -168,14 +168,15 @@ WebGUI::SQL->write("alter table USS_submission drop column image"); WebGUI::SQL->write("alter table USS_submission drop column attachment"); +# start migrating non-wobject stuff into assets my %migration; - +WebGUI::SQL->write("insert into wobject (assetId, styleTemplateId, printableStyleTemplateId) values ('PBasset000000000000002','1','3')"); +WebGUI::SQL->write("insert into Folder (assetId, templateId) values ('PBasset000000000000002','PBtmpl0000000000000078')"); print "\tConverting navigation system to asset tree\n" unless ($quiet); -my ($navRootLineage) = WebGUI::SQL->quickArray("select lineage from asset where length(lineage)=12 order by lineage desc limit 1"); -$navRootLineage = sprintf("%012d",($navRootLineage+1)); +my $navRootLineage = getNextLineage('PBasset000000000000002'); my $navRootId = WebGUI::SQL->setRow("asset","assetId",{ assetId=>"new", isHidden=>1, @@ -185,10 +186,10 @@ my $navRootId = WebGUI::SQL->setRow("asset","assetId",{ ownerUserId=>"3", groupIdView=>"4", groupIdEdit=>"4", - parentId=>"PBasset000000000000001", + parentId=>"PBasset000000000000002", lineage=>$navRootLineage, lastUpdated=>time(), - className=>"WebGUI::Asset::Wobject::Navigation", + className=>"WebGUI::Asset::Wobject::Folder", state=>"published" }); WebGUI::SQL->setRow("wobject","assetId",{ @@ -196,14 +197,9 @@ WebGUI::SQL->setRow("wobject","assetId",{ styleTemplateId=>"1", printableStyleTemplateId=>"3" },undef,$navRootId); -WebGUI::SQL->setRow("Navigation","assetId",{ +WebGUI::SQL->setRow("Folder","assetId",{ assetId=>$navRootId, - startType=>"relativeToCurrentUrl", - templateId=>"1", - startPoint=>"0", - endPoint=>"55", - assetsToInclude=>"descendants", - showHiddenPages=>1 + templateId=>"PBtmpl0000000000000078" },undef,$navRootId); my %macroCache; my $navRankCounter = 1; @@ -335,8 +331,7 @@ $sth->finish; print "\tConverting collateral manager items into assets\n" unless ($quiet); -my ($collateralRootLineage) = WebGUI::SQL->quickArray("select lineage from asset where length(lineage)=12 order by lineage desc limit 1"); -$collateralRootLineage = sprintf("%012d",($collateralRootLineage+1)); +my $collateralRootLineage = getNextLineage('PBasset000000000000002'); my $collateralRootId = WebGUI::SQL->setRow("asset","assetId",{ assetId=>"new", isHidden=>1, @@ -346,10 +341,10 @@ my $collateralRootId = WebGUI::SQL->setRow("asset","assetId",{ ownerUserId=>"3", groupIdView=>"4", groupIdEdit=>"4", - parentId=>"PBasset000000000000001", + parentId=>"PBasset000000000000002", lineage=>$collateralRootLineage, lastUpdated=>time(), - className=>"WebGUI::Asset::Wobject::Navigation", + className=>"WebGUI::Asset::Wobject::Folder", state=>"published" }); WebGUI::SQL->setRow("wobject","assetId",{ @@ -359,12 +354,7 @@ WebGUI::SQL->setRow("wobject","assetId",{ },undef,$collateralRootId); WebGUI::SQL->setRow("Navigation","assetId",{ assetId=>$collateralRootId, - startType=>"relativeToCurrentUrl", - templateId=>"1", - startPoint=>"0", - endPoint=>"55", - assetsToInclude=>"descendants", - showHiddenPages=>1 + templateId=>"PBtmpl0000000000000078" },undef,$collateralRootId); my %folderCache = ('0'=>$collateralRootId); my %folderNameCache; @@ -459,8 +449,7 @@ WebGUI::SQL->write("drop table collateral"); print "\tConverting template system to asset tree\n" unless ($quiet); WebGUI::SQL->write("update template set namespace='Layout' where namespace='page'"); WebGUI::SQL->write("alter table template add column assetId varchar(22) not null"); -my ($tempRootLineage) = WebGUI::SQL->quickArray("select lineage from asset where length(lineage)=12 order by lineage desc limit 1"); -$tempRootLineage = sprintf("%012d",($tempRootLineage+1)); +my $tempRootLineage = sprintf("%018d",($collateralRootLineage+1)); my $tempRootId = WebGUI::SQL->setRow("asset","assetId",{ assetId=>"new", isHidden=>1, @@ -470,10 +459,10 @@ my $tempRootId = WebGUI::SQL->setRow("asset","assetId",{ ownerUserId=>"3", groupIdView=>"4", groupIdEdit=>"4", - parentId=>"PBasset000000000000001", + parentId=>"PBasset000000000000002", lineage=>$tempRootLineage, lastUpdated=>time(), - className=>"WebGUI::Asset::Wobject::Navigation", + className=>"WebGUI::Asset::Wobject::Folder", state=>"published" }); WebGUI::SQL->setRow("wobject","assetId",{ @@ -481,14 +470,9 @@ WebGUI::SQL->setRow("wobject","assetId",{ styleTemplateId=>"1", printableStyleTemplateId=>"3" },undef,$tempRootId); -WebGUI::SQL->setRow("Navigation","assetId",{ +WebGUI::SQL->setRow("Folder","assetId",{ assetId=>$tempRootId, - templateId=>"1", - startType=>"relativeToCurrentUrl", - startPoint=>"0", - endPoint=>"55", - assetsToInclude=>"descendants", - showHiddenPages=>1 + templateId=>"PBtmpl0000000000000078" },undef,$tempRootId); my $tempRankCounter = 1; my %templateCache; @@ -1072,6 +1056,15 @@ sub copyFile { return $id; } +sub getNextLineage { + my $assetId = shift; + my ($startLineage) = WebGUI::SQL->quickArray("select lineage from asset where parentId='".$assetId."' order by lineage desc limit 1"); + $startLineage = '000001000001000000' unless ($startLineage); + my $rank = substr($startLineage,12,6); + my $parentLineage = substr($startLineage,0,12); + return $parentLineage.sprintf("%06d",($rank+1)); +} + sub getFileSize { my $id = shift; my $filename = shift; diff --git a/docs/upgrades/upgrade_6.2.11-6.3.0.sql b/docs/upgrades/upgrade_6.2.11-6.3.0.sql index f4770d7bf..6cf09e5c7 100644 --- a/docs/upgrades/upgrade_6.2.11-6.3.0.sql +++ b/docs/upgrades/upgrade_6.2.11-6.3.0.sql @@ -71,7 +71,8 @@ create table asset ( index (parentId) ); -insert into asset (assetId, parentId, lineage, state, className, title, menuTitle, url, isSystem, ownerUserId, groupIdView, groupIdEdit) values ('PBasset000000000000001', 'infinity', '000001','published','WebGUI::Asset','Root','Root','root',1,'3','3','3'); +insert into asset (assetId, parentId, lineage, state, className, title, menuTitle, url, isSystem, ownerUserId, groupIdView, groupIdEdit, isHidden) values ('PBasset000000000000001', 'infinity', '000001','published','WebGUI::Asset','Root','Root','root',1,'3','3','3',1); +insert into asset (assetId, parentId, lineage, state, className, title, menuTitle, url, isSystem, ownerUserId, groupIdView, groupIdEdit, isHidden) values ('PBasset000000000000002', 'PBasset000000000000001', '000001000001','published','WebGUI::Asset::Wobject::Folder','Import Node','Import','root/import',1,'3','3','3',1); create table assetHistory ( assetId varchar(22) not null, @@ -101,6 +102,7 @@ create table Folder ( templateId varchar(22) not null ); + create table FileAsset ( assetId varchar(22) not null primary key, storageId varchar(22) not null, @@ -223,7 +225,7 @@ INSERT INTO template VALUES ('1','Default Page','\"> INSERT INTO template VALUES ('1','File','\r\n

\r\n
\r\n
\">\" alt=\"\" border=\"0\" />','FileAsset',1,1); INSERT INTO template VALUES ('2','Image','\r\n

\r\n
\r\n\" />','ImageAsset',1,1); -INSERT INTO template VALUES ('15','File Folder','\">\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n\r\n\r\n \r\n \r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n
\">\" border=\"0\" alt=\"\">\">
\">\" border=\"0\" alt=\"\">\">^D(\"%z %Z\",);
', 'Folder',1,1); +INSERT INTO template VALUES ('15','File Folder','\">\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n
\">\" border=\"0\" alt=\"\"> \">
\">\" border=\"0\" alt=\"\"> \">^D(\"%z %Z\",);
', 'Folder',1,1); alter table HttpProxy add column cookieJarStorageId varchar(22); diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 83bb3dfa0..33a62bc8a 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -148,7 +148,7 @@ These methods are available from this class: =cut #------------------------------------------------------------------- -=head2 addChild ( properties ) +=head2 addChild ( properties [, id ] ) Adds a child asset to a parent. Creates a new AssetID for child. Makes the parent know that it has children. Adds a new asset to the asset table. Returns the newly created Asset. @@ -156,12 +156,16 @@ Adds a child asset to a parent. Creates a new AssetID for child. Makes the paren A hash reference containing a list of properties to associate with the child. The only used property value is "className" +=head3 id + +A unique 22 character ID. By default WebGUI will generate this and you should almost never specify it. This is mainly here for developers that want to include default templates in their plug-ins. + =cut sub addChild { my $self = shift; my $properties = shift; - my $id = WebGUI::Id::generate(); + my $id = WebGUI::Id::generate() || shift; my $lineage = $self->get("lineage").$self->getNextChildRank; $self->{_hasChildren} = 1; WebGUI::SQL->beginTransaction; @@ -1066,6 +1070,18 @@ sub getId { return $self->get("assetId"); } +#------------------------------------------------------------------- + +=head2 getImportNode () + +Returns the import node asset object. This is where developers will templates, files, etc to the asset tree that have no other obvious attachment point. + +=cut + +sub getImportNode { + return WebGUI::Asset->newByDynamicClass("PBasset000000000000002"); +} + #------------------------------------------------------------------- =head2 getIndexerParams ( )