From: <jes...@us...> - 2011-01-11 14:08:59
|
Revision: 7116 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=7116&view=rev Author: jesseeichar Date: 2011-01-11 14:08:49 +0000 (Tue, 11 Jan 2011) Log Message: ----------- fix for conflicting id Modified Paths: -------------- sandbox/geocat.ch/trunk/src/org/fao/geonet/Geonetwork.java sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ContactsStrategy.java sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/FormatsStrategy.java sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ReusableObjManager.java sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/Utils.java sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ViewNonValidated.java Modified: sandbox/geocat.ch/trunk/src/org/fao/geonet/Geonetwork.java =================================================================== --- sandbox/geocat.ch/trunk/src/org/fao/geonet/Geonetwork.java 2011-01-11 13:14:46 UTC (rev 7115) +++ sandbox/geocat.ch/trunk/src/org/fao/geonet/Geonetwork.java 2011-01-11 14:08:49 UTC (rev 7116) @@ -88,9 +88,9 @@ public Object start(Element config, ServiceContext context) throws Exception { - + System.setProperty("org.geotools.referencing.forceXY", "true"); - + logger = context.getLogger(); String path = context.getAppPath(); @@ -176,7 +176,7 @@ //--- ReusableObjectManager Iterator<Element> reusableConfig = handlerConfig.getChildren(Geonet.Config.REUSABLE_OBJECT_CONFIG); - ReusableObjManager reusableObjMan = new ReusableObjManager(path, reusableConfig); + ReusableObjManager reusableObjMan = new ReusableObjManager(path, reusableConfig, context.getSerialFactory()); //------------------------------------------------------------------------ //--- get edit params and initialize DataManager @@ -277,13 +277,13 @@ private DataStore createPostgisDatastore(ServiceConfig handlerConfig) throws IOException { PostgisDataStoreFactory factory = new PostgisDataStoreFactory(); - + String database = getPostgisConfigParam(handlerConfig, "database"); String user = getPostgisConfigParam(handlerConfig, "user"); String password = getPostgisConfigParam(handlerConfig, "password"); String host1 = getPostgisConfigParam(handlerConfig, "host"); String port = getPostgisConfigParam(handlerConfig, "port"); - + Map<String, Object> params = new HashMap<String, Object>(); params.put(PostgisDataStoreFactory.DBTYPE.key, PostgisDataStoreFactory.DBTYPE.sample); params.put(PostgisDataStoreFactory.DATABASE.key, database); Modified: sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ContactsStrategy.java =================================================================== --- sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ContactsStrategy.java 2011-01-11 13:14:46 UTC (rev 7115) +++ sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ContactsStrategy.java 2011-01-11 14:08:49 UTC (rev 7116) @@ -65,9 +65,11 @@ private final String _baseURL; private final String _currentLocale; private final String _appPath; + private SerialFactory _serialFactory; - public ContactsStrategy(Dbms dbms, String appPath, String baseURL, String currentLocale) + public ContactsStrategy(Dbms dbms, String appPath, String baseURL, String currentLocale, SerialFactory serialFactory) { + this._serialFactory = serialFactory; this._baseURL = baseURL; this._dbms = dbms; _styleSheet = appPath + Utils.XSL_REUSABLE_OBJECT_DATA_XSL; @@ -197,7 +199,7 @@ public Collection<Element> add(Element placeholder, Element originalElem, Dbms dbms, String metadataLang) throws Exception { - int id = new SerialFactory().getSerial(dbms, "Users"); + int id = _serialFactory.getSerial(dbms, "Users"); return doAdd (originalElem, id, dbms, metadataLang); } Modified: sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/FormatsStrategy.java =================================================================== --- sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/FormatsStrategy.java 2011-01-11 13:14:46 UTC (rev 7115) +++ sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/FormatsStrategy.java 2011-01-11 14:08:49 UTC (rev 7116) @@ -61,14 +61,16 @@ private final String _styleSheet; private final String _baseURL; private final String _currentLocale; - + private final SerialFactory _serialFactory; - public FormatsStrategy(Dbms dbms, String appPath, String baseURL, String currentLocale) + + public FormatsStrategy(Dbms dbms, String appPath, String baseURL, String currentLocale, SerialFactory serialFactory) { - _baseURL = baseURL; + this._serialFactory = serialFactory; + this._baseURL = baseURL; this._dbms = dbms; - _styleSheet = appPath + Utils.XSL_REUSABLE_OBJECT_DATA_XSL; - _currentLocale = currentLocale; + this._styleSheet = appPath + Utils.XSL_REUSABLE_OBJECT_DATA_XSL; + this._currentLocale = currentLocale; } public Pair<Collection<Element>, Boolean> find(Element placeholder, Element originalElem, String defaultMetadataLang) @@ -206,7 +208,7 @@ if (!xml.isEmpty()) { List<Element> results = new ArrayList<Element>(); for (Element element : xml) { - int id = new SerialFactory().getSerial(dbms, TABLE); + int id = _serialFactory.getSerial(dbms, TABLE); String name = element.getAttributeValue("name"); String version = element.getAttributeValue("version"); if (version == null) { Modified: sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ReusableObjManager.java =================================================================== --- sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ReusableObjManager.java 2011-01-11 13:14:46 UTC (rev 7115) +++ sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ReusableObjManager.java 2011-01-11 14:08:49 UTC (rev 7116) @@ -16,6 +16,7 @@ import jeeves.resources.dbms.Dbms; import jeeves.server.context.ServiceContext; import jeeves.utils.Log; +import jeeves.utils.SerialFactory; import jeeves.utils.Xml; import jeeves.xlink.Processor; import jeeves.xlink.XLink; @@ -61,10 +62,12 @@ private final GMLConfiguration gml3Conf = new GMLConfiguration(); private final org.geotools.gml2.GMLConfiguration gml2Conf = new org.geotools.gml2.GMLConfiguration(); + private final SerialFactory _serialFactory; - public ReusableObjManager(String appPath, Iterator<Element> reusableConfigIter) + public ReusableObjManager(String appPath, Iterator<Element> reusableConfigIter, SerialFactory serialFactory) { + this._serialFactory = serialFactory; this._appPath = appPath; this._styleSheet = appPath + "/xsl/reusable-objects-extractor.xsl"; this._processOnInsert = false; @@ -167,7 +170,6 @@ { try { - lock.lock(); Log.info(ReusableObjectLogger.REUSABLE_LOGGER_ID, "Beginning reusable object processing on metadata object id= " + parameterObject.metadataId); @@ -218,8 +220,6 @@ s.close(); throw x; - } finally { - lock.unlock(); } } @@ -242,7 +242,7 @@ ReusableObjectLogger logger = params.logger; String baseURL = params.baseURL; - FormatsStrategy strategy = new FormatsStrategy(dbms, _appPath, baseURL, null); + FormatsStrategy strategy = new FormatsStrategy(dbms, _appPath, baseURL, null, _serialFactory); return performReplace(dbms, xml, defaultMetadataLang, FORMATS_PLACEHOLDER, FORMATS, logger, strategy, params.addOnly); } @@ -253,7 +253,7 @@ ReusableObjectLogger logger = params.logger; String baseURL = params.baseURL; - ContactsStrategy strategy = new ContactsStrategy(dbms, _appPath, baseURL, null); + ContactsStrategy strategy = new ContactsStrategy(dbms, _appPath, baseURL, null, _serialFactory); return performReplace(dbms, xml, defaultMetadataLang, CONTACTS_PLACEHOLDER, CONTACTS, logger, strategy, params.addOnly); } @@ -398,9 +398,9 @@ if (xlink.getName().equals("contact") || xlink.getName().equals("pointOfContact") || xlink.getName().equals("distributorContact") || xlink.getName().equals("citedResponsibleParty")) { - strategy = new ContactsStrategy(dbms, _appPath, baseUrl, "unknown"); + strategy = new ContactsStrategy(dbms, _appPath, baseUrl, "unknown", _serialFactory); } else if (xlink.getName().equals("resourceFormat") || xlink.getName().equals("distributionFormat")) { - strategy = new FormatsStrategy(dbms, _appPath, baseUrl, "unknown"); + strategy = new FormatsStrategy(dbms, _appPath, baseUrl, "unknown", _serialFactory); } else if (xlink.getName().equals("descriptiveKeywords")) { strategy = new KeywordsStrategy(params.thesaurusManager, _appPath, baseUrl, "unknown"); } else { Modified: sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/Utils.java =================================================================== --- sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/Utils.java 2011-01-11 13:14:46 UTC (rev 7115) +++ sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/Utils.java 2011-01-11 14:08:49 UTC (rev 7116) @@ -213,7 +213,7 @@ * Get all the metadata that use the xlink. This does a sql like query so * only a unique portion of the sql is required * - * @param context + * @param context */ public static Set<MetadataRecord> getReferencingMetadata(ServiceContext context, String[] luceneFields, String id, boolean loadMetadata, Function<String,String> idConverter) throws Exception @@ -225,7 +225,7 @@ Dbms dbms = (Dbms) context.getResourceManager().open(Geonet.Res.MAIN_DB); SearchManager searchManager = gc.getSearchmanager(); - + MultiLingualIndexSupport support = new MultiLingualIndexSupport(searchManager); MultiSearcher searcher = support.createMultiMetaSearcher(support.sortCurrentLocalFirst(context.getLanguage())); @@ -387,10 +387,10 @@ strategy = new KeywordsStrategy(gc.getThesaurusManager(), appPath, baseUrl, language); break; case formats: - strategy = new FormatsStrategy(dbms, appPath, baseUrl, language); + strategy = new FormatsStrategy(dbms, appPath, baseUrl, language, context.getSerialFactory()); break; case contacts: - strategy = new ContactsStrategy(dbms, appPath, baseUrl, language); + strategy = new ContactsStrategy(dbms, appPath, baseUrl, language, context.getSerialFactory()); break; default: break; Modified: sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ViewNonValidated.java =================================================================== --- sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ViewNonValidated.java 2011-01-11 13:14:46 UTC (rev 7115) +++ sandbox/geocat.ch/trunk/src/org/fao/geonet/services/reusable/ViewNonValidated.java 2011-01-11 14:08:49 UTC (rev 7116) @@ -36,7 +36,7 @@ /** * Makes a list of all the non-validated elements - * + * * @author jeichar */ public class ViewNonValidated implements Service @@ -61,13 +61,13 @@ switch (ReusableTypes.valueOf(type)) { case contacts: - strategy = new ContactsStrategy(dbms, appPath, baseUrl, language); + strategy = new ContactsStrategy(dbms, appPath, baseUrl, language, context.getSerialFactory()); break; case extents: strategy = new ExtentsStrategy(baseUrl, appPath, gc.getExtentManager(), language); break; case formats: - strategy = new FormatsStrategy(dbms, appPath, baseUrl, language); + strategy = new FormatsStrategy(dbms, appPath, baseUrl, language, context.getSerialFactory()); break; case keywords: strategy = new KeywordsStrategy(gc.getThesaurusManager(), appPath, baseUrl, language); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |