diff --git a/common/.gitignore b/common/.gitignore new file mode 100644 index 00000000000..ea8c4bf7f35 --- /dev/null +++ b/common/.gitignore @@ -0,0 +1 @@ +/target diff --git a/common/src/main/java/org/fao/geonet/NodeInfo.java b/common/src/main/java/org/fao/geonet/NodeInfo.java index 00ff9f1bb10..1f538f4cd29 100644 --- a/common/src/main/java/org/fao/geonet/NodeInfo.java +++ b/common/src/main/java/org/fao/geonet/NodeInfo.java @@ -2,6 +2,8 @@ import java.io.Serializable; +import javax.annotation.Resource; + /** * Encapsulates informations about the current node such as the node id. * diff --git a/common/src/main/java/org/fao/geonet/utils/GeonetHttpRequestFactory.java b/common/src/main/java/org/fao/geonet/utils/GeonetHttpRequestFactory.java index 7d4bcacc865..cccde2c0a7d 100644 --- a/common/src/main/java/org/fao/geonet/utils/GeonetHttpRequestFactory.java +++ b/common/src/main/java/org/fao/geonet/utils/GeonetHttpRequestFactory.java @@ -51,6 +51,13 @@ public synchronized void setNumberOfConcurrentRequests(int numberOfConcurrentReq this.numberOfConcurrentRequests = numberOfConcurrentRequests; } + public synchronized int getNumberOfConcurrentRequests() { + return this.numberOfConcurrentRequests; + } + public synchronized HttpClientConnectionManager getNonShutdownableConnectionManager() { + return this.nonShutdownableConnectionManager; + } + /** * Create a default XmlRequest. * @@ -151,7 +158,7 @@ public HttpClientBuilder getDefaultHttpClientBuilder() { synchronized (this) { if (connectionManager == null) { connectionManager = new PoolingHttpClientConnectionManager(); - connectionManager.setMaxTotal(this.numberOfConcurrentRequests); + connectionManager.setMaxTotal(this.getNumberOfConcurrentRequests()); nonShutdownableConnectionManager = new HttpClientConnectionManager() { public void closeExpiredConnections() { connectionManager.closeExpiredConnections(); @@ -189,7 +196,6 @@ public void closeIdleConnections(long idleTimeout, TimeUnit tunit) { builder.setConnectionManager(nonShutdownableConnectionManager); } - return builder; } diff --git a/core/src/main/java/org/fao/geonet/kernel/AccessManager.java b/core/src/main/java/org/fao/geonet/kernel/AccessManager.java index d494912e7b5..79030e6f174 100644 --- a/core/src/main/java/org/fao/geonet/kernel/AccessManager.java +++ b/core/src/main/java/org/fao/geonet/kernel/AccessManager.java @@ -23,27 +23,50 @@ package org.fao.geonet.kernel; -import static org.fao.geonet.repository.specification.OperationAllowedSpecs.*; +import static org.fao.geonet.repository.specification.OperationAllowedSpecs.hasMetadataId; +import static org.fao.geonet.repository.specification.OperationAllowedSpecs.hasOperation; import static org.springframework.data.jpa.domain.Specifications.where; -import java.util.*; + +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.StringTokenizer; import jeeves.server.UserSession; import jeeves.server.context.ServiceContext; -import org.fao.geonet.domain.*; +import org.fao.geonet.domain.Group; +import org.fao.geonet.domain.HarvesterSetting; +import org.fao.geonet.domain.Metadata; +import org.fao.geonet.domain.Operation; +import org.fao.geonet.domain.OperationAllowed; import org.fao.geonet.domain.Pair; -import org.fao.geonet.repository.*; +import org.fao.geonet.domain.Profile; +import org.fao.geonet.domain.ReservedGroup; +import org.fao.geonet.domain.ReservedOperation; +import org.fao.geonet.domain.User; +import org.fao.geonet.domain.UserGroup; +import org.fao.geonet.domain.User_; +import org.fao.geonet.repository.GroupRepository; +import org.fao.geonet.repository.HarvesterSettingRepository; +import org.fao.geonet.repository.MetadataRepository; +import org.fao.geonet.repository.OperationAllowedRepository; +import org.fao.geonet.repository.OperationRepository; +import org.fao.geonet.repository.SortUtils; +import org.fao.geonet.repository.UserGroupRepository; +import org.fao.geonet.repository.UserRepository; import org.fao.geonet.repository.specification.UserGroupSpecs; import org.jdom.Element; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specifications; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; /** * Handles the access to a metadata depending on the metadata/group. */ +@Service public class AccessManager { @Autowired diff --git a/core/src/main/java/org/fao/geonet/kernel/DataManager.java b/core/src/main/java/org/fao/geonet/kernel/DataManager.java index 8c0e266781e..8ae9d45c6ac 100644 --- a/core/src/main/java/org/fao/geonet/kernel/DataManager.java +++ b/core/src/main/java/org/fao/geonet/kernel/DataManager.java @@ -29,42 +29,99 @@ import static org.fao.geonet.repository.specification.MetadataSpecs.hasMetadataUuid; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.collect.Collections2; -import org.eclipse.jetty.util.ConcurrentHashSet; -import org.fao.geonet.exceptions.JeevesException; -import org.fao.geonet.exceptions.ServiceNotAllowedEx; -import org.fao.geonet.exceptions.XSDValidationErrorEx; +import java.io.File; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.Vector; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + import jeeves.server.UserSession; import jeeves.server.context.ServiceContext; -import org.fao.geonet.utils.Log; -import org.fao.geonet.utils.Xml; -import org.fao.geonet.utils.Xml.ErrorHandler; import jeeves.xlink.Processor; import org.apache.commons.lang.StringUtils; +import org.eclipse.jetty.util.ConcurrentHashSet; import org.fao.geonet.GeonetContext; import org.fao.geonet.constants.Edit; import org.fao.geonet.constants.Geonet; import org.fao.geonet.constants.Geonet.Namespaces; import org.fao.geonet.constants.Params; -import org.fao.geonet.domain.*; +import org.fao.geonet.domain.Constants; +import org.fao.geonet.domain.ISODate; +import org.fao.geonet.domain.Metadata; +import org.fao.geonet.domain.MetadataCategory; +import org.fao.geonet.domain.MetadataDataInfo; +import org.fao.geonet.domain.MetadataDataInfo_; +import org.fao.geonet.domain.MetadataHarvestInfo; +import org.fao.geonet.domain.MetadataRatingByIp; +import org.fao.geonet.domain.MetadataRatingByIpId; +import org.fao.geonet.domain.MetadataStatus; +import org.fao.geonet.domain.MetadataStatusId; +import org.fao.geonet.domain.MetadataStatusId_; +import org.fao.geonet.domain.MetadataStatus_; +import org.fao.geonet.domain.MetadataType; +import org.fao.geonet.domain.MetadataValidation; +import org.fao.geonet.domain.MetadataValidationId; +import org.fao.geonet.domain.MetadataValidationStatus; +import org.fao.geonet.domain.Metadata_; +import org.fao.geonet.domain.Operation; +import org.fao.geonet.domain.OperationAllowed; +import org.fao.geonet.domain.OperationAllowedId; +import org.fao.geonet.domain.OperationAllowedId_; +import org.fao.geonet.domain.Pair; +import org.fao.geonet.domain.Profile; +import org.fao.geonet.domain.ReservedGroup; +import org.fao.geonet.domain.ReservedOperation; +import org.fao.geonet.domain.User; +import org.fao.geonet.domain.UserGroup; +import org.fao.geonet.domain.UserGroupId; +import org.fao.geonet.exceptions.JeevesException; import org.fao.geonet.exceptions.NoSchemaMatchesException; import org.fao.geonet.exceptions.SchemaMatchConflictException; import org.fao.geonet.exceptions.SchematronValidationErrorEx; +import org.fao.geonet.exceptions.ServiceNotAllowedEx; +import org.fao.geonet.exceptions.XSDValidationErrorEx; import org.fao.geonet.kernel.schema.MetadataSchema; import org.fao.geonet.kernel.search.SearchManager; -import org.fao.geonet.domain.Pair; import org.fao.geonet.kernel.setting.SettingManager; import org.fao.geonet.lib.Lib; import org.fao.geonet.notifier.MetadataNotifierManager; -import org.fao.geonet.repository.*; +import org.fao.geonet.repository.MetadataCategoryRepository; +import org.fao.geonet.repository.MetadataRatingByIpRepository; +import org.fao.geonet.repository.MetadataRepository; +import org.fao.geonet.repository.MetadataStatusRepository; +import org.fao.geonet.repository.MetadataValidationRepository; +import org.fao.geonet.repository.OperationAllowedRepository; +import org.fao.geonet.repository.SortUtils; +import org.fao.geonet.repository.StatusValueRepository; +import org.fao.geonet.repository.Updater; +import org.fao.geonet.repository.UserGroupRepository; +import org.fao.geonet.repository.UserRepository; import org.fao.geonet.repository.specification.MetadataSpecs; import org.fao.geonet.repository.specification.MetadataStatusSpecs; import org.fao.geonet.repository.specification.UserGroupSpecs; import org.fao.geonet.repository.specification.UserSpecs; import org.fao.geonet.util.ThreadUtils; +import org.fao.geonet.utils.Log; +import org.fao.geonet.utils.Xml; +import org.fao.geonet.utils.Xml.ErrorHandler; import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element; @@ -78,39 +135,22 @@ import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specifications; +import org.springframework.stereotype.Controller; import org.springframework.transaction.NoTransactionException; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -import java.io.File; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.Vector; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.collect.Collections2; /** * Handles all operations on metadata (select,insert,update,delete etc...). * */ +@Controller @Transactional(propagation = Propagation.REQUIRED, noRollbackFor = {XSDValidationErrorEx.class, NoSchemaMatchesException.class}) public class DataManager { diff --git a/core/src/main/java/org/fao/geonet/kernel/GeonetworkDataDirectory.java b/core/src/main/java/org/fao/geonet/kernel/GeonetworkDataDirectory.java index b608372153f..f0b3c8b29a3 100644 --- a/core/src/main/java/org/fao/geonet/kernel/GeonetworkDataDirectory.java +++ b/core/src/main/java/org/fao/geonet/kernel/GeonetworkDataDirectory.java @@ -5,17 +5,15 @@ import jeeves.server.ServiceConfig; import jeeves.server.sources.http.JeevesServlet; -import org.apache.commons.io.FileUtils; -import org.fao.geonet.Constants; + import org.fao.geonet.NodeInfo; +import org.fao.geonet.constants.Geonet; import org.fao.geonet.utils.BinaryFile; import org.fao.geonet.utils.IO; import org.fao.geonet.utils.Log; - -import org.fao.geonet.constants.Geonet; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; /** * The GeoNetwork data directory is the location on the file system where @@ -25,6 +23,7 @@ * used by GeoNetwork for various purposes (eg. Lucene index, spatial index, * logos). */ +@Service public class GeonetworkDataDirectory { /** * The default GeoNetwork data directory location. diff --git a/core/src/main/java/org/fao/geonet/kernel/search/LuceneConfig.java b/core/src/main/java/org/fao/geonet/kernel/search/LuceneConfig.java index b1ef476cb5a..d8ab0384701 100644 --- a/core/src/main/java/org/fao/geonet/kernel/search/LuceneConfig.java +++ b/core/src/main/java/org/fao/geonet/kernel/search/LuceneConfig.java @@ -38,10 +38,10 @@ import jeeves.server.context.ServiceContext; import jeeves.server.overrides.ConfigurationOverrides; + import org.fao.geonet.kernel.GeonetworkDataDirectory; import org.fao.geonet.utils.Log; import org.fao.geonet.utils.Xml; - import org.apache.lucene.search.TopFieldCollector; import org.apache.lucene.util.NumericUtils; import org.apache.lucene.util.Version; @@ -52,6 +52,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; /** * Lucene configuration class load Lucene XML configuration file. @@ -59,6 +60,7 @@ * @author fxprunayre * */ +@Service public class LuceneConfig { public static final String USE_NRT_MANAGER_REOPEN_THREAD = "useNRTManagerReopenThread"; private static final int ANALYZER_CLASS = 1; diff --git a/core/src/main/java/org/fao/geonet/kernel/search/SearchManager.java b/core/src/main/java/org/fao/geonet/kernel/search/SearchManager.java index cf3354129dc..bdfb5bff67b 100644 --- a/core/src/main/java/org/fao/geonet/kernel/search/SearchManager.java +++ b/core/src/main/java/org/fao/geonet/kernel/search/SearchManager.java @@ -22,17 +22,30 @@ package org.fao.geonet.kernel.search; -import com.vividsolutions.jts.geom.Envelope; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.index.SpatialIndex; -import org.fao.geonet.domain.MetadataType; -import org.fao.geonet.kernel.GeonetworkDataDirectory; -import org.fao.geonet.exceptions.JeevesException; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedSet; +import java.util.Timer; +import java.util.TimerTask; +import java.util.TreeSet; +import java.util.Vector; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + import jeeves.server.context.ServiceContext; -import org.fao.geonet.utils.IO; -import org.fao.geonet.utils.Log; -import org.fao.geonet.Util; -import org.fao.geonet.utils.Xml; + import org.apache.commons.lang.StringUtils; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.core.KeywordAnalyzer; @@ -56,8 +69,13 @@ import org.apache.lucene.search.Filter; import org.apache.lucene.util.BytesRef; import org.fao.geonet.GeonetContext; +import org.fao.geonet.Util; import org.fao.geonet.constants.Geonet; +import org.fao.geonet.domain.MetadataType; +import org.fao.geonet.domain.Pair; +import org.fao.geonet.exceptions.JeevesException; import org.fao.geonet.kernel.DataManager; +import org.fao.geonet.kernel.GeonetworkDataDirectory; import org.fao.geonet.kernel.SchemaManager; import org.fao.geonet.kernel.search.LuceneConfig.FacetConfig; import org.fao.geonet.kernel.search.LuceneConfig.LuceneConfigNumericField; @@ -72,12 +90,14 @@ import org.fao.geonet.kernel.search.spatial.OgcGenericFilters; import org.fao.geonet.kernel.search.spatial.OrSpatialFilter; import org.fao.geonet.kernel.search.spatial.OverlapsFilter; -import org.fao.geonet.domain.Pair; import org.fao.geonet.kernel.search.spatial.SpatialFilter; import org.fao.geonet.kernel.search.spatial.SpatialIndexWriter; import org.fao.geonet.kernel.search.spatial.TouchesFilter; import org.fao.geonet.kernel.search.spatial.WithinFilter; import org.fao.geonet.kernel.setting.SettingInfo; +import org.fao.geonet.utils.IO; +import org.fao.geonet.utils.Log; +import org.fao.geonet.utils.Xml; import org.geotools.data.DataStore; import org.geotools.data.DefaultTransaction; import org.geotools.data.FeatureSource; @@ -92,34 +112,16 @@ import org.opengis.filter.capability.FilterCapabilities; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.SortedSet; -import java.util.Timer; -import java.util.TimerTask; -import java.util.TreeSet; -import java.util.Vector; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.index.SpatialIndex; /** * Indexes metadata using Lucene. */ +@Service public class SearchManager { private static final String INDEXING_ERROR_MSG = "_indexingErrorMsg"; private static final String INDEXING_ERROR_FIELD = "_indexingError"; diff --git a/core/src/main/java/org/fao/geonet/kernel/search/index/LuceneIndexLanguageTracker.java b/core/src/main/java/org/fao/geonet/kernel/search/index/LuceneIndexLanguageTracker.java index 89d09f56f63..63cc5a3f48a 100644 --- a/core/src/main/java/org/fao/geonet/kernel/search/index/LuceneIndexLanguageTracker.java +++ b/core/src/main/java/org/fao/geonet/kernel/search/index/LuceneIndexLanguageTracker.java @@ -1,10 +1,27 @@ package org.fao.geonet.kernel.search.index; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + import org.apache.commons.io.IOUtils; import org.apache.lucene.document.Document; import org.apache.lucene.facet.taxonomy.CategoryPath; import org.apache.lucene.facet.taxonomy.TaxonomyWriter; -import org.apache.lucene.index.*; +import org.apache.lucene.index.ConcurrentMergeScheduler; +import org.apache.lucene.index.CorruptIndexException; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.index.Term; import org.apache.lucene.search.NRTManager.TrackingIndexWriter; import org.apache.lucene.store.Directory; import org.apache.lucene.store.LockObtainFailedException; @@ -15,15 +32,7 @@ import org.fao.geonet.kernel.search.index.GeonetworkNRTManager.AcquireResult; import org.fao.geonet.utils.Log; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; +import org.springframework.stereotype.Service; /** * Keeps track of the lucene indexes that currently exist so that we don't have @@ -31,6 +40,7 @@ * * @author jeichar */ +@Service public class LuceneIndexLanguageTracker { private final Map dirs = new HashMap(); private final Map trackingWriters = new HashMap(); diff --git a/core/src/main/java/org/fao/geonet/kernel/setting/HarvesterSettingsManager.java b/core/src/main/java/org/fao/geonet/kernel/setting/HarvesterSettingsManager.java index a307a08fca0..3ba0ac7fabb 100644 --- a/core/src/main/java/org/fao/geonet/kernel/setting/HarvesterSettingsManager.java +++ b/core/src/main/java/org/fao/geonet/kernel/setting/HarvesterSettingsManager.java @@ -32,14 +32,13 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import org.fao.geonet.utils.Log; - import org.fao.geonet.constants.Geonet; import org.fao.geonet.domain.HarvesterSetting; import org.fao.geonet.repository.HarvesterSettingRepository; +import org.fao.geonet.utils.Log; import org.jdom.Element; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; /** * Allows hierarchical management of harvester settings. The harvester settings API has been designed with the following goals: @@ -63,6 +62,7 @@ * Harvester settings depend on the harvester's protocol. * */ +@Service public class HarvesterSettingsManager { @Autowired diff --git a/core/src/main/java/org/fao/geonet/kernel/setting/ISettingManager.java b/core/src/main/java/org/fao/geonet/kernel/setting/ISettingManager.java new file mode 100644 index 00000000000..20e827ec300 --- /dev/null +++ b/core/src/main/java/org/fao/geonet/kernel/setting/ISettingManager.java @@ -0,0 +1,138 @@ +package org.fao.geonet.kernel.setting; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; + +import jeeves.server.context.ServiceContext; + +import org.fao.geonet.domain.Setting; +import org.jdom.Element; + +/** + * Used to change from Jeeves to Spring MVC easily. Deprecating all Element + * objects, as without Jeeves it doesn't make sense. + * + * @author delawen + * + */ +public interface ISettingManager { + + /** + * Get all settings as xml. + * + * @param asTree + * get the settings as a tree + * + * @return all settings as xml. + */ + @Deprecated + public abstract Element getAllAsXML(boolean asTree); + + /** + * Get all settings as list. + * + * + * @return all settings as list. + */ + public abstract List getAllAsList(); + + /** + * Return a setting by its key + * + * @param path + * eg. system/site/name + */ + public abstract String getValue(String path); + + /** + * Return a set of values as XML + * + * @param keys + * A list of setting's key to retrieve + */ + @Deprecated + public abstract Element getValues(String[] keys); + + /** + * Get value of a setting as boolean + * + * @param key + * The setting key + * @return The setting valueThe setting key + */ + public abstract boolean getValueAsBool(String key); + + /** + * Get value of a setting as boolean + * + * @param key + * The setting key + * @param defaultValue + * The default value + * @return The setting value as boolean + */ + public abstract boolean getValueAsBool(String key, boolean defaultValue); + + /** + * Get value of a setting as integer + * + * @param key + * The setting key + * @return The integer value of the setting or null + */ + public abstract Integer getValueAsInt(String key); + + /** + * Set the value of a Setting entity + * + * @param key + * the path/name/key of the setting. + * @param value + * the new value + * + * @return true if the types are correct and the setting is found. + */ + public abstract boolean setValue(String key, String value); + + /** + * Set the setting value by key to the boolean value. + * + * @param key + * the key/path/name of the setting. + * @param value + * the new boolean value + */ + public abstract boolean setValue(String key, boolean value); + + /** + * Set a list of settings. + * + * @param values + * The settings to update + * @return true if the types are correct and the setting is found. + * + * @throws SQLException + */ + public abstract boolean setValues(Map values); + + /** + * Refreshes current settings manager. This has to be used when updating the + * Settings table without using this class. For example when using an SQL + * script. + */ + public abstract boolean refresh() throws SQLException; + + public abstract String getSiteId(); + + public abstract String getSiteName(); + + public abstract void setSiteUuid(String siteUuid); + + public abstract String getSiteURL(ServiceContext context); + + public abstract boolean getHideWitheldElements(); + + public abstract boolean setHideWitheldElements(boolean value); + +} \ No newline at end of file diff --git a/core/src/main/java/org/fao/geonet/kernel/setting/SettingInfo.java b/core/src/main/java/org/fao/geonet/kernel/setting/SettingInfo.java index bbb669414c4..6d9eea4cd08 100644 --- a/core/src/main/java/org/fao/geonet/kernel/setting/SettingInfo.java +++ b/core/src/main/java/org/fao/geonet/kernel/setting/SettingInfo.java @@ -23,13 +23,14 @@ package org.fao.geonet.kernel.setting; +import java.util.Calendar; + import org.fao.geonet.constants.Geonet; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Calendar; +import org.springframework.stereotype.Service; //============================================================================= +@Service public class SettingInfo { @Autowired private SettingManager _settingManager; diff --git a/core/src/main/java/org/fao/geonet/kernel/setting/SettingManager.java b/core/src/main/java/org/fao/geonet/kernel/setting/SettingManager.java index a21d0a7a932..e710864cc1f 100644 --- a/core/src/main/java/org/fao/geonet/kernel/setting/SettingManager.java +++ b/core/src/main/java/org/fao/geonet/kernel/setting/SettingManager.java @@ -24,34 +24,37 @@ package org.fao.geonet.kernel.setting; import java.sql.SQLException; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; import javax.annotation.Nonnull; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; +import javax.persistence.EntityManagerFactory; import jeeves.constants.Jeeves; import jeeves.server.context.ServiceContext; -import org.fao.geonet.repository.LanguageRepository; -import org.fao.geonet.repository.SortUtils; -import org.fao.geonet.utils.Log; +import org.apache.commons.lang.NotImplementedException; import org.fao.geonet.constants.Geonet; import org.fao.geonet.domain.HarvesterSetting; import org.fao.geonet.domain.Setting; import org.fao.geonet.domain.Setting_; +import org.fao.geonet.repository.LanguageRepository; import org.fao.geonet.repository.SettingRepository; +import org.fao.geonet.repository.SortUtils; +import org.fao.geonet.utils.Log; import org.jdom.Element; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; /** * A convenience class for updating and accessing settings. One of the primary needs of this * class at the moment is to maintain backwards compatibility so not all code and xsl files * that make use of the settings need to be modified. */ -public class SettingManager { +@Service +public class SettingManager implements ISettingManager { public static final String SYSTEM_SITE_SITE_ID_PATH = "system/site/siteId"; public static final String SYSTEM_SITE_NAME_PATH = "system/site/name"; @@ -74,8 +77,12 @@ public class SettingManager { @Autowired private SettingRepository _repo; - @PersistenceContext - private EntityManager _entityManager; + /** + * Do not use @PersistenceContext + * https://weblogs.java.net/blog/ss141213/archive/2005/12/dont_use_persis_1.html + */ + @Autowired + private EntityManagerFactory _entityManagerFactory; /** * Get all settings as xml. @@ -84,7 +91,8 @@ public class SettingManager { * * @return all settings as xml. */ - public Element getAllAsXML(boolean asTree) { + @Override + public Element getAllAsXML(boolean asTree) { Element env = new Element("settings"); List settings = _repo.findAll(SortUtils.createSort(Setting_.name)); @@ -135,7 +143,8 @@ private void buildXmlTree(Element env, Map pathElements, Settin * * @param path eg. system/site/name */ - public String getValue(String path) { + @Override + public String getValue(String path) { if (Log.isDebugEnabled(Geonet.SETTINGS)) { Log.debug(Geonet.SETTINGS, "Requested setting with name: " + path); } @@ -160,7 +169,8 @@ public String getValue(String path) { * * @param keys A list of setting's key to retrieve */ - public Element getValues(String[] keys) { + @Override + public Element getValues(String[] keys) { Element env = new Element("settings"); for (int i = 0; i < keys.length; i++) { String key = keys[i]; @@ -185,7 +195,8 @@ public Element getValues(String[] keys) { * @param key The setting key * @return The setting valueThe setting key */ - public boolean getValueAsBool(String key) { + @Override + public boolean getValueAsBool(String key) { String value = getValue(key); if (value == null) return false; @@ -199,7 +210,8 @@ public boolean getValueAsBool(String key) { * @param defaultValue The default value * @return The setting value as boolean */ - public boolean getValueAsBool(String key, boolean defaultValue) { + @Override + public boolean getValueAsBool(String key, boolean defaultValue) { String value = getValue(key); return (value != null) ? Boolean.parseBoolean(value) : defaultValue; } @@ -210,7 +222,8 @@ public boolean getValueAsBool(String key, boolean defaultValue) { * @param key The setting key * @return The integer value of the setting or null */ - public Integer getValueAsInt(String key) { + @Override + public Integer getValueAsInt(String key) { String value = getValue(key); if (value == null || value.trim().length() == 0) return null; @@ -225,7 +238,8 @@ public Integer getValueAsInt(String key) { * * @return true if the types are correct and the setting is found. */ - public boolean setValue(String key, String value) { + @Override + public boolean setValue(String key, String value) { if (Log.isDebugEnabled(Geonet.SETTINGS)) { Log.debug(Geonet.SETTINGS, "Setting with name: " + key + ", value: " + value); } @@ -250,7 +264,8 @@ public boolean setValue(String key, String value) { * @param key the key/path/name of the setting. * @param value the new boolean value */ - public boolean setValue(String key, boolean value) { + @Override + public boolean setValue(String key, boolean value) { return setValue(key, String.valueOf(value)); } @@ -262,7 +277,8 @@ public boolean setValue(String key, boolean value) { * * @throws SQLException */ - public final boolean setValues(final Map values) { + @Override + public final boolean setValues(final Map values) { boolean success = true; for (Map.Entry entry : values.entrySet()) { String key = entry.getKey(); @@ -276,24 +292,41 @@ public final boolean setValues(final Map values) { * Refreshes current settings manager. This has to be used when updating the Settings table without using this class. For example when * using an SQL script. */ - public final boolean refresh() throws SQLException { - _entityManager.getEntityManagerFactory().getCache().evict(HarvesterSetting.class); + @Override + public final boolean refresh() throws SQLException { + _entityManagerFactory.getCache().evict(HarvesterSetting.class); return true; } - public final String getSiteId() { + /* (non-Javadoc) + * @see org.fao.geonet.kernel.setting.ISettingManager#getSiteId() + */ + @Override + public final String getSiteId() { return getValue(SYSTEM_SITE_SITE_ID_PATH); } - public final String getSiteName() { + /* (non-Javadoc) + * @see org.fao.geonet.kernel.setting.ISettingManager#getSiteName() + */ + @Override + public final String getSiteName() { return getValue(SYSTEM_SITE_NAME_PATH); } - public void setSiteUuid(String siteUuid) { + /* (non-Javadoc) + * @see org.fao.geonet.kernel.setting.ISettingManager#setSiteUuid(java.lang.String) + */ + @Override + public void setSiteUuid(String siteUuid) { setValue(SYSTEM_SITE_SITE_ID_PATH, siteUuid); } - public @Nonnull String getSiteURL(@Nonnull ServiceContext context) { + /* (non-Javadoc) + * @see org.fao.geonet.kernel.setting.ISettingManager#getSiteURL(jeeves.server.context.ServiceContext) + */ + @Override + public @Nonnull String getSiteURL(@Nonnull ServiceContext context) { String lang = context.getLanguage(); if(lang == null) { lang = context.getBean(LanguageRepository.class).findOneByDefaultLanguage().getId(); @@ -307,11 +340,24 @@ public void setSiteUuid(String siteUuid) { return protocol + "://" + host + (port.equals("80") ? "" : ":" + port) + locServ; } - public boolean getHideWitheldElements() { + /* (non-Javadoc) + * @see org.fao.geonet.kernel.setting.ISettingManager#getHideWitheldElements() + */ + @Override + public boolean getHideWitheldElements() { return getValueAsBool("system/"+Geonet.Config.HIDE_WITHHELD_ELEMENTS+"/enable", false); } - public boolean setHideWitheldElements(boolean value) { + /* (non-Javadoc) + * @see org.fao.geonet.kernel.setting.ISettingManager#setHideWitheldElements(boolean) + */ + @Override + public boolean setHideWitheldElements(boolean value) { return setValue("system/"+Geonet.Config.HIDE_WITHHELD_ELEMENTS+"/enable", value); } + + @Override + public List getAllAsList() { + throw new NotImplementedException("This is the Jeeves class, use the Spring autowired class"); + } } diff --git a/core/src/main/java/org/fao/geonet/kernel/setting/SpringSettingManager.java b/core/src/main/java/org/fao/geonet/kernel/setting/SpringSettingManager.java new file mode 100644 index 00000000000..bda9ff51aac --- /dev/null +++ b/core/src/main/java/org/fao/geonet/kernel/setting/SpringSettingManager.java @@ -0,0 +1,187 @@ +//============================================================================= +//=== Copyright (C) 2001-2013 Food and Agriculture Organization of the +//=== United Nations (FAO-UN), United Nations World Food Programme (WFP) +//=== and United Nations Environment Programme (UNEP) +//=== +//=== This program is free software; you can redistribute it and/or modify +//=== it under the terms of the GNU General Public License as published by +//=== the Free Software Foundation; either version 2 of the License, or (at +//=== your option) any later version. +//=== +//=== This program is distributed in the hope that it will be useful, but +//=== WITHOUT ANY WARRANTY; without even the implied warranty of +//=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//=== General Public License for more details. +//=== +//=== You should have received a copy of the GNU General Public License +//=== along with this program; if not, write to the Free Software +//=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +//=== +//=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2, +//=== Rome - Italy. email: geonetwork@osgeo.org +//============================================================================== + +package org.fao.geonet.kernel.setting; + +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jeeves.server.context.ServiceContext; + +import org.apache.commons.lang.NotImplementedException; +import org.fao.geonet.domain.Setting; +import org.fao.geonet.repository.SettingRepository; +import org.jdom.Element; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * A convenience class for updating and accessing settings. One of the primary needs of this + * class at the moment is to maintain backwards compatibility so not all code and xsl files + * that make use of the settings need to be modified. + */ +@Component +public class SpringSettingManager implements ISettingManager { + + @Autowired + private SettingRepository settingrepository; + + public SettingRepository getSettingrepository() { + return settingrepository; + } + + public void setSettingrepository(SettingRepository settingrepository) { + this.settingrepository = settingrepository; + } + + @Override + public Element getAllAsXML(boolean asTree) { + Element env = new Element("settings"); + List settings = getAllAsList(); + Map pathElements = new HashMap(); + + for (Setting setting : settings) { + if (asTree) { + buildXmlTree(env, pathElements, setting); + } else { + Element settingEl = new Element("setting"); + settingEl.setAttribute("name", setting.getName()); + settingEl.setAttribute("position", String.valueOf(setting.getPosition())); + settingEl.setAttribute("datatype", String.valueOf(setting.getDataType())); + settingEl.setText(setting.getValue()); + env.addContent(settingEl); + } + } + return env; + } + + private void buildXmlTree(Element env, Map pathElements, Setting setting) { + String[] segments = setting.getName().split("/"); + Element parent = env; + StringBuilder path = new StringBuilder(); + for (int i = 0; i < segments.length; i++) { + String segment = segments[i]; + path.append("/"); + path.append(segment); + Element currentElement = pathElements.get(path); + if (currentElement == null) { + currentElement = new Element(segment); + currentElement.setAttribute("name", path.substring(1)); + currentElement.setAttribute("position", String.valueOf(setting.getPosition())); + if (i == segments.length - 1) { + currentElement.setAttribute("datatype", String.valueOf(setting.getDataType().ordinal())); + currentElement.setAttribute("datatypeName", setting.getDataType().name()); + currentElement.setText(setting.getValue()); + } + parent.addContent(currentElement); + pathElements.put(path.toString(), currentElement); + } + + parent = currentElement; + } + } + + @Override + public List getAllAsList() { + return settingrepository.findAll(); + } + + @Override + public String getValue(String path) { + throw new NotImplementedException(); + } + + @Override + public Element getValues(String[] keys) { + throw new NotImplementedException(); + } + + @Override + public boolean getValueAsBool(String key) { + throw new NotImplementedException(); + } + + @Override + public boolean getValueAsBool(String key, boolean defaultValue) { + throw new NotImplementedException(); + } + + @Override + public Integer getValueAsInt(String key) { + throw new NotImplementedException(); + } + + @Override + public boolean setValue(String key, String value) { + throw new NotImplementedException(); + } + + @Override + public boolean setValue(String key, boolean value) { + throw new NotImplementedException(); + } + + @Override + public boolean setValues(Map values) { + throw new NotImplementedException(); + } + + @Override + public boolean refresh() throws SQLException { + throw new NotImplementedException(); + } + + @Override + public String getSiteId() { + throw new NotImplementedException(); + } + + @Override + public String getSiteName() { + throw new NotImplementedException(); + } + + @Override + public void setSiteUuid(String siteUuid) { + throw new NotImplementedException(); + } + + @Override + public String getSiteURL(ServiceContext context) { + throw new NotImplementedException(); + } + + @Override + public boolean getHideWitheldElements() { + throw new NotImplementedException(); + } + + @Override + public boolean setHideWitheldElements(boolean value) { + throw new NotImplementedException(); + } + + +} diff --git a/core/src/main/java/org/fao/geonet/web/LocaleRedirects.java b/core/src/main/java/org/fao/geonet/web/LocaleRedirects.java index a4cb6e42c34..bad45774a19 100644 --- a/core/src/main/java/org/fao/geonet/web/LocaleRedirects.java +++ b/core/src/main/java/org/fao/geonet/web/LocaleRedirects.java @@ -38,7 +38,6 @@ * Created by Jesse on 12/4/13. */ @Controller -@Lazy(value = false) public class LocaleRedirects { @@ -58,6 +57,9 @@ public class LocaleRedirects { @Autowired private ApplicationContext _appContext; + + @Autowired + private String configPath; private String _homeRedirectUrl; @@ -189,7 +191,6 @@ private String lang(String langParam, String langCookie, String langHeader) { @PostConstruct public void init() throws BeansException { - final String configPath = _appContext.getBean("configPath", String.class); final ServletContext servletContext = _appContext.getBean(ServletContext.class); try { final Element guiConfig = ConfigurationOverrides.DEFAULT.loadXmlFileAndUpdate(configPath + "config-gui.xml", servletContext); diff --git a/core/src/main/resources/config-spring-geonetwork.xml b/core/src/main/resources/config-spring-geonetwork.xml index f6d3e1382d6..53fcbe2b235 100644 --- a/core/src/main/resources/config-spring-geonetwork.xml +++ b/core/src/main/resources/config-spring-geonetwork.xml @@ -2,33 +2,17 @@ + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd" > + - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/domain/src/main/java/org/fao/geonet/bean/Address.java b/domain/src/main/java/org/fao/geonet/bean/Address.java new file mode 100644 index 00000000000..4c00def3fe5 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/Address.java @@ -0,0 +1,205 @@ +package org.fao.geonet.bean; + +import javax.persistence.Column; + +/** + * Represents an address. This is a JPA Entity object and is contained in a + * database table. + * + * @author Jesse + */ +public class Address extends GeonetEntity { + private static final long serialVersionUID = 557101670135536133L; + private static final int ZIP_COLUMN_LENGTH = 16; + private int _id; + private String _address; + private String _city; + private String _state; + private String _zip; + private String _country; + + /** + * Id of the address. This is automatically generated so when creating a new + * object leave this blank and allow the database or JPA set the value for + * you on save. + */ + public int getId() { + return _id; + } + + /** + * Set the id of the address. This is automatically generated so when + * creating a new object leave this blank and allow the database or JPA set + * the value for you on save. + * + * @param id + * the id + * @return this address object + */ + public Address setId(final int id) { + this._id = id; + return this; + } + + /** + * Get the address line of the address. This is typically the street name + * and number but varies depending on the type of address. + */ + public String getAddress() { + return _address; + } + + /** + * Set the address data. See {@link #getAddress()} for details on what the + * "address" is. + * + * @param address + * the new address data + * @return this address object + */ + public Address setAddress(final String address) { + this._address = address; + return this; + } + + /** + * Get the city of the address. + */ + public String getCity() { + return _city; + } + + /** + * Set the city of the address. + * + * @param city + * the city + * @return this address object + */ + public Address setCity(final String city) { + this._city = city; + return this; + } + + /** + * Return the state/province/Kantone/departement/etc... of the address. + * + * @return the state of the address. + */ + public String getState() { + return _state; + } + + /** + * Return the state/province/Kantone/departement/etc... of the address. + * + * @param state + * the state + * @return this address object + */ + public Address setState(final String state) { + this._state = state; + return this; + } + + /** + * Return the zip/postal code of the address. + * + * @return the zip/postal code + */ + @Column(length = ZIP_COLUMN_LENGTH) + public String getZip() { + return _zip; + } + + /** + * Set the zip/postal code of the address. + * + * @param zip + * the new value + * @return this address object + */ + public Address setZip(final String zip) { + this._zip = zip; + return this; + } + + /** + * Get iso2 country code of the address. + * + * @return the iso2 country code. + */ + public String getCountry() { + return _country; + } + + /** + * Set the iso2 country code of the address. + * + * @param iso2CountryCode + * the iso 2 country code. + * @return this address object + */ + public Address setCountry(final String iso2CountryCode) { + this._country = iso2CountryCode; + return this; + } + + // CSOFF: AvoidInlineConditionals + // CSOFF: NeedBraces + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((_address == null) ? 0 : _address.hashCode()); + result = prime * result + ((_city == null) ? 0 : _city.hashCode()); + result = prime * result + + ((_country == null) ? 0 : _country.hashCode()); + result = prime * result + _id; + result = prime * result + ((_state == null) ? 0 : _state.hashCode()); + result = prime * result + ((_zip == null) ? 0 : _zip.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Address other = (Address) obj; + if (_address == null) { + if (other._address != null) + return false; + } else if (!_address.equals(other._address)) + return false; + if (_city == null) { + if (other._city != null) + return false; + } else if (!_city.equals(other._city)) + return false; + if (_country == null) { + if (other._country != null) + return false; + } else if (!_country.equals(other._country)) + return false; + if (_id != other._id) + return false; + if (_state == null) { + if (other._state != null) + return false; + } else if (!_state.equals(other._state)) + return false; + if (_zip == null) { + if (other._zip != null) + return false; + } else if (!_zip.equals(other._zip)) + return false; + return true; + } + // CSON: AvoidInlineConditionals + // CSON: NeedBraces +} diff --git a/domain/src/main/java/org/fao/geonet/bean/CswCapabilitiesInfoField.java b/domain/src/main/java/org/fao/geonet/bean/CswCapabilitiesInfoField.java new file mode 100644 index 00000000000..fdd10914a51 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/CswCapabilitiesInfoField.java @@ -0,0 +1,66 @@ +package org.fao.geonet.bean; + +/** + * Variable substitutions and extra information that goes in a CSW capabilities + * document.
+ * Typically each entity represents the translated information for a single + * language of a single field. This is essentially a map where the key is the + * language+field and the value is the translated label. + * + * @author Jesse + */ +public class CswCapabilitiesInfoField extends GeonetEntity { + private static final long serialVersionUID = -4762806655058693446L; + private static final int ID_COLUMN_LENGTH = 10; + private static final int LANG_ID_COLUMN_LENGTH = 5; + private static final int FIELD_NAME_COLUMN_LENGTH = 32; + private int _id = 0; + private String _langId; + private String _fieldName; + private String _value; + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public String get_langId() { + return _langId; + } + + public void set_langId(String _langId) { + this._langId = _langId; + } + + public String get_fieldName() { + return _fieldName; + } + + public void set_fieldName(String _fieldName) { + this._fieldName = _fieldName; + } + + public String get_value() { + return _value; + } + + public void set_value(String _value) { + this._value = _value; + } + + public static int getIdColumnLength() { + return ID_COLUMN_LENGTH; + } + + public static int getLangIdColumnLength() { + return LANG_ID_COLUMN_LENGTH; + } + + public static int getFieldNameColumnLength() { + return FIELD_NAME_COLUMN_LENGTH; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/CustomElementSet.java b/domain/src/main/java/org/fao/geonet/bean/CustomElementSet.java new file mode 100644 index 00000000000..31bac82ae51 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/CustomElementSet.java @@ -0,0 +1,35 @@ +package org.fao.geonet.bean; + +/** + * Csw custom element set. This is part of the CSW specification related to what + * elements are returned by GetRecords and GetRecordById. + * + * @author Jesse + */ +public class CustomElementSet extends GeonetEntity { + private static final long serialVersionUID = -6426636768954186464L; + private static final int XPATH_COLUMN_LENGTH = 1000; + private String _xpath; + private int _xpathHashcode; + + public String get_xpath() { + return _xpath; + } + + public void set_xpath(String _xpath) { + this._xpath = _xpath; + } + + public int get_xpathHashcode() { + return _xpathHashcode; + } + + public void set_xpathHashcode(int _xpathHashcode) { + this._xpathHashcode = _xpathHashcode; + } + + public static int getXpathColumnLength() { + return XPATH_COLUMN_LENGTH; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/GeonetEntity.java b/domain/src/main/java/org/fao/geonet/bean/GeonetEntity.java new file mode 100644 index 00000000000..abb9f0d908d --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/GeonetEntity.java @@ -0,0 +1,14 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * Contains common methods of all entities in Geonetwork. + *

+ * User: Jesse Date: 9/10/13 Time: 4:33 PM + */ +public class GeonetEntity implements Serializable { + + private static final long serialVersionUID = -7902406684550736260L; + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/Group.java b/domain/src/main/java/org/fao/geonet/bean/Group.java new file mode 100644 index 00000000000..a4276a3d142 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/Group.java @@ -0,0 +1,85 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +import org.fao.geonet.domain.OperationAllowed; + +/** + * An entity representing group of users. Groups in conjunction with + * {@link Operation}s control what operations users can perform on metadata. + *

+ * For example, user userA is in group groupA and userB is in groupB. It could + * be that groupA is configured with view operation permission (See + * {@link OperationAllowed}) then userA could view metadata but userB could not. + *

+ * + * @author Jesse + */ +public class Group implements Serializable { + + private static final long serialVersionUID = 9120548507075846828L; + private int _id; + private String _name; + private String _description; + private String _email; + private Integer _referrer; + private String logo; + private String website; + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public String get_name() { + return _name; + } + + public void set_name(String _name) { + this._name = _name; + } + + public String get_description() { + return _description; + } + + public void set_description(String _description) { + this._description = _description; + } + + public String get_email() { + return _email; + } + + public void set_email(String _email) { + this._email = _email; + } + + public Integer get_referrer() { + return _referrer; + } + + public void set_referrer(Integer _referrer) { + this._referrer = _referrer; + } + + public String getLogo() { + return logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + public String getWebsite() { + return website; + } + + public void setWebsite(String website) { + this.website = website; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/HarvestHistory.java b/domain/src/main/java/org/fao/geonet/bean/HarvestHistory.java new file mode 100644 index 00000000000..2b2ab32680b --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/HarvestHistory.java @@ -0,0 +1,95 @@ +package org.fao.geonet.bean; + +import org.fao.geonet.domain.Constants; + +/** + * An entity representing a harvesting task that may have been completed or + * possibly ending in error. + * + * @author Jesse + */ +public class HarvestHistory extends GeonetEntity { + private static final long serialVersionUID = 4543334423903618392L; + private int _id; + private ISODate _harvestDate; + private int _elapsedTime; + private String _harvesterUuid; + private String _harvesterName; + private String _harvesterType; + private char _deleted = Constants.YN_FALSE; + private String _info; + private String _params; + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public ISODate get_harvestDate() { + return _harvestDate; + } + + public void set_harvestDate(ISODate _harvestDate) { + this._harvestDate = _harvestDate; + } + + public int get_elapsedTime() { + return _elapsedTime; + } + + public void set_elapsedTime(int _elapsedTime) { + this._elapsedTime = _elapsedTime; + } + + public String get_harvesterUuid() { + return _harvesterUuid; + } + + public void set_harvesterUuid(String _harvesterUuid) { + this._harvesterUuid = _harvesterUuid; + } + + public String get_harvesterName() { + return _harvesterName; + } + + public void set_harvesterName(String _harvesterName) { + this._harvesterName = _harvesterName; + } + + public String get_harvesterType() { + return _harvesterType; + } + + public void set_harvesterType(String _harvesterType) { + this._harvesterType = _harvesterType; + } + + public char get_deleted() { + return _deleted; + } + + public void set_deleted(char _deleted) { + this._deleted = _deleted; + } + + public String get_info() { + return _info; + } + + public void set_info(String _info) { + this._info = _info; + } + + public String get_params() { + return _params; + } + + public void set_params(String _params) { + this._params = _params; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/HarvesterSetting.java b/domain/src/main/java/org/fao/geonet/bean/HarvesterSetting.java new file mode 100644 index 00000000000..a98a2855b91 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/HarvesterSetting.java @@ -0,0 +1,58 @@ +package org.fao.geonet.bean; + +/** + * An entity representing a harvester configuration setting. + *

+ * Harvester settings are represented by a tree. One should use the + * {@link org.fao.geonet.repository.HarvesterSettingRepository} to traverse the + * hierarchy. + * + * @author Jesse + */ +public class HarvesterSetting extends GeonetEntity { + private static final long serialVersionUID = -3709818921970021407L; + + public static final int ROOT_ID = 0; + + private int _id; + private HarvesterSetting _parent; + private String _name; + private String _value; + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public HarvesterSetting get_parent() { + return _parent; + } + + public void set_parent(HarvesterSetting _parent) { + this._parent = _parent; + } + + public String get_name() { + return _name; + } + + public void set_name(String _name) { + this._name = _name; + } + + public String get_value() { + return _value; + } + + public void set_value(String _value) { + this._value = _value; + } + + public static int getRootId() { + return ROOT_ID; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/ISODate.java b/domain/src/main/java/org/fao/geonet/bean/ISODate.java new file mode 100644 index 00000000000..028d2ad81c2 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/ISODate.java @@ -0,0 +1,244 @@ +//============================================================================== +//=== +//=== ISODate +//=== +//============================================================================== +//=== Copyright (C) 2001-2007 Food and Agriculture Organization of the +//=== United Nations (FAO-UN), United Nations World Food Programme (WFP) +//=== and United Nations Environment Programme (UNEP) +//=== +//=== This program is free software; you can redistribute it and/or modify +//=== it under the terms of the GNU General Public License as published by +//=== the Free Software Foundation; either version 2 of the License, or (at +//=== your option) any later version. +//=== +//=== This program is distributed in the hope that it will be useful, but +//=== WITHOUT ANY WARRANTY; without even the implied warranty of +//=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//=== General Public License for more details. +//=== +//=== You should have received a copy of the GNU General Public License +//=== along with this program; if not, write to the Free Software +//=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +//=== +//=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2, +//=== Rome - Italy. email: geonetwork@osgeo.org +//============================================================================== + +package org.fao.geonet.bean; + +import static java.util.Calendar.DAY_OF_MONTH; +import static java.util.Calendar.HOUR_OF_DAY; +import static java.util.Calendar.MINUTE; +import static java.util.Calendar.MONTH; +import static java.util.Calendar.SECOND; +import static java.util.Calendar.YEAR; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.regex.Pattern; + +import javax.persistence.Transient; + +/** + * Represents a date at a given time. Provides methods for representing the date as a string and parsing from string. + *

+ * String format is: yyyy-mm-ddThh:mm:ss + *

+ */ +public class ISODate implements Cloneable, Comparable, Serializable { + private static final String DEFAULT_DATE_TIME = "3000-01-01T00:00:00.000Z"; // JUNK Value + + // Pattern to check dates + private static Pattern gsYear = Pattern + .compile("([0-9]{4})(-([0-2][0-9]):([0-5][0-9])([A-Z]))?"); + private static Pattern gsYearMonth = Pattern + .compile("([0-9]{4})-([0-1][0-9])(-([0-2][0-9]):([0-5][0-9])([A-Z]))?"); + + private boolean _shortDate; // --- 'true' if the format is yyyy-mm-dd + + private Calendar _calendar = Calendar.getInstance(); + + // --------------------------------------------------------------------------- + // --- + // --- Constructor + // --- + // --------------------------------------------------------------------------- + + public ISODate() { + } + + // --------------------------------------------------------------------------- + + public ISODate(final long time, final boolean shortDate) { + _calendar.setTimeInMillis(time); + _shortDate = shortDate; + } + + public ISODate(final long time) { + _calendar.setTimeInMillis(time); + _shortDate = false; + } + + + // --------------------------------------------------------------------------- + // --- + // --- API methods + // --- + // --------------------------------------------------------------------------- + + public ISODate clone() { + ISODate clone; + try { + clone = (ISODate) super.clone(); + clone._calendar = (Calendar) _calendar.clone(); + clone._shortDate = _shortDate; + return clone; + } catch (CloneNotSupportedException e) { + return new ISODate(_calendar.getTimeInMillis(), _shortDate); + } + } + + // --------------------------------------------------------------------------- + + /** + * Subtract a date from this date and return the seconds between them. + *

+ * The value is always positive so that date1.timeDifferenceInSeconds(date2) == date2.timeDifferenceInSeconds(date1) + *

+ */ + public long timeDifferenceInSeconds(ISODate date) { + return getTimeInSeconds() - date.getTimeInSeconds(); + } + + // -------------------------------------------------------------------------- + + public String getDateAsString() { + return getYears() + "-" + pad(getMonths()) + "-" + pad(getDays()); + } + + // -------------------------------------------------------------------------- + + public String toString() { + return getDateAndTime(); + } + + /** + * Create a java.util.Date object from this. + * + * @return a java.util.Date object from this. + */ + public Date toDate() { + return (Date) _calendar.getTime().clone(); + } + + // --------------------------------------------------------------------------- + + public long getTimeInSeconds() { + return _calendar.getTimeInMillis() / 1000; + } + + /** + * Get the Time and Date encoded as a String. + */ + public String getDateAndTime() { + if (_shortDate) { + return getDateAsString(); + } + return getDateAsString() + "T" + getTimeAsString(); + } + + /** + * Return true if this object is only the date (year, month, day) and time should be ignored. + * + * @return true if this object is only the date (year, month, day) and time should be ignored. + */ + @Transient + public boolean isDateOnly() { + return _shortDate; + } + + /** + * Get the date's year. + */ + @Transient + public int getYears() { + return _calendar.get(YEAR); + } + + /** + * Get the date's day of month starting at 1. + */ + @Transient + public int getDays() { + return _calendar.get(DAY_OF_MONTH); + } + + /** + * Get the date's month of the year starting at 1 and going to 12. + */ + @Transient + public int getMonths() { + return _calendar.get(MONTH) + 1; + } + + /** + * Get the date's hour in 24 hour time starting at 0 and going to 23 + */ + @Transient + public int getHours() { + return _calendar.get(HOUR_OF_DAY); + } + + /** + * Get the date's minute starting at 0 and going to 59 + */ + @Transient + public int getMinutes() { + return _calendar.get(MINUTE); + } + + /** + * Get the date's second starting at 0 and going to 59 + */ + @Transient + public int getSeconds() { + return _calendar.get(SECOND); + } + + // ------------------------------- Private methods ---------------------------------------------------- + + @Override + public int hashCode() { + return getTimeAsString().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ISODate other = (ISODate) obj; + return getTimeAsString().equals(other.getTimeAsString()); + } + + public String getTimeAsString() { + return pad(getHours()) + ":" + pad(getMinutes()) + ":" + pad(getSeconds()); + } + + private String pad(int value) { + if (value > 9) + return Integer.toString(value); + + return "0" + value; + } + + @Override + public int compareTo(ISODate o) { + return _calendar.compareTo(o._calendar); + } +} diff --git a/domain/src/main/java/org/fao/geonet/bean/IsoLanguage.java b/domain/src/main/java/org/fao/geonet/bean/IsoLanguage.java new file mode 100644 index 00000000000..a2499b9c80d --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/IsoLanguage.java @@ -0,0 +1,43 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * An entity representing the bi-directional mapping between the different iso + * language codes (de -> ger) and translations of the languages. (German, + * Deutsch, etc...) + * + * @author Jesse + */ +public class IsoLanguage implements Serializable { + + private static final long serialVersionUID = 1870845042572690280L; + private int id; + private String code; + private String shortCode; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getShortCode() { + return shortCode; + } + + public void setShortCode(String shortCode) { + this.shortCode = shortCode; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/Metadata.java b/domain/src/main/java/org/fao/geonet/bean/Metadata.java new file mode 100644 index 00000000000..aed6d5f16b0 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/Metadata.java @@ -0,0 +1,92 @@ +package org.fao.geonet.bean; + +import java.util.HashSet; +import java.util.Set; + +/** + * An entity representing a metadata object in the database. The xml, groups and + * operations are lazily loaded so accessing then will need to be done in a + * thread that has a bound EntityManager. Also they can trigger database access + * if they have not been cached and therefore can cause slowdowns so they should + * only be accessed in need. + * + * @author Jesse + */ +public class Metadata extends GeonetEntity { + + private static final long serialVersionUID = 6886741395209400709L; + public static final String METADATA_CATEG_JOIN_TABLE_NAME = "MetadataCateg"; + public static final String METADATA_CATEG_JOIN_TABLE_CATEGORY_ID = "categoryId"; + private int _id; + private String _uuid; + private String _data; + private MetadataDataInfo _dataInfo = new MetadataDataInfo(); + private MetadataSourceInfo _sourceInfo = new MetadataSourceInfo(); + private MetadataHarvestInfo _harvestInfo = new MetadataHarvestInfo(); + private Set _metadataCategories = new HashSet(); + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public String get_uuid() { + return _uuid; + } + + public void set_uuid(String _uuid) { + this._uuid = _uuid; + } + + public String get_data() { + return _data; + } + + public void set_data(String _data) { + this._data = _data; + } + + public MetadataDataInfo get_dataInfo() { + return _dataInfo; + } + + public void set_dataInfo(MetadataDataInfo _dataInfo) { + this._dataInfo = _dataInfo; + } + + public MetadataSourceInfo get_sourceInfo() { + return _sourceInfo; + } + + public void set_sourceInfo(MetadataSourceInfo _sourceInfo) { + this._sourceInfo = _sourceInfo; + } + + public MetadataHarvestInfo get_harvestInfo() { + return _harvestInfo; + } + + public void set_harvestInfo(MetadataHarvestInfo _harvestInfo) { + this._harvestInfo = _harvestInfo; + } + + public Set get_metadataCategories() { + return _metadataCategories; + } + + public void set_metadataCategories(Set _metadataCategories) { + this._metadataCategories = _metadataCategories; + } + + public static String getMetadataCategJoinTableName() { + return METADATA_CATEG_JOIN_TABLE_NAME; + } + + public static String getMetadataCategJoinTableCategoryId() { + return METADATA_CATEG_JOIN_TABLE_CATEGORY_ID; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataCategory.java b/domain/src/main/java/org/fao/geonet/bean/MetadataCategory.java new file mode 100644 index 00000000000..8aa0ede301d --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataCategory.java @@ -0,0 +1,31 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * A Metadata category. This is separate from any category listed in the + * metadata xml itself and is geonetwork specific. + * + * @author Jesse + */ +public class MetadataCategory implements Serializable { + private static final long serialVersionUID = -48215909798608235L; + private int _id; + private String _name; + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public String get_name() { + return _name; + } + + public void set_name(String _name) { + this._name = _name; + } +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataDataInfo.java b/domain/src/main/java/org/fao/geonet/bean/MetadataDataInfo.java new file mode 100644 index 00000000000..242dd16468b --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataDataInfo.java @@ -0,0 +1,113 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +import javax.persistence.Access; +import javax.persistence.AccessType; +import javax.persistence.Embeddable; + +import org.fao.geonet.domain.Constants; + +/** + * Encapsulates the metadata about a metadata document. (title, rating, schema + * etc...) This is a JPA Embeddable object that is embedded into a + * {@link Metadata} Entity + * + * @author Jesse + */ +@Embeddable +@Access(AccessType.PROPERTY) +public class MetadataDataInfo implements Serializable { + private static final long serialVersionUID = 8049813754167665960L; + private String _title; + private ISODate _changeDate = new ISODate(); + private ISODate _createDate = new ISODate(); + private String _schemaId; + private char _template = Constants.YN_FALSE; + private String _root; + private String _doctype; + private Integer _displayOrder; + private int _rating; + private int _popularity; + + public String get_title() { + return _title; + } + + public void set_title(String _title) { + this._title = _title; + } + + public ISODate get_changeDate() { + return _changeDate; + } + + public void set_changeDate(ISODate _changeDate) { + this._changeDate = _changeDate; + } + + public ISODate get_createDate() { + return _createDate; + } + + public void set_createDate(ISODate _createDate) { + this._createDate = _createDate; + } + + public String get_schemaId() { + return _schemaId; + } + + public void set_schemaId(String _schemaId) { + this._schemaId = _schemaId; + } + + public char get_template() { + return _template; + } + + public void set_template(char _template) { + this._template = _template; + } + + public String get_root() { + return _root; + } + + public void set_root(String _root) { + this._root = _root; + } + + public String get_doctype() { + return _doctype; + } + + public void set_doctype(String _doctype) { + this._doctype = _doctype; + } + + public Integer get_displayOrder() { + return _displayOrder; + } + + public void set_displayOrder(Integer _displayOrder) { + this._displayOrder = _displayOrder; + } + + public int get_rating() { + return _rating; + } + + public void set_rating(int _rating) { + this._rating = _rating; + } + + public int get_popularity() { + return _popularity; + } + + public void set_popularity(int _popularity) { + this._popularity = _popularity; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataHarvestInfo.java b/domain/src/main/java/org/fao/geonet/bean/MetadataHarvestInfo.java new file mode 100644 index 00000000000..196130bde98 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataHarvestInfo.java @@ -0,0 +1,43 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +import org.fao.geonet.domain.Constants; + +/** + * Encapsulates the harvest data related to a metadata document. Like whether + * the metadata was harvested, the uuid of the harvester, etc... This is a JPA + * Embeddable object that is embedded into a {@link Metadata} Entity + * + * @author Jesse + */ +public class MetadataHarvestInfo implements Serializable { + private static final long serialVersionUID = 7935704119616189903L; + private char _harvested = Constants.YN_FALSE; + private String _uuid; + private String _uri; + + public char get_harvested() { + return _harvested; + } + + public void set_harvested(char _harvested) { + this._harvested = _harvested; + } + + public String get_uuid() { + return _uuid; + } + + public void set_uuid(String _uuid) { + this._uuid = _uuid; + } + + public String get_uri() { + return _uri; + } + + public void set_uri(String _uri) { + this._uri = _uri; + } +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataNotification.java b/domain/src/main/java/org/fao/geonet/bean/MetadataNotification.java new file mode 100644 index 00000000000..f006f5ac6ca --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataNotification.java @@ -0,0 +1,49 @@ +package org.fao.geonet.bean; + +import org.fao.geonet.domain.Constants; +import org.fao.geonet.domain.MetadataNotificationAction; + +/** + * An entity representing a metadata related notification that has been made or is pending. + * + * @author Jesse + */ +public class MetadataNotification extends GeonetEntity { + private static final long serialVersionUID = 2320937039405670248L; + private MetadataNotificationId _id; + private char _notified = Constants.YN_FALSE; + private String _metadataUuid; + private MetadataNotificationAction _action; + private String _errorMessage; + public MetadataNotificationId get_id() { + return _id; + } + public void set_id(MetadataNotificationId _id) { + this._id = _id; + } + public char get_notified() { + return _notified; + } + public void set_notified(char _notified) { + this._notified = _notified; + } + public String get_metadataUuid() { + return _metadataUuid; + } + public void set_metadataUuid(String _metadataUuid) { + this._metadataUuid = _metadataUuid; + } + public MetadataNotificationAction get_action() { + return _action; + } + public void set_action(MetadataNotificationAction _action) { + this._action = _action; + } + public String get_errorMessage() { + return _errorMessage; + } + public void set_errorMessage(String _errorMessage) { + this._errorMessage = _errorMessage; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataNotificationId.java b/domain/src/main/java/org/fao/geonet/bean/MetadataNotificationId.java new file mode 100644 index 00000000000..7d91f8aceca --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataNotificationId.java @@ -0,0 +1,27 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * Id of a MetadataNotification object. + * + * @author Jesse + */ +public class MetadataNotificationId implements Serializable { + private static final long serialVersionUID = 8167301479650105617L; + private int metadataId; + private int notifierId; + public int getMetadataId() { + return metadataId; + } + public void setMetadataId(int metadataId) { + this.metadataId = metadataId; + } + public int getNotifierId() { + return notifierId; + } + public void setNotifierId(int notifierId) { + this.notifierId = notifierId; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataNotifier.java b/domain/src/main/java/org/fao/geonet/bean/MetadataNotifier.java new file mode 100644 index 00000000000..dec9ce58c3b --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataNotifier.java @@ -0,0 +1,80 @@ +package org.fao.geonet.bean; + +import java.util.ArrayList; +import java.util.List; + +import org.fao.geonet.domain.Constants; + +/** + * An entity representing a service that desires to be notified when a metadata + * is modified. + * + * @author Jesse + */ +public class MetadataNotifier extends GeonetEntity { + private static final long serialVersionUID = 1293846L; + private int _id; + private String _name; + private String _url; + private char _enabled = Constants.YN_FALSE; + private String _username; + private char[] password; + private List _notifications = new ArrayList(); + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public String get_name() { + return _name; + } + + public void set_name(String _name) { + this._name = _name; + } + + public String get_url() { + return _url; + } + + public void set_url(String _url) { + this._url = _url; + } + + public char get_enabled() { + return _enabled; + } + + public void set_enabled(char _enabled) { + this._enabled = _enabled; + } + + public String get_username() { + return _username; + } + + public void set_username(String _username) { + this._username = _username; + } + + public char[] get_password() { + return password.clone(); + } + + public void set_password(char[] _password) { + this.password = _password.clone(); + } + + public List get_notifications() { + return _notifications; + } + + public void set_notifications(List _notifications) { + this._notifications = _notifications; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataRatingByIp.java b/domain/src/main/java/org/fao/geonet/bean/MetadataRatingByIp.java new file mode 100644 index 00000000000..bd3d7dea761 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataRatingByIp.java @@ -0,0 +1,29 @@ +package org.fao.geonet.bean; + +/** + * An entity that tracks which users have rated a metadata. It currently tracks + * by Ip address so that each IP address can only rate a given metadata once. + * + * @author Jesse + */ +public class MetadataRatingByIp extends GeonetEntity { + private static final long serialVersionUID = 84720751487108559L; + private MetadataRatingByIpId _id; + private int _rating; + + public MetadataRatingByIpId get_id() { + return _id; + } + + public void set_id(MetadataRatingByIpId _id) { + this._id = _id; + } + + public int get_rating() { + return _rating; + } + + public void set_rating(int _rating) { + this._rating = _rating; + } +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataRatingByIpId.java b/domain/src/main/java/org/fao/geonet/bean/MetadataRatingByIpId.java new file mode 100644 index 00000000000..4903af6fb73 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataRatingByIpId.java @@ -0,0 +1,32 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * An Id object for {@link MetadataRatingByIp} + * + * @author Jesse + */ +public class MetadataRatingByIpId implements Serializable { + + private static final long serialVersionUID = 2793801901676171677L; + private int _metadataId; + private String _ipAddress; + + public int get_metadataId() { + return _metadataId; + } + + public void set_metadataId(int _metadataId) { + this._metadataId = _metadataId; + } + + public String get_ipAddress() { + return _ipAddress; + } + + public void set_ipAddress(String _ipAddress) { + this._ipAddress = _ipAddress; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataRelationId.java b/domain/src/main/java/org/fao/geonet/bean/MetadataRelationId.java new file mode 100644 index 00000000000..2d5caa793b4 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataRelationId.java @@ -0,0 +1,32 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * Id class for Metadata relation. + * + * @author Jesse + */ +public class MetadataRelationId implements Serializable { + private static final long serialVersionUID = -2705273953015744638L; + + private int _metadataId; + private int _relatedId; + + public int get_metadataId() { + return _metadataId; + } + + public void set_metadataId(int _metadataId) { + this._metadataId = _metadataId; + } + + public int get_relatedId() { + return _relatedId; + } + + public void set_relatedId(int _relatedId) { + this._relatedId = _relatedId; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataSourceInfo.java b/domain/src/main/java/org/fao/geonet/bean/MetadataSourceInfo.java new file mode 100644 index 00000000000..b7d892fe6d4 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataSourceInfo.java @@ -0,0 +1,41 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * Information about the source and owner of the metadata document. This is a + * JPA Embeddable object that is embedded into a {@link Metadata} Entity + * + * @author Jesse + */ +public class MetadataSourceInfo implements Serializable { + private static final long serialVersionUID = -6032075543035787580L; + private String _sourceId; + private Integer _groupOwner; + private int _owner; + + public String get_sourceId() { + return _sourceId; + } + + public void set_sourceId(String _sourceId) { + this._sourceId = _sourceId; + } + + public Integer get_groupOwner() { + return _groupOwner; + } + + public void set_groupOwner(Integer _groupOwner) { + this._groupOwner = _groupOwner; + } + + public int get_owner() { + return _owner; + } + + public void set_owner(int _owner) { + this._owner = _owner; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataStatus.java b/domain/src/main/java/org/fao/geonet/bean/MetadataStatus.java new file mode 100644 index 00000000000..467257f1539 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataStatus.java @@ -0,0 +1,93 @@ +package org.fao.geonet.bean; + +import org.fao.geonet.domain.StatusValue; + +/** + * An entity that represents a status change of a metadata. + *

+ * Note: I am not the author of metadata status, but it appears that this tracks + * the history as well since the Id consists of the User, date, metadata and + * statusvalue of the metadata status change. + * + * @author Jesse + */ +public class MetadataStatus extends GeonetEntity { + private static final long serialVersionUID = 3913761533850728587L; + /** + * The Root element of the xml returned by {@link #getAsXml}. + */ + public static final String EL_METADATA_STATUS = "metadataStatus"; + /** + * One of the child elements of the xml returned by {@link #getAsXml}. + */ + public static final String EL_STATUS_ID = "statusId"; + /** + * One of the child elements of the xml returned by {@link #getAsXml}. + */ + public static final String EL_USER_ID = "userId"; + /** + * One of the child elements of the xml returned by {@link #getAsXml}. + */ + public static final String EL_CHANGE_DATE = "changeDate"; + /** + * One of the child elements of the xml returned by {@link #getAsXml}. + */ + public static final String EL_CHANGE_MESSAGE = "changeMessage"; + /** + * One of the child elements of the xml returned by {@link #getAsXml}. + */ + public static final String EL_NAME = "name"; + + private MetadataStatusId id = new MetadataStatusId(); + private String changeMessage; + private StatusValue statusValue; + + public MetadataStatusId getId() { + return id; + } + + public void setId(MetadataStatusId id) { + this.id = id; + } + + public String getChangeMessage() { + return changeMessage; + } + + public void setChangeMessage(String changeMessage) { + this.changeMessage = changeMessage; + } + + public StatusValue getStatusValue() { + return statusValue; + } + + public void setStatusValue(StatusValue statusValue) { + this.statusValue = statusValue; + } + + public static String getElMetadataStatus() { + return EL_METADATA_STATUS; + } + + public static String getElStatusId() { + return EL_STATUS_ID; + } + + public static String getElUserId() { + return EL_USER_ID; + } + + public static String getElChangeDate() { + return EL_CHANGE_DATE; + } + + public static String getElChangeMessage() { + return EL_CHANGE_MESSAGE; + } + + public static String getElName() { + return EL_NAME; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataStatusId.java b/domain/src/main/java/org/fao/geonet/bean/MetadataStatusId.java new file mode 100644 index 00000000000..a4ccaa33415 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataStatusId.java @@ -0,0 +1,49 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * The id object of {@link MetadataStatus}. + * + * @author Jesse + */ +public class MetadataStatusId implements Serializable { + private static final long serialVersionUID = -4395314364468537427L; + private ISODate _changedate; + private int _metadataId; + private int _statusId; + private int _userId; + + public ISODate get_changedate() { + return _changedate; + } + + public void set_changedate(ISODate _changedate) { + this._changedate = _changedate; + } + + public int get_metadataId() { + return _metadataId; + } + + public void set_metadataId(int _metadataId) { + this._metadataId = _metadataId; + } + + public int get_statusId() { + return _statusId; + } + + public void set_statusId(int _statusId) { + this._statusId = _statusId; + } + + public int get_userId() { + return _userId; + } + + public void set_userId(int _userId) { + this._userId = _userId; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataValidation.java b/domain/src/main/java/org/fao/geonet/bean/MetadataValidation.java new file mode 100644 index 00000000000..b589de2b63a --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataValidation.java @@ -0,0 +1,58 @@ +package org.fao.geonet.bean; + +import org.fao.geonet.domain.MetadataValidationStatus; + +/** + * Entity representing metadata validation reports. + * + * @author Jesse + */ +public class MetadataValidation extends GeonetEntity { + private static final long serialVersionUID = 6980849290000321963L; + private MetadataValidationId _id; + private MetadataValidationStatus _status; + private int _tested; + private int _failed; + private ISODate _validationDate; + + public MetadataValidationId get_id() { + return _id; + } + + public void set_id(MetadataValidationId _id) { + this._id = _id; + } + + public MetadataValidationStatus get_status() { + return _status; + } + + public void set_status(MetadataValidationStatus _status) { + this._status = _status; + } + + public int get_tested() { + return _tested; + } + + public void set_tested(int _tested) { + this._tested = _tested; + } + + public int get_failed() { + return _failed; + } + + public void set_failed(int _failed) { + this._failed = _failed; + } + + public ISODate get_validationDate() { + return _validationDate; + } + + public void set_validationDate(ISODate _validationDate) { + this._validationDate = _validationDate; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/MetadataValidationId.java b/domain/src/main/java/org/fao/geonet/bean/MetadataValidationId.java new file mode 100644 index 00000000000..c5f0cae1290 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/MetadataValidationId.java @@ -0,0 +1,31 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * Id object for the {@link MetadataValidation} entity. + * + * @author Jesse + */ +public class MetadataValidationId implements Serializable { + private static final long serialVersionUID = -7162983572434017017L; + private int _metadataId; + private String _validationType; + + public int get_metadataId() { + return _metadataId; + } + + public void set_metadataId(int _metadataId) { + this._metadataId = _metadataId; + } + + public String get_validationType() { + return _validationType; + } + + public void set_validationType(String _validationType) { + this._validationType = _validationType; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/Operation.java b/domain/src/main/java/org/fao/geonet/bean/Operation.java new file mode 100644 index 00000000000..211c22ea8cc --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/Operation.java @@ -0,0 +1,31 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * An entity representing an operation that can be performed on a metadata. + * + * @author Jesse + */ +public class Operation implements Serializable { + private static final long serialVersionUID = -2860995235478408138L; + private int _id; + private String _name; + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public String get_name() { + return _name; + } + + public void set_name(String _name) { + this._name = _name; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/OperationAllowedId.java b/domain/src/main/java/org/fao/geonet/bean/OperationAllowedId.java new file mode 100644 index 00000000000..2c1a1877cdb --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/OperationAllowedId.java @@ -0,0 +1,41 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +/** + * The id object of {@link OperationAllowed} + * + * @author Jesse + */ +public class OperationAllowedId implements Serializable { + private static final long serialVersionUID = -5759713154514715316L; + + private int _metadataId; + private int _groupId; + private int _operationId; + + public int get_metadataId() { + return _metadataId; + } + + public void set_metadataId(int _metadataId) { + this._metadataId = _metadataId; + } + + public int get_groupId() { + return _groupId; + } + + public void set_groupId(int _groupId) { + this._groupId = _groupId; + } + + public int get_operationId() { + return _operationId; + } + + public void set_operationId(int _operationId) { + this._operationId = _operationId; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/Service.java b/domain/src/main/java/org/fao/geonet/bean/Service.java new file mode 100644 index 00000000000..b4bfbc9e8d6 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/Service.java @@ -0,0 +1,62 @@ +package org.fao.geonet.bean; + +import java.util.HashMap; +import java.util.Map; + +/** + * One of the entities responsible for dynamic service configuration. Entity + * representing a {@link jeeves.interfaces.Service}. Originally they were for + * CSW virtual services but are generic and could in theory be any arbitrary + * service. + * + * @author Jesse + */ +public class Service extends GeonetEntity { + private static final long serialVersionUID = 9183533103467569829L; + private int _id; + private String _name; + private String _className; + private String description; + private Map _parameters = new HashMap(); + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public String get_name() { + return _name; + } + + public void set_name(String _name) { + this._name = _name; + } + + public String get_className() { + return _className; + } + + public void set_className(String _className) { + this._className = _className; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map get_parameters() { + return _parameters; + } + + public void set_parameters(Map _parameters) { + this._parameters = _parameters; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/Setting.java b/domain/src/main/java/org/fao/geonet/bean/Setting.java new file mode 100644 index 00000000000..35365304870 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/Setting.java @@ -0,0 +1,45 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + * An entity representing a system configuration setting. + *

+ * Settings are represented by a tree. One should use the + * {@link org.fao.geonet.repository.HarvesterSettingRepository} to traverse the + * hierarchy. + * + * @author delawen + */ +@XmlRootElement(name="setting") +@XmlType(propOrder={"name", "position"}) +@javax.xml.bind.annotation.XmlTransient +public abstract class Setting implements Serializable { + + private static final long serialVersionUID = 5431195166983620627L; + private String name; + private int position; + + @XmlAttribute(name = "name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlAttribute(name = "position") + public int getPosition() { + return position; + } + + public void setPosition(int position) { + this.position = position; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/SettingChild.java b/domain/src/main/java/org/fao/geonet/bean/SettingChild.java new file mode 100644 index 00000000000..f00336a5395 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/SettingChild.java @@ -0,0 +1,51 @@ +package org.fao.geonet.bean; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; + +/** + * An entity representing a system configuration setting. + *

+ * Settings are represented by a tree. One should use the + * {@link org.fao.geonet.repository.HarvesterSettingRepository} to traverse the + * hierarchy. + * + * @author delawen + */ +@XmlRootElement(name = "setting") +public class SettingChild extends Setting { + + private static final long serialVersionUID = 3427895789235891L; + private String value; + private String dataTypeName; + private String dataType; + + @XmlAttribute(name = "datatype") + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + @XmlAttribute(name = "datatypeName") + public String getDataTypeName() { + return dataTypeName; + } + + public void setDataTypeName(String dataTypeName) { + this.dataTypeName = dataTypeName; + } + + @XmlValue + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/SettingParent.java b/domain/src/main/java/org/fao/geonet/bean/SettingParent.java new file mode 100644 index 00000000000..4522b7176d6 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/SettingParent.java @@ -0,0 +1,43 @@ +package org.fao.geonet.bean; + +import java.util.LinkedList; +import java.util.List; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + * An entity representing a system configuration setting. + *

+ * Settings are represented by a tree. One should use the + * {@link org.fao.geonet.repository.HarvesterSettingRepository} to traverse the + * hierarchy. + * + * @author delawen + */ +@XmlRootElement(name = "setting") +@XmlType(propOrder = { "children" }) +public class SettingParent extends Setting { + + private static final long serialVersionUID = -9076754640371279891L; + private List> children = null; + + @XmlAnyElement(lax = true) + public List> getChildren() { + if (this.children == null) { + this.children = new LinkedList>(); + } + return children; + } + + public void setChildren(List> children) { + this.children = children; + } + + public void addChild(JAXBElement child) { + this.getChildren().add(child); + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/Source.java b/domain/src/main/java/org/fao/geonet/bean/Source.java new file mode 100644 index 00000000000..9ba2dbbd4b7 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/Source.java @@ -0,0 +1,28 @@ +package org.fao.geonet.bean; + +/** + * Entity representing a metadata source. + * + * @author Jesse + */ +public class Source extends GeonetEntity { + private static final long serialVersionUID = -5810796138593573976L; + private String _uuid; + private String _name; + + public String get_uuid() { + return _uuid; + } + + public void set_uuid(String _uuid) { + this._uuid = _uuid; + } + + public String get_name() { + return _name; + } + + public void set_name(String _name) { + this._name = _name; + } +} diff --git a/domain/src/main/java/org/fao/geonet/bean/User.java b/domain/src/main/java/org/fao/geonet/bean/User.java new file mode 100644 index 00000000000..8fcca3081ce --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/User.java @@ -0,0 +1,108 @@ +package org.fao.geonet.bean; + +import java.util.HashSet; +import java.util.Set; + +import org.fao.geonet.domain.Profile; + +/** + * A user entity. A user is used in spring security, controlling access to + * metadata as well as in the {@link jeeves.server.UserSession}. + * + * @author Jesse + */ +public class User extends GeonetEntity { + private static final long serialVersionUID = 2589607276443866650L; + + private int _id; + private String _username; + private String _surname; + private String _name; + private Set _email = new HashSet(); + private Set

_addresses = new HashSet
(); + private String _organisation; + private String _kind; + private Profile _profile = Profile.RegisteredUser; + private UserSecurity _security = new UserSecurity(); + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public String get_username() { + return _username; + } + + public void set_username(String _username) { + this._username = _username; + } + + public String get_surname() { + return _surname; + } + + public void set_surname(String _surname) { + this._surname = _surname; + } + + public String get_name() { + return _name; + } + + public void set_name(String _name) { + this._name = _name; + } + + public Set get_email() { + return _email; + } + + public void set_email(Set _email) { + this._email = _email; + } + + public Set
get_addresses() { + return _addresses; + } + + public void set_addresses(Set
_addresses) { + this._addresses = _addresses; + } + + public String get_organisation() { + return _organisation; + } + + public void set_organisation(String _organisation) { + this._organisation = _organisation; + } + + public String get_kind() { + return _kind; + } + + public void set_kind(String _kind) { + this._kind = _kind; + } + + public Profile get_profile() { + return _profile; + } + + public void set_profile(Profile _profile) { + this._profile = _profile; + } + + public UserSecurity get_security() { + return _security; + } + + public void set_security(UserSecurity _security) { + this._security = _security; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/UserGroup.java b/domain/src/main/java/org/fao/geonet/bean/UserGroup.java new file mode 100644 index 00000000000..0950d6e4705 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/UserGroup.java @@ -0,0 +1,39 @@ +package org.fao.geonet.bean; + +/** + * The mapping between user, the groups a user is a part of and the profiles the + * user has for each group. + * + * @author Jesse + */ +public class UserGroup extends GeonetEntity { + private static final long serialVersionUID = 2373187130402366299L; + private UserGroupId _id = new UserGroupId(); + private Group _group; + private User _user; + + public UserGroupId get_id() { + return _id; + } + + public void set_id(UserGroupId _id) { + this._id = _id; + } + + public Group get_group() { + return _group; + } + + public void set_group(Group _group) { + this._group = _group; + } + + public User get_user() { + return _user; + } + + public void set_user(User _user) { + this._user = _user; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/UserGroupId.java b/domain/src/main/java/org/fao/geonet/bean/UserGroupId.java new file mode 100644 index 00000000000..547984b0236 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/UserGroupId.java @@ -0,0 +1,38 @@ +package org.fao.geonet.bean; + +import java.io.Serializable; + +import org.fao.geonet.domain.Profile; + +/** + * The id object for {@link UserGroup} + * + * @author Jesse + */ +public class UserGroupId implements Serializable { + private static final long serialVersionUID = 758566280699819800L; + + private int _userId; + private int _groupId; + private Profile _profile; + public int get_userId() { + return _userId; + } + public void set_userId(int _userId) { + this._userId = _userId; + } + public int get_groupId() { + return _groupId; + } + public void set_groupId(int _groupId) { + this._groupId = _groupId; + } + public Profile get_profile() { + return _profile; + } + public void set_profile(Profile _profile) { + this._profile = _profile; + } + + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/UserSecurity.java b/domain/src/main/java/org/fao/geonet/bean/UserSecurity.java new file mode 100644 index 00000000000..9e200849a3e --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/UserSecurity.java @@ -0,0 +1,45 @@ +package org.fao.geonet.bean; + +import java.util.HashSet; +import java.util.Set; + +import org.fao.geonet.domain.UserSecurityNotification; + +/** + * Encapsulates security information about the user. This is a JPA Embeddable + * object that is embedded into a {@link User} Entity + * + * @author Jesse + */ +public class UserSecurity extends GeonetEntity { + private static final long serialVersionUID = 192387419289273L; + private char[] _password; + private Set securityNotifications = new HashSet(); + private String _authType; + + public char[] get_password() { + return _password.clone(); + } + + public void set_password(char[] _password) { + this._password = _password.clone(); + } + + public String get_authType() { + return _authType; + } + + public void set_authType(String _authType) { + this._authType = _authType; + } + + public Set getSecurityNotifications() { + return securityNotifications; + } + + public void setSecurityNotifications( + Set securityNotifications) { + this.securityNotifications = securityNotifications; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/package-info.java b/domain/src/main/java/org/fao/geonet/bean/package-info.java new file mode 100644 index 00000000000..d45c99d5452 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/package-info.java @@ -0,0 +1,6 @@ +/** + * Bean objects geonetwork. These are objects to mimic jpa objects but with no jpa attributes, so they can be used to exchange data. + * + * @author Jesse + */ +package org.fao.geonet.bean; \ No newline at end of file diff --git a/domain/src/main/java/org/fao/geonet/bean/statistic/SearchRequest.java b/domain/src/main/java/org/fao/geonet/bean/statistic/SearchRequest.java new file mode 100644 index 00000000000..843109e92f2 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/statistic/SearchRequest.java @@ -0,0 +1,141 @@ +package org.fao.geonet.bean.statistic; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.fao.geonet.domain.ISODate; + +/** + * An entity representing a search request that was made by a user. This is part + * of the statistics tracing. + *

+ *

+ * When creating a SearchRequest and its parameters all the parameters and the + * search request must be saved individually because a limitation of JPA means + * that SearchRequest can't cascade operations from SearchRequest to the params. + *

+ * + * @author Jesse + */ +public class SearchRequest implements Serializable { + private static final long serialVersionUID = -1294836123657513520L; + private int _id; + private ISODate _requestDate; + private String _ipAddress; + private String _luceneQuery; + private int _hits; + private String _lang; + private String _sortBy; + private String _spatialFilter; + private String _metadataType; + private boolean _simple; + private boolean _autogenerated; + private String _service; + private List _params = new ArrayList(); + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public ISODate get_requestDate() { + return _requestDate; + } + + public void set_requestDate(ISODate _requestDate) { + this._requestDate = _requestDate; + } + + public String get_ipAddress() { + return _ipAddress; + } + + public void set_ipAddress(String _ipAddress) { + this._ipAddress = _ipAddress; + } + + public String get_luceneQuery() { + return _luceneQuery; + } + + public void set_luceneQuery(String _luceneQuery) { + this._luceneQuery = _luceneQuery; + } + + public int get_hits() { + return _hits; + } + + public void set_hits(int _hits) { + this._hits = _hits; + } + + public String get_lang() { + return _lang; + } + + public void set_lang(String _lang) { + this._lang = _lang; + } + + public String get_sortBy() { + return _sortBy; + } + + public void set_sortBy(String _sortBy) { + this._sortBy = _sortBy; + } + + public String get_spatialFilter() { + return _spatialFilter; + } + + public void set_spatialFilter(String _spatialFilter) { + this._spatialFilter = _spatialFilter; + } + + public String get_metadataType() { + return _metadataType; + } + + public void set_metadataType(String _metadataType) { + this._metadataType = _metadataType; + } + + public boolean is_simple() { + return _simple; + } + + public void set_simple(boolean _simple) { + this._simple = _simple; + } + + public boolean is_autogenerated() { + return _autogenerated; + } + + public void set_autogenerated(boolean _autogenerated) { + this._autogenerated = _autogenerated; + } + + public String get_service() { + return _service; + } + + public void set_service(String _service) { + this._service = _service; + } + + public List get_params() { + return _params; + } + + public void set_params(List _params) { + this._params = _params; + } + +} diff --git a/domain/src/main/java/org/fao/geonet/bean/statistic/SearchRequestParam.java b/domain/src/main/java/org/fao/geonet/bean/statistic/SearchRequestParam.java new file mode 100644 index 00000000000..3b25f1f175d --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/statistic/SearchRequestParam.java @@ -0,0 +1,97 @@ +package org.fao.geonet.bean.statistic; + +import java.io.Serializable; + +import org.fao.geonet.domain.Constants; +import org.fao.geonet.domain.statistic.LuceneQueryParamType; + +/** + * Entity representing the search parameters of a request. Related to + * {@link SearchRequest}. + * + * @author Jesse + */ +public class SearchRequestParam implements Serializable { + private static final long serialVersionUID = 7559077566870546729L; + private int _id; + private LuceneQueryParamType _queryType; + private String _termField; + private String _termText; + private double _similarity; + private String _lowerText; + private String _upperText; + private char _inclusive = Constants.YN_FALSE; + private SearchRequest _request; + + public int get_id() { + return _id; + } + + public void set_id(int _id) { + this._id = _id; + } + + public LuceneQueryParamType get_queryType() { + return _queryType; + } + + public void set_queryType(LuceneQueryParamType _queryType) { + this._queryType = _queryType; + } + + public String get_termField() { + return _termField; + } + + public void set_termField(String _termField) { + this._termField = _termField; + } + + public String get_termText() { + return _termText; + } + + public void set_termText(String _termText) { + this._termText = _termText; + } + + public double get_similarity() { + return _similarity; + } + + public void set_similarity(double _similarity) { + this._similarity = _similarity; + } + + public String get_lowerText() { + return _lowerText; + } + + public void set_lowerText(String _lowerText) { + this._lowerText = _lowerText; + } + + public String get_upperText() { + return _upperText; + } + + public void set_upperText(String _upperText) { + this._upperText = _upperText; + } + + public char get_inclusive() { + return _inclusive; + } + + public void set_inclusive(char _inclusive) { + this._inclusive = _inclusive; + } + + public SearchRequest get_request() { + return _request; + } + + public void set_request(SearchRequest _request) { + this._request = _request; + } +} diff --git a/domain/src/main/java/org/fao/geonet/bean/statistic/package-info.java b/domain/src/main/java/org/fao/geonet/bean/statistic/package-info.java new file mode 100644 index 00000000000..230bbe8a193 --- /dev/null +++ b/domain/src/main/java/org/fao/geonet/bean/statistic/package-info.java @@ -0,0 +1,6 @@ +/** + * Bean objects for tracking statistics of the server. + * + * @author Jesse + */ +package org.fao.geonet.bean.statistic; \ No newline at end of file diff --git a/domain/src/main/java/org/fao/geonet/domain/GeonetEntity.java b/domain/src/main/java/org/fao/geonet/domain/GeonetEntity.java index 5d434ae5366..3f0dce90bf4 100644 --- a/domain/src/main/java/org/fao/geonet/domain/GeonetEntity.java +++ b/domain/src/main/java/org/fao/geonet/domain/GeonetEntity.java @@ -6,6 +6,7 @@ import javax.annotation.Nonnull; import javax.persistence.Embeddable; import java.beans.PropertyDescriptor; +import java.io.Serializable; import java.util.List; import java.util.Map; @@ -16,9 +17,10 @@ * Date: 9/10/13 * Time: 4:33 PM */ -public class GeonetEntity { +public class GeonetEntity implements Serializable { - public static final String LABEL_EL_NAME = "label"; + private static final long serialVersionUID = -3882022670065995603L; + public static final String LABEL_EL_NAME = "label"; public static final String RECORD_EL_NAME = "record"; /** diff --git a/domain/src/main/java/org/fao/geonet/domain/Localized.java b/domain/src/main/java/org/fao/geonet/domain/Localized.java index 87b7e6fb5c3..416c84308bf 100644 --- a/domain/src/main/java/org/fao/geonet/domain/Localized.java +++ b/domain/src/main/java/org/fao/geonet/domain/Localized.java @@ -37,7 +37,8 @@ */ public abstract class Localized extends GeonetEntity { - private Map _labelTranslations = new HashMap(); + private static final long serialVersionUID = 2042917967381412158L; + private Map _labelTranslations = new HashMap(); /** * Get the map of langid -> label translations for metadata categories. diff --git a/domain/src/main/java/org/fao/geonet/domain/Metadata.java b/domain/src/main/java/org/fao/geonet/domain/Metadata.java index d6a2eff0188..73b1a748782 100644 --- a/domain/src/main/java/org/fao/geonet/domain/Metadata.java +++ b/domain/src/main/java/org/fao/geonet/domain/Metadata.java @@ -34,7 +34,8 @@ public class Metadata extends GeonetEntity { static final String ID_SEQ_NAME = "metadata_id_seq"; - public static final String METADATA_CATEG_JOIN_TABLE_NAME = "MetadataCateg"; + private static final long serialVersionUID = -1143579981236249988L; + public static final String METADATA_CATEG_JOIN_TABLE_NAME = "MetadataCateg"; public static final String METADATA_CATEG_JOIN_TABLE_CATEGORY_ID = "categoryId"; private int _id; private String _uuid; diff --git a/domain/src/main/java/org/fao/geonet/domain/MetadataHarvestInfo.java b/domain/src/main/java/org/fao/geonet/domain/MetadataHarvestInfo.java index c72fa58ffa3..9579aaf6cb3 100644 --- a/domain/src/main/java/org/fao/geonet/domain/MetadataHarvestInfo.java +++ b/domain/src/main/java/org/fao/geonet/domain/MetadataHarvestInfo.java @@ -1,6 +1,12 @@ package org.fao.geonet.domain; -import javax.persistence.*; +import java.io.Serializable; + +import javax.persistence.Access; +import javax.persistence.AccessType; +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.persistence.Transient; /** * Encapsulates the harvest data related to a metadata document. Like whether the metadata was harvested, the uuid of the harvester, @@ -11,8 +17,9 @@ */ @Embeddable @Access(AccessType.PROPERTY) -public class MetadataHarvestInfo { - private char _harvested = Constants.YN_FALSE; +public class MetadataHarvestInfo implements Serializable { + private static final long serialVersionUID = -3792707448380980096L; + private char _harvested = Constants.YN_FALSE; private String _uuid; private String _uri; diff --git a/domain/src/main/java/org/fao/geonet/domain/MetadataSourceInfo.java b/domain/src/main/java/org/fao/geonet/domain/MetadataSourceInfo.java index 18bb335db0c..4da56939e99 100644 --- a/domain/src/main/java/org/fao/geonet/domain/MetadataSourceInfo.java +++ b/domain/src/main/java/org/fao/geonet/domain/MetadataSourceInfo.java @@ -1,5 +1,7 @@ package org.fao.geonet.domain; +import java.io.Serializable; + import javax.persistence.Access; import javax.persistence.AccessType; import javax.persistence.Column; @@ -14,8 +16,9 @@ */ @Embeddable @Access(AccessType.PROPERTY) -public class MetadataSourceInfo { - private String _sourceId; +public class MetadataSourceInfo implements Serializable{ + private static final long serialVersionUID = -1152776956788517120L; + private String _sourceId; private Integer _groupOwner; private int _owner; diff --git a/domain/src/main/java/org/fao/geonet/domain/Setting.java b/domain/src/main/java/org/fao/geonet/domain/Setting.java index 9d359cc45ca..5127119de83 100644 --- a/domain/src/main/java/org/fao/geonet/domain/Setting.java +++ b/domain/src/main/java/org/fao/geonet/domain/Setting.java @@ -19,7 +19,8 @@ @Access(AccessType.PROPERTY) @EntityListeners(SettingEntityListenerManager.class) public class Setting extends GeonetEntity { - private String name; + private static final long serialVersionUID = -1884226715442176159L; + private String name; private String value; private SettingDataType dataType; private int position; diff --git a/domain/src/main/java/org/fao/geonet/domain/StatusValue.java b/domain/src/main/java/org/fao/geonet/domain/StatusValue.java index c5ce0257607..0da12e5b513 100644 --- a/domain/src/main/java/org/fao/geonet/domain/StatusValue.java +++ b/domain/src/main/java/org/fao/geonet/domain/StatusValue.java @@ -16,8 +16,9 @@ @EntityListeners(StatusValueEntityListenerManager.class) @SequenceGenerator(name=StatusValue.ID_SEQ_NAME, initialValue=100, allocationSize=1) public class StatusValue extends Localized { + private static final long serialVersionUID = 112093471293847L; + private int _id; static final String ID_SEQ_NAME = "status_value_id_seq"; - private int _id; private String _name; private char _reserved = Constants.YN_FALSE; private int displayOrder; diff --git a/domain/src/main/java/org/fao/geonet/domain/UserSecurityNotification.java b/domain/src/main/java/org/fao/geonet/domain/UserSecurityNotification.java index 97298d65938..d66bb5ab2bd 100644 --- a/domain/src/main/java/org/fao/geonet/domain/UserSecurityNotification.java +++ b/domain/src/main/java/org/fao/geonet/domain/UserSecurityNotification.java @@ -21,7 +21,7 @@ public enum UserSecurityNotification { public static UserSecurityNotification find(String notificationName) { for (UserSecurityNotification notification : values()) { if (notification.toString().equalsIgnoreCase(notificationName)) { - + return UNKNOWN; } } return UNKNOWN; diff --git a/domain/src/main/java/org/fao/geonet/repository/statistic/MetadataStatisticsQueries.java b/domain/src/main/java/org/fao/geonet/repository/statistic/MetadataStatisticsQueries.java index c33b34f30e8..8cd3d4a210e 100644 --- a/domain/src/main/java/org/fao/geonet/repository/statistic/MetadataStatisticsQueries.java +++ b/domain/src/main/java/org/fao/geonet/repository/statistic/MetadataStatisticsQueries.java @@ -1,15 +1,19 @@ package org.fao.geonet.repository.statistic; import com.google.common.base.Optional; + import org.fao.geonet.domain.*; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; import javax.persistence.Tuple; import javax.persistence.criteria.*; + import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -22,9 +26,16 @@ * Time: 4:23 PM */ public class MetadataStatisticsQueries { - - private final EntityManager _entityManager; - + + @PersistenceContext + @Qualifier(value = "entityManagerFactory") + private EntityManager _entityManager; + + /** + * Constructor for spring automated + */ + public MetadataStatisticsQueries() { + } /** * Constructor. diff --git a/domain/src/main/java/org/fao/geonet/repository/statistic/package-info.java b/domain/src/main/java/org/fao/geonet/repository/statistic/package-info.java index 7d9916b5722..241c26c4345 100644 --- a/domain/src/main/java/org/fao/geonet/repository/statistic/package-info.java +++ b/domain/src/main/java/org/fao/geonet/repository/statistic/package-info.java @@ -1,3 +1,5 @@ +package org.fao.geonet.repository.statistic; + /** * Repositories and objects for calculating statistics regarding metadata and search requests. */ \ No newline at end of file diff --git a/geonetwork-controllers/pom.xml b/geonetwork-controllers/pom.xml new file mode 100644 index 00000000000..0b19bdacbcd --- /dev/null +++ b/geonetwork-controllers/pom.xml @@ -0,0 +1,33 @@ + + + + geonetwork + org.geonetwork-opensource + 2.11.0-SNAPSHOT + + 4.0.0 + + geonetwork-controllers + + + + + ${project.groupId} + jeeves + ${project.version} + + + + ${project.groupId} + core + ${project.version} + + + + + + ${basedir}/.. + + \ No newline at end of file diff --git a/geonetwork-controllers/src/main/java/org/fao/geonet/beans/GroupBean.java b/geonetwork-controllers/src/main/java/org/fao/geonet/beans/GroupBean.java new file mode 100644 index 00000000000..3d52833aa8b --- /dev/null +++ b/geonetwork-controllers/src/main/java/org/fao/geonet/beans/GroupBean.java @@ -0,0 +1,41 @@ +package org.fao.geonet.beans; + + +public class GroupBean { + Integer id; + String name; + String description; + String email; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/BaseController.java b/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/BaseController.java new file mode 100644 index 00000000000..5901f511a86 --- /dev/null +++ b/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/BaseController.java @@ -0,0 +1,216 @@ +package org.fao.geonet.controllers; + +import jeeves.server.dispatchers.guiservices.XmlCacheManager; +import jeeves.server.dispatchers.guiservices.XmlFile; +import jeeves.server.sources.http.ServletPathFinder; +import org.apache.commons.io.FilenameUtils; +import org.fao.geonet.kernel.SchemaManager; +import org.fao.geonet.kernel.XmlSerializer; +import org.fao.geonet.kernel.setting.SettingManager; +import org.fao.geonet.repository.IsoLanguageRepository; +import org.fao.geonet.utils.Xml; +import org.jdom.Element; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Controller; + +import javax.servlet.ServletContext; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.util.List; +import java.util.Map; + +@Controller +public abstract class BaseController { + + private String FS = File.separator; + + @Autowired + protected ApplicationContext context; + + @Autowired + protected ServletContext servletContext; + + @Autowired + private XmlCacheManager cacheManager; + + @Autowired + private SchemaManager schemaManager; + + + /** + * Creates the html page to return from the model (response) and xsl sheet. + * + * @param response + * @return + */ + protected String buildHtmlPage(Element response, String xslSheet) throws Exception { + final ServletPathFinder pathFinder = new ServletPathFinder(servletContext); + String styleSheet = pathFinder.getAppPath() + xslSheet; + + // Adds translations, etc. to the model as required for xslt. + Element response2 = postProcessResponse(response); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + Xml.transform(response2, styleSheet, baos); + + return baos.toString(); + } + + /** + * Adds translations, etc. required by xslt to create html pages from xslt. + * + * TODO: Remove harcoded values and create dynamically from the request. + * + * @param response + * @return + */ + protected Element postProcessResponse(Element response) { + Element root = new Element("root"); + Element gui = new Element("gui"); + + + try { + Element xml = cacheManager.get(servletContext, true, "loc", "xml/strings.xml", "eng", "eng"); + gui.addContent(xml); + } catch (Exception ex) { + ex.printStackTrace(); + } + + try { + Element xml = cacheManager.get(servletContext, true, "loc", "xml/countries.xml", "eng", "eng"); + gui.addContent(xml); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + gui.addContent(getIsoLanguages()); + + Element session = new Element("session"); + session.addContent(new Element("userId").setText("1")); + session.addContent(new Element("username").setText("admin")); + session.addContent(new Element("name").setText("admin")); + session.addContent(new Element("surname").setText("admin")); + session.addContent(new Element("profile").setText("Administrator")); + + gui.addContent(session); + gui.addContent(getEnv()); + gui.addContent(getSystemConfig()); + gui.addContent(getSchemaList()); + gui.addContent(getSchemas()); + + gui.addContent(new Element("language").setText("eng")); + gui.addContent(new Element("reqService").setText("group.list")); + gui.addContent(new Element("url").setText("/geonetwork")); + gui.addContent(new Element("locUrl").setText("/geonetwork/loc/eng")); + gui.addContent(new Element("service").setText("/geonetwork/srv")); + gui.addContent(new Element("locService").setText("/geonetwork/srv/eng")); + + try { + Element xml = cacheManager.get(servletContext, false, "", "WEB-INF/config-gui.xml", "eng", "eng"); + gui.addContent(xml); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + root.addContent(gui); + root.addContent(response); + + return root; + } + + private Element getIsoLanguages() { + return context.getBean(IsoLanguageRepository.class).findAllAsXml(); + } + + private Element getSchemaList() { + SchemaManager schemaMan = context.getBean(SchemaManager.class); + + Element schemas = new Element("schemalist"); + + for (String schema : schemaMan.getSchemas()) { + Element elem = new Element("name").setText(schema); + elem.setAttribute("plugin","true"); // all schemas are plugins + elem.setAttribute("schemaConvertDirectory",schemaMan.getSchemaDir(schema)+"convert"+FS); + elem.setAttribute("namespaces",schemaMan.getNamespaceString(schema)); + // is it editable? + if (schemaMan.getSchema(schema).canEdit()) { + elem.setAttribute("edit","true"); + } else { + elem.setAttribute("edit","false"); + } + // get the conversion information and add it too + try { + List convElems = schemaMan.getConversionElements(schema); + if (convElems.size() > 0) { + Element conv = new Element("conversions"); + conv.addContent(convElems); + elem.addContent(conv); + } + } catch (Exception ex) { + // TODO: Handle exception + } + schemas.addContent(elem); + } + + return schemas; + } + + + private Element getSchemas() + { + Element schemas = new Element("schemas"); + + for(String schema : schemaManager.getSchemas()) { + try { + Map schemaInfo = schemaManager.getSchemaInfo(schema); + + for (Map.Entry entry : schemaInfo.entrySet()) { + XmlFile xf = entry.getValue(); + String fname = entry.getKey(); + Element response = xf.exec(new Element("junk"), cacheManager, servletContext); + + response.setName(FilenameUtils.removeExtension(fname)); + Element schemaElem = new Element(schema); + schemaElem.addContent(response); + schemas.addContent(schemaElem); + } + } catch (Exception e) { + //context.error("Failed to load guiservices for schema "+schema+": "+e.getMessage()); + e.printStackTrace(); + } + } + + //Log.info(Geonet.SCHEMA_MANAGER, "The response was "+Xml.getString(schemas)); + return schemas; + } + + private Element getEnv() { + // reset the thread local + XmlSerializer.clearThreadLocal(); + + Element response = context.getBean(SettingManager.class).getAllAsXML(true); + + final String READ_ONLY = "readonly"; + Element readOnly = new Element(READ_ONLY); + //readOnly.setText(Boolean.toString(gc.isReadOnly())); + readOnly.setText(Boolean.toString(false)); + + // Get the system node (which is for the time being the only child node + // of settings + Element system = response.getChild("system"); + system.addContent(readOnly); + system.setName("env"); + return (Element) system.clone(); + } + + private Element getSystemConfig() { + Element system = context.getBean(SettingManager.class).getAllAsXML(false); + return system; + } + + + +} \ No newline at end of file diff --git a/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/GenericController.java b/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/GenericController.java new file mode 100644 index 00000000000..923107fc19f --- /dev/null +++ b/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/GenericController.java @@ -0,0 +1,104 @@ +package org.fao.geonet.controllers; + +import jeeves.constants.Jeeves; +import jeeves.server.JeevesEngine; +import jeeves.server.UserSession; +import jeeves.server.sources.ServiceRequest; +import jeeves.server.sources.ServiceRequestFactory; +import org.fao.geonet.Util; +import org.fao.geonet.exceptions.FileUploadTooBigEx; +import org.fao.geonet.utils.Log; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + + +@Controller +public class GenericController { + public static final String USER_SESSION_ATTRIBUTE_KEY = Jeeves.Elem.SESSION; + + @Autowired + private ConfigurableApplicationContext jeevesApplicationContext; + + @RequestMapping(value = "/{lang}/{service}") + @ResponseBody + public void dispatch(@PathVariable String lang, @PathVariable String service, HttpServletRequest request, + HttpServletResponse response, HttpSession httpSession) throws Exception { + + String ip = request.getRemoteAddr(); + // if we do have the optional x-forwarded-for request header then + // use whatever is in it to record ip address of client + String forwardedFor = request.getHeader("x-forwarded-for"); + if (forwardedFor != null) ip = forwardedFor; + + Log.info (Log.REQUEST, "=========================================================="); + Log.info (Log.REQUEST, "Processing with Generic Controller"); + Log.info (Log.REQUEST, "HTML Request (from "+ ip +") : "+ request.getRequestURI()); + if(Log.isDebugEnabled(Log.REQUEST)) { + Log.debug(Log.REQUEST, "Method : "+ request.getMethod()); + Log.debug(Log.REQUEST, "Content type : "+ request.getContentType()); + // Log.debug(Log.REQUEST, "Context path : "+ req.getContextPath()); + // Log.debug(Log.REQUEST, "Char encoding: "+ req.getCharacterEncoding()); + Log.debug(Log.REQUEST, "Accept : "+ request.getHeader("Accept")); + // Log.debug(Log.REQUEST, "Server name : "+ req.getServerName()); + // Log.debug(Log.REQUEST, "Server port : "+ req.getServerPort()); + } + + if(Log.isDebugEnabled(Log.REQUEST)) Log.debug(Log.REQUEST, "Session id is "+httpSession.getId()); + UserSession session = (UserSession) httpSession.getAttribute(USER_SESSION_ATTRIBUTE_KEY); + + if (session == null) + { + //--- create session + + session = new UserSession(); + + httpSession.setAttribute(USER_SESSION_ATTRIBUTE_KEY, session); + session.setsHttpSession(httpSession); + + if(Log.isDebugEnabled(Log.REQUEST)) Log.debug(Log.REQUEST, "Session created for client : " + ip); + } + + ServiceRequest srvReq = null; + + JeevesEngine jeeves = jeevesApplicationContext.getBean(JeevesEngine.class); + try { + srvReq = ServiceRequestFactory.create(request, response, jeeves.getUploadDir(), jeeves.getMaxUploadSize()); + } catch (FileUploadTooBigEx e) { + StringBuffer sb = new StringBuffer(); + sb.append("File upload too big - exceeds "+jeeves.getMaxUploadSize()+" Mb\n"); + sb.append("Error : " +e.getClass().getName() +"\n"); + response.sendError(400, sb.toString()); + + // now stick the stack trace on the end and log the whole lot + sb.append("Stack :\n"); + sb.append(Util.getStackTrace(e)); + Log.error(Log.REQUEST, sb.toString()); + + } catch (Exception e) { + StringBuffer sb = new StringBuffer(); + + sb.append("Cannot build ServiceRequest\n"); + sb.append("Cause : " +e.getMessage() +"\n"); + sb.append("Error : " +e.getClass().getName() +"\n"); + response.sendError(400, sb.toString()); + + // now stick the stack trace on the end and log the whole lot + sb.append("Stack :\n"); + sb.append(Util.getStackTrace(e)); + Log.error(Log.REQUEST,sb.toString()); + } + + //--- execute request + + jeeves.dispatch(srvReq, session); + } +} diff --git a/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/GroupsController.java b/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/GroupsController.java new file mode 100644 index 00000000000..3fe8d3cd3e6 --- /dev/null +++ b/geonetwork-controllers/src/main/java/org/fao/geonet/controllers/GroupsController.java @@ -0,0 +1,71 @@ +package org.fao.geonet.controllers; + +import jeeves.constants.Jeeves; +import org.fao.geonet.beans.GroupBean; +import org.fao.geonet.domain.Group; +import org.fao.geonet.repository.GroupRepository; +import org.fao.geonet.repository.specification.GroupSpecs; +import org.fao.geonet.services.GroupsService; +import org.jdom.Element; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; + +import static org.springframework.data.jpa.domain.Specifications.not; + +@Controller +@Transactional +public class GroupsController extends BaseController { + + @Autowired + GroupsService service; + + @RequestMapping(value = "groups/list.html", method = RequestMethod.GET) + @ResponseBody + public String list(ModelMap map, HttpServletResponse response) throws Exception { + Element elRes = context.getBean(GroupRepository.class).findAllAsXml(not(GroupSpecs.isReserved())); + + //Element elOper = params.getChild(Jeeves.Elem.OPERATION); + + //if (elOper != null) + // elRes.addContent(elOper.detach()); + + elRes.setName(Jeeves.Elem.RESPONSE); + + return buildHtmlPage(elRes, "xsl/group-list.xsl"); + } + + + @RequestMapping(value = "groups/edit.html", method = RequestMethod.GET) + @ResponseBody + public String edit(@RequestParam(value="id", required=true) String id, ModelMap map, HttpServletResponse response) throws Exception { + + final Group group = context.getBean(GroupRepository.class).findOne(Integer.valueOf(id)); + + Element responseEl = new Element(Jeeves.Elem.RESPONSE); + + if (group != null) { + Element groupEl = group.asXml(); + responseEl.addContent(groupEl); + } + + return buildHtmlPage(responseEl, "xsl/group-update.xsl"); + } + + + @RequestMapping(value = "groups/update.html", method = RequestMethod.POST) + @ResponseBody + public String update(@ModelAttribute("group") final GroupBean group, ModelMap map, HttpServletResponse response) throws Exception { + final Element elRes = new Element(Jeeves.Elem.RESPONSE); + + service.update(group); + + elRes.addContent(new Element(Jeeves.Elem.OPERATION).setText(Jeeves.Text.UPDATED)); + + return buildHtmlPage(elRes, "xsl/group-list.xsl"); + } +} diff --git a/geonetwork-controllers/src/main/java/org/fao/geonet/services/GroupsService.java b/geonetwork-controllers/src/main/java/org/fao/geonet/services/GroupsService.java new file mode 100644 index 00000000000..6266b595625 --- /dev/null +++ b/geonetwork-controllers/src/main/java/org/fao/geonet/services/GroupsService.java @@ -0,0 +1,33 @@ +package org.fao.geonet.services; + +import org.fao.geonet.beans.GroupBean; +import org.fao.geonet.domain.Group; +import org.fao.geonet.repository.GroupRepository; +import org.fao.geonet.repository.Updater; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class GroupsService { + + @Autowired + GroupRepository groupRepository; + + @Transactional + public void update(final GroupBean group) { + groupRepository.update(Integer.valueOf(group.getId()), new Updater() { + @Override + public void apply(final Group entity) { + entity.setEmail(group.getEmail()) + .setName(group.getName()) + .setDescription(group.getDescription()); + } + }); + + //TODO: Check, seem not getting transactional behaviour + groupRepository.flush(); + } + +} diff --git a/jeeves/src/main/java/jeeves/config/springutil/JeevesDelegatingFilterProxy.java b/jeeves/src/main/java/jeeves/config/springutil/JeevesDelegatingFilterProxy.java index 840fda7cd33..ae0a5197c0b 100644 --- a/jeeves/src/main/java/jeeves/config/springutil/JeevesDelegatingFilterProxy.java +++ b/jeeves/src/main/java/jeeves/config/springutil/JeevesDelegatingFilterProxy.java @@ -35,7 +35,10 @@ public class JeevesDelegatingFilterProxy extends GenericFilterBean { public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (request instanceof HttpServletRequest) { HttpServletRequest httpRequest = (HttpServletRequest) request; - final String nodeName = httpRequest.getServletPath().substring(1); + String nodeName = "srv"; + if(httpRequest.getServletPath().length() > 0) { + nodeName = httpRequest.getServletPath().substring(1); + } String nodeId = User.NODE_APPLICATION_CONTEXT_KEY + nodeName; if (getServletContext().getAttribute(nodeId) == null) { if (nodeId != null && nodeName.equals(getFilterConfig().getInitParameter("loginService"))) { diff --git a/jeeves/src/main/java/jeeves/server/dispatchers/ServiceManager.java b/jeeves/src/main/java/jeeves/server/dispatchers/ServiceManager.java index f666a9256f3..81923c5f6ed 100644 --- a/jeeves/src/main/java/jeeves/server/dispatchers/ServiceManager.java +++ b/jeeves/src/main/java/jeeves/server/dispatchers/ServiceManager.java @@ -77,6 +77,7 @@ //============================================================================= @Transactional(propagation = Propagation.REQUIRED) +@org.springframework.stereotype.Service public class ServiceManager { private Map> htServices = new HashMap>(100); private Map htContexts = new HashMap(); diff --git a/jeeves/src/main/java/jeeves/server/dispatchers/guiservices/XmlCacheManager.java b/jeeves/src/main/java/jeeves/server/dispatchers/guiservices/XmlCacheManager.java index 49345dbaded..9991bfd5a3a 100644 --- a/jeeves/src/main/java/jeeves/server/dispatchers/guiservices/XmlCacheManager.java +++ b/jeeves/src/main/java/jeeves/server/dispatchers/guiservices/XmlCacheManager.java @@ -2,6 +2,7 @@ import jeeves.XmlFileCacher; import jeeves.server.context.ServiceContext; +import jeeves.server.sources.http.ServletPathFinder; import org.fao.geonet.utils.Log; import org.jdom.Element; import org.jdom.JDOMException; @@ -76,4 +77,51 @@ public synchronized Element get(ServiceContext context, boolean localized, Strin return result.setName(name); } + + public synchronized Element get(ServletContext servletContext, boolean localized, String base, String file, String preferedLanguage, String defaultLang) throws JDOMException, IOException { + + Map cacheMap = getCacheMap(localized, base, file); + + final ServletPathFinder pathFinder = new ServletPathFinder(servletContext); + String appPath = pathFinder.getAppPath(); //context.getAppPath(); + String xmlFilePath; + + boolean isBaseAbsolutePath = (new File(base)).isAbsolute(); + String rootPath = (isBaseAbsolutePath) ? base : appPath + base; + + if (localized) { + xmlFilePath = rootPath + File.separator + preferedLanguage +File.separator + file; + } else { + xmlFilePath = rootPath + File.separator + file; + if (!new File(xmlFilePath).exists()) { + xmlFilePath = appPath + file; + } + } + + XmlFileCacher xmlCache = cacheMap.get(preferedLanguage); + File xmlFile = new File(xmlFilePath); + if (xmlCache == null){ + xmlCache = new XmlFileCacher(xmlFile,servletContext,appPath); + cacheMap.put(preferedLanguage, xmlCache); + } + + Element result; + try { + result = (Element)xmlCache.get().clone(); + } catch (Exception e) { + Log.error(Log.RESOURCES, "Error cloning the cached data. Attempted to get: "+xmlFilePath+"but failed so falling back to default language"); + Log.debug(Log.RESOURCES, "Error cloning the cached data. Attempted to get: "+xmlFilePath+"but failed so falling back to default language", e); + String xmlDefaultLangFilePath = rootPath + File.separator + defaultLang + File.separator + file; + xmlCache = new XmlFileCacher(new File(xmlDefaultLangFilePath),servletContext, appPath); + cacheMap.put(preferedLanguage, xmlCache); + result = (Element)xmlCache.get().clone(); + } + String name = xmlFile.getName(); + int lastIndexOfDot = name.lastIndexOf('.'); + if (lastIndexOfDot > 0) { + name = name.substring(0,lastIndexOfDot); + } + return result.setName(name); + } + } diff --git a/jeeves/src/main/java/jeeves/server/dispatchers/guiservices/XmlFile.java b/jeeves/src/main/java/jeeves/server/dispatchers/guiservices/XmlFile.java index 8738205def9..32b57e80f51 100644 --- a/jeeves/src/main/java/jeeves/server/dispatchers/guiservices/XmlFile.java +++ b/jeeves/src/main/java/jeeves/server/dispatchers/guiservices/XmlFile.java @@ -30,6 +30,8 @@ import org.fao.geonet.exceptions.BadInputEx; import org.jdom.Element; +import javax.servlet.ServletContext; + //============================================================================= /** Loads and returns an xml file @@ -87,5 +89,19 @@ public Element exec(Element response, ServiceContext context) throws Exception element.setName(name); return element; } + + public Element exec(Element response, XmlCacheManager cacheManager, ServletContext context) throws Exception + { + // TODO: Change + String lang = "eng"; // context.getLanguage(); + + String preferedLanguage = language; + if(localized || preferedLanguage == null) preferedLanguage = lang; + //if(preferedLanguage == null) preferedLanguage = defaultLang; + + Element element = cacheManager.get(context, localized, base, file, preferedLanguage, defaultLang); + element.setName(name); + return element; + } } diff --git a/jeeves/src/main/resources/config-spring-geonetwork.xml b/jeeves/src/main/resources/config-spring-geonetwork.xml index 5efe3f2ffe0..ea27dc5c89a 100644 --- a/jeeves/src/main/resources/config-spring-geonetwork.xml +++ b/jeeves/src/main/resources/config-spring-geonetwork.xml @@ -3,23 +3,25 @@ xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" + xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd " > + - - - - - - + + + + + diff --git a/pom.xml b/pom.xml index 29159514d3d..ea1f83e7dda 100644 --- a/pom.xml +++ b/pom.xml @@ -186,7 +186,7 @@ - + org.codehaus.groovy.maven gmaven-plugin 1.0 @@ -886,6 +886,22 @@ spring-context ${spring.version} + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-oxm + ${spring.version} + + + org.springframework + spring-webmvc + ${spring.version} + org.springframework spring-orm @@ -1091,6 +1107,7 @@ web-client wro4j web + geonetwork-controllers e2e-tests @@ -1139,6 +1156,8 @@ 8.1.9.v20130131 8.6 4.1.0 + 3.1.4.RELEASE + 1.9.5 3.2.5.RELEASE 3.1.4.RELEASE 2.1.1 diff --git a/services/pom.xml b/services/pom.xml index d1085d24960..fcc37acc320 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -9,7 +9,7 @@ 4.0.0 services - GeoNetwork services + GeoNetwork services @@ -23,6 +23,25 @@ ${project.version} + + ${project.groupId} + geonetwork-controllers + ${project.version} + + + + + + org.springframework + spring-oxm + + org.geonetwork-opensource harvesters @@ -35,51 +54,61 @@ ${project.version} - - org.mockito - mockito-core - - - org.springframework - spring-test - - - com.h2database - h2 - test - - - ${project.groupId} - domain - ${project.version} - tests - test - - - ${project.groupId} - core - ${project.version} - tests - test - + + org.mockito + mockito-core + + + org.springframework + spring-test + + + com.h2database + h2 + test + + + ${project.groupId} + domain + ${project.version} + tests + test + + + ${project.groupId} + core + ${project.version} + tests + test + + + com.fasterxml.jackson.core + jackson-databind + 2.3.0 + + + javax.activation + activation + 1.1.1 + - - - - maven-jar-plugin - - - test-jar - - test-jar - - - - - - + + + + maven-jar-plugin + + + test-jar + + test-jar + + + + + + - + run-static-analysis diff --git a/services/src/main/java/org/fao/geonet/services/config/Get.java b/services/src/main/java/org/fao/geonet/services/config/Get.java index d4c9fb1c163..531e1e3bc2c 100644 --- a/services/src/main/java/org/fao/geonet/services/config/Get.java +++ b/services/src/main/java/org/fao/geonet/services/config/Get.java @@ -23,42 +23,200 @@ package org.fao.geonet.services.config; +import java.util.LinkedList; +import java.util.List; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.namespace.QName; + import jeeves.interfaces.Service; import jeeves.server.ServiceConfig; import jeeves.server.context.ServiceContext; -import org.fao.geonet.Util; + import org.fao.geonet.GeonetContext; +import org.fao.geonet.Util; +import org.fao.geonet.bean.Setting; +import org.fao.geonet.bean.SettingChild; +import org.fao.geonet.bean.SettingParent; import org.fao.geonet.constants.Geonet; import org.fao.geonet.kernel.setting.SettingManager; +import org.fao.geonet.kernel.setting.SpringSettingManager; import org.jdom.Element; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; //============================================================================= -public class Get implements Service -{ - //-------------------------------------------------------------------------- - //--- - //--- Init - //--- - //-------------------------------------------------------------------------- - - public void init(String appPath, ServiceConfig params) throws Exception {} - - //-------------------------------------------------------------------------- - //--- - //--- Service - //--- - //-------------------------------------------------------------------------- - - public Element exec(Element params, ServiceContext context) throws Exception - { - GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); +/** + * Return the list of languages + * + * + */ +@Controller +public class Get implements Service { + + @Autowired + private SpringSettingManager sm; + + + @RequestMapping(value = "/{lang}/admin.config.list@json", produces = "application/json") + public @ResponseBody + ReturnType json( + @PathVariable String lang, + @RequestParam(required = false, defaultValue = "false") Boolean asTree) { + + return xml(lang, asTree); + } + + @RequestMapping(value = "/{lang}/admin.config.list", produces = "application/xml") + public @ResponseBody + ReturnType xml( + @PathVariable String lang, + @RequestParam(required = false, defaultValue = "false") Boolean asTree) { + + // TODO lang internationalization + + List res = sm.getAllAsList(); + + if (asTree) { + List> settings = new LinkedList>(); + for (org.fao.geonet.domain.Setting s : res) { + + String name = s.getName(); + String setname = name.substring(name.lastIndexOf("/") + 1); + name = name.substring(0, name.lastIndexOf("/")); + String[] path = name.split("/"); + List> previousParentList = settings; + SettingParent currentParent = null; + String tmppath = null; + + for (String step : path) { + if (tmppath == null) { + tmppath = step; + } else { + tmppath = tmppath + "/" + step; + } + currentParent = null; + for (JAXBElement setting : previousParentList) { + if (step.equals(setting.getName().getLocalPart()) + && setting.getValue() instanceof SettingParent) { + currentParent = (SettingParent) setting.getValue(); + break; + } + } + + if (currentParent == null) { + currentParent = new SettingParent(); + currentParent.setName(tmppath); + currentParent.setPosition(s.getPosition()); + + JAXBElement jaxbchild = new JAXBElement( + new QName(step), SettingParent.class, + currentParent); + previousParentList.add(jaxbchild); + } + previousParentList = currentParent.getChildren(); + } + + SettingChild child = new SettingChild(); + child.setValue(s.getValue()); + child.setDataTypeName(s.getDataType().toString()); + child.setDataType(Integer.valueOf(s.getDataType().ordinal()) + .toString()); + child.setName(s.getName()); + child.setPosition(s.getPosition()); + + JAXBElement setting = new JAXBElement( + new QName(setname), SettingChild.class, child); + + currentParent.addChild(setting); + } + return new TreeSettings(settings); + } else { + List settings = new LinkedList(); + for (org.fao.geonet.domain.Setting s : res) { + SettingChild setting = new SettingChild(); + setting.setName(s.getName()); + setting.setPosition(s.getPosition()); + setting.setValue(s.getValue()); + setting.setDataType(s.getDataType().toString()); + settings.add(setting); + } + return new Settings(settings); + } + } + + public SpringSettingManager getSm() { + return sm; + } + + public void setSm(SpringSettingManager sm) { + this.sm = sm; + } + + public void init(String appPath, ServiceConfig params) throws Exception { + } + + @Override + @Deprecated + public Element exec(Element params, ServiceContext context) + throws Exception { + GeonetContext gc = (GeonetContext) context + .getHandlerContext(Geonet.CONTEXT_NAME); boolean asTree = Util.getParam(params, "asTree", "true").equals("true"); - Element system = gc.getBean(SettingManager.class).getAllAsXML(asTree); + Element system = gc.getBean(SettingManager.class).getAllAsXML(asTree); return system; } + } -//============================================================================= +@XmlRootElement(name = "settings") +@XmlSeeAlso({ Setting.class }) +class ReturnType { +} + +@XmlRootElement(name = "settings") +@XmlSeeAlso({ Setting.class, SettingParent.class, SettingChild.class }) +class Settings extends ReturnType { + protected List setting; + + public Settings() { + } + + public Settings(List list) { + this.setting = list; + } + + @XmlElement(name = "setting", type = Setting.class) + public List getSetting() { + return setting; + } +} + +@XmlRootElement(name = "settings") +@XmlSeeAlso({ Setting.class, SettingParent.class, SettingChild.class }) +class TreeSettings extends ReturnType { + protected List> setting; + + public TreeSettings() { + } + + public TreeSettings(List> list) { + this.setting = list; + } + + @XmlAnyElement(lax = true) + public List> getSetting() { + return setting; + } +} diff --git a/services/src/main/resources/config-spring-geonetwork.xml b/services/src/main/resources/config-spring-geonetwork.xml index 208014739d1..a8acdeb4cb8 100644 --- a/services/src/main/resources/config-spring-geonetwork.xml +++ b/services/src/main/resources/config-spring-geonetwork.xml @@ -1,16 +1,49 @@ - + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> + + + + + + + + + + + + + + + + + + html=text/html + json=application/json + xml=application/xml + + + - - + + - + + + + \ No newline at end of file diff --git a/web/pom.xml b/web/pom.xml index 747644c39f4..eb01660cda1 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -93,17 +93,12 @@ org.springframework spring-tx - - org.springframework - spring-webmvc - ${spring.version} - - - org.springframework - spring-web - ${spring.version} + + + org.springframework + spring-webmvc - + org.dspace @@ -335,6 +330,12 @@ ${project.version} + + ${project.groupId} + geonetwork-controllers + ${project.version} + + dlib diff --git a/web/src/main/java/org/fao/geonet/i18n/UrlLocaleChangeInterceptor.java b/web/src/main/java/org/fao/geonet/i18n/UrlLocaleChangeInterceptor.java new file mode 100644 index 00000000000..5ccd20115fd --- /dev/null +++ b/web/src/main/java/org/fao/geonet/i18n/UrlLocaleChangeInterceptor.java @@ -0,0 +1,58 @@ +package org.fao.geonet.i18n; + +import java.util.Locale; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.propertyeditors.LocaleEditor; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import org.springframework.web.servlet.support.RequestContextUtils; + +/** + * Strongly based on LocaleChangeInterceptor from Spring + * + * @author delawen + * + */ +public class UrlLocaleChangeInterceptor extends HandlerInterceptorAdapter { + public static final Integer DEFAULT_URL_POSITION = 0; + private Integer urlPosition = DEFAULT_URL_POSITION; + + public void setUrlPosition(Integer p) { + this.urlPosition = p; + } + + @Override + public boolean preHandle(HttpServletRequest request, + HttpServletResponse response, Object handler) + throws ServletException { + + String url = request.getRequestURI(); + String[] path = url.split("/"); + String newLocale = null; + Integer position = urlPosition; + + if (path.length >= position) { + newLocale = path[position]; + if (newLocale != null) { + LocaleResolver localeResolver = RequestContextUtils + .getLocaleResolver(request); + if (localeResolver == null) { + throw new IllegalStateException( + "No LocaleResolver found: not in a DispatcherServlet request?"); + } + LocaleEditor localeEditor = new LocaleEditor(); + localeEditor.setAsText(newLocale); + localeResolver.setLocale(request, response, + (Locale) localeEditor.getValue()); + } + } + + // Proceed in any case. + return true; + } + +} diff --git a/web/src/main/webResources/WEB-INF/web.xml b/web/src/main/webResources/WEB-INF/web.xml index abbf0927ab0..83ffcaee4a9 100644 --- a/web/src/main/webResources/WEB-INF/web.xml +++ b/web/src/main/webResources/WEB-INF/web.xml @@ -7,9 +7,25 @@ metadata-complete="true"> geonetwork + + + contextClass + + jeeves.config.springutil.JeevesApplicationContext + + + applicationContextPostProcessors + + + + contextConfigLocation + /WEB-INF/config-spring-geonetwork.xml + + jeeves.config.springutil.JeevesContextLoaderListener + org.springframework.web.context.request.RequestContextListener @@ -43,6 +59,10 @@ + springSecurityFilterChain jeeves.config.springutil.JeevesDelegatingFilterProxy @@ -55,6 +75,7 @@ localhost + springSecurityFilterChain /* @@ -254,30 +275,6 @@ /expensivehealthcheck - - - Handles requests that should be redirected to the page in the correct local. - For example index.html or index.jsp or error pages - - localeRedirects - org.springframework.web.servlet.DispatcherServlet - - - - localeRedirects - /home - - - - localeRedirects - /login.jsp - - - - localeRedirects - /accessDenied.jsp - - gn-servlet jeeves.server.sources.http.JeevesServlet @@ -301,7 +298,7 @@ gn-servlet - /srv/* + /nouse/* + + spring + + org.springframework.web.servlet.DispatcherServlet + + 2 + + + + spring + /srv/* + + + + spring + /* + + HttpProxy /proxy diff --git a/web/src/main/webapp/WEB-INF/config-db/initial_data.xml b/web/src/main/webapp/WEB-INF/config-db/initial_data.xml index 299ccb5c24e..103f657fe5b 100644 --- a/web/src/main/webapp/WEB-INF/config-db/initial_data.xml +++ b/web/src/main/webapp/WEB-INF/config-db/initial_data.xml @@ -1,8 +1,11 @@ + xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" > @@ -56,4 +63,28 @@ spa tur + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/src/main/webapp/WEB-INF/config/config-service-admin.xml b/web/src/main/webapp/WEB-INF/config/config-service-admin.xml index dd316e228a9..b78a5f41482 100644 --- a/web/src/main/webapp/WEB-INF/config/config-service-admin.xml +++ b/web/src/main/webapp/WEB-INF/config/config-service-admin.xml @@ -13,11 +13,11 @@ ]]> - + diff --git a/web/src/main/webapp/WEB-INF/spring-servlet.xml b/web/src/main/webapp/WEB-INF/spring-servlet.xml new file mode 100644 index 00000000000..ceeffede439 --- /dev/null +++ b/web/src/main/webapp/WEB-INF/spring-servlet.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file