http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java ---------------------------------------------------------------------- diff --git a/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java b/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java deleted file mode 100644 index 8ed95f9..0000000 --- a/opendapps/src/main/java/org/apache/oodt/opendapps/util/ProfileUtils.java +++ /dev/null @@ -1,421 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.oodt.opendapps.util; - -import org.apache.oodt.cas.metadata.Metadata; -import org.apache.oodt.cas.metadata.util.PathUtils; -import org.apache.oodt.opendapps.OpendapProfileElementExtractor; -import org.apache.oodt.opendapps.config.ConstantSpec; -import org.apache.oodt.opendapps.config.DatasetMetElem; -import org.apache.oodt.opendapps.config.OpendapConfig; -import org.apache.oodt.opendapps.config.RewriteSpec; -import org.apache.oodt.profile.EnumeratedProfileElement; -import org.apache.oodt.profile.Profile; -import org.apache.oodt.profile.ProfileAttributes; -import org.apache.oodt.profile.ProfileElement; -import org.apache.oodt.profile.ResourceAttributes; - -import org.springframework.util.StringUtils; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.Enumeration; -import java.util.concurrent.ConcurrentHashMap; -import java.util.List; -import java.util.Map; -import java.util.TimeZone; -import java.util.logging.Level; -import java.util.logging.Logger; - -import opendap.dap.BaseType; -import opendap.dap.DArray; -import opendap.dap.DConnect; -import opendap.dap.DDS; -import opendap.dap.DGrid; - -import static org.apache.oodt.opendapps.config.OpendapConfigMetKeys.*; - -//JDK imports -//OPENDAP imports -//OODT imports - -/** - * - * Static methods for unraveling and generating {@link ProfileElement}s, - * {@link ProfileAttributes} and {@link ResourceAttributes} for a - * {@link Profile}, derived from a set of OPeNDAP dataset information and an - * {@link OpendapConfig}. - * - * - */ -public class ProfileUtils { - - static { - // Note: must override the CAS PathUtils delimiter otherwise every sentence is split at the ',' as different metadata fields. - // The delimiter must be a character that is not commonly used in the metadata values, - // and that it does not a special regular expression character. - // Cannot use '#' as it is used in URL anchors, such as THREDDS urls. - // Cannot user '?', '&' as they are used in URL query strings. - // Cannot use '|' as it is used as multi-part separators in encoding of metadata fields. - PathUtils.DELIMITER = "~"; - } - - // character separating multiple parts of the same metadata field, - // when more than one piece of information needs to be stored in one field - public final static String CHAR = "|"; - - // HTTP mime types - public final static String MIME_TYPE_THREDDS = "application/xml+thredds"; - public final static String MIME_TYPE_NETCDF = "application/netcdf"; - public final static String MIME_TYPE_GRIDFTP = "application/gridftp"; - public final static String MIME_TYPE_FTP = "application/ftp"; - public final static String MIME_TYPE_LAS = "application/las"; - public final static String MIME_TYPE_HTML = "text/html"; - public final static String MIME_TYPE_GOOGLE_EARTH = "application/vnd.google-earth.kmz"; - public final static String MIME_TYPE_HDF = "application/x-hdf"; - public final static String MIME_TYPE_OPENDAP = "application/opendap"; - public final static String MIME_TYPE_OPENDAP_DODS = "application/opendap-dods"; - public final static String MIME_TYPE_OPENDAP_DAS = "application/opendap-das"; - public final static String MIME_TYPE_OPENDAP_DDS = "application/opendap-dds"; - public final static String MIME_TYPE_OPENDAP_HTML = "application/opendap-html"; - public final static String MIME_TYPE_RSS = "application/rss+xml"; - public final static String MIME_TYPE_GIS = "application/gis"; - - - private static final Logger LOG = Logger.getLogger(ProfileUtils.class - .getName()); - - public static ResourceAttributes getResourceAttributes(OpendapConfig conf, - String opendapUrl, DConnect dConn, Metadata datasetMet) { - ResourceAttributes resAttr = new ResourceAttributes(); - for (ConstantSpec spec : conf.getConstSpecs()) { - if (spec.getType().equals(RES_ATTR_SPEC_TYPE)) { - try { - - // first process expanded '[@...]' instructions - List<String> values = multipleEnvVariablesReplacement(spec.getValue(), datasetMet); - - // then process standard '[...]' instructions - for (String value : values) { - String _value = PathUtils.replaceEnvVariables(value, datasetMet, true); - if (StringUtils.hasText(_value)) { - setResourceAttributes(resAttr, spec.getName(), _value); - } - - } - - } catch (Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); - LOG.log(Level.WARNING, "Error setting field: [" + spec.getName() - + "] in resource attributes: Message: " + e.getMessage()); - } - } - } - - - return resAttr; - } - - /** - * Utility method to process environment replacement instructions of the form '[@key]' - * resulting in as many output values as there are values for the environment variable 'key'. - * Note that currently only one such pattern '[@key']' can be processed. - * - * @param value - * @param metadata - * @return - */ - private static List<String> multipleEnvVariablesReplacement(String value, Metadata metadata) { - - List<String> newValues = new ArrayList<String>(); - - // regexp matching found > replace values - int start = value.indexOf("[@"); - if (start>=0) { - - int end = value.indexOf("]",start+2); - // remove '[@',']' to obtain environment variable key - String envKey = value.substring(start+2,end); - List<String> envValues = metadata.getAllMetadata(envKey); - if (envValues!=null) { - for (String envValue : envValues) { - // create new metadata value for this environment replacement - String newValue = value.replaceAll("\\[@"+envKey+"\\]", envValue); - newValues.add(newValue); - } - } - - // regexp matching not found > return original value - } else { - newValues.add(value); - } - - return newValues; - - } - - public static ProfileAttributes getProfileAttributes(OpendapConfig conf, Metadata datasetMet) { - ProfileAttributes profAttr = new ProfileAttributes(); - for (ConstantSpec spec : conf.getConstSpecs()) { - if (spec.getType().equals(PROF_ATTR_SPEC_TYPE)) { - setProfileAttributesProperty(profAttr, spec.getName(), PathUtils - .replaceEnvVariables(spec.getValue(), datasetMet, true)); - } - } - - return profAttr; - - } - - public static Map<String, ProfileElement> getProfileElements( - OpendapConfig conf, DConnect dConn, Metadata datasetMet, Profile profile) throws Exception { - - OpendapProfileElementExtractor pe = new OpendapProfileElementExtractor(conf); - Map<String, ProfileElement> profElements = new ConcurrentHashMap<String, ProfileElement>(); - - // extracts all variables defined in DDS - try { - - DDS dds = dConn.getDDS(); - - // loop over all variables found - Enumeration variables = dds.getVariables(); - while (variables.hasMoreElements()) { - - BaseType variable = (BaseType)variables.nextElement(); - String varName = variable.getName(); - if (variable instanceof DArray) { - LOG.log(Level.FINE, "Extracting Darray variable: "+varName); - } else if (variable instanceof DGrid) { - LOG.log(Level.FINE, "Extracting Dgrid variable: "+varName); - } - - RewriteSpec spec = getProfileElementSpec(varName, conf); - if (spec!=null) { - // use configuration to set variable re-name and type - String peName = spec.getRename() != null && !spec.getRename().equals("") ? spec.getRename() : spec.getOrigName(); - if (spec.getElementType().equals(RANGED_ELEMENT_TYPE)) { - profElements.put(peName, pe.extractRangedProfileElement(peName, spec.getOrigName(), profile, dConn.getDAS())); - } else if (spec.getElementType().equals(ENUM_ELEMENT_TYPE)) { - profElements.put(peName, pe.extractEnumeratedProfileElement(peName, spec.getOrigName(), profile, dConn.getDAS())); - } - } else { - // if not explicitly configured, assume variable if of RANGED_ELEMENT_TYPE - profElements.put(varName, pe.extractRangedProfileElement(varName, varName, profile, dConn.getDAS())); - } - - } - - } catch(Exception e) { - LOG.log(Level.SEVERE, e.getMessage()); - LOG.log(Level.WARNING, "Error extracting metadata from DDS ("+dConn.URL()+") :" +e.getMessage()); - // rethrow the exception so that this dataset is not harvested - throw e; - } - - // add profile elements from <datasetMetadata> specification - if (datasetMet != null) { - for (DatasetMetElem datasetSpec : conf.getDatasetMetSpecs()) { - // retrieve values from metadata container - List<String> values = datasetMet.getAllMetadata(datasetSpec.getValue()); - addValuesToEnumeratedProfileElement(datasetSpec.getProfileElementName(), values, profile, profElements); - } - } - - // add profile elements from <constants> specification - for (ConstantSpec spec : conf.getConstSpecs()) { - if (spec.getType().equals(PROF_ELEM_SPEC_TYPE)) { - // retrieve value from XML configuration file, replace with value from metadata container if required, - // split according to delimiter - String replaceVal = PathUtils.replaceEnvVariables(spec.getValue(), datasetMet); - List<String> values = Arrays.asList(replaceVal.split(PathUtils.DELIMITER)); - addValuesToEnumeratedProfileElement(spec.getName(), values, profile, profElements); - } - } - - return profElements; - - } - - /** - * Method to add one or more values to an EnumeratedProfileElement, creating the element if not existing already. - * The supplied values are added only if valid. - */ - private static void addValuesToEnumeratedProfileElement(final String name, final List<String> values, Profile profile, Map<String, ProfileElement> profElements) { - - // try retrieve existing profile element - ProfileElement epe = profElements.get(name); - // or create a new one if not found - if (epe==null) { - epe = new EnumeratedProfileElement(profile); - epe.setName(name); - } - if (values!=null) { - for (String value : values) { - if (StringUtils.hasText(value) && !value.equalsIgnoreCase("null")) { - epe.getValues().add(value); - } - } - } - // only save profile elements with one or more values - if (epe.getValues().size()>0) { - profElements.put(name, epe); - } - - } - - private static void setProfileAttributesProperty(ProfileAttributes attr, - String propName, String value) { - if (propName.equals("profId")) { - attr.setID(value); - } else if (propName.equals("profVersion")) { - attr.setVersion(value); - } else if (propName.equals("profType")) { - attr.setType(value); - } else if (propName.equals("profStatusId")) { - attr.setStatusID(value); - } else if (propName.equals("profSecurityType")) { - attr.setSecurityType(value); - } else if (propName.equals("profParentId")) { - attr.setParent(value); - } else if (propName.equals("profRegAuthority")) { - attr.setRegAuthority(value); - } else if (propName.equals("profChildId")) { - attr.getChildren().addAll(Arrays.asList(value.split(PathUtils.DELIMITER))); - } else if (propName.equals("profRevisionNote")) { - attr.getRevisionNotes().addAll(Arrays.asList(value.split(PathUtils.DELIMITER))); - } - - } - - private static void setResourceAttributes(ResourceAttributes resAttr, - String propName, String value) { - if (StringUtils.hasText(value) && !value.equalsIgnoreCase("null")) { - if (propName.equals("Identifier")) { - resAttr.setIdentifier(value); - } else if (propName.equals("Title")) { - resAttr.setTitle(value); - } else if (propName.equals("Format")) { - resAttr.getFormats().addAll( parseValues(value) ); - } else if (propName.equals("Description")) { - resAttr.setDescription(value); - } else if (propName.equals("Creator")) { - resAttr.getCreators().addAll( parseValues(value) ); - } else if (propName.equals("Subject")) { - resAttr.getSubjects().addAll( parseValues(value) ); - } else if (propName.equals("Publisher")) { - resAttr.getPublishers().addAll( parseValues(value) ); - } else if (propName.equals("Contributor")) { - resAttr.getContributors().addAll( parseValues(value) ); - } else if (propName.equals("Date")) { - resAttr.getDates().addAll( parseValues(value) ); - } else if (propName.equals("Type")) { - resAttr.getTypes().addAll( parseValues(value) ); - } else if (propName.equals("Source")) { - resAttr.getSources().addAll( parseValues(value) ); - } else if (propName.equals("Language")) { - resAttr.getLanguages().addAll( parseValues(value) ); - } else if (propName.equals("Relation")) { - resAttr.getRelations().addAll( parseValues(value) ); - } else if (propName.equals("Coverage")) { - resAttr.getCoverages().addAll( parseValues(value) ); - } else if (propName.equals("Rights")) { - resAttr.getRights().addAll( parseValues(value) ); - } else if (propName.equals("resContext")) { - resAttr.getResContexts().addAll( parseValues(value) ); - } else if (propName.equals("resAggregation")) { - resAttr.setResAggregation(value); - } else if (propName.equals("resClass")) { - resAttr.setResClass(value); - } else if (propName.equals("resLocation")) { - resAttr.getResLocations().addAll( parseValues(value) ); - } - } - } - - /** - * Utility method to discover the rewrite specification for a named variable, if available. - * @param conf - */ - private static RewriteSpec getProfileElementSpec(String origName, OpendapConfig conf) { - for (RewriteSpec spec : conf.getRewriteSpecs()) { - if (spec.getOrigName().equals(origName)) { - return spec; - } - } - return null; - } - - /** - * Utility method to split a metadata field value according to the known delimiter. - * @param value - * @return - */ - public static List<String> parseValues(String value) { - List<String> values = new ArrayList<String>(); - for (String val : value.split(PathUtils.DELIMITER)) { - if (StringUtils.hasText(val) && !val.equalsIgnoreCase("null")) { - values.add(val); - } - } - - return values; - } - - /** - * Method to add a (name,value) pair to the metadata container if the value is not null or empty, - * and doesn't exist already. - * @param met - * @param value - */ - public static void addIfNotNull(Metadata met, String key, String value) { - // do not add a null value - if (StringUtils.hasText(value) && !value.equalsIgnoreCase("null")) { - // do not add the same value twice for the same metadata key - if (!met.containsKey(key) || !met.getAllMetadata(key).contains(value)) { - met.addMetadata(key, value); - } - } - } - - /** - * Method to add multiple (key, value) pairs to the metadata container if not existing already. - */ - public static void addIfNotExisting(Metadata metadata, String key, Enumeration<String> values) { - if (StringUtils.hasText(key) && !metadata.containsKey(key)) { - while (values.hasMoreElements()) { - String value = values.nextElement(); - if (StringUtils.hasText(value) && !value.equalsIgnoreCase("null")) { - metadata.addMetadata(key,value); - } - } - } - } - - // inspired from ASLv2 code at: - // http://www.java2s.com/Code/Java/Data-Type/ISO8601dateparsingutility.htm - public static String toISO8601(Date date) { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - TimeZone tz = TimeZone.getTimeZone("UTC"); - df.setTimeZone(tz); - return df.format(date); - } - -}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/opendapps/src/main/resources/logging.properties ---------------------------------------------------------------------- diff --git a/opendapps/src/main/resources/logging.properties b/opendapps/src/main/resources/logging.properties deleted file mode 100644 index 663006a..0000000 --- a/opendapps/src/main/resources/logging.properties +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Specify the handlers to create in the root logger -# (all loggers are children of the root logger) -# The following creates two handlers -handlers = java.util.logging.ConsoleHandler - -# Set the default logging level for the root logger -.level = ALL - -# Set the default logging level for new ConsoleHandler instances -java.util.logging.ConsoleHandler.level = ALL - -# Set the default formatter for new ConsoleHandler instances -java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter - -org.apache.oodt.opendapps.level = INFO -org.apache.oodt.opendapps.util.level = INFO -org.apache.oodt.opendapps.config.level = INFO - -# Tone down the Sun log messages -sun.net.www.level=SEVERE \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/opendapps/src/main/resources/opendap.config.xml ---------------------------------------------------------------------- diff --git a/opendapps/src/main/resources/opendap.config.xml b/opendapps/src/main/resources/opendap.config.xml deleted file mode 100644 index a338130..0000000 --- a/opendapps/src/main/resources/opendap.config.xml +++ /dev/null @@ -1,192 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -Description: This file defines a set of information used by an OODT Profile Server -to extract and deliver back OODT Profile metadata from an underlying OPeNDAP/THREDDS -accessible data source. This configuration file builds on prior work that was only -configurable in Java code, but is now configurable via this file. - ---> -<oodt:opendap xmlns:oodt="http://oodt.apache.org/1.0" id="urn:oodt:opendap:psid" name="OPeNDAP Handler"> - - <!-- - A set of THREDDS catalog roots to derive datasets from. Must specify at least one root. - - datasetURL - the original URL to the THREDDS dataset. - catalogURL - the original URL to the THREDDS catalog.xml file used to obtain dataset metadata - and information from. - filter (optional) - defines an optional dataset filter for inclusion/exclusion. - - --> - <root datasetURL="http://thredds1.pfeg.noaa.gov/thredds/dodsC/" catalogURL="http://thredds1.pfeg.noaa.gov/thredds/Satellite/aggregsatMW/chla/catalog.xml" filter=".*" /> - <root datasetURL="http://thredds1.pfeg.noaa.gov/thredds/dodsC/" catalogURL="http://thredds1.pfeg.noaa.gov/thredds/Satellite/aggregsatMH/chla/catalog.xml" filter=".*" /> - <root datasetURL="http://thredds1.pfeg.noaa.gov/thredds/dodsC/" catalogURL="http://thredds1.pfeg.noaa.gov/thredds/Satellite/aggregsatSW/chla/catalog.xml" filter=".*" /> - <root datasetURL="http://thredds1.pfeg.noaa.gov/thredds/dodsC/" catalogURL="http://thredds1.pfeg.noaa.gov/thredds/Satellite/aggregsatSA/chla/catalog.xml" filter=".*" /> - <root datasetURL="http://thredds1.pfeg.noaa.gov/thredds/dodsC/" catalogURL="http://thredds1.pfeg.noaa.gov/thredds/Satellite/aggregsatAG/tanm/catalog.xml" filter=".*" /> - <root datasetURL="http://thredds1.pfeg.noaa.gov/thredds/dodsC/" catalogURL="http://thredds1.pfeg.noaa.gov/thredds/Satellite/aggregsatAA/ssta/catalog.xml" filter=".*" /> - <root datasetURL="http://thredds1.pfeg.noaa.gov/thredds/dodsC/" catalogURL="http://thredds1.pfeg.noaa.gov/thredds/Satellite/aggregsatMH/sstd/catalog.xml" filter=".*" /> - - - <!-- - A set of specifications for how to rewrite the names of underlying OPeNDAP/THREDDS dataset variables - into profile elements within the generated OODT profile. These information are used only to transform - OPeNDAP variables into OODT profile elements. If an OPeNDAP element part of a dataset is not specified - in this rewrite block, the variable not be extracted. - - name: The original name of the OPeNDAP variable. - rename (optional): What to rename the variable to in the OODT Profile Elements section. - type: Either EnumeratedProfileElement or RangedProfileElement. EnumeratedProfileElement indicates this is - a variable with a select vocabulary of choices, with multiple values to specify those choices. RangedProfileElement - indicates this is an OPeNDAP variable with a specified min/max value. - - --> - <rewrite> - <var name="altitude" type="RangedProfileElement"/> - <var name="lat" rename="latitude" type="RangedProfileElement"/> - <var name="lon" rename="longitude" type="RangedProfileElement"/> - <var name="time" type="RangedProfileElement"/> - </rewrite> - - - <!-- - THREDDS Dataset metadata that you want to flow into the Profile - Elements portion of the profile. Each specified dataset metadata - will be turned into an EnumeratedProfileElement with 1 or more values. - - name: The name of the profile element. - value: The dataset metadata element to extract the metadata from. The - extracted metadata is shoved into the generated EnumeratedProfileElement's - value set. - --> - <datasetMetadata> - - <!-- variable names --> - <elem name="variable" value="Variables"/> - <elem name="cf_standard_name" value="CF Standard Names"/> - <elem name="variable_long_name" value="Variable Long Names"/> - - <!-- geospatial coverage --> - <elem name="south_deegrees" value="GeospatialCoverageLatSouth"/> - <elem name="north_deegrees" value="GeospatialCoverageLatNorth"/> - <elem name="west_deegrees" value="GeospatialCoverageLonWest"/> - <elem name="east_deegrees" value="GeospatialCoverageLonEast"/> - <elem name="spatial_coverage" value="GeospatialCoverage"/> - <elem name="latitude_resolution" value="GeospatialCoverageLatitudeResolution"/> - <elem name="longitude_resolution" value="GeospatialCoverageLongitudeResolution"/> - - <!-- temporal coverage --> - <elem name="datetime_start" value="StartDateTime"/> - <elem name="datetime_stop" value="EndDateTime"/> - <elem name="temporal_resolution" value="TimeCoverageResolution"/> - - </datasetMetadata> - - <!-- - A set of constant metadata to plumb through into the profile, either in the - profileAttributes section or the resourceAttributes section. The type parameter - indicates the section name, and the rest of the attributes are fairly evident from there. - Note: the value tag can use CAS/OODT based environment variable replacement, by specifying - values within the '[' and ']' delimiters, e.g., [PROFILE_REG_AUTHORITY]. - - type: either profAttr, resAttr, or profElem to indicate what section in the profile the information - should be part of. If profElem is selected, then an EnumeratedProfileElement with the provided - values will be created and added to the profile. - name: the name of the profileAttribute or resourceAttribute field. - value: the value to be set. - - - profAttr can be any of: - profId - profVersion - profType - profStatusId - profSecurityType - profParentId - profRegAuthority - profChildId - profRevisionNote - - resAttr can be any of: - Identifier - Title - Description - Creator - Subject - Publisher - Contributor - Date - Type - Source - Language - Relation - Coverage - Rights - resContext - resAggregation - resClass - resLocation - --> - <constants> - - <!-- profile attributes --> - <const type="profAttr" name="profType" value="CMDS Ocean Dataset Profile"/> - <const type="profAttr" name="profStatusId" value="active"/> - <const type="profAttr" name="profRegAuthority" value="NASA Coastal Marine Data Discovery Service (CMDS)" /> - <const type="profAttr" name="profId" value="[UUID]"/> - <const type="profAttr" name="profVersion" value="1.0"/> - - <!-- resource attributes --> - <const type="resAttr" name="Identifier" value="[ID]|[Host]" /> - <const type="resAttr" name="Title" value="[FullName]" /> - <const type="resAttr" name="Description" value="[Summary]" /> - <const type="resAttr" name="resLocation" value="[Access]"/> - <const type="resAttr" name="Rights" value="[Rights]" /> - <const type="resAttr" name="Relation" value="[Xlink]"/> - <const type="resAttr" name="Publisher" value="[Publisher]" /> - <const type="resAttr" name="Creator" value="[Creator]" /> - <const type="resAttr" name="Type" value="[DataType]"/> - <const type="resAttr" name="Format" value="[DataFormatType]"/> - <!-- dynamic keywords harvested from data --> - <const type="resAttr" name="Subject" value="[Keywords]" /> - <!-- static keywords to supplement keywords harvested from data --> - <const type="resAttr" name="Subject" value="Coastal Marine Data" /> - <const type="resAttr" name="Subject" value="Oceans" /> - <const type="resAttr" name="Subject" value="Climate Change" /> - <!-- OODT resource parameters --> - <const type="resAttr" name="resClass" value="data.dataSet" /> - <const type="resAttr" name="resContext" value="Oceanography"/> - <const type="resAttr" name="resAggregation" value="dataSet"/> - - <!-- profile elements from DAS/NC_GLOBAL section --> - <const type="profElem" name="mission_name" value="[satellite]"/> - <const type="profElem" name="sensor" value="[sensor]"/> - <const type="profElem" name="source" value="[source]"/> - <const type="profElem" name="project" value="[project]"/> - <const type="profElem" name="processing_level" value="[processing_level]"/> - <!-- constant values --> - <const type="profElem" name="spatial_coverage" value="Global"/> - <const type="profElem" name="institute" value="NOAA CoastWatch"/> - - <!-- constants required by ESGF harvesting process --> - <const type="profElem" name="master_id" value="[ID]|[Host]"/> - <const type="profElem" name="type" value="Dataset"/> - <const type="profElem" name="data_node" value="[Host]"/> - <const type="profElem" name="index_node" value="cmds-esg.jpl.nasa.gov"/> - - - </constants> - -</oodt:opendap> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index f5b1c3c..53c24cc 100644 --- a/pom.xml +++ b/pom.xml @@ -35,13 +35,6 @@ the License. <module>cli</module> <module>pcs/input</module> <module>metadata</module> - <module>protocol/api</module> - <module>protocol/ftp</module> - <module>protocol/http</module> - <module>protocol/imaps</module> - <module>protocol/sftp</module> - <module>xmlquery</module> - <module>sso</module> <module>filemgr</module> <module>catalog</module> <module>workflow</module> @@ -52,18 +45,10 @@ the License. <module>pge</module> <module>mvn/plugins/cas-install</module> <module>mvn/archetypes</module> - <module>pushpull</module> - <module>product</module> - <module>profile</module> - <module>grid</module> - <module>xmlps</module> - <module>opendapps</module> <module>webapp/components</module> <module>webapp/fmbrowser</module> <module>webapp/fmprod</module> <module>webapp/wmonitor</module> - <module>app/fmbrowser</module> - <module>app/weditor</module> <module>pcs/core</module> <module>pcs/opsui</module> <module>pcs/services</module> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/.gitignore ---------------------------------------------------------------------- diff --git a/product/.gitignore b/product/.gitignore deleted file mode 100644 index b54523f..0000000 --- a/product/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/maven-eclipse.xml http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/pom.xml ---------------------------------------------------------------------- diff --git a/product/pom.xml b/product/pom.xml deleted file mode 100644 index aa00f92..0000000 --- a/product/pom.xml +++ /dev/null @@ -1,138 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-core</artifactId> - <version>1.1-SNAPSHOT</version> - <relativePath>../core/pom.xml</relativePath> - </parent> - <artifactId>oodt-product</artifactId> - <name>Product Service</name> - <description>The Product Service provides access to data products. Products can be - scientific datasets, images, documents, or anything with an electronic - representation. The Product Service accepts standard query expressions (see - the Query Expression component) and returns zero or more matching products. - In addition, the product service can transform products from proprietary - formats and into Internet standard formats or run other transformations, all - without impacting local stores or operations.</description> - <!-- All dependencies should be listed in core/pom.xml and be ordered alphabetically by package and artifact. - Once the dependency is in the core pom, it can then be used in other modules without the version tags. - For example, within core/pom.xml: - - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - <version>1.7.4</version> - </dependency> - - Elsewhere in the platform: - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - </dependency> - - Where possible the same dependency version should be used across the whole platform but if required the version - can be overridden in a specific pom and should have a comment explaing why the version has been overridden - --> - <dependencies> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - <version>1.3</version> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-commons</artifactId> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-xmlquery</artifactId> - </dependency> - <dependency> - <groupId>org.apache.tika</groupId> - <artifactId>tika-core</artifactId> - </dependency> - </dependencies> - <build> - <resources> - <resource> - <targetPath>org/apache/oodt/product</targetPath> - <directory>${basedir}/src/main/conf</directory> - <includes> - <include>displayableTypes.xml</include> - </includes> - </resource> - </resources> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - </configuration> - </plugin> - </plugins> - </build> - <scm> - <!-- <connection>scm:svn:https://svn.apache.org/repos/asf/oodt/trunk/product</connection> - <developerConnection>scm:svn:https://svn.apache.org/repos/asf/oodt/trunk/product</developerConnection> - <url>http://svn.apache.org/viewvc/oodt/trunk/product</url>--> - <tag>0.13-SNAPSHOT</tag> - </scm> - <profiles> - <profile> - <id>audit</id> - <activation> - <activeByDefault>false</activeByDefault> - </activation> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>rat-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>check</goal> - </goals> - <phase>verify</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/conf/displayableTypes.xml ---------------------------------------------------------------------- diff --git a/product/src/main/conf/displayableTypes.xml b/product/src/main/conf/displayableTypes.xml deleted file mode 100644 index aca9ad0..0000000 --- a/product/src/main/conf/displayableTypes.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<!DOCTYPE displayableTypes [ - <!ELEMENT displayableTypes (type*)> - <!ELEMENT type (#PCDATA)> -]> -<displayableTypes> - <type>text/plain</type> - <type>text/richtext</type> - <type>text/enriched</type> - <type>text/tab-separated-values</type> - <type>text/html</type> - <type>text/xml</type> - <type>text/rtf</type> - <type>message/rfc822</type> - <type>message/partial</type> - <type>message/external-body</type> - <type>message/news</type> - <type>message/http</type> - <type>message/delivery-status</type> - <type>message/disposition-notification</type> - <type>message/s-http</type> - <type>application/rtf</type> - <type>application/pdf</type> - <type>image/jpeg</type> - <type>image/gif</type> - <type>image/tiff</type> - <type>image/png</type> - <type>audio/basic</type> - <type>audio/32kadpcm</type> - <type>audio/mpeg</type> - <type>video/mpeg</type> - <type>video/quicktime</type> - <type>model/vrml</type> -</displayableTypes> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/conf/ofsn-ps.xml ---------------------------------------------------------------------- diff --git a/product/src/main/conf/ofsn-ps.xml b/product/src/main/conf/ofsn-ps.xml deleted file mode 100644 index 01939dd..0000000 --- a/product/src/main/conf/ofsn-ps.xml +++ /dev/null @@ -1,201 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<!-- -Configures a new OODT OFSN style product server. This is a product server -of the form: - -http://host/webgrid/prod?OFSN=/some/ofsn+AND+RT=sometype - -OFSN is an online file specification name, as defined by the PDS standards. -RT is a transformation identifier, identifying a remote transformation to be applied -at the given OFSN path. - -More more information on the OFSN style product servers, see the PDS original here: - -http://oodt/pds-client/guide/product - -Required attributes: - id: defines a unique URN/id for this product server instance - name: defines a human readable name for this product server instance - productRoot: defines the root path in which the OFSN product server should start looking for - paths based on a given OFSN - -FIXME: Change XML namespace URI for oodt prefix? ---> -<oodt:ofsn xmlns:oodt="http://oodt.jpl.nasa.gov/xml/namespaces/oodt/1.0" - id="urn:oodt:prod:ofsn" - name="OODT OFSN Style Product Handler" - productRoot="/some/path" - > - - <!-- defines a new OFSN handler. There are 2 valid types: - - listing: this type generates a list of files given an OFSN. The list will - be returned and formatted in XML for easy parsing. - - get: this type returns the bits of the requested ofsn, after performing some - type of transformation on them. - - Required attributes: - - name: gives the handler type a identifiable name. This should be a valid RT name for use in the OODT - product server query, e.g., if you want the dir list non-recursive listing handler to be called on - RT=DIRLIST1, then set name to "DIRLIST1", as below. - - type: either listing, or get, depending on the desired handler type. - - class: defines a class that implements either the org.apache.oodt.product.handlers.ofsn.OFSNListHandler - interface (for "listing" handlers), or the org.apache.oodt.product.handlers.ofsn.OFSNGetHandler (for - "get" handlers). Note that this class must be on the classpath in order for it to be referenced in - this configuration. - - --> - - <!-- - Optionally, each handler can have its own configuration, specified on the form of - <property name="some name" value="some value"/> - - where some name is the name of the configuration property and some value is the - value of the configuration property. - - Optional properties (for GET handlers): - - property name: mimeType - property value: the desired MIME type (also referred to as content-type) a handler should return - content as (eg. "text/plain"). More formally, any value of the form - "type/subtype(; parameter=...)*" as defined in RFC 2045. - --> - - - <!-- - The DIRLIST1 type is identical to DIRLIST but does not recursively - descend into subdirectories. - --> - <handler name="DIRLIST1" type="listing" - class="org.apache.oodt.product.handlers.ofsn.DirListNonRecursiveHandler"/> - - - <!-- - The DIRLIST type returns an XML file with directory names (and only - directory names) and total size of files in each directory starting in - the requested directory and traversing into the subdirectories. - --> - <handler name="DIRLIST" type="listing" - class="org.apache.oodt.product.handlers.ofsn.DirListRecursiveHandler"/> - - - <!-- - The DIRFILELIST1 is identical to DIRFILELIST except that it does not - recurse into subdirectories. - --> - <handler name="DIRFILELIST1" type="listing" - class="org.apache.oodt.product.handlers.ofsn.FileListNonRecursiveHandler"/> - - <!-- - The DIRFILELIST returns an XML document containing all of the filenames - (and only the files, not directories) and their sizes, recursing into - subdirectories. - --> - <handler name="DIRFILELIST" type="listing" - class="org.apache.oodt.product.handlers.ofsn.FileListRecursiveHandler"/> - - <!-- - The RAW_SIZE generates an XML document telling the size of the raw file that - would be returned by the corresponding RAW type. - --> - <handler name="RAW_SIZE" type="listing" - class="org.apache.oodt.product.handlers.ofsn.RawSizeListHandler"> - - <!-- - Required attributes: - isSizeCmd: this value should be set to true in this handler to ensure that - only the size is printed in the OFSN doc. - --> - <property name="isSizeCmd" value="true"/> - </handler> - - <!-- - The FILELIST type returns an XML file naming the requested file and also - giving its size. - --> - <handler name="FILE_LIST" type="listing" - class="org.apache.oodt.product.handlers.ofsn.SingleFileListHandler"/> - - - <!-- - The FILELISTZIP is similar to FILELIST except that it tells what the size - of the requested file would be if compressed into a ZIP archive. - --> - <handler name="FILE_LIST_ZIP" type="listing" - class="org.apache.oodt.product.handlers.ofsn.SingleZipFileListHandler"> - - <!-- - Optional attributes: - cacheDirRoot: defines the cache dir that the product server should use when asked to create temporary - files, e.g., by a listing or get handler. By default, if not specified, it defaults to /tmp - - --> - <property name="cacheDirRoot" value="/tmp"/> - </handler> - - <!-- - The RAW type merely returns the requested file without any modification - (MIME type application/octet-stream ). - --> - <handler name="RAW" type="get" - class="org.apache.oodt.product.handlers.ofsn.StdOFSNGetHandler"/> - - - <!-- - The MD5 type returns an MD5 hash of the file bytes generated on the server side. - --> - - <handler name="MD5" type="get" - class="org.apache.oodt.product.handlers.ofsn.MD5GetHandler"> - - <property name="mimeType" value="text/plain"/> - - </handler> - - - <!-- - The URL type returns a URL listing pointing to files within an OFSN - - (Optional) Use the below properties to customize the constructed URL returned: - 1. prodServerHostname: the product server hostname - 2. prodServerPort: the product server's port - 3. prodServerContextRoot: the name of the product server webapp - 4. productRoot: the root directory of the product server - identical - to the root directory at the top of this XML file - 5. returnType: the desired return type. i.e. RAW, MD5, etc. - --> - <handler name="URL" type="get" - class="org.apache.oodt.product.handlers.ofsn.URLGetHandler"> - - <!-- the below values are the default if nothing specified - <property name="prodServerHostname" value="localhost"/> - <property name="prodServerPort" value="8080"/> - <property name="prodServerContextRoot" value="web-grid"/> - <property name="productRoot" value="/some/path"/> - <property name="returnType" value="RAW"/> - --> - - <property name="mimeType" value="text/plain"/> - - </handler> -</oodt:ofsn> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/LargeProductQueryHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/LargeProductQueryHandler.java b/product/src/main/java/org/apache/oodt/product/LargeProductQueryHandler.java deleted file mode 100644 index 029e9ce..0000000 --- a/product/src/main/java/org/apache/oodt/product/LargeProductQueryHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product; - -/** - * Handle requests for products that are too large to fit in an {@link - * org.apache.oodt.xmlquery.XMLQuery} object. - * - * @author Kelly - * @version $Revision: 1.1.1.1 $ - */ -public interface LargeProductQueryHandler extends QueryHandler { - /** - * Retrieve a chunk of a product. - * - * The product is identified by a string ID. The query handler should return a - * binary chunk of the product using the given offset and length. If the ID isn't - * recognized, it should return null. It should throw an exception if retrieval - * fails for some reason. - * - * @param id Product ID. - * @param offset Where in the product to get a chunk of it. - * @param length How much of the product to get. - * @return A chunk, or null if the <var>id</var> is unknown. - * @throws ProductException if an error occurs. - */ - byte[] retrieveChunk(String id, long offset, int length) throws ProductException; - - /** - * Close off a product. - * - * This method indicates that the product is no longer required and its resources - * can be freed by the query handler. If the ID is unknown, no untoward action is - * required. It should throw an exception if there is an error during the - * resource release (such as an {@link java.io.IOException} when closing a file. - * - * @param id Product ID. - * @throws ProductException if an error occurs. - */ - void close(String id); -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/QueryHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/QueryHandler.java b/product/src/main/java/org/apache/oodt/product/QueryHandler.java deleted file mode 100644 index 6addbce..0000000 --- a/product/src/main/java/org/apache/oodt/product/QueryHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product; - -import org.apache.oodt.xmlquery.XMLQuery; - -/** - * Handler for queries in a product service. - * - * @author Kelly - * @version $Revision: 1.1.1.1 $ - */ -public interface QueryHandler { - /** - * Run a query. - * - * @param q The query. - * @return The response. - * @throws ProductException if an error occurs. - */ - XMLQuery query(XMLQuery q) throws ProductException; -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java deleted file mode 100644 index 40b3094..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/AbstractCrawlLister.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -//JDK imports -import org.apache.oodt.product.ProductException; - -import java.io.File; -import java.io.FileFilter; -import java.util.Collections; -import java.util.List; -import java.util.Properties; -import java.util.Stack; -import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; - -//OODT imports - -/** - * - * An abstract {@link OFSNListHandler} for generating file lists based on two - * simple flags: recurse, and crawlForDirs, indicating to crawl for directories - * rather than files. - * - * @author mattmann - * @version $Revision$ - * - */ -public abstract class AbstractCrawlLister implements OFSNListHandler { - - protected final static Logger LOG = Logger - .getLogger(AbstractCrawlLister.class.getName()); - - protected static final FileFilter FILE_FILTER = new FileFilter() { - public boolean accept(File pathname) { - return pathname.isFile(); - } - }; - - protected static final FileFilter DIR_FILTER = new FileFilter() { - public boolean accept(File pathname) { - return pathname.isDirectory(); - } - }; - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.OFSNListHandler#configure(java. - * util.Properties) - */ - public abstract void configure(Properties conf); - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.OFSNListHandler#getListing(java - * .lang.String) - */ - public abstract File[] getListing(String ofsn) throws ProductException; - - protected File[] crawlFiles(File dirRoot, boolean recur, - boolean crawlForDirs) { - if (dirRoot == null || ((!dirRoot.exists()))) { - throw new IllegalArgumentException("dir root: [" + dirRoot - + "] is null or non existant!"); - } - - List<File> fileList = new Vector<File>(); - - // start crawling - Stack<File> stack = new Stack<File>(); - stack.push(dirRoot.isDirectory() ? dirRoot : dirRoot.getParentFile()); - while (!stack.isEmpty()) { - File dir = (File) stack.pop(); - LOG.log(Level.INFO, "OFSN: Crawling " + dir); - - File[] productFiles; - productFiles = crawlForDirs ? dir.listFiles(DIR_FILTER) : dir.listFiles(FILE_FILTER); - - if(productFiles!=null) { - Collections.addAll(fileList, productFiles); - } - if (recur) { - File[] subdirs = dir.listFiles(DIR_FILTER); - if (subdirs != null) { - for (File subdir : subdirs) { - stack.push(subdir); - } - } - } - } - - return fileList.toArray(new File[fileList.size()]); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/DirListNonRecursiveHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/DirListNonRecursiveHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/DirListNonRecursiveHandler.java deleted file mode 100644 index afabb4f..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/DirListNonRecursiveHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -//JDK imports -import java.io.File; -import java.util.Properties; - -//OODT imports -import org.apache.oodt.product.ProductException; - -/** - * - * Generates a directory listing, without recursing into the OFSN path. - * - * @author mattmann - * @version $Revision$ - * - */ -public class DirListNonRecursiveHandler extends AbstractCrawlLister { - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.OFSNListHandler#getListing(java - * .lang.String) - */ - public File[] getListing(String ofsn) throws ProductException { - return crawlFiles(new File(ofsn), false, true); - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.OFSNListHandler#configure(java. - * util.Properties) - */ - public void configure(Properties conf) { - // no properties defined yet - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/DirListRecursiveHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/DirListRecursiveHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/DirListRecursiveHandler.java deleted file mode 100644 index 00dd4ec..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/DirListRecursiveHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -//JDK imports -import java.io.File; -import java.util.Properties; - -//OODT imports -import org.apache.oodt.product.ProductException; - -/** - * - * Generates a directory listing, recursing into the OFSN path. - * - * @author mattmann - * @version $Revision$ - * - */ -public class DirListRecursiveHandler extends AbstractCrawlLister { - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.AbstractCrawlLister#configure(java - * .util.Properties) - */ - @Override - public void configure(Properties conf) { - // no properties yet - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.AbstractCrawlLister#getListing( - * java.lang.String) - */ - @Override - public File[] getListing(String ofsn) throws ProductException { - return crawlFiles(new File(ofsn), true, true); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/FileListNonRecursiveHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/FileListNonRecursiveHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/FileListNonRecursiveHandler.java deleted file mode 100644 index 2d8cfea..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/FileListNonRecursiveHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -//JDK imports -import java.io.File; -import java.util.Properties; - -//OODT imports -import org.apache.oodt.product.ProductException; - -/** - * - * A non recursive file listing from a given OFSN. - * - * @author mattmann - * @version $Revision$ - * - */ -public class FileListNonRecursiveHandler extends AbstractCrawlLister { - - /* (non-Javadoc) - * @see org.apache.oodt.product.handlers.ofsn.OFSNListHandler#configure(java.util.Properties) - */ - @Override - public void configure(Properties conf) { - // TODO Auto-generated method stub - // nothing yet - - } - - /* (non-Javadoc) - * @see org.apache.oodt.product.handlers.ofsn.OFSNListHandler#getListing(java.lang.String) - */ - @Override - public File[] getListing(String ofsn) throws ProductException { - return crawlFiles(new File(ofsn), false, false); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/FileListRecursiveHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/FileListRecursiveHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/FileListRecursiveHandler.java deleted file mode 100644 index 5543494..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/FileListRecursiveHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -//JDK imports -import java.io.File; -import java.util.Properties; - -//OODT imports -import org.apache.oodt.product.ProductException; - -/** - * - * A recursive file listing from the provided ofsn. - * - * @author mattmann - * @version $Revision$ - * - */ -public class FileListRecursiveHandler extends AbstractCrawlLister { - - /* (non-Javadoc) - * @see org.apache.oodt.product.handlers.ofsn.AbstractCrawlLister#configure(java.util.Properties) - */ - @Override - public void configure(Properties conf) { - // TODO Auto-generated method stub - // nothing yet - } - - /* (non-Javadoc) - * @see org.apache.oodt.product.handlers.ofsn.AbstractCrawlLister#getListing(java.lang.String) - */ - @Override - public File[] getListing(String ofsn) throws ProductException { - return crawlFiles(new File(ofsn), true, false); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/MD5GetHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/MD5GetHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/MD5GetHandler.java deleted file mode 100644 index 95ffe20..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/MD5GetHandler.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -//JDK imports - -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.io.FileUtils; -import org.apache.oodt.product.ProductException; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; - -//APACHE imports -//OODT imports - -/** - * - * A {@link OFSNGetHandler} to perform an MD5 for a file on the server side. - * - * @author mattmann - * @version $Revision$ - * - */ -public class MD5GetHandler implements OFSNGetHandler { - - private MessageDigest md = null; - private static Logger LOG = Logger.getLogger(MD5GetHandler.class.getName()); - public MD5GetHandler() throws InstantiationException { - try { - this.md = MessageDigest.getInstance("MD5"); - } catch (NoSuchAlgorithmException e) { - LOG.log(Level.SEVERE, e.getMessage()); - throw new InstantiationException(e.getMessage()); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.OFSNListHandler#configure(java. - * util.Properties) - */ - public void configure(Properties conf) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.OFSNGetHandler#retrieveChunk(java - * .lang.String, long, int) - */ - public byte[] retrieveChunk(String filepath, long offset, int length) - throws ProductException { - try { - String hash = this.hashData(FileUtils.readFileToByteArray(new File( - filepath))); - byte[] retBytes = new byte[length]; - byte[] hashBytes = hash.getBytes(); - ByteArrayInputStream is = new ByteArrayInputStream(hashBytes); - is.skip(offset); - is.read(retBytes, 0, length); - return retBytes; - } catch (IOException e) { - LOG.log(Level.SEVERE, e.getMessage()); - throw new ProductException("Error reading bytes from file: [" + filepath - + "] MD5: Message: " + e.getMessage()); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.handlers.ofsn.OFSNGetHandler#sizeOf(java.lang - * .String) - */ - public long sizeOf(String filepath) { - try { - String hash = this.hashData(FileUtils.readFileToByteArray(new File( - filepath))); - return hash.getBytes().length; - } catch (IOException e) { - LOG.log(Level.SEVERE, e.getMessage()); - return -1; - } - } - - /** - * Use this method ot generate a test MD5 of a provide {@link File} specified - * in args[0]. - * - * @param args - * Only need to specify 1 arg, the full path to the {@link File} to - * MD5. - * @throws Exception - * If any error occurs. - */ - public static void main(String[] args) throws Exception { - if (args.length != 1) { - System.err.println("MD5GetHandler <file>"); - System.exit(1); - } - - String filepath = args[0]; - String hashString = new MD5GetHandler().hashData(FileUtils - .readFileToByteArray(new File(filepath))); - System.out.println(hashString); - } - - private String hashData(byte[] dataToHash) { - this.md.update(dataToHash, 0, dataToHash.length); - byte[] hash = this.md.digest(); - return new String(Hex.encodeHex(hash)); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java deleted file mode 100644 index 016d714..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandler.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -import org.apache.oodt.commons.xml.XMLUtils; -import org.apache.oodt.product.LargeProductQueryHandler; -import org.apache.oodt.product.ProductException; -import org.apache.oodt.product.handlers.ofsn.metadata.OFSNMetKeys; -import org.apache.oodt.product.handlers.ofsn.metadata.OFSNXMLConfigMetKeys; -import org.apache.oodt.product.handlers.ofsn.metadata.OFSNXMLMetKeys; -import org.apache.oodt.product.handlers.ofsn.metadata.XMLQueryMetKeys; -import org.apache.oodt.product.handlers.ofsn.util.OFSNObjectFactory; -import org.apache.oodt.product.handlers.ofsn.util.OFSNUtils; -import org.apache.oodt.xmlquery.LargeResult; -import org.apache.oodt.xmlquery.Result; -import org.apache.oodt.xmlquery.XMLQuery; -import org.apache.tika.mime.MediaType; -import org.apache.tika.mime.MimeTypesFactory; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.Collections; -import java.util.concurrent.ConcurrentHashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - - -/** - * - * An extensible implementation of the PDS-inspired Online File Specification - * Name (OFSN) style product server. See the ofsn-ps.xml file for a detailed - * specification of the configuration and motivation behind this product - * handler. - * - * @author mattmann - * @version $Revision$ - */ -public class OFSNFileHandler implements LargeProductQueryHandler, - XMLQueryMetKeys, OFSNXMLMetKeys, OFSNMetKeys, OFSNXMLConfigMetKeys { - - private static final Logger LOG = Logger.getLogger(OFSNFileHandler.class - .getName()); - - private static final String CMD_SEPARATOR = ";"; - - // by default return dir size on listing commands - private boolean computeDirSize = true; - - // by default return file size on listing commands - private boolean computeFileSize = true; - - private OFSNFileHandlerConfiguration conf; - - private Map<String, Object> HANDLER_CACHE; - - public OFSNFileHandler() throws InstantiationException { - // init conf here - String xmlConfigFilePath = System.getProperty(OFSN_XML_CONF_FILE_KEY); - this.computeDirSize = Boolean.getBoolean(OFSN_COMPUTE_DIR_SIZE); - this.computeFileSize = Boolean.getBoolean(OFSN_COMPUTE_FILE_SIZE); - - - if (xmlConfigFilePath == null) { - throw new InstantiationException( - "Must define xml configuration file path via property : [" - + OFSN_XML_CONF_FILE_KEY + "]"); - } - - try { - this.conf = OFSNFileHandlerConfigurationReader - .getConfig(xmlConfigFilePath); - } catch (FileNotFoundException e) { - throw new InstantiationException("xml configuration file: [" - + xmlConfigFilePath + "] not found!"); - } - - if (this.conf.getProductRoot() == null) { - throw new InstantiationException( - "Must define: [productRoot] attribute in XML configuration!"); - } - - // used to cache handlers -- map of RT type to Get/List handler instance - HANDLER_CACHE = new ConcurrentHashMap<String, Object>(); - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.product.QueryHandler#query(org.apache.oodt.xmlquery.XMLQuery) - */ - public XMLQuery query(XMLQuery xmlQuery) throws ProductException { - String ofsn = OFSNUtils.extractFieldFromQuery(xmlQuery, OFSN); - String cmd = OFSNUtils.extractFieldFromQuery(xmlQuery, RETURN_TYPE); - validate(ofsn, cmd); - String cmdId = ofsn + CMD_SEPARATOR + cmd; - OFSNHandlerConfig cfg = this.conf.getHandlerConfig(cmd); - validateHandlerConfig(cfg, cmd); - - String realPath = this.conf.getProductRoot() + ofsn; - - if (isListingCmd(cmd)) { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - OFSNListHandler handler = getListHandler(cmd, cfg.getClassName()); - File[] fileList = handler.getListing(realPath); - generateOFSNXml(fileList, cfg, outStream); - xmlQuery.getResults().add( - new Result(cmdId, XML_MIME_TYPE, null, cmdId, Collections.EMPTY_LIST, - outStream.toString())); - } else if (isGetCmd(cmd)) { - OFSNGetHandler handler = getGetHandler(cmd, cfg.getClassName()); - String rtAndPath = cmd + CMD_SEPARATOR + realPath; - String mimeType; - - // check for and use mimetype conf property if available - if (cfg.getHandlerConf().containsKey(PROPERTY_MIMETYPE_ATTR)) { - MediaType mediaType = MediaType.parse(cfg.getHandlerConf() - .getProperty(PROPERTY_MIMETYPE_ATTR)); - if (mediaType == null) { - LOG.log(Level.WARNING, "MIME type [" - +cfg.getHandlerConf().getProperty(PROPERTY_MIMETYPE_ATTR)+"] specified " - +"for handler ["+cfg.getClassName()+"] invalid. Defaulting to MIME type [" - +MediaType.OCTET_STREAM.toString()+"]"); - mediaType = MediaType.OCTET_STREAM; - } - mimeType = mediaType.toString(); - } else { // use default mimetype of product on disk - try { - mimeType = MimeTypesFactory.create().getMimeType(new File(realPath)).getName(); - } catch (Exception e) { - mimeType = null; - } - } - - xmlQuery.getResults().add( - new LargeResult(/* id */rtAndPath,/* mimeType */ mimeType, /* profileID */null, - /* resourceID */new File(realPath).getName(), Collections.EMPTY_LIST, - handler.sizeOf(realPath))); - } else { - throw new ProductException("return type: [" + cmd + "] is unsupported!"); - } - - return xmlQuery; - - } - - /* - * (non-Javadoc) - * - * @see org.apache.oodt.product.LargeProductQueryHandler#close(java.lang.String) - */ - public void close(String id) { - // nothing to do - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.oodt.product.LargeProductQueryHandler#retrieveChunk(java.lang.String, - * long, int) - */ - public byte[] retrieveChunk(String id, long offset, int length) - throws ProductException { - // unmarshall the return type and path - String[] rtTypeAndPathArr = id.split(CMD_SEPARATOR); - String rtType = rtTypeAndPathArr[0]; - String filepath = rtTypeAndPathArr[1]; - - OFSNGetHandler handler = getGetHandler(rtType, this.conf - .getHandlerClass(rtType)); - - return handler.retrieveChunk(filepath, offset, length); - } - - private void generateOFSNXml(File[] mlsFileList, OFSNHandlerConfig cfg, - OutputStream outStream) { - XMLUtils.writeXmlToStream(OFSNUtils.getOFSNDoc(Arrays.asList(mlsFileList), - cfg, this.conf.getProductRoot(), this.computeDirSize, this.computeFileSize), - outStream); - } - - private void validate(String ofsn, String cmd) throws ProductException { - if (ofsn == null || cmd == null || (ofsn.equals("")) || (cmd.equals(""))) { - throw new ProductException("must specify OFSN and RT parameters!"); - } else if (!OFSNUtils.validateOFSN(ofsn)) { - throw new ProductException("OFSN is invalid"); - } - } - - private void validateHandlerConfig(OFSNHandlerConfig cfg, String cmd) - throws ProductException { - if (cfg == null) { - throw new ProductException("Unrecognized command: [" + cmd + "]!"); - } - } - - private OFSNListHandler getListHandler(String rtType, String className) { - if (HANDLER_CACHE.containsKey(rtType)) { - return (OFSNListHandler) HANDLER_CACHE.get(rtType); - } else { - OFSNListHandler handler = OFSNObjectFactory.getListHandler(className); - LOG.log(Level.INFO, "Getting handler config for RT: ["+rtType+"]"); - handler.configure(this.conf.getHandlerConfig(rtType).getHandlerConf()); - HANDLER_CACHE.put(rtType, handler); - return handler; - } - } - - private OFSNGetHandler getGetHandler(String rtType, String className) { - if (HANDLER_CACHE.containsKey(rtType)) { - return (OFSNGetHandler) HANDLER_CACHE.get(rtType); - } else { - OFSNGetHandler handler = OFSNObjectFactory.getGetHandler(className); - handler.configure(this.conf.getHandlerConfig(rtType).getHandlerConf()); - HANDLER_CACHE.put(rtType, handler); - return handler; - } - } - - private boolean isListingCmd(String cmd) throws ProductException { - OFSNHandlerConfig cfg = this.conf.getHandlerConfig(cmd); - if (cfg == null) { - throw new ProductException("Unrecognized command: [" + cmd + "]!"); - } - - return cfg.getType().equals(LISTING_CMD); - } - - private boolean isGetCmd(String cmd) { - OFSNHandlerConfig cfg = this.conf.getHandlerConfig(cmd); - - return cfg.getType().equals(GET_CMD); - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java deleted file mode 100644 index 46d97c9..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfiguration.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -//JDK imports -import java.util.Arrays; -import java.util.concurrent.ConcurrentHashMap; -import java.util.List; -import java.util.Map; - -/** - * - * The OFSN product handler's configuration object. - * - * @author mattmann - * @version $Revision$ - * - */ -public class OFSNFileHandlerConfiguration { - - protected Map<String, OFSNHandlerConfig> handlerTable; - - private String productRoot; - - private String id; - - private String name; - - public OFSNFileHandlerConfiguration(String productRoot, String id, String name) { - this.handlerTable = new ConcurrentHashMap<String, OFSNHandlerConfig>(); - this.productRoot = productRoot; - this.id = id; - this.name = name; - cleanse(this.productRoot); - } - - public OFSNFileHandlerConfiguration() { - this(null, null, null); - } - - public String getHandlerType(String handlerName) { - if (this.handlerTable.containsKey(handlerName)) { - return this.handlerTable.get(handlerName).getType(); - } else { - return null; - } - } - - public String getHandlerClass(String handlerName) { - if (this.handlerTable.containsKey(handlerName)) { - return this.handlerTable.get(handlerName).getClassName(); - } else { - return null; - } - } - - public List<OFSNHandlerConfig> getHandlerConfigs() { - return Arrays.asList(this.handlerTable.values().toArray( - new OFSNHandlerConfig[this.handlerTable.size()])); - } - - public OFSNHandlerConfig getHandlerConfig(String handlerName) { - return this.handlerTable.get(handlerName); - } - - /** - * @return the productRoot - */ - public String getProductRoot() { - return productRoot; - } - - /** - * @param productRoot - * the productRoot to set - */ - public void setProductRoot(String productRoot) { - this.productRoot = productRoot; - cleanse(this.productRoot); - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - private void cleanse(String path) { - - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfigurationReader.java ---------------------------------------------------------------------- diff --git a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfigurationReader.java b/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfigurationReader.java deleted file mode 100644 index feeb738..0000000 --- a/product/src/main/java/org/apache/oodt/product/handlers/ofsn/OFSNFileHandlerConfigurationReader.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.oodt.product.handlers.ofsn; - -//JDK imports -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.Properties; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -//OODT imports -import org.apache.oodt.commons.xml.XMLUtils; -import org.apache.oodt.product.handlers.ofsn.metadata.OFSNXMLConfigMetKeys; - -/** - * - * Reads an XML file representation of the {@link OFSNFileHandlerConfiguration}. - * - * @author mattmann - * @version $Revision$ - * - */ -public final class OFSNFileHandlerConfigurationReader implements - OFSNXMLConfigMetKeys { - - public static OFSNFileHandlerConfiguration getConfig(String filePath) - throws FileNotFoundException { - OFSNFileHandlerConfiguration config = new OFSNFileHandlerConfiguration(); - - Document configDoc = XMLUtils.getDocumentRoot(new FileInputStream(new File( - filePath))); - Element configElem = configDoc.getDocumentElement(); - config.setId(configElem.getAttribute(OFSN_CFG_ID_ATTR)); - config.setName(configElem.getAttribute(OFSN_CFG_NAME_ATTR)); - config.setProductRoot(configElem.getAttribute(OFSN_PRODUCT_ROOT_ATTR)); - addHandlers(configElem, config); - return config; - } - - private static void addHandlers(Element configRootElem, - OFSNFileHandlerConfiguration config) { - NodeList handlerNodes = configRootElem.getElementsByTagName(HANDLER_TAG); - for (int i = 0; i < handlerNodes.getLength(); i++) { - OFSNHandlerConfig cfg = getHandlerConfig((Element) handlerNodes.item(i)); - config.handlerTable.put(cfg.getName(), cfg); - } - } - - private static OFSNHandlerConfig getHandlerConfig(Element handlerNodeElem) { - OFSNHandlerConfig cfg = new OFSNHandlerConfig(); - cfg.setClassName(handlerNodeElem.getAttribute(HANDLER_CLASSNAME_ATTR)); - cfg.setName(handlerNodeElem.getAttribute(HANDLER_NAME_ATTR)); - cfg.setType(handlerNodeElem.getAttribute(HANDLER_TYPE_ATTR)); - cfg.setHandlerConf(readConfig(handlerNodeElem)); - return cfg; - } - - private static Properties readConfig(Element handlerNodeElem) { - Properties config = new Properties(); - NodeList propertyNodes = handlerNodeElem.getElementsByTagName(PROPERTY_TAG); - - if (propertyNodes != null && propertyNodes.getLength() > 0) { - for (int j = 0; j < propertyNodes.getLength(); j++) { - Element propertyElem = (Element) propertyNodes.item(j); - String propertyName = propertyElem.getAttribute(PROPERTY_NAME_ATTR); - String propertyValue = propertyElem.getAttribute(PROPERTY_VALUE_ATTR); - - config.setProperty(propertyName, propertyValue); - } - } - - return config; - } -}
