Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit ebc227c

Browse files
author
Julien Jomier
committed
ENH: Fixing migration
1 parent dcabde8 commit ebc227c

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

core/controllers/components/MIDAS2MigrationComponent.php

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class MIDAS2MigrationComponent extends AppComponent
88
{
99

10-
/** function to create the items */
10+
/** function to create the items */
1111
private function _createFolderForItem($collectionId, $parentFolderid)
1212
{
1313
set_time_limit(0);
@@ -20,10 +20,10 @@ private function _createFolderForItem($collectionId, $parentFolderid)
2020
$Folderpolicyuser = $modelLoader->loadModel("Folderpolicyuser");
2121
$Itempolicygroup = $modelLoader->loadModel("Itempolicygroup");
2222

23-
$colquery = pg_query("SELECT i.item_id,mtitle.text_value AS title,mabstract.text_value AS abstract".
23+
$colquery = pg_query("SELECT i.item_id,mtitle.text_value AS title,mabstract.text_value AS abstract ".
2424
"FROM item AS i ".
25-
"LEFT JOIN metadatavalue AS mtitle ON (i.item_id = mtitle.item_id AND mtitle.metadata_field_id = 64)".
26-
"LEFT JOIN metadatavalue AS mabstract ON (i.item_id = mabstract.item_id AND mabstract.metadata_field_id = 27)".
25+
"LEFT JOIN metadatavalue AS mtitle ON (i.item_id = mtitle.item_id AND mtitle.metadata_field_id = 64) ".
26+
"LEFT JOIN metadatavalue AS mabstract ON (i.item_id = mabstract.item_id AND mabstract.metadata_field_id = 27) ".
2727
"WHERE i.owning_collection=".$collectionId);
2828
while(pg_fetch_array($colquery))
2929
{
@@ -34,7 +34,7 @@ private function _createFolderForItem($collectionId, $parentFolderid)
3434
$folderDao = false;
3535
try
3636
{
37-
// Create the folder for the community
37+
// Create the folder for the item
3838
$folderDao = $Folder->createFolder($title, $abstract, $parentFolderid);
3939

4040
// Assign the policies to the folder as the same as the parent folder
@@ -57,15 +57,16 @@ private function _createFolderForItem($collectionId, $parentFolderid)
5757
catch(Zend_Exception $e)
5858
{
5959
$this->getLogger()->info($e->getMessage());
60-
//Zend_Debug::dump($e);
60+
Zend_Debug::dump($e);
6161
//we continue
62+
exit();
6263
}
6364

6465
if($folderDao)
6566
{
6667
// Create the item from the bitstreams
67-
$bitquery = pg_query("SELECT b.bitstream_id,b.name,b.description,b.internal_id FROM bitstream AS b,item2bitstream AS i2b".
68-
"WHERE i2b.bitstream_id = b.bitstream_id AND i2b.item_id=".$item_id);
68+
$bitquery = pg_query("SELECT b.bitstream_id,b.name,b.description,b.internal_id FROM bitstream AS b,item2bitstream AS i2b ".
69+
"WHERE i2b.bitstream_id = b.bitstream_id AND i2b.item_id=".$item_id);
6970
while($bitquery_array = pg_fetch_array($bitquery))
7071
{
7172
$filename = $bitquery_array['name'];
@@ -112,7 +113,7 @@ private function _createFolderForItem($collectionId, $parentFolderid)
112113
}
113114
} // end _createFolderForItem()
114115

115-
/** function to create the collections */
116+
/** function to create the collections */
116117
private function _createFolderForCollection($communityId, $parentFolderid)
117118
{
118119
set_time_limit(0);
@@ -172,15 +173,19 @@ private function _createFolderForCollection($communityId, $parentFolderid)
172173

173174

174175
/** Recursive function to create the communities */
175-
private function _createFolderForCommunity($parentidMIDAS2, $parentFolderid)
176+
private function _createFolderForCommunity($communityidMIDAS2, $parentFolderid)
176177
{
177178
set_time_limit(0);
178179
$modelLoader = new MIDAS_ModelLoader;
179180
$Folder = $modelLoader->loadModel("Folder");
180181
$Folderpolicygroup = $modelLoader->loadModel("Folderpolicygroup");
181182
$Folderpolicyuser = $modelLoader->loadModel("Folderpolicyuser");
182183

183-
$comquery = pg_query("SELECT community_id,name,short_description,introductory_text FROM community WHERE owning_community=".$parentidMIDAS2);
184+
// Create the collections attached to this community
185+
$this->_createFolderForCollection($communityidMIDAS2,$parentFolderid);
186+
187+
// Find the subcommunities
188+
$comquery = pg_query("SELECT community_id,name,short_description,introductory_text FROM community WHERE owning_community=".$communityidMIDAS2);
184189
while($comquery_array = pg_fetch_array($comquery))
185190
{
186191
$community_id = $comquery_array['community_id'];
@@ -215,21 +220,18 @@ private function _createFolderForCommunity($parentidMIDAS2, $parentFolderid)
215220
$this->getLogger()->info($e->getMessage());
216221
//Zend_Debug::dump($e);
217222
//we continue
218-
}
219-
220-
if($folderDao)
223+
}
224+
225+
if($folderDao) // The folder has been created for the community
221226
{
227+
// Find the subcommunities
222228
$this->_createFolderForCommunity($community_id, $folderDao->getFolderId());
223229
}
224-
else
230+
else
225231
{
226232
echo "Cannot create Folder for community: ".$name."<br>";
227-
}
228-
}
229-
230-
// Create the collections attached to this community
231-
$this->_createFolderForCollection($parentidMIDAS2, $parentFolderid);
232-
233+
} // end cannot create folder
234+
} // end find information about the current community
233235
} // end _createCommunity()
234236

235237
/** */
@@ -244,7 +246,7 @@ function migrate()
244246
}
245247

246248
// Connect to the local PGSQL database
247-
$pgdb = pg_connect("host = localhost port = 5432 dbname = midasopen user = midas password = midas");
249+
$pgdb = pg_connect("host='localhost' port='5432' dbname='midasopen' user='midas' password='midas'");
248250
if($pgdb === false)
249251
{
250252
throw new Zend_Exception("Cannot connect to the MIDAS2 database.");
@@ -253,7 +255,7 @@ function migrate()
253255
// Check that the password prefix is not defined
254256
if(Zend_Registry::get('configGlobal')->password->prefix != '')
255257
{
256-
throw new Zend_Exception("Cannot connect to the MIDAS2 database.");
258+
throw new Zend_Exception("Password prefix cannot be set because MIDAS2 doesn't use salt.");
257259
}
258260

259261
$modelLoader = new MIDAS_ModelLoader;

core/models/base/FolderModelBase.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,15 @@ function createFolder($name, $description, $parent)
6060
{
6161
throw new Zend_Exception("Should be a folder.");
6262
}
63-
if(!is_string($name) || !is_string($description))
63+
64+
if(empty($name))
65+
{
66+
throw new Zend_Exception("Name cannot be empty.");
67+
}
68+
69+
if(!is_string($name))
6470
{
65-
throw new Zend_Exception("Should be a string.");
71+
throw new Zend_Exception("Name should be a string.");
6672
}
6773

6874
if($parent instanceof FolderDao)

modules/ldap/configs/module.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ ldap.autoAddUnknownUser = true
1919
ldap.search = uid
2020
ldap.useActiveDirectory = false
2121
ldap.proxyBasedn =
22-
ldap.proxyPassword =
22+
ldap.proxyPassword =

0 commit comments

Comments
 (0)