Skip to content

Commit

Permalink
SettingsManager / Split harvester settings and system settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
François Prunayre committed Jul 5, 2013
1 parent 2ef9aeb commit 7df46d0
Show file tree
Hide file tree
Showing 21 changed files with 766 additions and 18 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public boolean setValues(Dbms dbms, Map<String, Object> values) throws SQLExcept
{
String path = entry.getKey();
String value= makeString(entry.getValue());
if(Log.isDebugEnabled(Geonet.SPATIAL))
if(Log.isDebugEnabled(Geonet.SETTINGS))
Log.debug(Geonet.SETTINGS, "Set path: " + path + ", value: " + value);

Setting s = resolve(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

package org.fao.geonet.kernel.harvest;

import static org.quartz.impl.matchers.GroupMatcher.jobGroupEquals;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import jeeves.exceptions.BadInputEx;
import jeeves.exceptions.JeevesException;
import jeeves.exceptions.MissingParameterEx;
Expand All @@ -31,6 +38,7 @@
import jeeves.server.resources.ResourceManager;
import jeeves.utils.Log;
import jeeves.utils.Xml;

import org.fao.geonet.GeonetContext;
import org.fao.geonet.constants.Edit;
import org.fao.geonet.constants.Geonet;
Expand All @@ -41,17 +49,11 @@
import org.fao.geonet.kernel.harvest.harvester.AbstractHarvester;
import org.fao.geonet.kernel.harvest.harvester.HarversterJobListener;
import org.fao.geonet.kernel.harvest.harvester.HarvesterHistoryDao;
import org.fao.geonet.kernel.setting.HarvesterSettingsManager;
import org.fao.geonet.kernel.setting.SettingManager;
import org.jdom.Element;
import org.quartz.SchedulerException;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import static org.quartz.impl.matchers.GroupMatcher.jobGroupEquals;

/**
* TODO Javadoc.
*
Expand All @@ -73,7 +75,7 @@ public class HarvestManager implements HarvestInfoProvider
* @param dm datamanager
* @throws Exception hmm
*/
public HarvestManager(ServiceContext context, GeonetContext gc, SettingManager sm, DataManager dm) throws Exception {
public HarvestManager(ServiceContext context, GeonetContext gc, HarvesterSettingsManager sm, DataManager dm) throws Exception {
this.context = context;
this.readOnly = gc.isReadOnly();
Log.debug(Geonet.HARVEST_MAN, "HarvesterManager initializing, READONLYMODE is " + this.readOnly);
Expand Down Expand Up @@ -548,7 +550,7 @@ public void setReadOnly(boolean readOnly) {
//---------------------------------------------------------------------------

private String xslPath;
private SettingManager settingMan;
private HarvesterSettingsManager settingMan;
private DataManager dataMan;
private ServiceContext context;
private boolean readOnly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import org.fao.geonet.kernel.harvest.harvester.wfsfeatures.WfsFeaturesHarvester;
import org.fao.geonet.kernel.harvest.harvester.z3950.Z3950Harvester;
import org.fao.geonet.kernel.harvest.harvester.z3950Config.Z3950ConfigHarvester;
import org.fao.geonet.kernel.setting.SettingManager;
import org.fao.geonet.kernel.setting.HarvesterSettingsManager;
import org.fao.geonet.lib.Lib;
import org.fao.geonet.monitor.harvest.AbstractHarvesterErrorCounter;
import org.fao.geonet.resources.Resources;
Expand Down Expand Up @@ -143,7 +143,7 @@ private static void register(ServiceContext context, Class<?> harvester) throws
* @throws BadParameterEx
* @throws OperationAbortedEx
*/
public static AbstractHarvester create(String type, ServiceContext context, SettingManager sm, DataManager dm) throws BadParameterEx, OperationAbortedEx {
public static AbstractHarvester create(String type, ServiceContext context, HarvesterSettingsManager sm, DataManager dm) throws BadParameterEx, OperationAbortedEx {
//--- raises an exception if type is null
if (type == null) {
throw new BadParameterEx("type", null);
Expand Down Expand Up @@ -864,7 +864,7 @@ protected Element getResult() {
private boolean running = false;

protected ServiceContext context;
protected SettingManager settingMan;
protected HarvesterSettingsManager settingMan;
protected DataManager dataMan;

protected AbstractParams params;
Expand Down
8 changes: 5 additions & 3 deletions web/src/main/java/org/fao/geonet/Geonetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@
import org.fao.geonet.kernel.csw.CatalogConfiguration;
import org.fao.geonet.kernel.csw.CswHarvesterResponseExecutionService;
import org.fao.geonet.kernel.harvest.HarvestManager;
import org.fao.geonet.kernel.metadata.StatusActions;
import org.fao.geonet.kernel.oaipmh.OaiPmhDispatcher;
import org.fao.geonet.kernel.search.LuceneConfig;
import org.fao.geonet.kernel.search.SearchManager;
import org.fao.geonet.kernel.search.spatial.Pair;
import org.fao.geonet.kernel.search.spatial.SpatialIndexWriter;
import org.fao.geonet.kernel.setting.HarvesterSettingsManager;
import org.fao.geonet.kernel.setting.SettingInfo;
import org.fao.geonet.kernel.setting.SettingManager;
import org.fao.geonet.languages.IsoLanguagesMapper;
Expand All @@ -86,7 +88,6 @@
import org.fao.geonet.notifier.MetadataNotifierControl;
import org.fao.geonet.notifier.MetadataNotifierManager;
import org.fao.geonet.resources.Resources;
import org.fao.geonet.kernel.metadata.StatusActions;
import org.fao.geonet.services.util.z3950.Repositories;
import org.fao.geonet.services.util.z3950.Server;
import org.fao.geonet.util.ThreadPool;
Expand Down Expand Up @@ -420,8 +421,8 @@ public Object start(Element config, ServiceContext context) throws Exception {
gnContext.threadPool = threadPool;
gnContext.statusActionsClass = statusActionsClass;


HarvestManager harvestMan = new HarvestManager(context, gnContext, settingMan, dataMan);
HarvesterSettingsManager harvesterSettingsMan = new HarvesterSettingsManager(dbms, context.getProviderManager());
HarvestManager harvestMan = new HarvestManager(context, gnContext, harvesterSettingsMan, dataMan);

//------------------------------------------------------------------------
//--- return application context
Expand All @@ -432,6 +433,7 @@ public Object start(Element config, ServiceContext context) throws Exception {
beanFactory.registerSingleton("schemaManager", schemaMan);
beanFactory.registerSingleton("serviceHandlerConfig", handlerConfig);
beanFactory.registerSingleton("settingManager", settingMan);
beanFactory.registerSingleton("harvesterSettingsMan", harvesterSettingsMan);
beanFactory.registerSingleton("thesaurusManager", thesaurusMan);
beanFactory.registerSingleton("oaipmhDisatcher", oaipmhDis);
beanFactory.registerSingleton("metadataNotifierManager", metadataNotifierMan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ CREATE TABLE Settings
value CLOB(1G),
primary key(id)
);

CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value CLOB(1G),
primary key(id)
);

-- ======================================================================

Expand Down Expand Up @@ -464,6 +473,7 @@ ALTER TABLE OperationsDes ADD FOREIGN KEY (idDes) REFERENCES Operations (id);
ALTER TABLE RegionsDes ADD FOREIGN KEY (langId) REFERENCES Languages (id);
ALTER TABLE RegionsDes ADD FOREIGN KEY (idDes) REFERENCES Regions (id);
ALTER TABLE Settings ADD FOREIGN KEY (parentId) REFERENCES Settings (id);
ALTER TABLE HarvesterSettings ADD FOREIGN KEY (parentId) REFERENCES HarvesterSettings (id);
ALTER TABLE UserGroups ADD FOREIGN KEY (userId) REFERENCES Users (id);
ALTER TABLE UserGroups ADD FOREIGN KEY (groupId) REFERENCES Groups (id);
ALTER TABLE MetadataNotifications ADD FOREIGN KEY (notifierId) REFERENCES MetadataNotifiers(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ CREATE TABLE Settings
foreign key(parentId) references Settings(id)
);

CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value longvarchar,

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);

-- ======================================================================

CREATE TABLE Languages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,18 @@ CREATE TABLE Settings

foreign key(parentId) references Settings(id)
);

CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value longtext,

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
-- ======================================================================

CREATE TABLE Languages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ CREATE TABLE Settings
value clob,
primary key(id)
);


CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar2(64) not null,
value clob,
primary key(id)
);

REM ======================================================================

CREATE TABLE Languages
Expand Down Expand Up @@ -487,6 +496,7 @@ ALTER TABLE OperationsDes ADD FOREIGN KEY (idDes) REFERENCES Operations (id);
ALTER TABLE RegionsDes ADD FOREIGN KEY (langId) REFERENCES Languages (id);
ALTER TABLE RegionsDes ADD FOREIGN KEY (idDes) REFERENCES Regions (id);
ALTER TABLE Settings ADD FOREIGN KEY (parentId) REFERENCES Settings (id);
ALTER TABLE HarvesterSettings ADD FOREIGN KEY (parentId) REFERENCES HarvesterSettings (id);
ALTER TABLE UserGroups ADD FOREIGN KEY (userId) REFERENCES Users (id);
ALTER TABLE UserGroups ADD FOREIGN KEY (groupId) REFERENCES Groups (id);
ALTER TABLE MetadataNotifications ADD FOREIGN KEY (notifierId) REFERENCES MetadataNotifiers(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ CREATE TABLE Settings
foreign key(parentId) references Settings(id)
);

CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value text,

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
-- ======================================================================

CREATE TABLE Languages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ CREATE TABLE Settings
foreign key(parentId) references Settings(id)
);

CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value text,

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
-- ======================================================================

CREATE TABLE Languages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ CREATE TABLE Settings
foreign key(parentId) references Settings(id)
);

CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value varchar(max),

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
-- ======================================================================

CREATE TABLE Languages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,6 @@ INSERT INTO Regions VALUES (371,43.58,41.82,18.196,20.396);

INSERT INTO Settings VALUES (0,NULL,'root',NULL);
INSERT INTO Settings VALUES (1,0,'system',NULL);
INSERT INTO Settings VALUES (2,0,'harvesting',NULL);
INSERT INTO Settings VALUES (10,1,'site',NULL);
INSERT INTO Settings VALUES (11,10,'name','My GeoNetwork catalogue');
INSERT INTO Settings VALUES (12,10,'siteId','Dummy');
Expand Down Expand Up @@ -993,6 +992,9 @@ INSERT INTO Settings VALUES (956,1,'hidewithheldelements',NULL);
INSERT INTO Settings VALUES (957,956,'enable','false');
INSERT INTO Settings VALUES (958,956,'keepMarkedElement','true');


INSERT INTO HarvesterSettings VALUES (1,NULL,'harvesting',NULL);

-- ======================================================================
-- === Table: Users
-- ======================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value CLOB(1G),
primary key(id)
);

ALTER TABLE HarvesterSettings ADD FOREIGN KEY (parentId) REFERENCES HarvesterSettings (id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value longvarchar,

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value longtext,

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar2(64) not null,
value clob,
primary key(id)
);

ALTER TABLE HarvesterSettings ADD FOREIGN KEY (parentId) REFERENCES HarvesterSettings (id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value text,

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value text,

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE HarvesterSettings
(
id int not null,
parentId int,
name varchar(64) not null,
value varchar(max),

primary key(id),

foreign key(parentId) references HarvesterSettings(id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
INSERT INTO HarvesterSettings VALUES (1,NULL,'harvesting',NULL);
-- Copy all harvester's root nodes config
INSERT INTO HarvesterSettings SELECT id, 1, name, value FROM Settings WHERE parentId = 2;
-- Copy all harvester's properties (Greater than last 2.10.0 settings ie. keepMarkedElement)
INSERT INTO HarvesterSettings SELECT * FROM Settings WHERE id > (SELECT max(id) FROM HarvesterSettings);
-- Drop harvester config from Settings table
DELETE FROM Settings WHERE id > 958;
DELETE FROM Settings WHERE id=2;

-- Version update
UPDATE Settings SET value='2.11.0' WHERE name='version';
UPDATE Settings SET value='SNAPSHOT' WHERE name='subVersion';

0 comments on commit 7df46d0

Please sign in to comment.